/* Shared tokens + transcript styles for the studio and the preview page. */
:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: #e6e6e3;
  --hover: #f0f0ec;
  --accent: #3b5bdb;
  --accent-fg: #ffffff;
  --active-bg: #fff6d6;
  --word-bg: #ffd43b;
  --word-fg: #1d1d1f;
  --unsure: #e8590c;
  --ok: #2b8a3e;
  --warn: #c76a00;
  --err: #c92a2a;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --panel: #1c1c1f;
    --fg: #ececf0;
    --muted: #9b9ba3;
    --line: #2c2c31;
    --hover: #26262b;
    --accent: #7c93ff;
    --accent-fg: #0f0f12;
    --active-bg: #2f2a14;
    --word-bg: #c9a227;
    --word-fg: #111;
    --unsure: #ff8f5a;
    --ok: #51cf66;
    --warn: #ffb347;
    --err: #ff6b6b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
button, select, input, textarea { font: inherit; color: inherit; }
.btn {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn[aria-pressed="true"] { background: var(--active-bg); border-color: var(--word-bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
select.btn { padding-right: 8px; }

video, audio { display: block; width: 100%; border-radius: var(--radius); }
video { background: #000; max-height: 56vh; }

.transcript { position: relative; overflow-y: auto; }
.seg {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 12px;
}
.seg + .seg { border-top: 1px solid var(--line); }
.seg.active { background: var(--active-bg); }
/* Zero-height and sticky, so the button floats at the bottom of whatever scrolls the
   transcript (its own box, or the page) without taking up a row. */
.follow-back {
  position: sticky;
  bottom: 0;
  z-index: 3;
  height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.follow-back .btn {
  margin-bottom: 14px;
  pointer-events: auto;
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.follow-back .btn:hover { background: var(--fg); filter: brightness(1.15); }
.ts {
  all: unset;
  cursor: pointer;
  color: var(--muted);
  font: 12px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ts:hover, .ts:focus-visible { color: var(--accent); text-decoration: underline; }
.txt { line-height: 1.75; min-width: 0; overflow-wrap: anywhere; }
.w { border-radius: 4px; padding: 1px 2px; margin: 0 -2px; cursor: pointer; }
.w:hover { background: var(--hover); }
.w.on { background: var(--word-bg); color: var(--word-fg); }
.w.unsure {
  text-decoration: underline wavy var(--unsure);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.stale .ts::after { content: " ⚠"; color: var(--warn); }
kbd {
  font: 11px ui-monospace, Menlo, monospace;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
}

/* Phones and narrow portrait windows: the video + controls ("stage") stick to the top
   and the transcript flows in the page under them, so there's one scroll bar. */
@media (max-width: 860px) and (orientation: portrait) {
  .stage {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: 0 -16px;
    padding: 8px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .stage video { max-height: 38vh; max-height: 38dvh; }
  .transcript { overflow: visible; max-height: none; }
  .seg { grid-template-columns: 50px 1fr auto; gap: 8px; padding: 9px 10px; }
}
/* Phones either way up: icon-only control buttons so they stay on one row. */
@media (max-width: 520px) and (orientation: portrait), (orientation: landscape) and (max-height: 520px) {
  .stage .label { display: none; }
}
/* Touch screens: no keyboard shortcuts to explain. */
@media (hover: none) {
  .keys-help { display: none !important; }
}
