/* =====================================================================
   Scribe — "Modern Airy Minimal"
   Light, spacious, friendly-premium SaaS. Refined neutral paper palette
   with one calm sage/teal accent. Soft large radii, layered shadows,
   floating hero caption card. Reduced-motion aware.
   ===================================================================== */

/* The [hidden] attribute is the show/hide contract app.js drives — always wins. */
[hidden] { display: none !important; }

/* ---------- design tokens ---------- */
:root {
  /* neutral paper palette (warm, refined) */
  --paper:        #f6f5f2;   /* page bg */
  --paper-2:      #fbfaf8;   /* raised */
  --card:         #ffffff;   /* surfaces */
  --line:         #eae6df;   /* hairlines */
  --line-2:       #e2ddd4;

  --ink:          #1f2421;   /* primary text */
  --ink-2:        #4d544f;   /* secondary */
  --ink-3:        #6b736c;   /* muted — passes 4.5:1 on card/paper (text-safe) */
  --ink-4:        #9aa19a;   /* faint — DECORATIVE ONLY (dots, dividers), never text */

  /* one calm accent — sage / teal */
  --accent:       #2f8f7e;
  --accent-deep:  #1f6f60;
  --accent-soft:  #e4f1ec;
  --accent-tint:  #f0f7f4;
  --accent-glow:  rgba(47,143,126,.22);

  /* status hues (gentle, never alarming) */
  --warn:         #c08a3e;
  --warn-soft:    #f8efe0;
  --info:         #5b86a8;
  --info-soft:    #eaf1f6;
  --danger:       #c0473d;
  --low:          #9c7521;   /* low-confidence underline — perceptible on paper */

  /* radii — soft & large */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;
  --r-pill: 999px;

  /* layered shadows */
  --sh-1: 0 1px 2px rgba(31,36,33,.04), 0 2px 6px rgba(31,36,33,.04);
  --sh-2: 0 2px 6px rgba(31,36,33,.05), 0 10px 26px rgba(31,36,33,.07);
  --sh-3: 0 4px 12px rgba(31,36,33,.06), 0 22px 50px rgba(31,36,33,.10);
  --sh-float: 0 6px 16px rgba(31,36,33,.06), 0 30px 70px rgba(31,52,46,.12);

  /* type */
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* spacing rhythm (~8pt) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --speed: .32s;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
  letter-spacing: .002em;
  /* Desktop: the app owns the viewport and the transcript scrolls INSIDE the
     stage. Mobile reverts to normal page scroll (see the 880px breakpoint). */
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* visible, generous focus rings */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* ---------- atmospheric background (soft aurora) ---------- */
.aurora {
  position: fixed; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
}
.aurora__blob {
  position: absolute; border-radius: 50%;
  filter: blur(110px); opacity: .32;
}
.aurora__blob--1 { width: 48vw; height: 48vw; top: -18vw; left: -10vw;
  background: radial-gradient(circle, #d4ede4 0%, transparent 70%); }
.aurora__blob--2 { width: 40vw; height: 40vw; top: 36vh; right: -12vw;
  background: radial-gradient(circle, #ecf3ee 0%, transparent 70%); opacity: .26; }
/* third blob removed — a single calm accent reads cleaner than three muddy washes */
.aurora__blob--3 { display: none; }

.shell {
  position: relative; z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(20px, 3.2vw, 44px);
  height: 100dvh;                 /* bound the app to the viewport… */
  display: flex; flex-direction: column;   /* …so .layout (flex:1) can scroll inside */
}

/* =====================================================================
   HEADER
   ===================================================================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand__mark {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  color: #fff;
  background: linear-gradient(155deg, var(--accent), var(--accent-deep));
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name {
  font-weight: 600; font-size: 19px; letter-spacing: -.01em;
}
.brand__tag {
  font-size: 12px; color: var(--ink-3);
  letter-spacing: .06em; text-transform: lowercase;
}

.engine-pill {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 9px 15px 9px 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-1);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.engine-pill__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-4);
  box-shadow: 0 0 0 0 transparent;
}
.engine-pill[data-engine="ok"]      { color: var(--accent-deep); border-color: var(--accent-soft); }
.engine-pill[data-engine="ok"] .engine-pill__dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.engine-pill[data-engine="down"]    { color: var(--danger); }
.engine-pill[data-engine="down"] .engine-pill__dot { background: var(--danger); box-shadow: 0 0 0 4px #f7e6e4; }
.engine-pill[data-engine="unknown"] .engine-pill__dot { background: var(--ink-4); box-shadow: 0 0 0 4px var(--line); }

/* =====================================================================
   BANNERS
   ===================================================================== */
.banners { display: flex; flex-direction: column; gap: var(--s3); }
.banners:empty { display: none; }
.banner {
  display: flex; align-items: center; gap: var(--s3);
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--sh-1);
  margin-bottom: var(--s4);
  animation: bannerIn var(--speed) var(--ease);
}
.banner[hidden] { display: none; }
.banner__icon {
  flex: none;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600;
  background: var(--line); color: var(--ink-2);
}
.banner__msg { font-size: 14px; color: var(--ink); flex: 1 1 auto; }
.banner__btn {
  flex: none;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  transition: background var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.banner__btn:hover { background: var(--accent-deep); transform: translateY(-1px); }
.banner__btn:active { transform: translateY(0); }

.banner--info { background: var(--info-soft); border-color: #dfe9f1; }
.banner--info .banner__icon { background: #d6e4ee; color: var(--info); }
.banner--warn { background: var(--warn-soft); border-color: #f0e3cd; }
.banner--warn .banner__icon { background: #f1e2c6; color: var(--warn); }

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

/* =====================================================================
   LAYOUT
   ===================================================================== */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: clamp(20px, 2.4vw, 36px);
  align-items: stretch;
  /* Fill the remaining viewport height below the header, BOUNDED (min-height:0)
     so the stage is a fixed-height hero and the transcript scrolls inside it
     rather than growing the page. */
  flex: 1 1 auto;
  min-height: 0;
}

/* ---------- control rail ---------- */
.rail { display: flex; flex-direction: column; gap: var(--s4); min-height: 0; overflow-y: auto; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s5);
  box-shadow: none;   /* rail stays flat; only the stage lifts */
}
.panel__title {
  font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s4);
}

/* segmented control */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--s1);
  padding: var(--s1);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.segmented__opt { display: block; }
.segmented__face {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px;
  padding: 11px 4px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 12.5px; font-weight: 500;
  transition: background var(--speed) var(--ease),
              color var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease);
}
.segmented__face svg { color: var(--ink-3); transition: color var(--speed) var(--ease); }
.segmented__opt:hover .segmented__face { color: var(--ink); }
.segmented__opt input:checked + .segmented__face {
  background: var(--card);
  color: var(--accent-deep);
  box-shadow: var(--sh-1);
}
.segmented__opt input:checked + .segmented__face svg { color: var(--accent); }
.segmented__opt input:focus-visible + .segmented__face {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

/* file picker */
.filepick { margin-top: var(--s4); }
.filepick[hidden] { display: none; }
.file-drop {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  padding: var(--s5);
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink-3);
  text-align: center;
  transition: border-color var(--speed) var(--ease),
              background var(--speed) var(--ease),
              color var(--speed) var(--ease);
}
.file-drop:hover, .file-drop.is-drag {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-deep);
}
.file-drop svg { color: var(--accent); }
.file-drop__lead { font-size: 14px; font-weight: 600; color: var(--ink); }
.file-drop__sub  { font-size: 12px; }
.file-name { margin-top: var(--s3); font-size: 13px; color: var(--ink-3); text-align: center; }

/* ---------- mic device picker ---------- */
.mic-picker { margin-top: var(--s4); }
.mic-picker__label {
  display: block;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-3);
  margin-bottom: var(--s2);
}
.select-wrap { position: relative; }
.mic-select {
  appearance: none; -webkit-appearance: none;
  width: 100%;
  padding: 10px 38px 10px 14px;
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.mic-select:hover { border-color: var(--ink-4); }
.mic-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.select-wrap__chev {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  transition: transform var(--speed) var(--ease),
              background var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease),
              color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.btn:active { transform: translateY(1px); }

/* record — primary, large touch target */
.btn--record {
  position: relative;
  width: 100%;
  min-height: 54px;
  padding: 0 22px;
  color: #fff;
  background: linear-gradient(160deg, var(--accent), var(--accent-deep));
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.18);
  letter-spacing: .01em;
  overflow: hidden;
}
.btn--record:hover { box-shadow: var(--sh-3), inset 0 1px 0 rgba(255,255,255,.2); }
.btn__glyph {
  width: 13px; height: 13px; border-radius: 50%;   /* idle = record dot */
  background: #fff;
  transition: border-radius var(--speed) var(--ease), width var(--speed) var(--ease);
}
.btn__pulse {
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

/* transport row */
.transport-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--s2);
  margin-top: var(--s3);
}
.btn--ghost {
  min-height: 44px;
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn--ghost:hover { background: var(--paper-2); border-color: var(--line-2); color: var(--ink); }
.btn--ghost svg { color: var(--ink-3); }

/* chips */
.chips { margin-top: var(--s4); display: flex; gap: var(--s2); flex-wrap: wrap; }
.vad-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
}
.vad-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.vad-chip[data-mode="silero"] { color: var(--accent-deep); border-color: var(--accent-soft); background: var(--accent-tint); }
.vad-chip[data-mode="silero"] .vad-chip__dot { background: var(--accent); }
.vad-chip[data-mode="energy"] { color: var(--warn); border-color: #f0e3cd; background: var(--warn-soft); }
.vad-chip[data-mode="energy"] .vad-chip__dot { background: var(--warn); }
.vad-chip[data-mode="idle"] .vad-chip__dot { background: var(--ink-4); }

/* level meter */
.meter { margin-top: var(--s4); display: flex; align-items: center; gap: var(--s3); }
.meter__label {
  font-size: 12px; letter-spacing: .01em;
  color: var(--ink-3); flex: none;
}
.level {
  flex: 1 1 auto; height: 8px;
  border-radius: var(--r-pill);
  background: var(--line);
  overflow: hidden;
}
.level__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #54b39f);
  transition: width .12s linear;
}

/* ---------- history ---------- */
.panel--history { padding: var(--s4) var(--s4) var(--s4); }
.history-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 6px 8px;
  background: transparent; border: 0;
  border-radius: var(--r-sm);
}
.history-toggle:hover { background: var(--paper); }
.history-toggle__lead {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: .01em;
}
.history-toggle__chev {
  color: var(--ink-3);
  transition: transform var(--speed) var(--ease);
}
.panel--history[data-open="false"] .history-toggle__chev { transform: rotate(-90deg); }
.pill-count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-deep);
  font-size: 12px; font-weight: 600;
}

