/* ==========================================================================
   越译通 · 中越双语同声传译 PWA
   Design System: Calm Slate (Dark) & Sunlight Paper (Light)
   Mobile-First, Safe-Area Aware, High Vietnamese Diacritic Legibility
   ========================================================================== */

:root {
  /* Dark Theme (Default) */
  --bg: #0c1220;
  --surface-1: #131c2e;
  --surface-2: #1b2740;
  --surface-elevated: #223150;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #8b9bb8;

  /* Semantic Speaker Colors (Ocean Blue for ZH, Jade Emerald for VI) */
  --zh-accent: #2563eb;
  --zh-accent-hover: #1d4ed8;
  --zh-bubble: #162441;
  --zh-bubble-border: rgba(59, 130, 246, 0.26);
  --zh-trans: #93c5fd;

  --vi-accent: #059669;
  --vi-accent-hover: #047857;
  --vi-bubble: #102a24;
  --vi-bubble-border: rgba(16, 185, 129, 0.28);
  --vi-trans: #6ee7b7;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.16);
  --warn-soft: rgba(217, 119, 6, 0.16);
  --warn-text: #fcd34d;
  --ok-soft: rgba(16, 185, 129, 0.16);
  --ok-text: #6ee7b7;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
  --bg: #f4f6f9;
  --surface-1: #ffffff;
  --surface-2: #eef2f7;
  --surface-elevated: #e2e8f0;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;

  --zh-accent: #1d4ed8;
  --zh-accent-hover: #1e40af;
  --zh-bubble: #eff6ff;
  --zh-bubble-border: rgba(37, 99, 235, 0.2);
  --zh-trans: #1e40af;

  --vi-accent: #047857;
  --vi-accent-hover: #065f46;
  --vi-bubble: #ecfdf5;
  --vi-bubble-border: rgba(5, 150, 105, 0.22);
  --vi-trans: #065f46;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warn-soft: rgba(217, 119, 6, 0.12);
  --warn-text: #92400e;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --ok-text: #065f46;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.16);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
}

.brand-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.mode-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
  white-space: nowrap;
}

