/* ==========================================================================
   OneLens (๑ส่องแปล) — Clean Camera-First Split-Screen Stylesheet
   - Minimal Zero-Clutter Header & Blank-Until-Scanned Cards
   - 3-Button Balanced Bottom Action Strip
   - 5 Soothing Pastel Themes + Eye-Care Dark Mode
   ========================================================================== */

:root {
  --font-sans: "Plus Jakarta Sans", "Noto Sans Thai", "Noto Sans Lao",
    "Noto Sans Myanmar", "Noto Sans Devanagari", "Noto Sans SC",
    "Noto Sans JP", "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Default Pastel Theme: Mint */
  --bg-app: #eef7f2;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f5fbf8;
  --bg-source-card: #f8fcfa;
  --bg-pill: #e1f2e9;
  --bg-pill-hover: #d1ebdd;

  --text-primary: #162921;
  --text-secondary: #486357;
  --text-muted: #6e887d;

  --accent-primary: #1f8f6b;
  --accent-primary-hover: #187758;
  --accent-soft: #d3f3e6;
  --accent-contrast: #ffffff;

  --currency-bg: #fef3c7;
  --currency-text: #92400e;
  --currency-border: #fde68a;

  --pro-gold-bg: #fff8e6;
  --pro-gold-border: #f6d275;
  --pro-gold-text: #855208;

  --border-subtle: rgba(24, 62, 46, 0.09);
  --border-strong: rgba(24, 62, 46, 0.18);
  --shadow-card: 0 4px 14px rgba(17, 45, 33, 0.05);
  --shadow-modal: 0 18px 44px rgba(12, 32, 24, 0.22);

  --source-font-size: 0.94rem;
  --trans-font-size: 1.18rem;
  --summary-font-size: 1.04rem;

  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;
}

/* --------------------------------------------------------------------------
   5 โทนสีพาสเทล
   -------------------------------------------------------------------------- */
html[data-theme="sky"] {
  --bg-app: #eef5fc;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f5f9fe;
  --bg-source-card: #f7fbff;
  --bg-pill: #dfeefb;
  --bg-pill-hover: #cfe4f8;
  --text-primary: #162436;
  --text-secondary: #485d75;
  --text-muted: #6e8299;
  --accent-primary: #2573c2;
  --accent-primary-hover: #1d5ea1;
  --accent-soft: #d7eafd;
  --border-subtle: rgba(25, 58, 96, 0.09);
  --border-strong: rgba(25, 58, 96, 0.18);
}

html[data-theme="peach"] {
  --bg-app: #fdf2ed;
  --bg-surface: #ffffff;
  --bg-surface-soft: #fef8f5;
  --bg-source-card: #fffaf7;
  --bg-pill: #fbe5db;
  --bg-pill-hover: #f7d6c7;
  --text-primary: #2e1d17;
  --text-secondary: #6b4e43;
  --text-muted: #8f7065;
  --accent-primary: #d4623b;
  --accent-primary-hover: #b84f2c;
  --accent-soft: #fde2d6;
  --border-subtle: rgba(88, 42, 24, 0.09);
  --border-strong: rgba(88, 42, 24, 0.18);
}

html[data-theme="lavender"] {
  --bg-app: #f3f0fb;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f9f7fd;
  --bg-source-card: #faf8ff;
  --bg-pill: #e8e1f8;
  --bg-pill-hover: #dcd1f4;
  --text-primary: #221b33;
  --text-secondary: #584e70;
  --text-muted: #7c7294;
  --accent-primary: #6c52bd;
  --accent-primary-hover: #583fa4;
  --accent-soft: #e6defb;
  --border-subtle: rgba(54, 36, 98, 0.09);
  --border-strong: rgba(54, 36, 98, 0.18);
}

