/* Scenelle base layer, written from DESIGN_SYSTEM.md §2–§6 and §9.
   Variables only: every colour, size and shadow comes from tokens.css. */

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper-100);
  color: var(--ink);
  font: 400 15px/22px var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 0;
}

a {
  color: var(--marigold-ink);
  font-weight: 600;
}

strong,
b {
  font-weight: 600;
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Type (§2) ---------- */

.dxl {
  font: 800 56px/56px var(--font-display);
  letter-spacing: -0.5px;
}

.dl {
  font: 700 40px/44px var(--font-display);
}

.tt {
  font: 700 24px/30px var(--font-display);
}

.hd {
  font: 600 18px/24px var(--font-body);
}

.h6 {
  font: 600 16px/22px var(--font-body);
}

.lbl {
  font: 600 13px/16px var(--font-body);
  letter-spacing: 0.2px;
}

.sm {
  font: 400 13px/18px var(--font-body);
}

.xs {
  font: 400 var(--fs-xs)/16px var(--font-body);
}

.mono {
  font: 500 var(--fs-xs)/16px var(--font-mono);
}

.brand {
  font: 800 28px/32px var(--font-display);
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Buttons (§4 Button) ---------- */

/* 18px either side (a quiet button 10px), as the canvas's buttons. */

.b1,
.b2,
.b3,
.bx,
.bpost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font: 600 15px/22px var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform var(--t-press) var(--e-out),
    box-shadow var(--t-press) var(--e-out);
}

.b1 {
  background: var(--marigold);
  color: var(--on-marigold);
  border: var(--border-ink);
  box-shadow: var(--shadow-ink);
}

.bpost {
  background: var(--peacock);
  color: var(--on-peacock);
  border: var(--border-ink);
  box-shadow: var(--shadow-ink);
}

.bx {
  background: var(--danger);
  color: var(--on-danger);
  border: var(--border-ink);
  box-shadow: var(--shadow-ink);
}

.b1:hover:not(:disabled),
.bpost:hover:not(:disabled),
.bx:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-ink-lg);
}

.b1:active:not(:disabled),
.bpost:active:not(:disabled),
.bx:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: var(--shadow-none);
}

.b2 {
  background: var(--paper-200);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
}

.b2:hover:not(:disabled) {
  border-color: var(--ink);
}

.b2.bdg {
  color: var(--danger-ink);
  border-color: var(--danger);
}

.b2.bdg:hover:not(:disabled) {
  background: var(--danger-tint);
}

.b3 {
  padding: 0 10px;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid transparent;
}

.b3:hover:not(:disabled) {
  background: var(--paper-000);
}