.mode-switch button.active {
  background: var(--surface-1);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.icon-btn:hover {
  background: var(--surface-elevated);
  border-color: var(--border-strong);
}

.icon-btn:active {
  transform: scale(0.97);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.icon-btn.primary {
  background: var(--zh-accent);
  border-color: transparent;
  color: #ffffff;
}

.icon-btn.primary:hover {
  background: var(--zh-accent-hover);
}

/* ==========================================================================
   Context Banners (Offline, PWA Install, LAN Viewer)
   ========================================================================== */
.banner-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12.5px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.banner-strip.show {
  display: flex;
}

.banner-strip.install {
  background: var(--zh-bubble);
  color: var(--text);
}

.banner-strip.offline {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.banner-strip.viewer {
  background: var(--ok-soft);
  color: var(--ok-text);
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Chat Workspace
   ========================================================================== */
.chat-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  flex-shrink: 0;
}

.status-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.status-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.live-dot.listening {
  background: var(--danger);
  animation: softPulse 1.4s ease-in-out infinite;
}

@keyframes softPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.status-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.engine-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 20px;
}

.chat-inner {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-list,
.live-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  margin: 42px auto 20px;
  max-width: 440px;
  text-align: center;
  padding: 24px 20px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.empty-state p {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
}

.quick-hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.quick-hint-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.quick-hint-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

/* Message Bubbles */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 88%;
  animation: msgIn 0.16s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.left {
  align-self: flex-start;
  flex-direction: row;
}

.msg-row.right {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 18px;
}

.msg-row.left .avatar {
  background: var(--zh-accent);
  color: #ffffff;
}

.msg-row.right .avatar {
  background: var(--vi-accent);
  color: #ffffff;
}

.bubble-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.msg-row.right .bubble-col {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}

.bubble {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 7px;
  word-break: break-word;
  max-width: 100%;
}

.msg-row.left .bubble {
  background: var(--zh-bubble);
  border: 1px solid var(--zh-bubble-border);
  border-top-left-radius: 5px;
}

.msg-row.right .bubble {
  background: var(--vi-bubble);
  border: 1px solid var(--vi-bubble-border);
  border-top-right-radius: 5px;
}

.bubble.interim {
  border-style: dashed;
  opacity: 0.92;
}

.bubble-src {
  font-size: calc(14.5px * var(--font-scale));
  line-height: 1.55;
  color: var(--text);
  font-weight: 500;
}

.bubble-divider {
  height: 1px;
  background: var(--border);
}

.bubble-tgt {
  font-size: calc(18px * var(--font-scale));
  line-height: 1.55;
  font-weight: 700;
  letter-spacing: 0.005em;
}

.msg-row.left .bubble-tgt {
  color: var(--zh-trans);
}

.msg-row.right .bubble-tgt {
  color: var(--vi-trans);
}

.bubble-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.bubble-act-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.14s, color 0.14s;
}

.bubble-act-btn:hover,
.bubble-act-btn.speaking {
  background: var(--surface-2);
  color: var(--text);
}

.bubble-act-btn svg {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   Bottom Control Dock (Portable Mode + DJI Stereo Mode)
   ========================================================================== */
.control-dock {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 10px 14px calc(12px + var(--safe-bottom));
  flex-shrink: 0;
  z-index: 15;
}

.dock-inner {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.text-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-pill {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 11px;
  height: 40px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.dir-pill:hover {
  background: var(--surface-elevated);
}

.text-input-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0 13px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.text-input-row input:focus {
  border-color: var(--zh-accent);
  background: var(--surface-1);
}

.send-btn {
  height: 40px;
  padding: 0 15px;
  border: none;
  border-radius: 11px;
  background: var(--zh-accent);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.send-btn:hover {
  background: var(--zh-accent-hover);
}

.send-btn:active {
  transform: scale(0.97);
}

/* Portable Mode Dual Big Mic Buttons */
.portable-mics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mic-btn {
  position: relative;
  border: none;
  border-radius: 14px;
  padding: 13px 14px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.mic-btn:active {
  transform: scale(0.98);
}

.mic-btn.zh {
  background: var(--zh-accent);
}

.mic-btn.zh:hover {
  background: var(--zh-accent-hover);
}

.mic-btn.vi {
  background: var(--vi-accent);
}

.mic-btn.vi:hover {
  background: var(--vi-accent-hover);
}

.mic-btn.active {
  background: var(--danger);
}

.mic-btn-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  text-align: left;
}

.mic-btn-main {
  font-size: 15px;
  font-weight: 700;
}

.mic-btn-sub {
  font-size: 11.5px;
  opacity: 0.88;
}

.wave-bars {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  height: 18px;
}

.wave-bars span {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.9);
  transition: height 0.15s;
}

.mic-btn.active .wave-bars span:nth-child(1) { animation: wave 0.7s ease-in-out infinite 0s; }
.mic-btn.active .wave-bars span:nth-child(2) { animation: wave 0.7s ease-in-out infinite 0.15s; }
.mic-btn.active .wave-bars span:nth-child(3) { animation: wave 0.7s ease-in-out infinite 0.3s; }

@keyframes wave {
  0%, 100% { height: 5px; }
  50% { height: 18px; }
}

/* DJI Stereo Dock */
.dji-dock {
  display: none;
  flex-direction: column;
  gap: 9px;
}

.dji-dock.show {
  display: flex;
}

.portable-mics.hidden {
  display: none;
}

.dji-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dji-channels {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

.ch-pill {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  border-radius: 11px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 0.15s, background 0.15s;
}

.ch-pill.active-left {
  background: var(--zh-bubble);
  border-color: var(--zh-accent);
  color: var(--text);
}

.ch-pill.active-right {
  background: var(--vi-bubble);
  border-color: var(--vi-accent);
  color: var(--text);
}

.ch-pill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.mini-meter {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.mini-meter-fill {
  height: 100%;
  width: 0%;
  transition: width 0.06s linear;
}

.mini-meter-fill.left { background: #3b82f6; }
.mini-meter-fill.right { background: #10b981; }

.dji-live-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  background: var(--vi-accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 156px;
  transition: background 0.15s, transform 0.1s;
}

.dji-live-btn:hover { background: var(--vi-accent-hover); }
.dji-live-btn.running { background: var(--danger); }
.dji-live-btn:active { transform: scale(0.98); }

/* ==========================================================================
   Slide-Over Drawers (Settings & Offline Phrasebook)
   ========================================================================== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: calc(14px + var(--safe-top)) 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok-text);
  border-color: transparent;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn-text);
  border-color: transparent;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--zh-accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.toggle-row small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--zh-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:hover {
  background: var(--surface-elevated);
  color: var(--text);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}

.btn:hover { background: var(--surface-elevated); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--zh-accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--zh-accent-hover); }
.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.diag-box {
  font-size: 12px;
  line-height: 1.55;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.diag-box.ok {
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok-text);
}

.diag-box.warn {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn-text);
}

.meter-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.meter-tag { width: 68px; font-weight: 700; flex-shrink: 0; }
.meter-tag.left { color: #3b82f6; }
.meter-tag.right { color: #10b981; }
.meter-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-db { width: 48px; text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }

audio#testPlayback {
  width: 100%;
  height: 36px;
  display: none;
}

/* ==========================================================================
   Offline Phrasebook Drawer
   ========================================================================== */
.phrase-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  flex-shrink: 0;
}

.phrase-tabs button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.phrase-tabs button.active {
  background: var(--zh-accent);
  border-color: transparent;
  color: #ffffff;
}

.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phrase-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phrase-zh {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 600;
}

.phrase-vi {
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--vi-trans);
  font-weight: 700;
}

.phrase-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

/* ==========================================================================
   Face-to-Face Split Screen Overlay
   ========================================================================== */
.face-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: none;
  flex-direction: column;
}

.face-overlay.open {
  display: flex;
}

.face-half {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 18px 16px;
  gap: 12px;
}

.face-half.top {
  transform: rotate(180deg);
  background: var(--vi-bubble);
  border-top: 1px solid var(--border);
  padding: 16px 18px calc(16px + var(--safe-top));
}

.face-half.bottom {
  background: var(--zh-bubble);
  padding: 16px 18px calc(16px + var(--safe-bottom));
}

.face-text-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.face-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.face-main {
  font-size: clamp(22px, 5.4vw, 34px);
  font-weight: 800;
  line-height: 1.45;
  color: var(--text);
}

.face-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.face-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.face-controls .mic-btn {
  flex: 1;
  padding: 13px 16px;
}

/* ==========================================================================
   Full-Screen Big Text Card Modal (For Taxi / Street / Factory Reading)
   ========================================================================== */
.bigcard-modal {
  position: fixed;
  inset: 0;
  background: var(--surface-1);
  z-index: 70;
  display: none;
  flex-direction: column;
  padding: calc(18px + var(--safe-top)) 22px calc(22px + var(--safe-bottom));
}

.bigcard-modal.open {
  display: flex;
}

.bigcard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bigcard-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 20px 8px;
  transition: transform 0.22s ease;
}

.bigcard-content.flipped {
  transform: rotate(180deg);
}

.bigcard-tgt {
  font-size: clamp(28px, 7.5vw, 56px);
  font-weight: 800;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.bigcard-src {
  font-size: clamp(15px, 3.6vw, 20px);
  color: var(--muted);
  line-height: 1.5;
  max-width: 680px;
}

.bigcard-bottom {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: calc(92px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
  .brand-title {
    display: none;
  }

  .header-tools .btn-label {
    display: none;
  }

  .icon-btn {
    padding: 0 9px;
  }

  .msg-row {
    max-width: 95%;
  }

  .avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
    border-radius: 8px;
  }

  .mic-btn {
    padding: 12px 10px;
  }

  .mic-btn-main {
    font-size: 14px;
  }

  .mic-btn-sub {
    font-size: 11px;
  }

  .dji-live-btn {
    width: 100%;
  }
}

/* Viewer Mode Hides Input Dock */
body.viewer-mode .control-dock,
body.viewer-mode .mode-switch {
  display: none;
}