html[data-theme="butter"] {
  --bg-app: #fbf7ea;
  --bg-surface: #ffffff;
  --bg-surface-soft: #fdfbf3;
  --bg-source-card: #fefcf6;
  --bg-pill: #f4ebd0;
  --bg-pill-hover: #ece0ba;
  --text-primary: #2b2515;
  --text-secondary: #665b3f;
  --text-muted: #8a7e60;
  --accent-primary: #9d741c;
  --accent-primary-hover: #815e13;
  --accent-soft: #f6ebc8;
  --border-subtle: rgba(78, 60, 18, 0.1);
  --border-strong: rgba(78, 60, 18, 0.2);
}

/* --------------------------------------------------------------------------
   โหมดมืดถนอมสายตา (Dark Mode)
   -------------------------------------------------------------------------- */
html[data-color-mode="dark"] {
  --bg-app: #101614;
  --bg-surface: #18211e;
  --bg-surface-soft: #1f2b27;
  --bg-source-card: #151d1a;
  --bg-pill: #24322d;
  --bg-pill-hover: #2e403a;

  --text-primary: #ecf5f0;
  --text-secondary: #b1c5bb;
  --text-muted: #7f968b;

  --accent-soft: rgba(52, 211, 153, 0.18);
  --currency-bg: rgba(251, 191, 36, 0.16);
  --currency-text: #fcd34d;
  --currency-border: rgba(251, 191, 36, 0.34);

  --pro-gold-bg: rgba(245, 158, 11, 0.14);
  --pro-gold-border: rgba(245, 158, 11, 0.35);
  --pro-gold-text: #fbbf24;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.17);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.34);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.65);
}

html[data-color-mode="dark"][data-theme="mint"] {
  --accent-primary: #2bb386;
  --accent-primary-hover: #229971;
}
html[data-color-mode="dark"][data-theme="sky"] {
  --bg-app: #0f151d;
  --bg-surface: #17202b;
  --bg-surface-soft: #1e2a38;
  --bg-source-card: #141c26;
  --bg-pill: #233142;
  --accent-primary: #4796e5;
  --accent-primary-hover: #3582d0;
}
html[data-color-mode="dark"][data-theme="peach"] {
  --bg-app: #191311;
  --bg-surface: #241b18;
  --bg-surface-soft: #2e231f;
  --bg-source-card: #1e1614;
  --bg-pill: #362924;
  --accent-primary: #e57a54;
  --accent-primary-hover: #cf6742;
}
html[data-color-mode="dark"][data-theme="lavender"] {
  --bg-app: #14121c;
  --bg-surface: #1e1b29;
  --bg-surface-soft: #272336;
  --bg-source-card: #191623;
  --bg-pill: #302b42;
  --accent-primary: #8d74dc;
  --accent-primary-hover: #795ec9;
}
html[data-color-mode="dark"][data-theme="butter"] {
  --bg-app: #181610;
  --bg-surface: #232017;
  --bg-surface-soft: #2d291e;
  --bg-source-card: #1d1a13;
  --bg-pill: #363124;
  --accent-primary: #c99c38;
  --accent-primary-hover: #b38829;
}

/* --------------------------------------------------------------------------
   ระดับขนาดตัวอักษร A- / A+ / A++ / MAX
   -------------------------------------------------------------------------- */
.app-shell.font-scale-sm {
  --source-font-size: 0.86rem;
  --trans-font-size: 1.02rem;
  --summary-font-size: 0.94rem;
}
.app-shell.font-scale-md {
  --source-font-size: 0.95rem;
  --trans-font-size: 1.18rem;
  --summary-font-size: 1.04rem;
}
.app-shell.font-scale-lg {
  --source-font-size: 1.05rem;
  --trans-font-size: 1.38rem;
  --summary-font-size: 1.16rem;
}
.app-shell.font-scale-xl {
  --source-font-size: 1.14rem;
  --trans-font-size: 1.58rem;
  --summary-font-size: 1.28rem;
}