.ib {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none; /* never squeezed below the 44px touch target in a flex row */
  padding: 0;
  background: transparent;
  color: var(--ink);
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.ib:hover:not(:disabled) {
  background: var(--paper-000);
}

.b1:disabled,
.b2:disabled,
.b3:disabled,
.bx:disabled,
.bpost:disabled,
.ib:disabled {
  background: var(--paper-000);
  color: var(--ink-muted);
  box-shadow: var(--shadow-none);
  transform: none;
  cursor: not-allowed;
}

/* Bordered buttons keep a border when disabled; quiet and icon buttons stay borderless. */
.b1:disabled,
.b2:disabled,
.bx:disabled,
.bpost:disabled {
  border-color: var(--line);
}

/* Unavailable but focusable (aria-disabled), so the reason that describes it can still be read:
   it looks like a disabled button and does not move on press or hover. */
.b1[aria-disabled="true"],
.b1[aria-disabled="true"]:hover,
.b1[aria-disabled="true"]:active,
.b2[aria-disabled="true"],
.b2[aria-disabled="true"]:hover,
.b2[aria-disabled="true"]:active,
.b3[aria-disabled="true"],
.b3[aria-disabled="true"]:hover,
.b3[aria-disabled="true"]:active,
.bx[aria-disabled="true"],
.bx[aria-disabled="true"]:hover,
.bx[aria-disabled="true"]:active,
.bpost[aria-disabled="true"],
.bpost[aria-disabled="true"]:hover,
.bpost[aria-disabled="true"]:active,
.ib[aria-disabled="true"],
.ib[aria-disabled="true"]:hover,
.ib[aria-disabled="true"]:active,
.b2.bdg[aria-disabled="true"]:hover {
  background: var(--paper-000);
  color: var(--ink-muted);
  box-shadow: var(--shadow-none);
  transform: none;
  cursor: not-allowed;
}

.b1[aria-disabled="true"],
.b1[aria-disabled="true"]:hover,
.b2[aria-disabled="true"],
.b2[aria-disabled="true"]:hover,
.bx[aria-disabled="true"],
.bx[aria-disabled="true"]:hover,
.bpost[aria-disabled="true"],
.bpost[aria-disabled="true"]:hover,
.b2.bdg[aria-disabled="true"],
.b2.bdg[aria-disabled="true"]:hover {
  border-color: var(--line);
}

/* Quiet and icon buttons stay quiet when unavailable: no ground (the paper fill is their hover, so
   a filled one read as hovered), only the muted ink. */
.b3:disabled,
.ib:disabled,
.b3[aria-disabled="true"],
.b3[aria-disabled="true"]:hover,
.b3[aria-disabled="true"]:active,
.ib[aria-disabled="true"],
.ib[aria-disabled="true"]:hover,
.ib[aria-disabled="true"]:active {
  background: transparent;
}

/* ---------- Action links (ActionLink.tsx) ----------
   A link that stands on its own as a way somewhere: "Open planner" in a card's head, "All
   episodes", "Details" in the plan box. Ink, medium weight, a small trailing chevron, no underline
   until hover; the target reaches 44px tall through a hit area. Links inside a sentence keep the
   plain `a` look (underlined, marigold ink). `.alink-row` is the full-width row form (a panel's
   foot): the words at the left, the chevron at the right, a ground on hover. */

.alink {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 24px;
  color: var(--ink);
  font: 600 13px/18px var(--font-body);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  white-space: nowrap;
  transition: text-decoration-color var(--t-quick) var(--e-out);
}

.alink::before {
  content: "";
  position: absolute;
  inset: -10px -6px;
}

.alink > .shell-icon {
  transition: transform var(--t-quick) var(--e-out);
}

.alink:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.alink:hover > .shell-icon {
  transform: translateX(2px);
}

.alink:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.alink-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  font-size: 15px;
  line-height: 20px;
  transition:
    text-decoration-color var(--t-quick) var(--e-out),
    background-color var(--t-quick) var(--e-out);
}

.alink-row::before {
  content: none;
}

.alink-row:hover {
  color: var(--ink);
  background: var(--paper-100);
  text-decoration-color: transparent;
}

.alink-row:focus-visible {
  outline-offset: -2px;
  border-radius: 0;
}

/* The way back (BackLink): an action link led by a 16px chevron-left, standing at the start of its
   column; as a button it drops the button chrome. The chevron nudges back on hover. */
.alink-back {
  align-self: flex-start;
  gap: var(--space-1);
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.alink-back:hover > .shell-icon {
  transform: translateX(-2px);
}

/* ---------- Status badge (§4 StatusBadge) ---------- */

/* 4px by 8px inside, the word 6px from the dot, as the canvas's `.bd`. */
.bd {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font: 600 13px/16px var(--font-body);
  letter-spacing: 0.2px;
  white-space: nowrap;
  max-width: 100%;
}

/* A badge with more words ("Scheduled · Sun 7:00 pm", StatusBadge) may break after the "·" only:
   each part stays whole, the rest goes to a second line in a narrow card instead of overflowing
   it (2026-11-30: Series home cards, phone Episodes cards, the Episodes detail panel). */
.bd-text {
  min-width: 0;
  white-space: normal;
}

.bd-part {
  white-space: nowrap;
}

/* The dot sits on the first line (the same place as centred, on a one-line badge). */
.bd .dot {
  align-self: flex-start;
  margin-top: 4px;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.bd.draft,
.bd.held {
  background: var(--info-tint);
  color: var(--info);
}

.bd.run {
  background: var(--marigold-tint);
  color: var(--marigold-ink);
}

.bd.ready {
  background: var(--peacock-tint);
  color: var(--peacock-ink);
}

.bd.posted {
  background: var(--peacock);
  color: var(--on-peacock);
}

.bd.fail {
  background: var(--danger-tint);
  color: var(--danger-ink);
}

/* ---------- Still (§4 Still): the 9:16 frame ---------- */

.still {
  position: relative;
  margin: 0;
  aspect-ratio: var(--aspect-reel);
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--stage);
  color: var(--on-stage);
}

.still > img,
.still > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.still-cap {
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: 18%;
  font: 800 28px/32px var(--font-display);
  text-align: center;
  color: var(--on-stage);
  -webkit-text-stroke: 1px var(--ink);
  paint-order: stroke fill;
}

/* M23: a Devanagari caption in Mukta (the face the engine burns Hindi captions in). */
.still-cap:lang(hi) {
  font-family: var(--font-body);
  font-weight: 600;
}

.still-wm {
  position: absolute;
  right: var(--space-2);
  top: var(--space-2);
  font: 500 var(--fs-xs)/16px var(--font-mono);
  color: var(--on-stage);
}

.still-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-3) 10% 8%;
  text-align: center;
  font: 500 var(--fs-xs)/16px var(--font-mono);
  color: var(--on-stage);
}

