/* Studio recorder — mobile-first, dark, minimal. "Words before and after,
   colors during": mid-take UI is deliberately sparse and glanceable. */

:root {
  --bg: #0b0d12;
  --ink: #f3f5f8;
  --muted: #9aa4b2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #6ea8fe;
  --good: #35d07f;
  --warn: #ffcf5c;
  --bad: #ff6b6b;
  --sheet: rgba(14, 17, 24, 0.92);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Shared full-bleed camera preview */
#preview {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000;
  transform: scaleX(-1); /* mirror front camera so it reads like a mirror */
  transition: opacity 0.4s ease;
}
#scrim {
  position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.05) 30%, rgba(0,0,0,0.55) 100%);
}
/* Preview only visible on setup + rolling screens */
body[data-screen="loading"] #preview,
body[data-screen="brief"] #preview,
body[data-screen="review"] #preview { opacity: 0; }
body[data-screen="loading"] #scrim,
body[data-screen="brief"] #scrim,
body[data-screen="review"] #scrim { background: var(--bg); }

/* Screen visibility */
.screen { position: fixed; inset: 0; display: none; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); }
body[data-screen="loading"] .screen[data-for="loading"],
body[data-screen="brief"] .screen[data-for="brief"],
body[data-screen="setup"] .screen[data-for="setup"],
body[data-screen="rolling"] .screen[data-for="rolling"],
body[data-screen="review"] .screen[data-for="review"] { display: block; }

.center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 8px; }
.brand { font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 22px; }
.brand.small { font-size: 13px; color: var(--muted); letter-spacing: 0.16em; }
.muted { color: var(--muted); }

/* Sheets (brief, review) — scrollable card */
.sheet {
  position: relative; max-width: 560px; margin: 0 auto; height: 100%;
  overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
  -webkit-overflow-scrolling: touch;
}
.sheet h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 0; }
.intent { color: var(--muted); margin: 0; }
.label { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.fineprint { color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 12px; }

.beats { list-style: none; counter-reset: b; padding: 0; margin: 4px 0; display: grid; gap: 10px; }
.beats li {
  counter-increment: b; position: relative; padding: 12px 12px 12px 44px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px;
}
.beats li::before {
  content: counter(b); position: absolute; left: 12px; top: 11px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #06101f;
  font-size: 13px; font-weight: 700; display: grid; place-content: center;
}
.beats li b { display: block; }
.beats li .tgt { color: var(--muted); font-size: 12px; }

/* Buttons */
button { font: inherit; cursor: pointer; border: none; border-radius: 12px; }
.primary {
  background: var(--accent); color: #06101f; font-weight: 700;
  padding: 15px 18px; width: 100%; font-size: 17px;
}
.primary:disabled { opacity: 0.5; }
.link { background: none; color: var(--muted); text-decoration: underline; padding: 8px; width: 100%; }

/* Setup check */
.top-bar { position: absolute; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; display: flex; gap: 8px; }
.pill { background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.pill.ghost { color: var(--muted); }
.setup-readouts {
  position: absolute; left: 12px; right: 12px; bottom: 190px;
  display: grid; gap: 8px;
}
.check {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(10px); border-radius: 12px;
  border-left: 3px solid var(--muted); font-size: 14.5px;
}
.check .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.check.good { border-left-color: var(--good); } .check.good .dot { background: var(--good); }
.check.warn { border-left-color: var(--warn); } .check.warn .dot { background: var(--warn); }
.check.bad  { border-left-color: var(--bad); }  .check.bad  .dot { background: var(--bad); }
.check .msg { flex: 1; }
.check .metric { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.bottom-dock {
  position: absolute; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bottom));
  display: grid; gap: 8px; text-align: center;
}
.setup-summary { margin: 0 0 4px; font-size: 15px; min-height: 22px; }

/* Rolling */
#selfview {
  position: absolute; top: calc(58px + var(--safe-top)); right: 14px;
  width: 96px; height: 128px; object-fit: cover; border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.6); transform: scaleX(-1);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5); background: #000; z-index: 3;
}
.roll-top {
  position: absolute; top: calc(16px + var(--safe-top)); left: 16px;
  display: flex; align-items: center; gap: 10px; z-index: 3;
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bad); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.clock { font-variant-numeric: tabular-nums; font-size: 15px; background: rgba(0,0,0,0.5); padding: 4px 10px; border-radius: 999px; }