/* --------------------------------------------------------------------------
   Reset & Base Full-Viewport Shell (100dvh)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 4px) calc(var(--safe-right) + 10px)
    calc(var(--safe-bottom) + 8px) calc(var(--safe-left) + 10px);
  gap: 6px;
  overflow: hidden;
}

/* ==========================================================================
   1. COMPACT TOP BAR (ซ้ายโลโก้เดี่ยว · ขวา ประวัติ + A+ + ⋮)
   ========================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  flex-shrink: 0;
  gap: 8px;
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.brand-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.brand-main {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.icon-pill-btn:active {
  transform: scale(0.96);
  background: var(--bg-pill);
}

.font-btn {
  min-width: 36px;
  font-weight: 700;
}

.more-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.more-menu-btn:active {
  transform: scale(0.95);
  background: var(--bg-pill);
}

@media (max-width: 350px) {
  .pill-text-hide-xs {
    display: none;
  }
}

/* ==========================================================================
   2. SMART VIEWFINDER (36%–40% ของความสูงจอ)
   ========================================================================== */
.viewfinder-section {
  position: relative;
  width: 100%;
  height: 37dvh;
  min-height: 184px;
  max-height: 310px;
  flex-shrink: 0;
}

.viewfinder-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #0d1311;
  box-shadow: var(--shadow-card);
  border: 1.5px solid var(--border-subtle);
  user-select: none;
  touch-action: none;
}

.camera-video,
.frozen-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  transition: filter 0.2s ease, transform 0.22s ease;
}

.camera-video.enhance-preview {
  filter: brightness(1.16) contrast(1.22) saturate(1.06);
}

.camera-video.digital-zoom-2x {
  transform: scale(2);
}

.hidden-work-canvas {
  display: none !important;
}

.vf-top-controls {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.vf-controls-left,
.vf-controls-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  pointer-events: auto;
}

.vf-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 29px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 20, 0.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.vf-chip-btn:active {
  transform: scale(0.95);
}

.vf-chip-btn[aria-pressed="true"],
.vf-chip-btn.is-active {
  background: rgba(31, 143, 107, 0.9);
  border-color: rgba(167, 243, 208, 0.7);
  color: #ffffff;
}

@media (max-width: 430px) {
  .vf-btn-label {
    display: none;
  }
  .vf-chip-btn {
    padding: 0 8px;
    font-size: 0.78rem;
  }
}

.reticle-guides {
  position: absolute;
  inset: 44px 18px 34px 18px;
  pointer-events: none;
  z-index: 5;
}

.reticle-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: rgba(255, 255, 255, 0.78);
  border-style: solid;
}

.rc-tl {
  top: 0;
  left: 0;
  border-width: 2.5px 0 0 2.5px;
  border-top-left-radius: 8px;
}
.rc-tr {
  top: 0;
  right: 0;
  border-width: 2.5px 2.5px 0 0;
  border-top-right-radius: 8px;
}
.rc-bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 2.5px 2.5px;
  border-bottom-left-radius: 8px;
}
.rc-br {
  bottom: 0;
  right: 0;
  border-width: 0 2.5px 2.5px 0;
  border-bottom-right-radius: 8px;
}

.vf-bottom-hint {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  max-width: 90%;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: rgba(12, 19, 17, 0.56);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Touch-Drag Region Highlight */
.crop-touch-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  cursor: crosshair;
  touch-action: none;
}

.crop-selection-box {
  position: absolute;
  border: 2.5px solid #4ade80;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(8, 14, 12, 0.55);
  pointer-events: none;
  will-change: left, top, width, height;
}

.crop-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #ffffff;
  border: 2px solid #16a34a;
  border-radius: 50%;
}

.ch-tl { top: -6px; left: -6px; }
.ch-tr { top: -6px; right: -6px; }
.ch-bl { bottom: -6px; left: -6px; }
.ch-br { bottom: -6px; right: -6px; }

.crop-floating-bar {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: popUpIn 0.16s ease-out;
}