/* The drawn sketch behind the words (the Still board's empty state; it draws in on twos, below). */
.still-empty .st-sketch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.still-empty .st-sketch g {
  fill: none;
  stroke: var(--on-stage);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.55;
}

.still-empty-text {
  position: relative;
}

.still-lbl {
  position: absolute;
  left: var(--space-2);
  right: var(--space-2);
  bottom: var(--space-2);
  font: 500 var(--fs-xs)/16px var(--font-mono);
  color: var(--on-stage);
}

/* ---------- Patterns (§4 Smaller patterns) ---------- */

.card {
  background: var(--paper-200);
  border: var(--border-hair);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.inked {
  background: var(--paper-200);
  border: var(--border-ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-ink);
  padding: var(--space-4);
}

.well {
  background: var(--paper-000);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink);
}

/* The notice's icon (ui/Note.tsx), in the note's text colour, level with the first line. */
.note-icon {
  flex: none;
  margin-top: 2px;
}

.note.info {
  background: var(--info-tint);
}

.note.warn {
  background: var(--marigold-tint);
}

.note.bad {
  background: var(--danger-tint);
  color: var(--danger-ink);
}

.note.good {
  background: var(--peacock-tint);
  color: var(--peacock-ink);
}

/* 8px inside its hairline, as the canvas's (content-box). */
.meter {
  box-sizing: content-box;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--paper-000);
  border: var(--border-hair);
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--marigold);
}

.fld {
  display: block;
  width: 100%;
  min-height: 44px;
  /* 10px by 12px inside, as the canvas's fields (45px tall with the edge). */
  padding: 10px var(--space-3);
  background: var(--paper-200);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: 400 15px/22px var(--font-body);
}

.fld[aria-invalid="true"] {
  border-color: var(--danger);
}

/* The native select (FieldSelect): the system arrow, whose inset differed by browser, gives way to
   the house chevron, 16px, 12px in from the right and centred, as the house Select's is; the words
   stop 12px short of it. */
.fld-select {
  position: relative;
  display: block;
  min-width: 0;
}

.fld-select > .fld {
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
}

.fld-select > .fld:hover:not(:disabled) {
  border-color: var(--ink);
}

.fld-select > .fld:disabled {
  cursor: not-allowed;
}

.fld-select-chev {
  position: absolute;
  top: 50%;
  right: var(--space-3);
  translate: 0 -50%;
  color: var(--ink);
  pointer-events: none;
}

.fld-select > .fld:disabled + .fld-select-chev {
  color: var(--ink-muted);
}

.help {
  font: 400 13px/18px var(--font-body);
  color: var(--ink-muted);
}

.err {
  font: 600 13px/18px var(--font-body);
  color: var(--danger-ink);
}

/* The one chip (Chip, §4 Choice chip): a toggle or a filter, 16px either side, 15/22 words, ink-
   filled when pressed as the canvas's Episodes filters are. `.chip-sm` is the 13px form for rows of
   filters and the storyboard's options: 36px to the eye, 44px to a finger through its hit area (and
   44px outright on a coarse pointer). Locked (aria-disabled) keeps its look and refuses the press. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: 0 var(--space-4);
  background: var(--paper-200);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: 600 15px/22px var(--font-body);
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-100);
  border-color: var(--ink);
}

.chip[aria-disabled="true"] {
  cursor: not-allowed;
}

.chip-sm {
  position: relative;
  min-height: 36px;
  padding: 0 var(--space-3);
  font: 600 13px/16px var(--font-body);
}

.chip-sm::before {
  content: "";
  position: absolute;
  inset: -4px 0;
}

@media (pointer: coarse) {
  .chip-sm {
    min-height: 44px;
  }
}

/* A switch's visible words press it too: they are a <label for> the switch. */
.tog ~ label,
.tog ~ * label {
  cursor: pointer;
}

/* The one segmented control (SegmentedControl): a radio group on a paper track, the checked
   segment white with an ink edge. Each segment is 44px tall. */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--paper-000);
  border-radius: var(--radius-md);
}