/* Ambient pace cue — pure color + motion, no text */
.pace-cue { width: 26px; height: 26px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 rgba(0,0,0,0); }
.pace-cue.pocket { background: var(--good); animation: pocket-pulse 1.7s ease-in-out infinite; }
.pace-cue.slow   { background: var(--warn); animation: slow-flash 0.5s steps(2) infinite; }
.pace-cue.quiet  { background: rgba(255,255,255,0.25); }
@keyframes pocket-pulse { 0%,100% { transform: scale(0.85); box-shadow: 0 0 0px 0px rgba(53,208,127,0.0);} 50% { transform: scale(1.1); box-shadow: 0 0 14px 4px rgba(53,208,127,0.45);} }
@keyframes slow-flash { 0% { opacity: 1; } 100% { opacity: 0.35; } }

.segue-wrap { position: absolute; left: 16px; right: 16px; bottom: 128px; text-align: center; z-index: 3; }
.segue {
  font-size: 21px; line-height: 1.3; font-weight: 600; text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  transition: opacity 0.4s ease, transform 0.4s ease; opacity: 1;
}
.segue.swapping { opacity: 0; transform: translateY(8px); }
.beat-progress { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.beat-progress span { width: 26px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); }
.beat-progress span.active { background: var(--accent); }
.beat-progress span.done { background: rgba(255,255,255,0.6); }
.good-length { margin-top: 8px; color: var(--good); font-size: 13px; opacity: 0; transition: opacity 0.4s; }
.good-length.show { opacity: 1; }

.roll-dock {
  position: absolute; left: 0; right: 0; bottom: calc(20px + var(--safe-bottom));
  display: flex; align-items: center; justify-content: center; gap: 16px; z-index: 3;
}
.next-beat { background: rgba(255,255,255,0.14); color: var(--ink); padding: 14px 22px; font-weight: 600; backdrop-filter: blur(8px); }
.talkback, .stop {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-content: center;
  backdrop-filter: blur(8px);
}
.talkback { background: rgba(110,168,254,0.22); border: 1.5px solid var(--accent); color: var(--ink); flex-direction: column; gap: 0; }
.talkback.listening { background: var(--accent); color: #06101f; animation: pocket-pulse 1s infinite; }
.talkback .tb-icon { font-size: 20px; font-weight: 700; line-height: 1; }
.talkback .tb-label { font-size: 10px; }
.stop { background: rgba(255,107,107,0.2); border: 1.5px solid var(--bad); color: var(--ink); font-size: 18px; }

.talkback-answer {
  position: absolute; left: 16px; right: 16px; bottom: calc(96px + var(--safe-bottom)); z-index: 5;
  background: var(--sheet); border: 1px solid var(--accent); border-radius: 16px; padding: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.tb-answer-text { font-size: 16px; margin-bottom: 10px; }

/* Review / upload */
.upload-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.upload-row span { width: 46px; color: var(--muted); }
.upload-row b { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 8px; background: rgba(255,255,255,0.1); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.bar.done i { background: var(--good); }
.beat-timeline { display: grid; gap: 6px; margin: 8px 0; }
.tl-beat { display: flex; gap: 8px; font-size: 13px; align-items: baseline; }
.tl-beat .tc { color: var(--accent); font-variant-numeric: tabular-nums; width: 96px; flex: none; }
.tl-beat .bl { color: var(--muted); }
.contribution {
  background: #05070b; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-size: 11px; line-height: 1.4; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(0,0,0,0.85); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 20; max-width: 90vw; text-align: center;
}

/* ---- Build 2: the real director ---- */
.director-pill { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.director-pill.live { color: var(--good); border-color: var(--good); }
.coach-note { margin-top: 10px; font-size: 14px; font-style: italic; color: #ffd97a; text-shadow: 0 1px 6px rgba(0,0,0,0.6); animation: coach-in 0.3s ease-out; }
@keyframes coach-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tb-answer-meta { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