.btn-translate-crop {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: #16a34a;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.btn-clear-crop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(15, 23, 20, 0.82);
  color: #ffffff;
  font-size: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.scan-shimmer-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(10, 20, 16, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-laser-line {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 2.5px;
  background: linear-gradient(90deg, transparent, #6ee7b7, #ffffff, #6ee7b7, transparent);
  box-shadow: 0 0 14px #34d399;
  animation: scanSweep 1.35s ease-in-out infinite alternate;
}

.scan-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 20, 0.82);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.spinner-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  animation: pulseDot 0.8s ease-in-out infinite alternate;
}

@keyframes scanSweep {
  0% { top: 16%; }
  100% { top: 84%; }
}

@keyframes pulseDot {
  from { transform: scale(0.75); opacity: 0.5; }
  to { transform: scale(1.25); opacity: 1; }
}

@keyframes popUpIn {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.camera-fallback-overlay {
  position: absolute;
  inset: 0;
  z-index: 11;
  background: linear-gradient(145deg, #16241f, #1f332c);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}

.fallback-card {
  max-width: 390px;
  color: #f1f5f9;
}

.fallback-msg {
  margin: 0 0 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.fallback-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.fallback-btn.primary {
  background: var(--accent-primary);
  border-color: transparent;
}

/* ==========================================================================
   3. QUICK ACTION STRIP
   ========================================================================== */
.quick-action-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  height: 48px;
  flex-shrink: 0;
}

.lang-pair-pill {
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  max-width: 100%;
  height: 44px;
  padding: 0 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  text-align: left;
}

.lang-pair-main {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.lang-pair-sub {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.shutter-main-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: var(--accent-contrast);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(24, 119, 88, 0.26);
  white-space: nowrap;
  transition: background-color 0.16s ease, transform 0.1s ease;
}

.shutter-main-btn:active {
  transform: scale(0.96);
}

.shutter-main-btn[data-state="frozen"] {
  background: var(--text-primary);
  color: var(--bg-surface);
}

.shutter-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.voice-mode-pill {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
  height: 44px;
  padding: 0 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.voice-mode-pill[data-voice-mode="speak"] {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

.voice-mode-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 380px) {
  .shutter-main-btn {
    padding: 0 14px;
    font-size: 0.83rem;
  }
  .voice-mode-text {
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   4. DUAL-ROW BILINGUAL CARDS (สะอาด โล่งสบายตา)
   ========================================================================== */
.bilingual-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(76px, 0.68fr) minmax(0, 1.32fr);
  gap: 7px;
}

.bilingual-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.source-card {
  background: var(--bg-source-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.lang-tag-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.lang-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-pill);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-badge {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.crop-mini-tag {
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: #dcfce7;
  color: #166534;
  font-size: 0.67rem;
  font-weight: 700;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}

.mini-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

.mini-action-btn:active:not(:disabled) {
  background: var(--bg-pill);
}

.card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 13px;
  -webkit-overflow-scrolling: touch;
}

.source-text {
  margin: 0;
  font-size: var(--source-font-size);
  line-height: 1.68;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.translated-text {
  margin: 0;
  font-size: var(--trans-font-size);
  font-weight: 600;
  line-height: 1.74;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* กล่องแก้ไขข้อความต้นฉบับ */
.source-edit-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-edit-textarea {
  width: 100%;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  font-size: 0.9rem;
  line-height: 1.55;
  resize: none;
}

.source-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.btn-xs-secondary,
.btn-xs-primary {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.btn-xs-secondary {
  background: var(--bg-pill);
  color: var(--text-secondary);
}

.btn-xs-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

/* ชิปสลับโหมด 📄 คำแปลเต็ม ⇄ 💡 สรุปเป็นข้อๆ */
.view-mode-switch {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--bg-pill);
  gap: 2px;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-chip.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ป้ายไฮไลต์แปลงราคาอัตโนมัติ */
.currency-tag {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 7px;
  background: var(--currency-bg);
  color: var(--currency-text);
  border: 1px solid var(--currency-border);
  font-weight: 700;
  font-size: 0.92em;
  line-height: 1.35;
  vertical-align: baseline;
}

.summary-points-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--summary-font-size);
  line-height: 1.7;
  font-weight: 500;
}

.summary-points-list li::marker {
  color: var(--accent-primary);
  font-weight: 700;
}

.pronunciation-box {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--bg-surface-soft);
  border: 1px dashed var(--border-subtle);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.pronun-label {
  font-weight: 700;
  margin-right: 4px;
  color: var(--accent-primary);
}

.ai-disclaimer-note {
  margin: 8px 0 0;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* แถบปุ่มด่วนท้ายกล่องคำแปล: 3 ปุ่มสมดุลเต็มความกว้าง */
.translation-footer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-soft);
  flex-shrink: 0;
}

.footer-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-act-btn:active:not(:disabled) {
  transform: scale(0.97);
  background: var(--bg-pill);
}

.footer-act-btn.share-highlight:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

/* ==========================================================================
   MODALS, BOTTOM SHEETS & HISTORY DRAWER
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(9, 16, 13, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.side-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  width: min(92vw, 400px);
  background: var(--bg-surface);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  animation: slideInLeft 0.2s ease-out;
}

@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.drawer-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title,
.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.drawer-subtitle {
  margin: 2px 0 0;
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.close-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-pill);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.drawer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.history-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
  text-align: left;
  cursor: pointer;
}

.history-item-card:active {
  background: var(--bg-pill);
}

.history-thumb {
  width: 58px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: #1a2420;
}

.history-meta {
  min-width: 0;
}

.history-meta-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.history-trans-preview {
  margin: 2px 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-src-preview {
  margin: 0;
  font-size: 0.73rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-del-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history-empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.bottom-sheet-modal {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 100;
  width: min(100vw, 560px);
  max-height: 86dvh;
  background: var(--bg-surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 12px);
  animation: sheetSlideUp 0.2s ease-out;
}

@keyframes sheetSlideUp {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}

.sheet-grabber {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: var(--border-strong);
  margin: 8px auto 0;
}

.center-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: min(94vw, 480px);
  max-height: 88dvh;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-subtle);
}

.menu-sheet-list {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  gap: 6px;
  overflow-y: auto;
}

.menu-row-btn {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
  text-align: left;
  text-decoration: none;
  color: var(--text-primary);
}

.menu-row-btn:active {
  background: var(--bg-pill);
}

.highlight-pro-row {
  background: var(--pro-gold-bg);
  border-color: var(--pro-gold-border);
}

.menu-row-icon {
  font-size: 1.25rem;
  text-align: center;
}

.menu-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-title-with-pill {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.menu-quota-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--pro-gold-border);
  color: var(--pro-gold-text);
  font-size: 0.69rem;
  font-weight: 700;
}

.menu-row-text strong {
  font-size: 0.88rem;
  line-height: 1.35;
}

.menu-row-text small {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.menu-chevron {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 700;
}

.setting-block {
  margin-bottom: 14px;
}

.setting-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.setting-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.setting-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.clean-input,
.clean-select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-soft);
  color: var(--text-primary);
  font-size: 0.86rem;
}

.mono-input {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.ui-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ui-lang-option-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
}

.ui-lang-option-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  font-weight: 700;
}

.theme-swatches-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-swatch-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1.5px solid var(--border-subtle);
}

.theme-swatch-card.active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.swatch-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.swatch-mint { background: linear-gradient(135deg, #bbf7d0, #1f8f6b); }
.swatch-sky { background: linear-gradient(135deg, #bae6fd, #2573c2); }
.swatch-peach { background: linear-gradient(135deg, #fed7aa, #d4623b); }
.swatch-lavender { background: linear-gradient(135deg, #ddd6fe, #6c52bd); }
.swatch-butter { background: linear-gradient(135deg, #fef08a, #9d741c); }

.swatch-name {
  font-size: 0.76rem;
  font-weight: 600;
}

.swatch-tag {
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.64rem;
  font-weight: 700;
}

.free-tag {
  background: var(--bg-pill);
  color: var(--text-secondary);
}

.pro-lock-tag {
  background: var(--pro-gold-bg);
  border: 1px solid var(--pro-gold-border);
  color: var(--pro-gold-text);
}

.dark-mode-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
}

.dark-switch-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clean-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 25px;
  flex-shrink: 0;
}

.clean-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--border-strong);
  transition: background-color 0.18s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.clean-switch input:checked + .switch-slider {
  background: var(--accent-primary);
}

.clean-switch input:checked + .switch-slider::before {
  transform: translateX(19px);
}

.wallet-summary-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.wallet-sum-left {
  display: flex;
  flex-direction: column;
}

.wallet-sum-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.wallet-sum-value {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.tier-pill {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.starter-pill {
  background: var(--bg-pill);
  color: var(--text-secondary);
}

.pro-active-pill {
  background: var(--pro-gold-bg);
  border: 1px solid var(--pro-gold-border);
  color: var(--pro-gold-text);
}

.pro-lifetime-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface-soft);
  border: 1.5px solid var(--pro-gold-border);
}

.pro-price-ribbon {
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border-subtle);
}

.pro-badge-label {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--pro-gold-bg);
  color: var(--pro-gold-text);
  font-size: 0.72rem;
  font-weight: 700;
}

.pro-price-display {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.pro-price-display span {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.pro-price-display small {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.pro-benefits-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pro-benefits-list li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  font-size: 0.82rem;
  line-height: 1.52;
}

.playtest-banner {
  margin-bottom: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 0.73rem;
  color: var(--text-primary);
}

.btn-buy-pro,
.btn-primary-full {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.15);
}

.btn-buy-pro:active,
.btn-primary-full:active {
  transform: scale(0.98);
}

.pro-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.btn-ghost-sm {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-pill);
}

.billing-status-msg {
  margin: 8px 0 0;
  font-size: 0.76rem;
  text-align: center;
  color: var(--accent-primary);
  font-weight: 600;
}

.byok-locked-card,
.byok-guide-box {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
}

.byok-locked-text {
  margin: 0 0 12px;
  font-size: 0.84rem;
  line-height: 1.6;
}

.guide-heading {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.byok-steps-list {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 0.79rem;
  line-height: 1.58;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.byok-steps-list code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-pill);
  font-family: var(--font-mono);
  font-weight: 700;
}

.btn-open-aistudio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.key-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.btn-icon-inline {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
  font-size: 0.95rem;
}

.byok-active-switch-row {
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
}

.byok-status-box {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  font-weight: 600;
}

.byok-status-box.is-ok {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

html[data-color-mode="dark"] .byok-status-box.is-ok {
  color: #86efac;
}

.byok-status-box.is-err {
  background: rgba(220, 38, 38, 0.13);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

html[data-color-mode="dark"] .byok-status-box.is-err {
  color: #fca5a5;
}

.byok-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.btn-danger-ghost {
  height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

html[data-color-mode="dark"] .btn-danger-ghost {
  color: #f87171;
}

.btn-link-xs {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.demo-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 14px;
  overflow-y: auto;
}

.demo-sample-btn {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-soft);
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.demo-sample-btn:active {
  background: var(--bg-pill);
}

.demo-emoji {
  font-size: 1.45rem;
  text-align: center;
}

.demo-info {
  display: flex;
  flex-direction: column;
}

.demo-info strong {
  font-size: 0.85rem;
  line-height: 1.35;
}

.demo-info small {
  font-size: 0.73rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.toast-container {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast-pill {
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  background: rgba(18, 28, 24, 0.92);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  animation: popUpIn 0.18s ease-out;
}

.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }