/* ═══════════════════════════════════════════════════════════════════════════
   EchoLocate Phase 1 — style.css
   A11y-first dark theme: pure black, high-contrast, large sans-serif text,
   two-column "lanes" UI for simulated speaker diarization.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Custom Properties ──────────────────────────────────────────────────────── */
:root {
  /* Palette */
  --bg-page:      #000000;
  --bg-surface:   #0d0d0d;
  --bg-card-a:    #071524;   /* deep blue-tinted dark  */
  --bg-card-b:    #160826;   /* deep purple-tinted dark */

  --accent-a:     #4dabf7;   /* Speaker A — sky blue   */
  --accent-b:     #cc5de8;   /* Speaker B — vivid purple */

  --text-primary: #f1f3f5;
  --text-muted:   #868e96;
  --text-interim: rgba(241, 243, 245, 0.45);

  --warning:      #ffd43b;
  --danger:       #ff6b6b;
  --success:      #69db7c;

  /* Layout */
  --header-h:     64px;
  --footer-h:     96px;
  --interim-h:    58px;

  --radius-card:  10px;
  --radius-btn:   8px;

  /* Typography */
  --font:         'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  /* Animation */
  --ease:         200ms ease;

  /* ── Theme-aware tokens (dark defaults) ────────────────────────────────── */
  --bg-lane:            #050505;
  --bg-card-low:        #071524;
  --bg-card-mid:        #1a1407;
  --bg-card-high:       #160826;
  --border-subtle:      #1a1a1a;
  --border-divider:     #141414;
  --btn-secondary-bg:   #3a3a3a;
  --btn-secondary-fg:   var(--text-primary);
  --btn-danger-bg:      #1e0808;
  --btn-danger-fg:      var(--danger);
  --btn-danger-border:  #3a1010;
  --theme-badge-bg:     #1c1c1c;
  --interim-bg:         rgba(0, 0, 0, 0.92);
  --interim-label-col:  #808080;  /* was #282828 — 1.42:1 → now 5.3:1 against near-black (WCAG AA) */
  --lane-active-border: rgba(255, 255, 255, 0.35);
  --status-dot-idle:    #333333;
  --mic-info-col:       #909090;  /* was #6d6d6d — 3.75:1 → now 6.4:1 against #0d0d0d (WCAG AA) */
  --autosave-col:       #52a652;  /* was #2c4a2c — 1.96:1 → now 6.7:1 against #0d0d0d (WCAG AA) */
  --scrollbar-thumb:    #222222;
}

/* ── Light theme overrides ───────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-page:            #f0f2f5;
  --bg-surface:         #ffffff;
  --bg-lane:            #ffffff;
  --bg-card-low:        #e8f4fd;
  --bg-card-mid:        #fef9e7;
  --bg-card-high:       #f5e6ff;
  --border-subtle:      #d0d3d8;
  --border-divider:     #e4e6ea;
  --btn-secondary-bg:   #e4e6ea;
  --btn-secondary-fg:   #1a1a2e;
  --btn-danger-bg:      #fff0f0;
  --btn-danger-fg:      #c92a2a;
  --btn-danger-border:  #ffc9c9;
  --theme-badge-bg:     #e9ecef;
  --interim-bg:         rgba(240, 242, 245, 0.97);
  --interim-label-col:  #595959;  /* was #b0b3b8 — 1.79:1 → now 6.2:1 against #f0f2f5 (WCAG AA) */
  --lane-active-border: rgba(0, 0, 0, 0.20);
  --status-dot-idle:    #ced4da;
  --text-primary:       #1a1a2e;
  --text-muted:         #5c6370;
  --text-interim:       rgba(26, 26, 46, 0.5);
  --mic-info-col:       #767676;  /* was #888888 — 3.56:1 → now 4.5:1 against #ffffff (WCAG AA) */
  --autosave-col:       #2f6b2f;  /* 5.9:1 against #ffffff — already passing */
  --scrollbar-thumb:    #ced4da;
  --danger:             #c92a2a;
  --success:            #2f9e44;
  --warning:            #e67600;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
html {
  height: 100%;
  font-size: 16px;
}