.seg-b {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font: 600 15px/22px var(--font-body);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--t-quick) var(--e-out),
    border-color var(--t-quick) var(--e-out);
}

.seg-b[aria-checked="true"] {
  background: var(--paper-200);
  border-color: var(--ink);
}

.seg-b:disabled {
  cursor: default;
}

.pick {
  display: block;
  width: 100%;
  padding: var(--space-4);
  text-align: left;
  background: var(--paper-200);
  color: var(--ink);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.pick[aria-checked="true"] {
  border-color: var(--ink);
  box-shadow: var(--shadow-ink);
}

/* 48×28 in an ink edge, a 19px ink knob 3px inside; on, peacock with the knob white at the right
   (the canvas's switch). */
.tog {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  padding: 0;
  background: var(--paper-000);
  border: var(--border-ink);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.tog::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  transition: transform var(--t-base) var(--e-spring);
}

/* The toggle (28px tall) and the swatch (32px) draw smaller but take touches over at least 44px
   (§9). */
.tog::before,
.sw::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}

.tog[aria-checked="true"] {
  background: var(--peacock);
  border-color: var(--ink);
}

.tog[aria-checked="true"]::after {
  background: var(--paper-200);
  transform: translateX(20px);
}

table.t {
  width: 100%;
  border-collapse: collapse;
}

/* One class deep, so a page's own table measures (`.plans-table th`) win by coming later. */
.t th,
.t td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: var(--border-hair);
}

.t th {
  font: 600 13px/16px var(--font-body);
  letter-spacing: 0.2px;
  color: var(--ink-muted);
}

.card:has(> table.t) {
  overflow-x: auto;
}

.sw {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: var(--border-hair);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.sw[aria-checked="true"],
.sw[aria-pressed="true"] {
  border: 3px solid var(--ink);
}

/* ---------- Layout (§5) ---------- */

.app {
  display: flex;
  min-height: calc(100vh / var(--ui-zoom, 1));
}

.side {
  flex: 1 1 233px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  background: var(--paper-000);
  border-right: var(--border-hair);
}

.col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-8);
}

@media (max-width: 800px) {
  .app {
    flex-direction: column;
  }

  .side {
    width: auto;
    border-right: 0;
    border-bottom: var(--border-hair);
  }

  .col {
    padding: var(--space-4);
  }
}

/* ---------- Focused layout and setup (§5; the canvas's setup boards 03, 21–24) ---------- */

/* The page is a column: header, the step bar, the page itself (taking the height left), footer. */
.focus {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh / var(--ui-zoom, 1));
}

/* Behind the sign-in card while signed out (FocusLayout): hidden under its own display rules,
   setup's main (`.focus-main.setup-main`, display: flex) included, so each is one class more
   specific than the rule it must beat. */
.focus[hidden],
.focus-main[hidden],
.focus-main.setup-main[hidden] {
  display: none;
}

.focus-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  border-bottom: var(--border-hair);
}