.sessions { list-style: none; margin: var(--s3) 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.panel--history[data-open="false"] .sessions,
.panel--history[data-open="false"] .sessions-empty { display: none; }
.session {
  display: flex; align-items: center; gap: 6px;
  padding: 4px;
  border-radius: var(--r-md);
  transition: background var(--speed) var(--ease);
}
.session:hover { background: var(--paper); }
.session__open {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px;
  background: transparent; border: 0; border-radius: var(--r-sm);
  text-align: left;
}
.session__open strong {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session__open time { font-size: 11.5px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.session__tools {
  display: flex; gap: 4px; flex: none;
  opacity: 0; transform: translateX(4px);
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.session:hover .session__tools,
.session:focus-within .session__tools { opacity: 1; transform: translateX(0); }
.session__tool {
  padding: 5px 9px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 11.5px; font-weight: 500; color: var(--ink-2);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.session__tool:hover { background: var(--paper); color: var(--ink); }
.session__tool--danger { color: var(--danger); }
.session__tool--danger:hover { background: #f9ebea; border-color: #f0d6d3; color: var(--danger); }
.sessions-empty { margin: var(--s3) 8px 4px; font-size: 13px; color: var(--ink-3); }
.sessions-empty[hidden] { display: none; }

/* =====================================================================
   HERO CAPTION STAGE
   ===================================================================== */
.stage-wrap { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; min-height: 0; }

.stage {
  position: relative;
  display: flex; flex-direction: column;
  flex: 1 1 auto;       /* grow to fill the layout column — the transcript hero */
  min-height: 340px;    /* floor only, for very short windows */
  padding: clamp(22px, 2.6vw, 38px);
  background:
    radial-gradient(130% 55% at 50% 0%, var(--accent-tint) 0%, transparent 28%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;     /* clips children to the radius; .transcript scrolls */
}

.stage__top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3);
  padding-bottom: var(--s3);
  margin-bottom: var(--s3);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.statusword {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px 5px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-2);
}
.statusword__live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-4); flex: none;
}
.statusword__clock {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  letter-spacing: 0; font-weight: 600;
  padding-left: 8px; margin-left: 1px;
  border-left: 1px solid currentColor; opacity: .72;
}
.statusword__clock:empty { display: none; }
.stage__hint { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }
.stage__hint[hidden] { display: none; }

/* transcript — THE scroll container (the stage clips for radius only) */
.transcript {
  flex: 1 1 auto;
  min-height: 0;            /* lets the flex child actually shrink + scroll */
  overflow-y: auto;
  padding-right: 8px;
  padding-bottom: var(--s4); /* last line clears the bottom edge */
  scroll-behavior: smooth;
  /* fade the TOP edge only so the newest live words at the bottom stay crisp */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 16px, #000 100%);
}
.transcript::-webkit-scrollbar { width: 8px; }
.transcript::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: var(--r-pill); }
.transcript::-webkit-scrollbar-track { background: transparent; }

.line {
  font-family: var(--serif);
  font-size: clamp(19px, 1.55vw, 23px);
  line-height: 1.55;
  color: var(--ink-2);            /* older lines recede… */
  max-width: 66ch;                /* comfortable reading measure */
  margin-bottom: var(--s3);
  text-wrap: pretty;
  overflow-wrap: anywhere;        /* long tokens wrap, never clip the card */
  animation: lineIn .3s var(--ease) both;
}
.transcript .line:last-of-type { color: var(--ink); }  /* …newest is dominant */
@keyframes lineIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.line__ts {
  display: inline-block;
  margin-right: 10px;
  font-family: var(--mono);
  font-size: .58em;
  font-weight: 500;
  color: var(--ink-4);
  vertical-align: 2px;
  letter-spacing: .02em;
}
.word { transition: color var(--speed) var(--ease); }
/* low-confidence — subtle dotted underline, never alarming */
.word--low {
  color: var(--ink-2);
  border-bottom: 1.5px dotted var(--low);
  padding-bottom: 1px;
  cursor: help;
}

/* interim live line — the words being spoken NOW, so full-contrast, not faded */
.interim {
  flex: none;
  font-family: var(--serif);
  font-size: clamp(19px, 1.55vw, 23px);
  line-height: 1.55;
  font-style: italic;
  color: var(--ink);
  max-width: 66ch;
  margin-top: var(--s2);
  padding-top: var(--s3);
  overflow-wrap: anywhere;
}
.interim[data-empty] { display: none; }      /* no empty italic line + caret at idle */
.interim::after {
  content: "";
  display: inline-block;
  width: 2px; height: 1.05em;
  margin-left: 4px;
  vertical-align: -2px;
  background: var(--accent);
  border-radius: 2px;
  animation: caret 1.1s steps(2, start) infinite;
}
@keyframes caret { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* empty state — a quiet hint, shown ONLY at true idle (app.js toggles [hidden]) */
.empty {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: var(--s2);
  padding: var(--s6) var(--s5);
}
.empty[hidden] { display: none; }
/* Defensive belt-and-suspenders: the placeholder can never co-exist with text. */
.stage:has(.line) #empty-state { display: none; }
.empty__art {
  color: var(--accent);
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--accent-tint);
  margin-bottom: var(--s1);
}
.empty__art svg { width: 34px; height: 34px; }
.empty__title { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--ink); }
.empty__sub { max-width: 34ch; font-size: 14px; color: var(--ink-3); line-height: 1.6; }

/* jump-to-live floating button */
.jump-live {
  position: absolute;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--accent-soft);
  background: var(--card);
  color: var(--accent-deep);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--sh-2);
  animation: jumpIn var(--speed) var(--ease);
}
.jump-live[hidden] { display: none; }
.jump-live:hover { background: var(--accent-tint); transform: translateX(-50%) translateY(-1px); }
@keyframes jumpIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ---------- readouts strip ---------- */
.readouts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s1);
  padding: 6px var(--s3);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: none;
  flex: none;
}
.readout {
  display: flex; flex-direction: column; align-items: center;
  gap: 1px;
  padding: 7px 6px;
  border-radius: var(--r-sm);
}
.readout__val {
  font-family: var(--mono);
  font-size: 15px; font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.readout__key {
  font-size: 10.5px; letter-spacing: .02em;
  color: var(--ink-3);
}

/* ---------- export ---------- */
.export {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: none;
  flex: none;
}
.btn--soft {
  position: relative;
  min-height: 40px; padding: 0 16px;
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
}
.btn--soft:hover { background: var(--paper-2); border-color: var(--line-2); color: var(--ink); }
.btn--soft svg { color: var(--ink-3); }
#btn-copy { color: var(--ink); }
.export__sep { width: 1px; height: 24px; background: var(--line); margin: 0 2px; }
.copy-flash {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: inherit;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
  opacity: 0; transform: scale(.96);
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.btn--copied .copy-flash { opacity: 1; transform: scale(1); }

/* =====================================================================
   STATE-DRIVEN VISUALS  (html[data-state])
   ===================================================================== */

/* recording — UNMISTAKABLE: the primary button turns into a red Stop, and the
   stage status becomes a live red pill with a scaling dot + a moving clock. */
[data-state="recording"] .btn--record,
[data-state="paused"]    .btn--record {
  background: linear-gradient(160deg, #d9726a, var(--danger));
}
[data-state="recording"] .btn__glyph,
[data-state="paused"]    .btn__glyph { border-radius: 3px; }   /* stop square */
[data-state="recording"] .btn--record .btn__pulse {
  box-shadow: 0 0 0 0 rgba(255,255,255,.5);
  animation: recPulse 2.4s var(--ease) infinite;
}
[data-state="recording"] .statusword {
  background: #fdeceb; border-color: #f3d4d1; color: var(--danger);
}
[data-state="recording"] .statusword__live {
  background: var(--danger);
  animation: livePulse 1.5s var(--ease) infinite;
}
@keyframes livePulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%      { transform: scale(1.4); opacity: .55; }
}
@keyframes recPulse {
  0%   { box-shadow: inset 0 0 0 0 rgba(255,255,255,.4); }
  60%  { box-shadow: inset 0 0 0 2px rgba(255,255,255,0); }
  100% { box-shadow: inset 0 0 0 0 rgba(255,255,255,0); }
}

/* paused — calm amber, motion frozen */
[data-state="paused"] .statusword {
  background: var(--warn-soft); border-color: #f0e3cd; color: var(--warn);
}
[data-state="paused"] .statusword__live { background: var(--warn); }
[data-state="paused"] .stage { box-shadow: var(--sh-2); }

/* reconnecting — info blue, blinking */
[data-state="reconnecting"] .statusword {
  background: var(--info-soft); border-color: #dfe9f1; color: var(--info);
}
[data-state="reconnecting"] .statusword__live {
  background: var(--info);
  animation: blink 1s steps(2, start) infinite;
}
[data-state="reconnecting"] .stage { opacity: .94; }
@keyframes blink { 50% { opacity: .25; } }

/* idle — calm record button, neutral dot */
[data-state="idle"] .statusword__live { background: var(--ink-4); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

/* tablet ~960 — a real intermediate step (was a jump from 280px to stacked) */
@media (max-width: 1080px) and (min-width: 881px) {
  .layout { grid-template-columns: 248px minmax(0, 1fr); }
}

/* stacked — the transcript LEADS, controls follow; the PAGE scrolls again */
@media (max-width: 880px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100dvh; display: block; }
  .layout { display: flex; flex-direction: column; min-height: 0; gap: var(--s4); }
  .stage-wrap { order: -1; }
  /* Stage is a capped region: the transcript scrolls inside it, the page
     scrolls for the controls below. */
  .stage { min-height: min(56vh, 460px); max-height: 74vh; }
  .rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s4);
    align-items: start;
    overflow: visible;
  }
  .panel--transport,
  .panel--history { grid-column: 1 / -1; }
}

/* mobile ~390 */
@media (max-width: 560px) {
  .shell { padding: 16px; }
  .topbar { flex-wrap: nowrap; }
  #engine-pill-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail { grid-template-columns: 1fr; }
  .readouts { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .readout:last-child { grid-column: 1 / -1; } /* "words" spans its own row, no empty cell */
  .export { gap: 6px; }
  .btn--soft { flex: 1 1 auto; min-height: 44px; }  /* 44px touch target */
  .export__sep { display: none; }
  .line, .interim { font-size: 18px; }
  .stage { padding: 20px; border-radius: var(--r-lg); }
  .empty { padding: var(--s5) var(--s4); }
  .empty__art { width: 54px; height: 54px; }
  .history-toggle { padding: 10px 8px; }   /* 44px-class touch target */
}

@media (max-width: 380px) {
  .segmented__face span:not(.sr-only) { font-size: 11.5px; }
}

/* =====================================================================
   REDUCED MOTION
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .interim::after { animation: none; opacity: 1; }
}