body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.5;
  overflow: hidden;
  /* Prevent iOS font-size inflation */
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Enforce the HTML hidden attribute over any author-set display values. */
[hidden] { display: none !important; }

/* ── Accessibility: reduced-motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Focus visible ring ─────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 3px;
  border-radius: var(--radius-btn);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SECURE CONTEXT WARNING BANNER
   ═══════════════════════════════════════════════════════════════════════════ */
#secure-warning {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #1a0e00;
  border-bottom: 2px solid var(--warning);
  color: var(--warning);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 100;
}

#secure-warning strong { font-weight: 700; }
#secure-warning code   { font-family: monospace; opacity: 0.8; }

#speech-warning {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #2a0909;
  border-bottom: 2px solid var(--danger);
  color: #ffb3b3;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  z-index: 100;
}

[data-theme="light"] #speech-warning {
  background: #fff2f2;
  color: #a61e1e;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SPEECH HELP MODAL DIALOG
   ═══════════════════════════════════════════════════════════════════════════ */
#speech-help-modal {
  border: none;
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 0;
  max-width: min(600px, 92vw);
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
}

#speech-help-modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.speech-modal-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.speech-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.speech-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--danger);
  margin: 0;
}

.speech-modal-title.info {
  color: var(--warning);
}

.speech-modal-close {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-subtle);
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  line-height: 1;
  border-radius: var(--radius-btn);
}

.speech-modal-close:hover {
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
}

.speech-modal-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.speech-modal-body p {
  margin: 0 0 0.75rem;
}

.speech-modal-body p:last-child {
  margin-bottom: 0;
}

.speech-modal-body ol {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.5rem;
}

.speech-modal-body li {
  margin: 0.35rem 0;
}

.speech-modal-body code {
  background: var(--bg-lane);
  border: 1px solid var(--border-subtle);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.88em;
  -webkit-user-select: all;
  user-select: all;
}

.speech-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
.app-header {
  position: relative;   /* anchor for the absolute options panel */
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  font-size: 1.6rem;
  color: var(--accent-a);
  animation: icon-pulse 2.4s ease-in-out infinite;
}

@keyframes icon-pulse {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.3; }
}

.brand h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.phase-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2em 0.55em;
  background: var(--theme-badge-bg);
  color: var(--text-muted);
  border-radius: 4px;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.mic-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-right: 0.5rem;
  min-width: 8rem; /* prevents layout shift as text changes */
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-dot-idle);
  transition: background var(--ease), box-shadow var(--ease);
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: dot-blink 1.4s ease-in-out infinite;
}

.status-dot.restarting { background: var(--warning); }
.status-dot.error      { background: var(--danger);  }

@keyframes dot-blink {
  0%, 100% { opacity: 1;   }
  50%       { opacity: 0.3; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--ease), transform var(--ease);
  white-space: nowrap;
}

.btn:disabled       { opacity: 0.3; cursor: not-allowed; }
.btn:not(:disabled):hover  { opacity: 0.82; transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0); }

.btn-primary   { background: var(--accent-a); color: #000; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-fg); }
.btn-danger    { background: var(--btn-danger-bg); color: var(--btn-danger-fg); border: 1px solid var(--btn-danger-border); }

.lang-picker-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.lang-select {
  height: 33px;
  min-width: 170px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0 0.45rem;
}

.merge-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.merge-tools select {
  height: 31px;
  min-width: 84px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.76rem;
  padding: 0 0.35rem;
}

.merge-tools #btn-merge {
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
}

.btn-quick-lang {
  padding: 0.4rem 0.65rem;
  font-size: 0.76rem;
}

/* Theme toggle — minimal icon button sitting in the controls row */
.theme-toggle {
  background: transparent;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-btn);
  line-height: 1;
  transition: border-color var(--ease), color var(--ease), opacity var(--ease);
}
.theme-toggle:not(:disabled):hover { opacity: 0.8; transform: none; }

/* Dark mode (default): show sun icon (clicking switches to light). */
/* Light mode: show moon icon (clicking switches to dark). */
.sun-icon  { display: block; }
.moon-icon { display: none; }

[data-theme="light"] .sun-icon  { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* ── Options toggle button ──────────────────────────────────────────────────── */
/* Active (expanded) state matches the primary button style so it's obvious. */
.nav-options-toggle[aria-expanded="true"] {
  background: var(--accent-a);
  color: #000;
}

.nav-options-toggle[aria-expanded="false"]::after { content: ' ▾'; }
.nav-options-toggle[aria-expanded="true"]::after  { content: ' ▴'; }

/* ── Secondary options panel ───────────────────────────────────────────────── */
/* Drops below the header as an overlay so the main content does not reflow.   */
.nav-options-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  z-index: 45;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.nav-options-panel[hidden] { display: none !important; }

[data-theme="light"] .nav-options-panel {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.nav-options-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem;
  padding: 0.65rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN — flex: 1 so it fills everything between header and footer
   ═══════════════════════════════════════════════════════════════════════════ */
.app-main {
  flex: 1;
  min-height: 0;      /* critical for flex children to shrink and scroll */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LANES GRID
   ═══════════════════════════════════════════════════════════════════════════ */
.lanes-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
  overflow: hidden;
}

.lane-sep {
  background: #181818;
  align-self: stretch;
}

.lane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem 1rem 0.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-lane);
  transition: background-color 0.25s ease, border-color var(--ease), opacity var(--ease), transform var(--ease);
}

.lane.active {
  border-color: var(--lane-active-border);
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--speaker-color, var(--accent-a)) 45%, transparent);
  animation: lane-energy 1s ease-in-out infinite;
}

@keyframes lane-energy {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--speaker-color, var(--accent-a)) 34%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--speaker-color, var(--accent-a)) 62%, transparent); }
}

.lane-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.085em;
  color: var(--text-muted);
  margin-bottom: 0.72rem;
  flex-shrink: 0;
}

.lane-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--speaker-color, #4dabf7);
  flex-shrink: 0;
}

.lane-hint {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 400;
  color: #8a9097;
  text-transform: none;
  letter-spacing: 0;
}

.lane-language {
  margin-left: 0.2rem;
  font-size: 0.63rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.08rem 0.38rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.lane-language.shifted {
  border-color: var(--warning);
  color: var(--warning);
}

.lane-translation-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin-left: 0.2rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.lane-trans-mode,
.lane-trans-target {
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.63rem;
  padding: 0 0.26rem;
}

.lane-trans-mode:focus-visible,
.lane-trans-target:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 1px;
  border-color: var(--accent-a);
}

.lane-trans-targets {
  display: inline-flex;
  gap: 0.25rem;
}

