/* The line rehearsal page (rehearse-lines). On top of formatter-page.css,
   which gives it the opening, the input card, buttons, sections, steps,
   questions, the pitch and the other tools. Light only, like the site; the
   stage the script lies on is the one dark surface, as the formatter's desk.

   The idea of the page: your sides, marked up. Your lines carry a
   highlighter, the read's place is a cue light, and what went wrong is
   written on the page in a stage manager's red pencil (circled, struck,
   a caret). See .claude/rehearse-registry.md.

   The tool fills the screen below the site's bar (69px): on the left the
   script and the cast list (only the list scrolls), on the right a bar with
   the run's settings over the stage, which gives the page as much height as
   the window has, so a line and its marks stay in view.

   Colour carries meaning, never decoration: green is go and done (a step
   done, Start, a switch on), yellow is your part (the highlighter), each
   other part has its own hue in the list, on its cues and among the voices,
   and the levels and the pencil keep theirs. */

:root {
  --script: "Courier Prime", "Courier New", Courier, monospace;
  --paper: #ffffff;
  --paper-ink: #1b1b1b;
  --hl: rgba(250, 204, 21, 0.4);
  --hl-turn: rgba(250, 204, 21, 0.7);
  --hl-done: rgba(250, 204, 21, 0.14);
  --pencil: #c4231b;
  --pencil-amber: #b45309;
  --prompt: #0369a1;
  --prompt-wash: rgba(14, 165, 233, 0.16);
  --reading: rgba(5, 150, 105, 0.08);
  --reading-word: rgba(5, 150, 105, 0.24);

  /* The four levels and "not said", darkest to lightest step of trust. */
  --lv-perfect: #15803d;
  --lv-near: #4d7c0f;
  --lv-loose: #c2410c;
  --lv-off: #b91c1c;
  --lv-skip: #a1a1aa;
  --lv-empty: #d4d4d8;

  --cue-off: #3f3f46;
  --cue-reading: #e4e4e7;
  --cue-standby: #f59e0b;
  --cue-go: #22c55e;

  /* the stage's well, a shade under the desk, and the site's bar */
  --well: #141417;
  --nav-h: 69px;
  --tool-h: clamp(620px, calc(100svh - var(--nav-h) - 28px), 1400px);
}

[data-level="perfect"] { --lv-c: var(--lv-perfect); }
[data-level="near"]    { --lv-c: var(--lv-near); }
[data-level="loose"]   { --lv-c: var(--lv-loose); }
[data-level="off"]     { --lv-c: var(--lv-off); }
[data-level="skipped"] { --lv-c: var(--lv-skip); }
[data-level="checking"] { --lv-c: var(--muted); }

