:root {
  --bg: #F3F4F8;
  --surface: #FFFFFF;
  --ink: #141A26;
  --muted: #5C6577;
  --line: #DADEE7;
  --accent: #2F4BD8;
  --accent-ink: #FFFFFF;
  --soft: #E9EDFB;
  --night: #151A26;
  --go: #1C8A4C;
  --warn: #F2C230;
  --stop: #D1352A;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1218;
    --surface: #181C26;
    --ink: #E7EAF1;
    --muted: #9AA3B6;
    --line: #2A303D;
    --accent: #8FA2FF;
    --accent-ink: #0F1218;
    --soft: #1F2538;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#app { max-width: 560px; margin: 0 auto; padding-inline: 16px; padding-block: 0 56px; display: grid; gap: 14px; }

h1 { font: 800 clamp(36px, 10vw, 52px)/0.95 var(--display); letter-spacing: -0.015em; margin: 6px 0 10px; text-wrap: balance; }
h2 { font: 800 26px/1.05 var(--display); letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h3 { font: 600 16px/1.3 var(--body); margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font: 600 11px/1.2 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stack { display: grid; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 12px; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* buttons */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 14px 18px; min-height: 54px; width: 100%;
  font: 600 16px/1.2 var(--body); background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.secondary { background: var(--soft); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); min-height: 46px; }
.link { background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--accent); cursor: pointer; justify-self: start; }

/* top bar */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 14px 2px; }
.bar a { color: var(--muted); text-decoration: none; font-weight: 500; }

/* home */
.hero { padding-block: 26px 6px; display: grid; gap: 4px; }
.roles { display: grid; gap: 10px; }
.roles a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  color: inherit; text-decoration: none;
}
.roles a:hover { border-color: var(--accent); }
.roles b { font: 700 20px/1.15 var(--display); }
.roles span { color: var(--muted); font-size: 14px; grid-column: 1; }
.roles a::after { content: "→"; grid-row: 1 / 3; grid-column: 2; color: var(--muted); font-size: 18px; }
.note { display: grid; gap: 12px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.note b { color: var(--ink); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px;
  font: 600 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--soft); color: var(--ink); white-space: nowrap;
}
.chip.live, .chip.pitching { background: var(--stop); color: #fff; }
.chip.qa { background: var(--warn); color: #141A26; }
.chip.scoring { background: var(--accent); color: var(--accent-ink); }
.chip.done { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* forms */
label.f { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input[type="text"], textarea, select {
  font: 400 16px/1.4 var(--body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.nudge { font-size: 13px; color: var(--accent); font-weight: 500; }
.error { color: var(--stop); font-weight: 600; }
.who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.who b { color: var(--ink); }

.sr { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label {
  flex: 1 1 140px; display: grid; gap: 2px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  cursor: pointer; font-weight: 600;
}
.choice label small { font-weight: 400; color: var(--muted); font-size: 13px; }
.choice.two label { text-align: center; font-size: 17px; }
.choice input:checked + label { border-color: var(--accent); background: var(--soft); }
.choice input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

/* scorecard */
.crit { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding-top: 10px; border-top: 1px solid var(--line); }
.crit b { display: block; font-size: 15px; }
.term { font: 500 10.5px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg label {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; font: 600 14px/1 var(--mono); cursor: pointer;
}
.seg input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

/* chair */
.now-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.clockbox { text-align: right; display: grid; }
.clockbox .clock { font: 600 40px/1 var(--mono); font-variant-numeric: tabular-nums; }
.clockbox small { color: var(--muted); font-size: 12px; }
.sentence { display: grid; gap: 4px; }
.sentence p { font-weight: 500; }
.say { background: var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; display: grid; gap: 4px; }
.say b { font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ros ol { list-style: none; margin: 8px 0 0; padding: 0; }
.ros li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.ros li.cur span:first-child { font-weight: 700; }

/* jargon hunter */
.speaker { display: flex; gap: 10px; align-items: center; font-size: 18px; }
.tally { display: grid; gap: 12px; }
.tally button {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; text-align: left;
  min-height: 108px; padding: 18px 20px; border-radius: 18px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font: inherit;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.tally button:active { background: var(--soft); }
.tally b { font: 800 28px/1 var(--display); }
.tally small { grid-column: 1; color: var(--muted); font-size: 13px; }
.tally output { grid-row: 1 / 3; grid-column: 2; font: 600 46px/1 var(--mono); font-variant-numeric: tabular-nums; }

/* empty / eyes-up states */
.empty { padding-block: 40px 8px; display: grid; gap: 12px; }
.empty.eyes h2 { font-size: 44px; }

/* timer screen */
body[data-view="timer"] #app { max-width: none; padding: 0; }
.screen {
  position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; gap: 16px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--night); color: #FFFFFF; transition: background-color 0.25s;
}
.screen .top { display: flex; justify-content: space-between; align-items: center; }
.screen .top a { color: inherit; opacity: 0.75; text-decoration: none; font-weight: 500; }
.screen .eyebrow { color: inherit; opacity: 0.75; }
.screen .mid { display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; }
.shape { font-size: clamp(56px, 20vw, 150px); line-height: 1; min-height: 1em; }
.word { font: 800 clamp(48px, 15vw, 120px)/0.9 var(--display); text-transform: uppercase; letter-spacing: -0.01em; }
.word.small { font-size: clamp(36px, 11vw, 72px); }
.screen .clock { font: 600 clamp(30px, 9vw, 64px)/1 var(--mono); font-variant-numeric: tabular-nums; }
.screen .clock.big { font-size: clamp(64px, 22vw, 150px); }
.screen .sub { opacity: 0.8; max-width: 32ch; }
.screen .foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; opacity: 0.85; }
.screen .btn { background: rgba(255, 255, 255, 0.14); color: inherit; border: 1.5px solid rgba(255, 255, 255, 0.45); }
.screen[data-state="green"] { background: var(--go); }
.screen[data-state="yellow"] { background: var(--warn); color: #141A26; }
.screen[data-state="yellow"] .btn { border-color: rgba(20, 26, 38, 0.4); }
.screen[data-state="red"], .screen[data-state="stop"] { background: var(--stop); }
.screen[data-state="stop"] .word { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* reports */
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.awards div { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 4px; }
.awards b { font: 700 19px/1.2 var(--display); }
.report { gap: 20px; }
.report section { display: grid; gap: 8px; }
.report h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.verdict { display: flex; align-items: center; gap: 16px; }
.verdict .big { font: 800 68px/0.85 var(--display); font-variant-numeric: tabular-nums; }
.verdict .big span { font-size: 30px; color: var(--muted); }
.dots { display: flex; gap: 6px; margin-top: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--go); }
.dots i.n { background: transparent; border: 2.5px solid var(--stop); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { font-size: 15px; }
.list li span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.meant p { font-weight: 600; font-size: 17px; line-height: 1.4; margin-top: 2px; }
.heard { margin-top: 6px; display: grid; gap: 6px; }
mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.profile { font-size: 14px; }
.bars { display: grid; gap: 9px; }
.brow { display: grid; grid-template-columns: 104px 1fr 34px; gap: 10px; align-items: center; }
.brow b { display: block; font-size: 14px; line-height: 1.2; }
.brow small { font: 500 10px/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.track { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.track i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.val { font: 600 14px/1 var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; border-top: 1px solid var(--line); padding-top: 16px; }
.stats div { display: grid; gap: 2px; align-content: start; }
.stats b { font: 600 24px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: 12.5px; }
.sample-flag { font-size: 13px; color: var(--muted); }

@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .seg { gap: 4px; }
  .seg label { width: 36px; height: 36px; }
  .awards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .screen { transition: none; }
  .screen[data-state="stop"] .word { animation: none; }
}

/* ---------- script follower: handwritten on papyrus ---------- */
/* One deliberate look in both themes: dark ink on papyrus, red ink for headings (rubrics). */
body[data-view="script"] {
  --papyrus: #E8D6A8;
  --ink: #3A2716;
  --ink-faint: rgba(58, 39, 22, 0.36);
  --muted: rgba(58, 39, 22, 0.68);
  --line: rgba(58, 39, 22, 0.25);
  --rubric: #8E3B1F;
  --swash: rgba(196, 128, 52, 0.32);
  --accent: #8E3B1F;
  --accent-ink: #F6E7C8;
  --soft: rgba(255, 248, 228, 0.5);
  --hand: "Kalam", "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
  --hand-title: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  color-scheme: light;
  color: var(--ink);
  background-color: var(--papyrus);
  /* Papyrus is two layers of plant strips laid crosswise: stretched noise in each direction, plus grain. */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .45' numOctaves='4' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .40 0 0 0 0 .27 0 0 0 0 .11 0 0 0 .30 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.5 .006' numOctaves='4' seed='6' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .40 0 0 0 0 .27 0 0 0 0 .11 0 0 0 .14 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .40 0 0 0 0 .27 0 0 0 0 .11 0 0 0 .10 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 40%, rgba(255, 246, 220, 0.5), rgba(140, 96, 44, 0.24) 100%);
  background-attachment: fixed;
}
body[data-view="script"] #app { max-width: 680px; padding-block-end: 170px; font-family: var(--hand); }
body[data-view="script"] .bar a,
body[data-view="script"] .link { font: 700 18px/1.2 var(--hand); color: var(--rubric); }
body[data-view="script"] .bar select {
  width: auto; font: 400 16px/1.2 var(--hand); color: var(--ink); padding: 4px 8px;
  background: transparent; border: 1.5px dashed var(--line); border-radius: 8px;
}
body[data-view="script"] .btn.secondary { font-family: var(--hand); font-size: 18px; background: var(--soft); border: 1.5px dashed var(--line); }

.rubric { font: 700 clamp(32px, 8vw, 44px)/1 var(--hand-title); color: var(--rubric); margin: 14px 0 4px; letter-spacing: 0.01em; }
.rubric .num { font-size: 0.7em; margin-right: 6px; opacity: 0.85; }
.hand-note { font: 400 18px/1.45 var(--hand); color: var(--muted); }

.where {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2;
  display: grid; gap: 6px; padding-block: 10px 14px;
  font: 700 24px/1.1 var(--hand-title); color: var(--rubric);
  background: linear-gradient(var(--papyrus) 72%, rgba(232, 214, 168, 0));
}
.ink-line { display: block; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ink-line i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.4s; }

.scroll { font: 400 clamp(22px, 5.6vw, 28px)/1.65 var(--hand); }
.scroll p { margin: 0; }
.part { padding-block: 6px 10px; opacity: 0.75; transition: opacity 0.3s; }
.part.cur { opacity: 1; }
.s { cursor: pointer; padding: 0 2px; border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.s.now { background: linear-gradient(transparent 56%, var(--swash) 56% 94%, transparent 94%); }
.w { color: var(--ink-faint); transition: color 0.25s; }
.w.said { color: var(--ink); }
.w.next { color: var(--ink); text-decoration: underline wavy var(--rubric); text-decoration-thickness: 1.5px; text-underline-offset: 7px; }

.cue {
  position: fixed; left: 50%; bottom: calc(132px + env(safe-area-inset-bottom, 0px)); z-index: 3;
  width: min(92vw, 560px); transform: translateX(-50%) rotate(-0.8deg);
  background: #F4E7C5; padding: 10px 16px 12px; box-shadow: 0 6px 16px rgba(70, 40, 10, 0.25);
  font: 400 21px/1.35 var(--hand); color: var(--ink);
}
.cue span { display: block; font: 700 20px/1 var(--hand-title); color: var(--rubric); margin-bottom: 4px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 26px max(16px, calc((100% - 680px) / 2)) calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(rgba(232, 214, 168, 0), var(--papyrus) 40%);
}
.elapsed { justify-self: start; font: 700 28px/1 var(--hand-title); font-variant-numeric: tabular-nums; }
.dock .link { justify-self: end; }

/* the wax seal that starts and stops listening */
.seal {
  width: 96px; height: 96px; border: 0; cursor: pointer; display: grid; place-items: center;
  border-radius: 47% 53% 50% 50% / 52% 47% 53% 48%;
  background: radial-gradient(circle at 36% 30%, #C9573F, #8C2B1B 58%, #6A1C10);
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.12), inset 0 0 0 10px rgba(255, 255, 255, 0.07), 0 6px 14px rgba(70, 30, 10, 0.35);
  color: #F6E7C8; font: 700 23px/1 var(--hand-title);
}
.seal.small { width: 84px; height: 84px; justify-self: center; font-size: 22px; }
.seal.on { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe {
  50% { transform: scale(1.05); box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.12), 0 0 0 12px rgba(142, 59, 31, 0.14), 0 6px 14px rgba(70, 30, 10, 0.35); }
}

.upload {
  display: block; text-align: center; cursor: pointer; padding: 14px; border-radius: 10px;
  border: 1.5px dashed var(--rubric); color: var(--rubric); font: 700 19px/1.3 var(--hand);
  background: var(--soft);
}
.upload:focus-within { outline: 3px solid var(--rubric); outline-offset: 2px; }
.papyrus-text {
  min-height: 55vh; padding: 14px 16px; border-radius: 8px; color: var(--ink);
  font: 400 21px/1.6 var(--hand);
  background: rgba(255, 250, 235, 0.35); border: 1.5px dashed var(--line);
}
.editor { outline: none; overflow-wrap: anywhere; }
.editor:focus-visible { border-color: var(--rubric); }
.editor h2 { font: 700 34px/1.1 var(--hand-title); color: var(--rubric); margin: 0.5em 0 0.15em; }
.editor h2:first-child { margin-top: 0; }
.editor p { margin: 0 0 0.6em; }
.editor b, .editor strong { font-weight: 700; }
.editor span[style*="background"] { border-radius: 3px; mix-blend-mode: multiply; }

/* formatting toolbar */
.toolbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px;
  background: rgba(236, 222, 182, 0.94); border: 1.5px dashed var(--line); border-radius: 10px;
}
.toolbar button {
  min-width: 42px; height: 42px; padding: 0 10px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--line); background: rgba(255, 250, 235, 0.55); color: var(--ink);
  font: 700 21px/1 var(--hand-title);
}
.toolbar button.wide { font: 700 17px/1 var(--hand); }
.toolbar button[aria-pressed="true"] { background: var(--ink); color: var(--papyrus); border-color: var(--ink); }
.toolbar button:focus-visible { outline: 3px solid var(--rubric); outline-offset: 2px; }
.toolbar .swatch { min-width: 36px; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--sw); border: 2px solid rgba(58, 39, 22, 0.28); }
.toolbar .swatch.none { background: linear-gradient(135deg, transparent 44%, var(--rubric) 44% 56%, transparent 56%), rgba(255, 250, 235, 0.7); }
.toolbar .sep { width: 1.5px; align-self: stretch; background: var(--line); margin: 0 2px; }

/* the speaker's own formatting, shown while following */
.fb { font-weight: 700; }
.fi { font-style: italic; }
.fu { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.hl { border-radius: 3px; mix-blend-mode: multiply; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hl-yellow { background-color: #EFD36A; }
.hl-green { background-color: #B9D08B; }
.hl-blue { background-color: #A9C2E0; }
.hl-pink { background-color: #EAB4C0; }
.hl-orange { background-color: #EDB477; }

@media (prefers-reduced-motion: reduce) {
  .seal.on { animation: none; outline: 4px solid rgba(142, 59, 31, 0.35); outline-offset: 4px; }
  .w, .part, .ink-line i { transition: none; }
}