.lane-trans-summary {
  font-size: 0.6rem;
  color: var(--text-muted);
  max-width: 8.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .lane-hint,
[data-theme="light"] .lane-trans-summary {
  color: #5f6775;
}

[data-theme="light"] .lane-language {
  color: #2b3240;
  border-color: #d7dbe0;
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .lane-trans-mode,
[data-theme="light"] .lane-trans-target {
  color: #243044;
  border-color: #d0d6de;
  background: #f8f9fb;
}

.lane-confidence {
  margin-left: 0.55rem;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.lane-confidence.conf-high {
  color: #69db7c;
  border-color: #2f5f39;
  background: rgba(30, 61, 35, 0.35);
}

.lane-confidence.conf-medium {
  color: #ffd43b;
  border-color: #5a4a17;
  background: rgba(92, 72, 16, 0.35);
}

.lane-confidence.conf-low {
  color: #ff8787;
  border-color: #693030;
  background: rgba(80, 28, 28, 0.35);
}

.lane-cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  scroll-behavior: smooth;
  /* Prevent content from hiding under padding */
  padding-right: 0.5rem;
}

/* Slim scrollbar */
.lane-cards::-webkit-scrollbar       { width: 3px; }
.lane-cards::-webkit-scrollbar-track { background: transparent; }
.lane-cards::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* ═══════════════════════════════════════════════════════════════════════════
   TRANSCRIPT CARDS
   Minimum 24pt text (1.5rem). High contrast. No background clutter.
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  border-radius: var(--radius-card);
  padding: 0.9rem 1.1rem;
  font-size: 1.5rem;       /* 24pt baseline as specified */
  font-weight: 500;
  line-height: 1.45;
  word-break: break-word;
  animation: card-enter 160ms ease-out both;
  flex-shrink: 0;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.card-tone-low {
  background: var(--bg-card-low);
  border-left: 3px solid var(--speaker-color, var(--accent-a));
  color: var(--text-primary);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.card-tone-mid {
  background: var(--bg-card-mid);
  border-left: 3px solid var(--speaker-color, #f59f00);
  color: var(--text-primary);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.card-tone-high {
  background: var(--bg-card-high);
  border-left: 3px solid var(--speaker-color, var(--accent-b));
  color: var(--text-primary);
  transition: background-color 0.25s ease, color 0.25s ease;
}

/*
  Low confidence text ( < 0.7 ) — yellow underline so the user knows
  the recognition engine was uncertain about this word/phrase.
*/
.card .low-confidence {
  text-decoration: underline;
  text-decoration-color: var(--warning);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.card-meta {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.confidence-meter {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.confidence-fill {
  display: block;
  height: 7px;
  width: 0;
  min-width: 12px;
  max-width: 72%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8787, #ffd43b, #69db7c);
}

.confidence-value {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Translation block — shown inline below the original transcript text */
.translation-text {
  display: block;
  margin-top: 0.45rem;
  padding: 0.28rem 0.5rem;
  font-size: 0.82rem;
  font-style: italic;
  /* Use near-primary contrast at smaller size to meet WCAG AA (4.5:1 required
     for text < 14px/18.66px bold). text-muted alone is too low. */
  color: rgba(241, 243, 245, 0.88);
  border-left: 2px solid rgba(77, 171, 247, 0.55);
  border-radius: 0 4px 4px 0;
  background: rgba(77, 171, 247, 0.09);
  line-height: 1.45;
}

.translation-lang-tag {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(77, 171, 247, 0.9);
}

[data-theme="light"] .translation-text {
  /* Dark-on-light: #2d3a4a against white gives > 9:1 contrast */
  color: #2d3a4a;
  border-left-color: rgba(30, 100, 200, 0.45);
  background: rgba(30, 100, 200, 0.07);
}

[data-theme="light"] .translation-lang-tag {
  color: rgba(30, 100, 200, 0.85);
}

/* Translation status pill shown in the options panel */
.translation-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  white-space: nowrap;
}

.translation-status.hidden { display: none; }

.translation-status--available {
  color: #37b24d;
  border: 1px solid rgba(55, 178, 77, 0.45);
  background: rgba(55, 178, 77, 0.1);
}

.translation-status--downloading,
.translation-status--checking {
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.translation-status--unavailable,
.translation-status--unsupported {
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  opacity: 0.75;
}

[data-theme="light"] .translation-status--available {
  color: #2a7c3a;
  background: rgba(55, 178, 77, 0.12);
}

/* Translation controls — compact toggle + dropdown button ─────────────────── */
.translation-controls {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
}

.translation-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.translation-enable-label {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.15rem 0.2rem;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.translation-enable-label input[type="checkbox"] {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.translation-lang-btn {
  font-size: 0.74rem;
  padding: 0.28rem 0.55rem;
  min-height: 34px;
  white-space: nowrap;
}

.translation-lang-btn:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 2px;
}

/* Dropdown panel — positioned absolute relative to .translation-controls */
.translation-lang-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  padding: 0.55rem 0.6rem 0.6rem;
  min-width: 235px;
}

.translation-lang-dropdown.hidden { display: none; }

[data-theme="light"] .translation-lang-dropdown {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.translation-dropdown-hint {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.translation-target-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 0.5rem;
}

.translation-target-option {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 32px;
  font-size: 0.74rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  padding: 0.12rem 0.18rem;
}

.translation-target-option input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: 2px;
}

.translation-target-option:focus-within {
  background: color-mix(in srgb, var(--accent-a) 14%, transparent);
}

[data-theme="light"] .translation-lang-btn:focus-visible,
[data-theme="light"] .translation-target-option input[type="checkbox"]:focus-visible,
[data-theme="light"] .lane-trans-mode:focus-visible,
[data-theme="light"] .lane-trans-target:focus-visible {
  outline-color: #1f6fd1;
}

.translation-selection-note {
  margin: 0.4rem 0 0;
  font-size: 0.68rem;
  color: var(--warning);
}

.translation-help {
  margin: 0;
  max-width: 42ch;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.32;
}

/* ═══════════════════════════════════════════════════════════════════════════
   INTERIM STRIP — live, in-progress speech
   ═══════════════════════════════════════════════════════════════════════════ */
.interim-strip {
  flex-shrink: 0;
  height: var(--interim-h);
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0 1.5rem;
  background: var(--interim-bg);
  border-top: 1px solid var(--border-divider);
  overflow: hidden;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.interim-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--interim-label-col);
  flex-shrink: 0;
}

.interim-text {
  font-size: 1.2rem;
  font-style: italic;
  color: var(--text-interim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  transition: color var(--ease);
}

/* Slightly brighter while actively speaking */
.interim-text.speaking { color: rgba(241, 243, 245, 0.65); }

/* ─── Inline interim (live) card ────────────────────────────────────────────
   Shown inside the active speaker's lane while speech is in progress.
   Removed and replaced by the finalised card once the utterance ends.
   ────────────────────────────────────────────────────────────────────────── */
.card-interim-live {
  opacity: 0.7;
  font-style: italic;
  border-left-style: dashed !important;
  animation: none;   /* skip the card-enter animation — text updates too rapidly */
}

.interim-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--speaker-color, var(--accent-a));
  margin-left: 0.6rem;
  vertical-align: middle;
  animation: interim-dot-pulse 1.2s ease-in-out infinite;
}

@keyframes interim-dot-pulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.3; transform: scale(0.75); }
}

[data-theme="light"] .card-interim-live {
  opacity: 0.75;
}

.lang-mismatch-hint {
  flex-shrink: 0;
  max-width: 45%;
  font-size: 0.72rem;
  color: var(--warning);
  border: 1px solid rgba(255, 212, 59, 0.45);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme="light"] .lang-mismatch-hint {
  color: #ad6700;
  border-color: rgba(230, 118, 0, 0.5);
  background: rgba(255, 243, 191, 0.7);
}

.debug-overlay {
  position: absolute;
  right: 1rem;
  bottom: calc(var(--interim-h) + 0.75rem);
  width: min(380px, calc(100% - 2rem));
  padding: 0.6rem;
  border: 1px solid #2d2d2d;
  border-radius: 10px;
  background: rgba(5, 5, 5, 0.94);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 20;
}

.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.7rem;
}

#debug-legend {
  color: #8b8b8b;
  font-size: 0.64rem;
}

#debug-canvas {
  display: block;
  width: 100%;
  height: 150px;
  border-radius: 6px;
  background: #090909;
  border: 1px solid #1f1f1f;
}

.debug-summary {
  margin-top: 0.4rem;
  font-size: 0.68rem;
  color: #a6a6a6;
  line-height: 1.4;
}

/* ── On-screen debug console (mobile-friendly log panel) ─────────────────── */
.debug-log-panel {
  margin: 0.5rem 1rem 0;
  padding: 0.6rem 0.75rem;
  background: rgba(5, 5, 5, 0.94);
  border: 1px solid #2d2d2d;
  border-radius: 10px;
  font-size: 0.7rem;
  line-height: 1.4;
}

.debug-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.7rem;
}

.debug-log-actions {
  display: flex;
  gap: 0.35rem;
}

.debug-log-head .btn {
  padding: 0.15rem 0.55rem;
  font-size: 0.64rem;
}

.debug-device-info {
  margin: 0 0 0.4rem;
  padding: 0.35rem 0.5rem;
  background: #111;
  border-radius: 5px;
  color: #7ec8e3;
  font-family: monospace;
  font-size: 0.6rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-log-entries {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 12rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

.debug-log-entry {
  padding: 0.1rem 0;
  border-bottom: 1px solid #1a1a1a;
  font-family: monospace;
  font-size: 0.62rem;
  word-break: break-all;
  color: #a6a6a6;
}

.debug-log-entry--error { color: #ff8787; }
.debug-log-entry--warn  { color: #ffd43b; }
.debug-log-entry--info  { color: #74c0fc; }

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER — waveform visualizer
   ═══════════════════════════════════════════════════════════════════════════ */
.app-footer {
  flex-shrink: 0;
  height: var(--footer-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-divider);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

#visualizer {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 1.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mic-info {
  color: var(--mic-info-col);
  text-align: center;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stereo-info {
  color: #8cb5ff;
  white-space: nowrap;
}

.system-audio-info {
  color: #f9a825;
  white-space: nowrap;
  font-weight: 600;
}

/* Source badge — inline icon shown on cards and chat messages */
.source-badge {
  display: inline-block;
  font-size: 0.85em;
  margin-left: 0.25em;
  vertical-align: middle;
  line-height: 1;
  cursor: help;
}

.source-badge--computer {
  /* Subtle amber tint to make computer-source cards visually distinct */
  filter: drop-shadow(0 0 2px rgba(249, 168, 37, 0.5));
}

/* Computer-source cards get a faint left border accent */
.card.card-source-computer {
  border-left: 3px solid rgba(249, 168, 37, 0.6);
}

/* Source picker wrapper — keeps label + select inline like language picker */
.source-picker-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.source-select {
  min-width: 140px;
}

#btn-stereo[disabled] {
  opacity: 0.25;
}

.autosave-note {
  color: var(--autosave-col);
  font-size: 0.65rem;
}

.footer-community {
  padding: 0.2rem 1.5rem 0.45rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.footer-community a {
  color: var(--accent-a);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-community a:hover,
.footer-community a:focus-visible {
  opacity: 0.85;
}

/* ═══════════════════════════════════════════════════════════════════════════
   NO-SUPPORT MESSAGE (injected by app.js if API unavailable)
   ═══════════════════════════════════════════════════════════════════════════ */
.no-support-msg {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-page);
  text-align: center;
  padding: 2.5rem;
  z-index: 999;
}

.no-support-msg h2 {
  font-size: 1.75rem;
  color: var(--danger);
}

.no-support-msg p {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — stack lanes vertically on narrow screens
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  /* Default on mobile: single chat view (JS will also set body.view-chat) */
  .lanes-grid {
    display: none;
    grid-template-columns: 1fr;  /* used when body.view-lanes overrides on mobile */
    gap: 0.5rem;
    padding: 0.5rem;
  }
  .chat-feed { display: flex; }

  .card { font-size: 1.25rem; }

  .brand h1 { font-size: 1.2rem; }

  .controls { gap: 0.35rem; }
  .btn      { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

  /* Keep lane header controls compact and readable on phones. */
  .lane {
    padding: 0.85rem 0.8rem 0.45rem;
  }

  .lane-header {
    gap: 0.34rem 0.45rem;
    font-size: 0.67rem;
    margin-bottom: 0.62rem;
    letter-spacing: 0.075em;
  }

  .lane-language {
    margin-left: 0;
    font-size: 0.61rem;
    padding: 0.08rem 0.35rem;
  }

  .lane-translation-controls {
    margin-left: 0;
    flex: 1 1 100%;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .lane-trans-mode,
  .lane-trans-target {
    min-height: 34px;
    font-size: 0.62rem;
    padding: 0 0.24rem;
    max-width: 6.3rem;
  }

  .lane-trans-targets {
    flex-wrap: wrap;
  }

  .lane-trans-summary {
    display: none;
  }

  .lane-hint {
    margin-left: 0;
    width: 100%;
    order: 3;
    font-size: 0.6rem;
    color: var(--text-muted);
  }

  /* Hide verbose status text on small screens; the dot alone is sufficient. */
  .mic-status { display: none; }
  .mic-info   { display: none; }
  .stereo-info { display: none; }
  .system-audio-info { display: none; }
}

/* ── Extra-narrow screens (phones ≤ 480 px) ──────────────────────────────── */
/* Reduce padding and hide the Phase badge + layout toggle so the primary     */
/* toolbar items (Start, Stop, Options, Theme) fit without overflowing.       */
@media (max-width: 480px) {
  .header-inner { padding: 0 0.625rem; }
  .phase-badge  { display: none; }
  .btn-view-toggle { display: none !important; }

  .lang-mismatch-hint {
    max-width: 52%;
    font-size: 0.64rem;
    padding: 0.16rem 0.42rem;
  }

  .footer-community {
    font-size: 0.68rem;
    padding: 0.2rem 0.75rem 0.45rem;
  }

  .lane {
    padding: 0.75rem 0.68rem 0.42rem;
  }

  .lane-header {
    gap: 0.28rem 0.35rem;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
  }

  .lane-trans-mode {
    max-width: 5.1rem;
  }

  .lane-trans-targets {
    flex-direction: column;
    gap: 0.2rem;
  }

  .lane-trans-target {
    min-height: 32px;
    max-width: 5.8rem;
  }

  .debug-overlay {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRIVACY NOTICE BANNER
   Shown until the user dismisses it; confirms no data leaves the browser.
   ═══════════════════════════════════════════════════════════════════════════ */
.privacy-notice {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: #061c2e;
  border-bottom: 1px solid #0d4f8a;
  font-size: 0.84rem;
  line-height: 1.5;
  z-index: 90;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

[data-theme="light"] .privacy-notice {
  background: #e8f4fd;
  border-bottom-color: #74b7e8;
}

.privacy-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.15em;
}

.privacy-text {
  flex: 1;
  color: var(--text-primary);
}

.privacy-text strong {
  color: #74c0fc;
}

[data-theme="light"] .privacy-text strong {
  color: #1971c2;
}

.btn-privacy-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.2rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--ease);
}

.btn-privacy-dismiss:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   CHAT FEED — unified single-column transcript view
   ═══════════════════════════════════════════════════════════════════════════ */
.chat-feed {
  flex: 1;
  min-height: 0;
  display: none;          /* default on desktop; shown via JS / mobile media query */
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.875rem;
  gap: 0.65rem;
  scroll-behavior: smooth;
}

.chat-feed::-webkit-scrollbar       { width: 3px; }
.chat-feed::-webkit-scrollbar-track { background: transparent; }
.chat-feed::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

.chat-feed:focus-visible {
  outline: 2px solid var(--accent-a);
  outline-offset: -2px;
}

.empty-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100% - 2rem));
  text-align: center;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  background: rgba(10, 10, 10, 0.84);
  z-index: 3;
  pointer-events: none;
}

[data-theme="light"] .empty-stage {
  background: rgba(255, 255, 255, 0.9);
}

.empty-stage h2 {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.empty-stage p {
  color: var(--text-muted);
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  line-height: 1.55;
}

.empty-stage p + p {
  margin-top: 0.45rem;
}

.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: card-enter 160ms ease-out both;
}

.chat-avatar {
  width: 38px;
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--speaker-color, #4dabf7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
}

.chat-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chat-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chat-speaker {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--speaker-color, #4dabf7);
}

.chat-bubble {
  border-radius: 0 14px 14px 14px;
  padding: 0.65rem 1rem;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble .low-confidence {
  text-decoration: underline;
  text-decoration-color: var(--warning);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.chat-time {
  font-size: 0.64rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ── View toggle button active state ────────────────────────────────────────── */
#btn-view-toggle[aria-pressed="true"],
#btn-view-toggle-alt[aria-pressed="true"] {
  background: var(--accent-a);
  color: #000;
}

/* The alt layout toggle lives in the options panel; show it only when the    */
/* primary toolbar toggle is hidden (narrow screens).                         */
.btn-view-toggle-alt { display: none; }
@media (max-width: 480px) {
  .btn-view-toggle-alt { display: inline-flex; }
}

/* ── View override classes (set by JS applyView) ────────────────────────────── */
body.view-chat  .lanes-grid { display: none  !important; }
body.view-chat  .chat-feed  { display: flex  !important; }
body.view-lanes .chat-feed  { display: none  !important; }
body.view-lanes .lanes-grid { display: grid  !important; }

@media (max-width: 700px) {
  .empty-stage {
    width: calc(100% - 1rem);
    padding: 0.95rem 0.85rem;
  }
}