.focus-actions {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

/* The header's save state: "Saving…" after a blinking dot, "Saved" after a peacock tick that draws
   itself in (board 00b row 11). Setup's (`save-mark`) is muted. */
.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.save-mark {
  color: var(--ink-muted);
}

.save-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.save-tick {
  display: inline-flex;
  color: var(--peacock-ink);
}

.save-tick path {
  stroke-dasharray: 30;
  animation: draw 0.38s var(--e-out) backwards;
}

.focus-main {
  display: grid;
  gap: var(--space-6);
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: var(--space-8);
}

/* The setup steps: a bar and a numbered word each, across 1040px. */
.sp {
  padding: var(--space-6) var(--space-8) 0;
}

.sp-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 1040px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.sp-step {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 6px, plus the current one's 1px edge (content-box). */
.sp-bar {
  box-sizing: content-box;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--line);
}

.sp-step.done .sp-bar {
  background: var(--ink);
}

.sp-step.current .sp-bar {
  background: var(--marigold);
  border: 1px solid var(--ink);
}

.sp-label {
  font: 600 13px/18px var(--font-body);
  color: var(--ink-muted);
}

/* Board 03 (the character step) sets the words on a 16px line. */
.sp[data-step="2"] .sp-label {
  line-height: 16px;
}

.sp-step.done .sp-label,
.sp-step.current .sp-label {
  color: var(--ink);
}

/* "Step n of 5", for assistive technology only. */
.sp-count {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* A setup step's page: the canvas's width for the step (1040; 1104 with a preview; 880 for
   Review), taking the height between the step bar and the footer. */
.focus-main.setup-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 1040px;
}

.focus-main.setup-main.wide {
  max-width: 1104px;
}

.focus-main.setup-main.narrow {
  max-width: 880px;
}

.setup-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-sub {
  color: var(--ink-muted);
}

/* The form, and its preview card beside it (below it when there is no room). */
.setup-split {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  align-items: flex-start;
}

.setup-form {
  flex: 999 1 480px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.setup-form.roomy {
  gap: 28px;
}

.setup-aside {
  flex: 1 1 300px;
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Label, field and its line under it, 6px apart (8px on the character step). */
.setup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-field.roomy {
  gap: var(--space-2);
}

.setup-w320 {
  max-width: 320px;
}

.setup-w360 {
  max-width: 360px;
}

.setup-w480 {
  max-width: 480px;
}

.setup-w560 {
  max-width: 560px;
}

.setup-help {
  font: 400 var(--fs-xs)/16px var(--font-body);
}

.setup-help-split {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.setup-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 20px;
}

.setup-preview.center {
  align-items: center;
  gap: var(--space-3);
}

.setup-kicker {
  color: var(--ink-muted);
  text-transform: uppercase;
}

.setup-preview-name {
  font: 700 28px/32px var(--font-display);
  overflow-wrap: anywhere;
}

/* The character on its paper well; the 9:16 picture as tall as the canvas's drawing. */
.setup-portrait {
  display: flex;
  justify-content: center;
  width: 100%;
  padding-top: var(--space-6);
  background: var(--paper-000);
  border-radius: var(--radius-md);
}

.setup-portrait-box {
  display: flex;
  justify-content: center;
  width: 200px;
  height: 267px;
}

/* The lead as the episodes draw them (the stage figure, transparent 3:4, `figure=1`): the box is 3:4
   too, so the whole figure shows, standing on the preview's paper rather than a dark frame. */
.setup-portrait-box > .still {
  width: auto;
  height: 100%;
  aspect-ratio: 3 / 4;
  background: transparent;
}

.setup-portrait-box > .still > img {
  object-fit: contain;
}

.setup-portrait-name {
  max-width: 100%;
  font: 700 28px/32px var(--font-display);
  overflow-wrap: anywhere;
}

.setup-portrait-meta {
  max-width: 100%;
  font-size: 13px;
  color: var(--ink-muted);
}

.setup-note {
  font: 400 var(--fs-xs)/16px var(--font-body);
  color: var(--ink-muted);
  text-align: center;
}

.setup-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* The canvas's 44px swatches with a paper ring inside the chosen one's ink edge. */
.setup-swatches {
  gap: var(--space-3);
}

.setup-swatches .sw {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--line-strong);
}

.setup-swatches .sw[aria-checked="true"] {
  border: 3px solid var(--ink);
}

.setup-swatches .sw[aria-checked="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--paper-100);
  border-radius: var(--radius-pill);
}

/* Voice, genre and review steps: the heading, then the choices. */
.setup-stack {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.setup-stack.review {
  gap: var(--space-6);
}

.setup-voices {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.setup-voices-sub {
  font-weight: 400;
}

/* The tone filters over a long list of voices (VoiceStep). */
.setup-voice-tones {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.setup-voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

/* A voice card: its play button, then the voice (the radio), inked when chosen. */
.setup-voice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px;
  background: var(--paper-200);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
}

.setup-voice:has(> [aria-checked="true"]) {
  border-color: var(--ink);
  box-shadow: var(--shadow-ink);
}

.play {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  /* The standard control: coral belongs to the character, never to a control (§1). */
  background: var(--paper-200);
  color: var(--ink);
  border: var(--border-ink);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.play:disabled {
  background: var(--paper-000);
  color: var(--ink-muted);
  border-color: var(--line-strong);
  cursor: not-allowed;
}

.setup-voice-pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.setup-voice-name {
  font-weight: 600;
}

.setup-genres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.pick.setup-genre {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-color: var(--line);
  border-radius: var(--radius-lg);
}

.pick.setup-genre[aria-checked="true"] {
  border-color: var(--ink);
}

.setup-genre-name {
  font: 700 20px/26px var(--font-display);
}

/* Review: the character beside one row per answer. */
.setup-review-card {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
  padding: var(--space-6);
}

.setup-review-portrait {
  display: flex;
  justify-content: center;
  flex: none;
  width: 180px;
  margin: 0 auto;
  padding-top: 20px;
  background: var(--paper-000);
  border-radius: var(--radius-md);
}

.setup-review-portrait .setup-portrait-box {
  width: 150px;
  height: 200px;
}

.setup-review {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.setup-review-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  column-gap: var(--space-4);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: var(--border-hair);
}

.setup-review-value {
  grid-column: 2;
  margin: 0;
  font-weight: 600;
}

.setup-review-flag {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
}

.setup-review-edit {
  grid-column: 3;
  grid-row: 1 / span 2;
  margin: 0;
}

/* A plain link, as the canvas's, whose hit area reaches 44px (DESIGN_SYSTEM §9). */
.setup-edit {
  position: relative;
  font-weight: 400;
}

.setup-edit::before {
  content: "";
  position: absolute;
  inset: -13px -11px;
}

/* The footer: Back, then what comes next and Continue at the right; under the page, pinned to
   the bottom of the window while the page is taller (§5). Its parent is the whole page. */
.setup-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8);
  background: var(--paper-100);
  border-top: var(--border-hair);
}

/* Review's actions sit under its card instead, Create series at the right. */
.setup-foot.inline {
  position: static;
  padding: 0;
  background: none;
  border-top: 0;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.setup-next {
  margin-left: auto;
  font: 400 13px/18px var(--font-body);
  color: var(--ink-muted);
}

.setup-foot.inline .b1 {
  margin-left: auto;
}

/* Editing a series: the current tab in the quiet tab row. */
.b3[aria-current="page"] {
  background: var(--paper-000);
  border-color: var(--ink);
}

/* A tab whose name field is blank: an icon, named for assistive technology, not colour alone. */
.edit-flag {
  flex: none;
  color: var(--danger-ink);
}

.setup-review dd,
.focus-main .dl {
  overflow-wrap: anywhere;
}

@media (max-width: 800px) {
  .focus-top {
    padding: var(--space-3) var(--space-4);
  }

  .focus-main {
    padding: var(--space-4);
  }

  .sp {
    padding: var(--space-4) var(--space-4) 0;
  }

  /* One row of steps: the numbers, and the current step's word. */
  .sp-step {
    flex: 1 1 0;
    min-width: 0;
  }

  .sp-step:not(.current) .sp-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* The character step reads heading, preview, then the choices: the form's parts join the
     column so the preview can sit between its heading and its fields. */
  .setup-split.character {
    flex-direction: column;
    align-items: stretch;
    gap: 28px;
  }

  .setup-split.character > .setup-form {
    display: contents;
  }

  .setup-split.character .setup-head {
    order: -2;
  }

  .setup-split.character .setup-aside {
    order: -1;
    width: 100%;
  }

  .setup-portrait-box {
    height: 178px;
  }

  /* The actions and their help line, pinned to the bottom (§5). The footer is the sticky box
     because its parent is the whole page. */
  .setup-foot {
    position: sticky;
    bottom: 0;
    padding: var(--space-4);
    background: var(--paper-100);
  }

  /* Review's, inside the page, bleeds into the page's side padding. */
  .setup-foot.inline {
    position: sticky;
    margin: 0 calc(-1 * var(--space-4));
    background: var(--paper-100);
    padding: var(--space-4);
    border-top: var(--border-hair);
  }

  .setup-next {
    display: none;
  }

  .setup-actions .b1 {
    flex: 1;
  }
}

/* ---------- Motion (§6): "Ink & Cel" (canvas studio.css, M22) ----------
   1. The interface glides: ease-out, under 300ms, transform and opacity only.
   2. Things that land (a chosen card, a stamp, a dialog) settle with a small spring, once.
   3. Loops are only for work in progress (the blinking dot, the barber stripe, the sketch).
   Durations and curves are the tokens in tokens.css; prefers-reduced-motion stills it all (below).
   Selectors start with body so a page's own rules for the same class do not undo them. */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

@keyframes press-pop {
  from {
    transform: scale(0.95);
  }
}

@keyframes stamp {
  0% {
    opacity: 0;
    transform: scale(1.3) rotate(-6deg);
  }

  55% {
    opacity: 1;
  }

  100% {
    transform: none;
  }
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes draw {
  from {
    stroke-dashoffset: 30;
  }
}

@keyframes grow {
  from {
    width: 0;
  }
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

@keyframes barber {
  to {
    background-position: 16px 0;
  }
}

@keyframes shake {
  20% {
    transform: translateX(-5px);
  }

  40% {
    transform: translateX(5px);
  }

  60% {
    transform: translateX(-3px);
  }

  80% {
    transform: translateX(2px);
  }
}

@keyframes burst {
  0% {
    opacity: 1;
    transform: scale(0.15) rotate(0);
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: scale(1) rotate(24deg);
  }
}

@keyframes sketch {
  to {
    stroke-dashoffset: 0;
  }
}

/* Page entrance: the page's parts rise in, 40ms apart (at most 200ms). Once, on mount; never
   blocks input. */
body main > * {
  animation: rise var(--t-enter) var(--e-out) backwards;
}

body main > *:nth-child(2) {
  animation-delay: 40ms;
}

body main > *:nth-child(3) {
  animation-delay: 80ms;
}

body main > *:nth-child(4) {
  animation-delay: 120ms;
}

body main > *:nth-child(5) {
  animation-delay: 160ms;
}

body main > *:nth-child(n + 6) {
  animation-delay: 200ms;
}

/* Press: the primary drops onto its inked shadow (above); everything else gives 3%. */
body .b1,
body .b2,
body .b3,
body .bx,
body .bpost,
body .chip,
body .ib {
  transition:
    transform var(--t-press) var(--e-out),
    box-shadow var(--t-press) var(--e-out),
    background-color var(--t-quick) ease,
    border-color var(--t-quick) ease,
    color var(--t-quick) ease;
}

body .b2:active:not(:disabled, [aria-disabled="true"]),
body .b3:active:not(:disabled, [aria-disabled="true"]),
body .chip:active:not(:disabled, [aria-disabled="true"]),
body .ib:active:not(:disabled, [aria-disabled="true"]) {
  transform: scale(0.97);
}

/* Cards you can open or choose lift toward you (fine pointers only); the chosen one lands with a
   spring. */
body a.card,
body a.inked,
body .pick {
  transition:
    transform var(--t-quick) var(--e-out),
    box-shadow var(--t-quick) var(--e-out),
    border-color var(--t-quick) ease,
    background-color var(--t-quick) ease;
}

@media (hover: hover) and (pointer: fine) {
  body a.card:hover {
    border-color: var(--ink);
    transform: translateY(-2px);
  }

  body a.inked:hover,
  body .pick:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: var(--ink);
    box-shadow: var(--shadow-ink-lg);
    transform: translate(-2px, -2px);
  }
}

body .pick:active:not(:disabled, [aria-disabled="true"]) {
  box-shadow: var(--shadow-ink-sm);
  transform: translate(1px, 1px);
}

body .pick[aria-checked="true"],
body .chip[aria-pressed="true"],
body .chip[aria-checked="true"],
body .sw[aria-checked="true"],
body .sw[aria-pressed="true"] {
  animation: press-pop var(--t-enter) var(--e-spring);
}

/* Switch: the knob springs across. */
body .tog {
  transition: background-color var(--t-quick) ease;
}

body .tog::after {
  transition:
    transform var(--t-base) var(--e-spring),
    background-color var(--t-quick) ease;
}

/* Fields: the edge inks in on focus; an invalid field keeps its crimson edge and shakes once. */
body .fld {
  transition:
    border-color var(--t-quick) ease,
    box-shadow var(--t-quick) var(--e-out);
}

body .fld:focus:not([aria-invalid="true"]) {
  border-color: var(--ink);
}

body .fld[aria-invalid="true"] {
  animation: shake 0.32s var(--e-out);
}

/* Messages slide down from where they belong and stay; dialogs pop from the centre. */
body .note,
body [role="alert"],
body [role="status"] {
  animation: slide-down var(--t-enter) var(--e-out) backwards;
}

body [role="dialog"],
body [role="alertdialog"],
body dialog[open] {
  animation: pop var(--t-enter) var(--e-spring) backwards;
}

body details[open] > *:not(summary) {
  animation: slide-down var(--t-base) var(--e-out);
}

/* Status: work in progress blinks on twos; meters fill; a live meter shows a moving barber
   stripe. Each runs for 5 seconds and then stands still (WCAG 2.2.2: nothing blinks or moves on
   its own for longer), the dot settling solid; the words beside them say the work goes on. */
body .bd.run .dot,
body .pill-dot,
body .save-dot {
  animation: pulse 1s steps(2, jump-none) 5;
}

body .meter > span {
  transition: width var(--t-scene) var(--e-out);
  animation: grow 0.7s var(--e-out) 0.15s backwards;
}

body .meter.live > span,
body .live-fill {
  background-image: var(--barber-stripe);
  background-size: 16px 16px;
  animation: barber 0.5s steps(4) 10;
}

/* Success: the tick stamps down, draws itself, and throws a little paper confetti, once. */
body .ok {
  position: relative;
  animation: stamp var(--t-enter) var(--e-spring) backwards;
}

body .ok svg path {
  stroke-dasharray: 30;
  animation: draw 0.38s var(--e-out) 0.2s backwards;
}

body .ok::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  box-shadow: var(--confetti-burst);
  animation: burst 0.75s var(--e-out) 0.12s both;
}

/* The round success tick (48px, peacock), as the account and outcome boards draw it. */
.ok-tick {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--peacock);
  color: var(--on-peacock);
}

/* The drawn sketch of an empty or loading still: a figure and a window drawing in on twos, three
   passes (about 5 seconds, WCAG 2.2.2), then it stays drawn. */
.st-sketch path {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: sketch 1.6s steps(14) 3 alternate forwards;
}

/* Sketch-paper dots on the sidebar's sunk ground. */
body .side {
  background-image: var(--paper-dots);
  background-size: 14px 14px;
}

/* Reorders and moves glide (View Transitions); the page itself never cross-fades. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

::view-transition-group(*) {
  animation-duration: 0.3s;
  animation-timing-function: var(--e-out);
}

/* Reduced motion: keep colour, pressed state and words; drop travel, loops and springs. Every
   animation and transition runs once, at once; the confetti is not thrown. */
/* Popovers (usePopover: the series switcher, the notifications panel, the account menu): they open
   from the trigger's corner with a fade, a 4px drop and a scale from 0.96, their first items
   following 25ms apart (all inside about 200ms); closing runs it back, quicker, while the panel
   stays drawn (`data-state="closed"`, not yet `hidden`) and takes no presses. Transform and opacity
   only. The switcher and the house select's list (Select.tsx) open from their top left, the bell's panel and the account menu from their
   top right, the tab bar's account menu (opening upwards) from its bottom right. */
@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
}

@keyframes popover-out {
  to {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
}

@keyframes popover-up-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
}

@keyframes popover-up-out {
  to {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
}

@keyframes popover-item {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}

body .ss-panel,
body .sel-list {
  transform-origin: top left;
}

body .am-panel,
body .nt-panel {
  transform-origin: top right;
}

body .am-tab .am-panel {
  transform-origin: bottom right;
}

body .ss-panel[data-state="open"],
body .am-panel[data-state="open"],
body .nt-panel[data-state="open"],
body .sel-list[data-state="open"] {
  animation: popover-in var(--t-quick) var(--e-out);
}

body .ss-panel[data-state="closed"],
body .am-panel[data-state="closed"],
body .nt-panel[data-state="closed"],
body .sel-list[data-state="closed"] {
  animation: popover-out var(--t-press) var(--e-out) forwards;
  pointer-events: none;
}

body .am-tab .am-panel[data-state="open"] {
  animation-name: popover-up-in;
}

body .am-tab .am-panel[data-state="closed"] {
  animation-name: popover-up-out;
}

body .am-panel[data-state="open"] > *,
body .ss-panel[data-state="open"] .ss-list > li,
body .nt-panel[data-state="open"] .nt-list > li {
  animation: popover-item var(--t-quick) var(--e-out) backwards;
}

body .am-panel[data-state="open"] > :nth-child(2),
body .ss-panel[data-state="open"] .ss-list > li:nth-child(2),
body .nt-panel[data-state="open"] .nt-list > li:nth-child(2) {
  animation-delay: 25ms;
}

body .am-panel[data-state="open"] > :nth-child(3),
body .ss-panel[data-state="open"] .ss-list > li:nth-child(3),
body .nt-panel[data-state="open"] .nt-list > li:nth-child(3) {
  animation-delay: 50ms;
}

body .am-panel[data-state="open"] > :nth-child(n + 4),
body .ss-panel[data-state="open"] .ss-list > li:nth-child(n + 4),
body .nt-panel[data-state="open"] .nt-list > li:nth-child(n + 4) {
  animation-delay: 75ms;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }

  body .ok::after {
    display: none;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }

  body .ss-panel[data-state],
  body .sel-list[data-state],
  body .am-panel[data-state],
  body .nt-panel[data-state],
  body .am-panel[data-state] > *,
  body .ss-panel[data-state] .ss-list > li,
  body .nt-panel[data-state] .nt-list > li {
    animation: none;
  }

  .b1:hover:not(:disabled),
  .b1:active:not(:disabled),
  .bpost:hover:not(:disabled),
  .bpost:active:not(:disabled),
  .bx:hover:not(:disabled),
  .bx:active:not(:disabled) {
    transform: none;
  }
}