/* ───────────────────── the opening ───────────────────── */
.facts { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 26px; }
.facts li { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.facts svg { flex: none; color: var(--accent); }

/* ───────────────────── the tool ───────────────────── */
/* The site's own width (.wrap, 1180px), lined up with the heading above it
   and with every other tool page. */
.wrap.tool.rh {
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px; align-items: stretch;
  height: var(--tool-h);
  scroll-margin-top: calc(var(--nav-h) + 14px);
}

/* ───────────── the call sheet (left): the script, then your part ─────────────
   The column is as tall as the stage. Only the cast list scrolls, in a well
   of its own that takes whatever height the script's section leaves; every
   other setting is on the bar over the stage (.rig). */
.rh .draft {
  position: static; height: 100%; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 18px 16px; gap: 0;
  border-radius: 20px;
  scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent;
}
.call-sec {
  border: none; margin: 0; min-width: 0;
  padding: 16px 0;
  display: grid; gap: 12px; align-content: start;
  border-top: 1px solid var(--line-soft);
}
.call-source { flex: none; border-top: none; padding-top: 14px; }
.call-h {
  display: flex; align-items: center; gap: 10px;
  padding: 0; margin: 0;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.call-n {
  position: relative; flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff;
  font: 600 11.5px/1 var(--sans); font-variant-numeric: tabular-nums;
  transition: background 0.2s, color 0.2s;
}
/* a step done turns green and shows a tick */
.call-sec.is-done > .call-h .call-n { background: var(--accent); color: transparent; }
.call-sec.is-done > .call-h .call-n::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 9px; height: 5px; margin: -4px 0 0 -4.5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}
.call-t { font-size: 14px; font-weight: 600; color: var(--ink); cursor: default; }
label.call-t { cursor: pointer; }
.call-h .text-btn { margin-left: auto; font-size: 13.5px; padding: 0; }
.call-aside {
  margin-left: auto; padding: 2px 9px; border-radius: 999px;
  background: #fef9c3; color: #854d0e;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.call-aside:empty { display: none; }
.call-aside-quiet { background: var(--bg-soft); color: var(--muted); }

/* the script, dropped or chosen: one slim row, since the sample is already up */
.rh .drop {
  grid-template-columns: 38px minmax(0, 1fr);
  justify-items: stretch; align-items: center; gap: 12px;
  text-align: left; padding: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.rh .drop:hover { border-color: var(--accent-soft); background: var(--accent-glow); }
.drop-icon {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-wash); color: var(--accent);
}
.rh .drop .drop-icon svg { margin: 0; }
.drop-words { display: grid; gap: 1px; min-width: 0; }
.rh .drop strong { font-size: 14px; letter-spacing: 0; }
.rh .drop .drop-words span { font-size: 12.5px; line-height: 1.35; max-width: none; }
.rh .drop .text-btn { padding: 0; font-size: inherit; text-decoration-color: currentColor; text-decoration-thickness: 1px; }
.rh .drop .text-btn:hover { color: var(--accent-deep); }
.rh .paste summary { font-size: 13px; }
.rh .paste .btn { margin-top: 12px; width: 100%; }
.rh .draft .paste textarea { min-height: 180px; }
.rh .file-chip { padding: 11px 12px 11px 14px; font-size: 14px; }

.setup { display: flex; flex-direction: column; flex: 1 1 0; min-height: 300px; }
.setup[hidden] { display: none; }
.setup-label { padding: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.setup-hint { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.setup-hint:empty, .setup-hint[hidden] { display: none; }

/* ───────────── the cast list: a well that scrolls on its own ─────────────
   Each part has a colour (data-pc, the biggest five; grey for the rest),
   the same on its disc here, on its cues in the script and among the voices.
   Your part is the yellow of the highlighter, as on the page. */
[data-pc="0"] { --pc: #52525b; --pc-wash: #f0f0ef; }
[data-pc="1"] { --pc: #1d4ed8; --pc-wash: #dbeafe; }
[data-pc="2"] { --pc: #6d28d9; --pc-wash: #ede9fe; }
[data-pc="3"] { --pc: #a21caf; --pc-wash: #fae8ff; }
[data-pc="4"] { --pc: #0e7490; --pc-wash: #cffafe; }
[data-pc="5"] { --pc: #be185d; --pc-wash: #fce7f3; }

.call-parts { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }
.call-parts > :not(.parts) { flex: none; }
.parts {
  flex: 0 1 auto; min-height: 0;
  display: grid; gap: 5px; align-content: start;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px; border-radius: 14px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent;
}
/* the list fades at an edge with more beyond it */
.parts[data-more="down"] { -webkit-mask-image: linear-gradient(#000 calc(100% - 26px), transparent); mask-image: linear-gradient(#000 calc(100% - 26px), transparent); }
.parts[data-more="up"] { -webkit-mask-image: linear-gradient(transparent, #000 26px); mask-image: linear-gradient(transparent, #000 26px); }
.parts[data-more="both"] { -webkit-mask-image: linear-gradient(transparent, #000 26px, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(transparent, #000 26px, #000 calc(100% - 26px), transparent); }
.part { position: relative; display: block; cursor: pointer; }
.part[hidden] { display: none; }
.part input { position: absolute; opacity: 0; pointer-events: none; }
.part-face {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center;
  column-gap: 10px; row-gap: 6px;
  padding: 8px 11px 9px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.part-disc {
  grid-row: 1 / 3; position: relative;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pc-wash); color: var(--pc);
  font: 700 12.5px/1 var(--sans);
  transition: background 0.15s, color 0.15s;
}
.part-disc::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 10px; height: 5.5px; margin: -4.5px 0 0 -5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg); opacity: 0;
}
.part-name { font: 700 13.5px/1.2 var(--script); letter-spacing: 0.01em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-count { font: 500 12px var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.part-share { grid-column: 2 / 4; height: 3px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.part-share::before { content: ""; display: block; height: 100%; width: calc(100% * var(--share, 0)); border-radius: 3px; background: var(--pc); opacity: 0.45; transition: background 0.15s, opacity 0.15s; }
.part:hover .part-face { border-color: #c8c8c5; }
.part input:checked + .part-face { background: #fefce8; border-color: #f2d64b; }
.part input:checked + .part-face .part-disc { background: var(--ink); color: transparent; }
.part input:checked + .part-face .part-disc::after { opacity: 1; }
.part input:checked + .part-face .part-name { background: var(--hl-turn); box-shadow: -3px 0 0 var(--hl-turn), 3px 0 0 var(--hl-turn); border-radius: 2px; justify-self: start; max-width: 100%; }
.part input:checked + .part-face .part-count { color: #854d0e; }
.part input:checked + .part-face .part-share::before { background: #eab308; opacity: 1; }
.part input:focus-visible + .part-face { outline: 2px solid var(--accent); outline-offset: 1px; }

/* a long cast: a search box over the well */
.parts-find { position: relative; display: flex; align-items: center; color: var(--muted); }
.parts-find[hidden] { display: none; }
.parts-find svg { position: absolute; left: 11px; pointer-events: none; }
.parts-find input {
  width: 100%; padding: 8px 12px 8px 33px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font: 14px var(--sans); color: var(--ink); appearance: none; -webkit-appearance: none;
}
.parts-find input::placeholder { color: #8a8a8e; }
.parts-find input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.parts-find input::-webkit-search-cancel-button { cursor: pointer; }
.parts-none { margin: 0; font-size: 13px; color: var(--muted); }
.parts-none[hidden] { display: none; }

.select {
  width: 100%; padding: 10px 34px 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  font: 14px var(--sans); color: var(--ink); appearance: none; -webkit-appearance: none;
  text-overflow: ellipsis; cursor: pointer;
}
.select:hover { border-color: #c8c8c5; }
.select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* a switch for each yes-or-no */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.switch input {
  order: 2; flex: none; appearance: none; -webkit-appearance: none; margin: 0;
  width: 34px; height: 20px; border-radius: 999px; background: #d4d4d8;
  position: relative; cursor: pointer; transition: background 0.18s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.18s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the scenes the run covers: from one, to another */
.call-scenes { flex: none; padding-bottom: 6px; gap: 11px; }
.range { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); align-items: center; gap: 7px 8px; }
.range-l { font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.range .select { padding-top: 8px; padding-bottom: 8px; font-size: 13.5px; }
.call-scenes .switch { font-size: 13.5px; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; cursor: pointer; }

.voices { display: grid; gap: 7px; }
.voice-row { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 10px; align-items: center; }
.voice-row span { display: flex; align-items: center; gap: 7px; min-width: 0; font: 700 12.5px var(--script); }
.voice-row span::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--pc, #a1a1aa); }
.voice-row label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.voice-row .select { padding-top: 7px; padding-bottom: 7px; font-size: 13px; }

/* the promise about the script, under the tool */
.tool-fine { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); text-align: center; }
.tool-fine a { color: var(--accent); font-weight: 600; }

/* ───────────── the run's settings: a bar over the stage ───────────── */
.rh-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; height: 100%; }
.rh-main > .stage { flex: 1 1 auto; height: auto; }
.rig {
  position: relative; z-index: 5; flex: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 9px 10px 9px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.rig[hidden] { display: none; }
.rig-field { display: flex; align-items: center; gap: 9px; min-width: 0; }
.rig-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: default; }
.rig-label svg { flex: none; color: #a1a1aa; }
label.rig-label { cursor: pointer; }
/* the voices' two speeds, each a stepper: slower, the speed, faster */
.rig-speeds { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.rig-title { color: var(--ink); font-size: 13px; }
.stepper {
  display: inline-flex; align-items: center; height: 32px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden;
}
.stepper button {
  display: grid; place-items: center; width: 30px; height: 100%;
  border: 0; background: none; color: var(--ink-2); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.stepper button:hover:not(:disabled) { background: var(--accent-wash); color: var(--accent-deep); }
.stepper button:disabled { color: #d4d4d8; cursor: default; }
.stepper button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.stepper output {
  min-width: 3.1em; padding: 0 2px; text-align: center;
  font: 600 13px var(--sans); color: var(--ink); font-variant-numeric: tabular-nums;
}
/* the action's speed while nothing is read by the narrator */
.speed-field.is-off { opacity: 0.45; }

/* how your lines show: three choices in one control, the chosen one in the
   highlighter's yellow, since it is about your lines */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--bg-soft); border: 1px solid var(--line); }
.seg label { position: relative; display: flex; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 5px 11px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; text-align: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: #fef9c3; color: #713f12; box-shadow: 0 0 0 1px #f2d64b, 0 1px 2px rgba(113, 63, 18, 0.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* the reading and the voices: a panel off the bar */
.pop { position: relative; margin-left: auto; }
.pop > summary {
  list-style: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pop > summary::-webkit-details-marker { display: none; }
.pop > summary svg { color: var(--muted); }
.pop > summary:hover { border-color: #c8c8c5; }
.pop[open] > summary { background: var(--bg-soft); border-color: var(--ink); }
.pop > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: 360px; max-width: calc(100vw - 40px); max-height: min(72vh, 600px); overflow-y: auto;
  display: grid; gap: 0;
  padding: 4px 18px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 28px 56px -24px rgba(24, 24, 27, 0.4), 0 2px 6px rgba(24, 24, 27, 0.06);
  scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent;
}
.pop-sec { display: grid; gap: 11px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.pop-h { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.keys-note { margin: 0; padding-top: 14px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.keys-note:empty { display: none; }

/* ───────────── the stage (right) ───────────── */
.stage {
  background: var(--desk); color: var(--desk-ink);
  border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0; height: 100%; min-height: 0;
  box-shadow: 0 30px 60px -36px rgba(24, 24, 27, 0.6);
}
/* only the page gives up height; the head and the controls keep theirs */
.stage > :not(.book) { flex: none; }
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 20px; font-size: 13.5px; min-height: 52px;
}
#rh-caption { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
#rh-caption .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rh-caption .tag {
  flex: none; padding: 3px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: var(--desk-muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0;
}
.head-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 0 1 auto; }
#rh-summary { color: var(--desk-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rh-summary:empty { display: none; }

/* how your lines show, in the head over the page: the chosen way in the
   highlighter's yellow, since it is about your lines */
.hint-pick { flex: none; display: flex; align-items: center; gap: 8px; color: var(--desk-muted); }
.seg.seg-dark { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); }
.seg-dark span { color: var(--desk-muted); }
.seg-dark label:hover span { color: var(--desk-ink); }
.seg-dark input:checked + span { background: #fde68a; color: #422006; box-shadow: none; }
.seg-dark input:focus-visible + span { outline-color: var(--accent-soft); }

/* fill the window: the bar and the stage over the whole page, for the most
   script in view at once (the button, F, or Escape when no read is on) */
.head-btn {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-right: -6px;
  border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.06);
  color: var(--desk-ink); cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.head-btn:hover { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.12); }
.head-btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.head-btn .i-shrink { display: none; }
.is-expanded .head-btn .i-grow { display: none; }
.is-expanded .head-btn .i-shrink { display: block; }
.rh-main.is-expanded { position: fixed; inset: 0; z-index: 1000; height: auto; padding: 12px; background: var(--bg); }
.rh-main.is-expanded > .stage { flex: 1 1 auto; height: auto; }
html.rh-expanded { overflow: hidden; }
.stage-note { margin: 0; padding: 0 20px 10px; font-size: 13.5px; line-height: 1.5; color: #fde68a; }
.stage-note[hidden] { display: none; }

/* your part from first line to last, one bar a line, in the head between
   the title and the count */
.strip-wrap { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
.strip { display: flex; align-items: flex-end; gap: 2px; height: 24px; width: 100%; max-width: 420px; }
.strip:empty { display: none; }
.strip button {
  flex: 1 1 0; min-width: 2px; max-width: 64px; height: 18%;
  padding: 0; border: 0; border-radius: 2px 2px 0 0; cursor: pointer;
  background: #3a3a42;
  transition: height 0.35s cubic-bezier(.2,.8,.2,1), background 0.2s;
}
.strip button[data-level] { background: var(--lv-c); height: calc(20% + 80% * var(--acc, 0)); }
.strip button[data-level="skipped"] { height: 18%; }
.strip button.is-now { background: var(--cue-go); height: 100%; opacity: 0.85; }
.strip button:hover { filter: brightness(1.25); }
.strip button.is-out { opacity: 0.3; }
.strip.dense { gap: 1px; }
.strip.dense button { min-width: 1px; border-radius: 0; }
.strip button:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

/* ───────────────────── the paper ─────────────────────
   The well scrolls; the page is a sheet in it, as wide as a script page
   reads. The room under the last line lets any line come up to the top
   third, where the read keeps its place. */
.book {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: var(--well);
  box-shadow: inset 0 10px 14px -12px rgba(0, 0, 0, 0.7), inset 0 -10px 14px -12px rgba(0, 0, 0, 0.7);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 22px 42vh;
  scrollbar-color: #4a4a52 transparent; scrollbar-width: thin;
}
.book:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: -3px; }
.script {
  max-width: 840px; margin: 0 auto;
  background: var(--paper); color: var(--paper-ink);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 24px 48px -24px rgba(0, 0, 0, 0.9);
  padding: 56px 64px 72px 112px;
  font: 15px/1.5 var(--script);
}
.script:empty { min-height: 60vh; }

.ln { position: relative; margin: 1em 0 0; white-space: pre-wrap; overflow-wrap: break-word; cursor: pointer; border-radius: 2px; }
.ln:first-child { margin-top: 0; }
.l-scene { font-weight: 700; margin-top: 2em; }
.l-character { margin-left: 37%; }
.l-parenthetical { margin-left: 27%; max-width: 38%; }
.l-dialogue { margin-left: 17%; max-width: 62%; }
.l-transition { text-align: right; }
.l-character[data-pc] { color: var(--pc); }
.l-character[data-pc="0"] { color: var(--paper-ink); }
.l-character + .l-dialogue, .l-character + .l-parenthetical,
.l-parenthetical + .l-dialogue, .l-dialogue + .l-parenthetical,
.l-dialogue + .l-dialogue { margin-top: 0; }
.ln:hover { background: rgba(0, 0, 0, 0.025); box-shadow: -8px 0 0 rgba(0, 0, 0, 0.025), 8px 0 0 rgba(0, 0, 0, 0.025); }

/* where a fresh read starts, and the line being read */
.ln.is-start::before {
  content: "Start"; position: absolute; right: calc(100% + 14px); top: 0.15em;
  font: 600 10.5px/1 var(--sans); color: var(--accent); white-space: nowrap;
  padding: 3px 6px; border-radius: 4px; background: var(--accent-wash);
}
/* the run's range: what is outside it is dimmed, its last line flagged */
.ln.is-out { opacity: 0.38; transition: opacity 0.2s; }
.ln.is-out:hover { opacity: 0.7; }
.ln.is-end::before {
  content: "End"; position: absolute; right: calc(100% + 14px); bottom: 0.15em;
  font: 600 10.5px/1 var(--sans); color: var(--ink-2); white-space: nowrap;
  padding: 3px 6px; border-radius: 4px; background: #ececeb;
}
.ln.is-end { box-shadow: 0 12px 0 -10px #d4d4d8; }
.ln.is-reading { background: var(--reading); box-shadow: -10px 0 0 var(--reading), 10px 0 0 var(--reading); }
.ln.is-reading::after {
  content: ""; position: absolute; left: -22px; top: 0.25em; bottom: 0.25em; width: 3px; border-radius: 3px;
  background: var(--accent-bright);
}
::highlight(rh-reading) { background-color: var(--reading-word); }

/* your lines: the highlighter */
.mine .hl { background: var(--hl); padding: 0.04em 0.12em; margin: 0 -0.12em; border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.mine.is-turn .hl { background: var(--hl-turn); }
.mine.is-scored .hl { background: var(--hl-done); }
.mine.is-turn { line-height: 1.7; }
.mine.is-scored { line-height: 2.25; }

/* your line, written in as you say it */
.w { position: relative; border-radius: 2px; }
.stage[data-hint="first"] .mine:not(.is-scored) .w:not(.shown) .wr,
.stage[data-hint="hide"] .mine:not(.is-scored) .w:not(.shown) .w1,
.stage[data-hint="hide"] .mine:not(.is-scored) .w:not(.shown) .wr {
  color: transparent;
  text-decoration: underline; text-decoration-color: rgba(27, 27, 27, 0.4);
  text-decoration-thickness: 1.5px; text-underline-offset: 0.22em;
}
.w.said { background-image: linear-gradient(var(--lv-perfect), var(--lv-perfect)); background-repeat: no-repeat; background-size: 100% 2px; background-position: 0 100%; }
.w.next::before {
  content: ""; position: absolute; left: -3px; top: 0.12em; bottom: 0.12em; width: 2px;
  background: var(--paper-ink); animation: rh-caret 1.05s steps(2, start) infinite;
}
@keyframes rh-caret { to { visibility: hidden; } }
.w.prompted { background-color: var(--prompt-wash); box-shadow: inset 0 -2px 0 var(--prompt); }

/* the marks, in the stage manager's pencil */
.w.m-missed { color: var(--pencil); box-shadow: 0 0 0 1.5px var(--pencil); border-radius: 0.9em; padding: 0 0.14em; margin: 0 0.06em; }
.w.m-wrong { color: rgba(27, 27, 27, 0.5); text-decoration: line-through; text-decoration-color: var(--pencil); text-decoration-thickness: 2px; }
.w.m-close { text-decoration: underline wavy; text-decoration-color: var(--pencil-amber); text-decoration-thickness: 1.5px; text-underline-offset: 0.26em; }
.w.m-close.prompted, .w.m-ok.prompted { text-decoration: none; }
ruby.said-as, ruby.added { ruby-position: over; }
/* An insertion takes the width of its words, with room either side, so
   its note never runs into the note of the word beside it. */
ruby.added { margin: 0 0.35em; }
ruby.said-as rt, ruby.added rt {
  font: italic 500 0.8em/1 var(--serif); color: var(--pencil);
  letter-spacing: 0; padding-bottom: 0.1em; white-space: nowrap;
}
ruby.said-as.is-close rt { color: var(--pencil-amber); }
.caret {
  display: inline-block; width: 0.42em; height: 0.42em; margin: 0 0.12em 0 0.18em;
  border-left: 2px solid var(--pencil); border-top: 2px solid var(--pencil);
  transform: translateY(0.18em) rotate(45deg);
}

/* the mark a line gets in the margin */
.lvl {
  position: absolute; right: calc(100% + 16px); top: 0.35em;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11px/1 var(--sans); color: var(--lv-c); white-space: nowrap;
  letter-spacing: 0; user-select: none;
}
.lvl b { font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

.meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; color: var(--lv-c); flex: none; }
.meter i { display: block; width: 3px; border-radius: 1px; background: var(--lv-empty); }
.meter i:nth-child(1) { height: 35%; }
.meter i:nth-child(2) { height: 57%; }
.meter i:nth-child(3) { height: 78%; }
.meter i:nth-child(4) { height: 100%; }
.meter[data-bars="1"] i:nth-child(-n+1),
.meter[data-bars="2"] i:nth-child(-n+2),
.meter[data-bars="3"] i:nth-child(-n+3),
.meter[data-bars="4"] i { background: currentColor; }

/* ───────────────────── the transport ───────────────────── */
.transport {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 12px 16px 12px 20px;
  border-top: 1px solid var(--desk-line);
}
.cue { display: flex; align-items: center; gap: 13px; min-width: 0; flex: 1 1 12rem; }
.cue-light {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--cue-off);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.35);
  transition: background 0.2s, box-shadow 0.25s;
}
.stage[data-cue="reading"] .cue-light { background: var(--cue-reading); box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.2); }
.stage[data-cue="standby"] .cue-light { background: var(--cue-standby); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16), 0 0 12px rgba(245, 158, 11, 0.5); }
.stage[data-cue="go"] .cue-light { background: var(--cue-go); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16), 0 0 14px rgba(34, 197, 94, 0.55); }
.cue-words { display: grid; min-width: 0; }
.cue-text { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.cue-sub { font-size: 13px; line-height: 1.4; color: var(--desk-muted); }
.cue-sub:empty { display: none; }
/* What is being heard: one line, its newest words kept in view. */
.cue-sub.is-heard { font: italic 15.5px/1.4 var(--serif); color: #e4e4e7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.cue-sub bdi { direction: ltr; unicode-bidi: isolate; }

/* the microphone's level while it is your line */
.hearing { display: inline-flex; align-items: center; gap: 2px; height: 18px; flex: none; opacity: 0; transition: opacity 0.2s; }
.hearing i { display: block; width: 3px; border-radius: 2px; background: var(--cue-go); height: calc(18% + 82% * var(--lvl, 0) * var(--k, 1)); transition: height 0.08s linear; }
.hearing i:nth-child(1) { --k: 0.5; }
.hearing i:nth-child(2) { --k: 0.85; }
.hearing i:nth-child(3) { --k: 1; }
.hearing i:nth-child(4) { --k: 0.7; }
.hearing i:nth-child(5) { --k: 0.45; }
.stage[data-cue="go"] .hearing { opacity: 1; }
.lvl.is-checking { color: var(--muted); }

.challenge:empty { display: none; }
.challenge { padding: 0 20px 12px; }

.controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.ctl {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  font: 600 13.5px var(--sans); white-space: nowrap;
  background: rgba(255, 255, 255, 0.06); color: var(--desk-ink);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.ctl svg { flex: none; opacity: 0.85; }
.ctl:hover:not(:disabled) { border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.1); }
.ctl:disabled { opacity: 0.32; cursor: default; }
.ctl:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
.ctl-main {
  height: 44px; padding: 0 22px 0 18px; margin-left: 6px;
  background: #fff; color: var(--ink); border-color: #fff; font-size: 15px;
}
.ctl-main svg { opacity: 1; }
.ctl-main:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--ink); }
/* Start (or Resume) is green, the colour of go; Pause is plain */
.stage:not([data-state="running"]) .ctl-main:not(:disabled) { background: #34d399; border-color: #34d399; color: #052e16; }
.stage:not([data-state="running"]) .ctl-main:not(:disabled):hover { background: #6ee7b7; border-color: #6ee7b7; }
.ctl-main .i-pause { display: none; }
.stage[data-state="running"] .ctl-main .i-play { display: none; }
.stage[data-state="running"] .ctl-main .i-pause { display: block; }
.ctl-quiet { background: transparent; border-color: transparent; color: var(--desk-muted); padding: 0 10px; }
.ctl.is-nudge { border-color: var(--cue-standby); color: #fde68a; }

.stage-foot { margin: 0; padding: 0 20px 14px; font-size: 13px; line-height: 1.5; color: #fde68a; }
.stage-foot:empty { display: none; }

/* ───────────────────── how a run goes: a picture each ───────────────────── */
.rh-steps li { display: flex; flex-direction: column; }
.rh-steps strong { margin-top: 2px; }
.art {
  order: -1; height: 128px; margin: 0 0 18px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 14px; overflow: hidden;
}
.art-doc {
  width: 52px; height: 66px; border-radius: 4px; background: var(--surface);
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--line);
  display: grid; align-content: start; gap: 6px; padding: 12px 9px;
}
.art-doc i { display: block; height: 3px; border-radius: 2px; background: #d4d4d1; }
.art-doc i:nth-child(2) { width: 70%; margin-left: 20%; }
.art-doc i:nth-child(3) { width: 80%; }
.art-cast { display: grid; grid-template-columns: auto auto; gap: 5px 14px; font: 700 12px/1.2 var(--script); color: var(--paper-ink); }
.art-cast em { font: 500 11.5px var(--sans); color: var(--muted); text-align: right; font-style: normal; }
.art-part { flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; }
.art-line { display: grid; gap: 2px; font: 12px/1.45 var(--script); color: var(--paper-ink); padding-left: 14%; }
.art-line b { padding-left: 22%; font-weight: 700; }
.art-line .hl { background: var(--hl); padding: 0.04em 0.14em; border-radius: 2px; justify-self: start; }
.art-line.is-other { color: var(--faint); }
.art-run { flex-direction: column; gap: 14px; background: var(--desk); border-color: var(--desk); }
.art-cue { display: inline-flex; align-items: center; gap: 9px; font: 600 13px var(--sans); color: var(--desk-ink); }
.art-cue i { width: 12px; height: 12px; border-radius: 50%; background: var(--cue-go); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16), 0 0 12px rgba(34, 197, 94, 0.5); }
.art-said { font: 13px/1.6 var(--script); color: var(--paper-ink); background: var(--paper); padding: 6px 12px; border-radius: 3px; }
.art-said .ok { background-image: linear-gradient(var(--lv-perfect), var(--lv-perfect)); background-repeat: no-repeat; background-size: 100% 2px; background-position: 0 100%; }
.art-said .miss { color: var(--pencil); box-shadow: 0 0 0 1.5px var(--pencil); border-radius: 0.9em; padding: 0 0.14em; }

/* ───────────────────── the line notes ───────────────────── */
.notes { margin-top: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px 32px 26px; }
.notes[hidden] { display: none; }
.notes-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 28px; }
.notes h2 { font-family: var(--serif); font-size: clamp(26px, 3vw, 34px); font-weight: 600; letter-spacing: -0.016em; line-height: 1.1; margin: 0; }
.notes-headline { margin: 8px 0 0; font-size: 16px; color: var(--ink-2); }
.notes-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.notes-actions .btn { padding: 11px 20px; font-size: 14.5px; }
.notes .copied { font-size: 13.5px; color: var(--accent); }
.notes .copied:empty { display: none; }

.tally { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tally li { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 13px; display: grid; gap: 4px; align-content: start; }
.tally .meter { height: 13px; }
.tally b { font: 600 26px/1.05 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.tally span { font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.tally li[data-level] b { color: var(--lv-c); }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 64px; margin: 22px 0 0; padding-bottom: 1px; border-bottom: 1px solid var(--line); }
.chart i { flex: 1 1 0; max-width: 22px; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--lv-empty); height: 10%; }
.chart i[data-level] { background: var(--lv-c); height: calc(14% + 86% * var(--acc, 0)); }
.chart i[data-level="skipped"] { height: 10%; }

.note-list { list-style: none; margin: 8px 0 0; padding: 0; }
.note-list > li { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) auto; gap: 6px 22px; padding: 18px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.note-list > li:last-child { border-bottom: none; }
.note-list .empty { display: block; color: var(--muted); font-size: 15px; }
.note-who { display: grid; gap: 6px; align-content: start; }
.note-who .lvl { position: static; font-size: 12px; }
.note-who small { font-size: 12.5px; color: var(--muted); }
.note-line { margin: 0; font: 14.5px/2.2 var(--script); color: var(--paper-ink); }
.note-line .hl { background: var(--hl-done); padding: 0.04em 0.12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.note-line .cue-name { display: block; font-weight: 700; line-height: 1.5; margin-bottom: 2px; }
.note-says { margin: 6px 0 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.5; color: var(--ink-2); display: grid; gap: 2px; }
.note-list .text-btn { font-size: 13.5px; white-space: nowrap; }

/* ───────────────────── the marks, explained ───────────────────── */
.marks { margin: 30px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 44px; }
.mark-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; padding: 18px 0; border-top: 1px solid var(--line); align-items: center; }
.mark-sample { margin: 0; font: 15px/2.3 var(--script); color: var(--paper-ink); }
.mark-sample .hl { background: var(--hl-done); padding: 0.04em 0.12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.mark-row strong { display: block; font-size: 15.5px; }
.mark-row div span { display: block; margin-top: 3px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.levels-h { margin: 40px 0 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.levels { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.levels li { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; background: var(--surface); display: grid; gap: 6px; align-content: start; }
.levels .meter { height: 16px; }
.levels .meter i { width: 4px; }
.levels strong { font-size: 15.5px; color: var(--lv-c); }
.levels span:last-child { font-size: 14px; line-height: 1.45; color: var(--ink-2); }

/* ───────────────────── responsive ───────────────────── */
@media (max-width: 1180px) {
  .tally { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wrap.tool.rh { grid-template-columns: 300px minmax(0, 1fr); }
  .script { padding: 48px 44px 64px 104px; }
}
/* beside a narrower stage, the panel's button keeps only its icon */
@media (min-width: 981px) and (max-width: 1180px) {
  .pop > summary { padding: 8px 10px; }
  .pop > summary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 980px) {
  .wrap.tool.rh { grid-template-columns: minmax(0, 1fr); height: auto; }
  .rh .draft { height: auto; overflow: visible; }
  .setup { flex: none; min-height: 0; }
  .parts { max-height: min(50vh, 380px); }
  .rh-main { height: auto; }
  .rh-main > .stage { flex: none; height: clamp(540px, calc(100svh - var(--nav-h) - 24px), 1000px); }
  .marks { grid-template-columns: minmax(0, 1fr); }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rh-steps { grid-template-columns: minmax(0, 1fr); }
  /* the form is the page's width here: the parts sit side by side */
  .parts { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
@media (max-width: 720px) {
  .stage { border-radius: 18px; }
  .stage-head { padding: 12px 14px 10px; flex-wrap: wrap; row-gap: 10px; }
  .head-title { order: 1; flex: 1 1 calc(100% - 52px); }
  .head-btn { order: 2; }
  .strip-wrap { order: 3; flex: 1 1 0; }
  .hint-pick { order: 4; }
  .hint-pick > svg, #rh-summary { display: none; }
  .seg-dark span { padding: 5px 8px; font-size: 12.5px; }
  .strip { max-width: none; }
  .book { padding: 12px 10px 42vh; }
  .script { padding: 26px 18px 40px; font-size: 14px; }
  .l-character { margin-left: 30%; }
  .l-parenthetical { margin-left: 20%; max-width: 70%; }
  .l-dialogue { margin-left: 10%; max-width: 86%; }
  .lvl { position: static; display: flex; margin: 0 0 2px; }
  .ln.is-start::before, .ln.is-end::before { position: static; display: inline-block; margin-right: 8px; }
  .ln.is-reading::after { left: -12px; }
  .transport { padding: 10px 12px 12px; }
  .controls { justify-content: flex-start; gap: 5px; width: 100%; }
  .ctl { height: 36px; padding: 0 11px; font-size: 13px; gap: 6px; }
  .ctl-main { height: 40px; padding: 0 16px 0 13px; margin-left: auto; font-size: 14px; }
  .ctl-quiet { padding: 0 6px; }
  .challenge { padding: 0 14px 10px; }
  .stage-foot { padding: 0 14px 12px; }
  .notes { padding: 22px 18px; border-radius: 18px; }
  .tally { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-list > li { grid-template-columns: minmax(0, 1fr); }
  .mark-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .levels { grid-template-columns: minmax(0, 1fr); }
  .facts { gap: 8px 18px; }
  .facts li { font-size: 14px; }
  .rh-main.is-expanded { padding: 0; gap: 0; }
  .rh-main.is-expanded > .rig { display: none; }
  .rh-main.is-expanded > .stage { border-radius: 0; }
  /* 16px keeps a phone from zooming into the field */
  .parts-find input { font-size: 16px; padding-top: 10px; padding-bottom: 10px; }
  .parts { grid-template-columns: minmax(0, 1fr); }
  .rig { padding: 10px; gap: 8px; }
  .range .select { font-size: 16px; }
  .rig-speeds { flex: 1 1 100%; justify-content: space-between; gap: 6px; }
  .rig-title, .rig-speeds .rig-label svg { display: none; }
  .speed-field { gap: 6px; }
  .stepper { height: 36px; }
  .stepper button { width: 32px; }
  .stepper output { min-width: 2.7em; }
  .pop { flex: 1 1 100%; margin-left: 0; position: static; }
  .pop > summary { width: 100%; justify-content: center; }
  .pop-panel { left: 0; right: 0; width: auto; max-width: none; }
}
@media (max-width: 420px) {
  .ctl > span:not(#rh-play-label) { display: none; }
  .ctl { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .strip button, .cue-light, .ctl, .part-face, .part-disc, .switch input, .switch input::after, .seg span, .call-n, .stepper button, .ln.is-out { transition: none; }
  .w.next::before { animation: none; }
  .hearing i { transition: none; }
  .book { scroll-behavior: auto; }
}
