/* styles.css — no framework, no build step.
 *
 * ========================================================= BRAND, AND ITS LIMIT
 *
 * The brand colours below were SAMPLED from web/assets/whoopmasters-logo.png, not
 * taken from a style guide (there is none in the repo). Measured pixel shares of
 * the opaque ink:
 *
 *   #ed217c  pink    3.3%      #175fad  blue   0.3%
 *   #da1b5c  crimson 1.0%      #15914b  green  0.3%
 *   #000000  black  31.3%      #ed612c  orange 0.2%
 *
 * ---------------------------------------------------------------------------
 * SAFETY COLOURS ARE NOT BRAND COLOURS, and where they conflicted the brand lost.
 * ---------------------------------------------------------------------------
 *
 * --ok / --warn / --bad mean "armed and healthy", "look at this" and "failsafe" on
 * a page read at a flying field. They are UNCHANGED from before the brand work,
 * and two brand colours were REJECTED as accents because of them:
 *
 *   BRAND PINK  #ed217c is 27 degrees of hue from --bad #ef6f6f, and 1.40:1 in
 *               contrast. On a status page where red means the aircraft lost its
 *               link, a brand accent that reads as "nearly the failsafe colour" is
 *               a hazard, not a style choice. NOT used as an accent. It appears
 *               only in the wordmark, which is text and carries no status meaning.
 *
 *   BRAND GREEN #15914b is 3 degrees from --ok #4ec98a. Same problem: an accent
 *               indistinguishable from "healthy". NOT used.
 *
 *   BRAND BLUE  #175fad is 211 degrees, clear of all three safety hues (62/170/149
 *               degrees away), and the outgoing accent #5aa9e6 was already 206
 *               degrees. So blue IS the brand-correct accent and barely moves the
 *               design. Lightened to #4a9fe0 for contrast: #175fad itself is only
 *               2.83:1 on --bg, below the 3:1 floor for UI text.
 *
 * Measured contrast ratios are in docs/BRANDING.md, regenerated by
 * tools/check_contrast.py, which FAILS THE BUILD if any safety colour drops below
 * its floor. A palette change cannot quietly degrade them.
 *
 * ---------------------------------------------- light AND dark, light as fallback
 *
 * REVERSED 2026-10-01. This used to say "dark stays the default: a white page in
 * sunlight is unreadable". At a flying field the argument runs the other way: a
 * near-black screen is a MIRROR in daylight, and a phone's auto-brightness raises the
 * backlight to fight a mostly-black screen -- draining the battery that also powers
 * the USB link. A workshop at night is real too. So `prefers-color-scheme` decides,
 * both themes are first-class, and LIGHT is what renders when no preference is given.
 *
 * EACH THEME HAS ITS OWN SAFETY PALETTE. --ok #4ec98a is 8.65:1 on the dark --bg and
 * 2.09:1 on white: the dark values cannot be reused. Same HUE per meaning in both, so
 * "green means ready" reads the same at noon and at midnight; different LIGHTNESS, and
 * each set measured against its OWN backgrounds by tools/check_contrast.py. Never
 * derived from each other at runtime (no color-mix, no opacity over a background): a
 * derived colour's contrast depends on what it was mixed with, which nobody measured.
 *
 * EVERY COLOUR VARIABLE IS REDEFINED IN THE DARK BLOCK. One left out would inherit its
 * LIGHT value onto a dark background -- check_contrast.py fails on that.
 */

/*
 * ================================================= DESIGN V2 (docs/PLAN-DESIGN-V2.md)
 *
 * Three colour families that never stand in for each other: EVERYDAY (bg, ink, cards,
 * the one blue button), PICTURES AND STEPS (one colour per wizard step, sky, plane, and
 * one MOVING-PART colour), and SAFETY (--ok/--warn/--bad, values UNCHANGED from v1).
 * Every picture colour is a cool hue, >= 35 degrees from all three safety hues: the
 * checker below rejects anything closer, and brand amber (1 degree from --warn) is gone.
 *
 * `--on-step-N-text` is the tick or number drawn ON a step fill. It is a `-text` colour,
 * so check_contrast.py measures it against --step-N and allows it only as `color:` --
 * which is why a tick on a step fill is an SVG stroked in currentColor.
 *
 * The Developer view reads the same names and picks up the colour values only: its
 * font (--sans), sizes and layout are unchanged. Customer screens use --round.
 */

:root {
  color-scheme: light dark;   /* form controls and scrollbars follow the theme too */

  /* ---- LIGHT (the fallback) ---------------------------------------------- */
  /* A faint blue page instead of white; cards are white on it. */
  --bg: #f6f8ff;
  --panel: #ffffff;
  --panel2: #eaeefb;
  --line: #c9d0e6;

  --fg: #1b2140;
  --dim: #4a5275;

  /* SAFETY, light values. UNCHANGED. Same hues as the dark set, darkened to clear 4.5:1
     on all three light backgrounds. tools/check_contrast.py enforces both sets. */
  --ok: #0f7a43;
  --warn: #8a5a00;
  --bad: #c62828;
  /* Fills OF a safety colour: the gate, a takeover, the "connected" chip. The checker
     exempts a `-tint` from the hue rule against ITS OWN colour only. */
  --ok-tint: #e6f4ec;
  --bad-tint: #fdecec;
  --warn-tint: #fdf4e3;

  /* Brand blue UNMODIFIED: the one primary button and the focus ring. */
  --accent: #175fad;

  /* Brand pink, for the WORDMARK ONLY -- inside <header>, as large bold text. */
  --brand-text: #ed217c;

  --btn-bg: #e6eaf7;
  --log-fg: #2f3a59;
  --input-fg: #1b2140;

  /* Text ON the accent (the primary button). */
  --on-accent-text: #ffffff;

  /* ---- pictures and steps ------------------------------------------------ */
  /* One per wizard step: shape, board, radio, flaps, finish. Cyan to purple. */
  --step-1: #0e7490;
  --step-2: #1d4ed8;
  --step-3: #4f46e5;
  --step-4: #7c3aed;
  --step-5: #9022c8;
  /* The picture panel behind each step. */
  --step-1-soft: #e3f6fb;
  --step-2-soft: #e6edfd;
  --step-3-soft: #ecebfd;
  --step-4-soft: #f1eafe;
  --step-5-soft: #f3e8fb;
  /* A tick or number ON a step fill. */
  --on-step-1-text: #ffffff;
  --on-step-2-text: #ffffff;
  --on-step-3-text: #ffffff;
  --on-step-4-text: #ffffff;
  --on-step-5-text: #ffffff;
  --sky: #dcefff;
  /* The plane's body: near-white with a blue cast. Pure #ffffff has hue 0 to colorsys,
     which the hue rule reads as 0 degrees from --bad. */
  --plane: #fcfdff;
  --plane-line: #1b2140;
  /* EVERY part that moves, everywhere, and nothing else. */
  --move: #b0209a;

  /* ---- type, space, radius, motion --------------------------------------- */
  --t-hero: 1.875rem;     /* 30px  the instruction itself  */
  --t-title: 1.5rem;      /* 24px  card heading            */
  --t-lead: 1.3125rem;    /* 21px  the one sentence        */
  --t-body: 1.125rem;     /* 18px                          */
  --t-small: .9375rem;    /* 15px  the floor on customer screens */
  --t-btn: 1.25rem;       /* 20px  buttons                 */

  --s-1: 4px; --s-2: 8px; --s-3: 16px; --s-4: 24px;
  --s-5: 32px; --s-6: 48px; --s-7: 64px; --s-8: 96px;

  --r-control: 30px;
  --r-card: 24px;
  --r-art: 22px;
  --r-chip: 999px;

  --m-fast: 120ms;
  --m-step: 200ms;
  --m-loop: 3.2s;         /* ONE loop drives stick, flap and arrow together */
  --m-ease: cubic-bezier(.22, .61, .36, 1);   /* ease-out */

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
  /* System stacks. No webfont: the page must load on a phone tethered at a field with
     no signal. --round is SF Rounded on Apple devices, the system face elsewhere; the
     Developer view keeps --sans. */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto,
           "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* ---- DARK. Every colour variable above, redefined. A navy, not a grey. --- */
    --bg: #0f1328;
    --panel: #181d3a;
    --panel2: #121733;
    --line: #2e3660;

    --fg: #f2f4ff;
    --dim: #b3b9d9;

    /* SAFETY, dark values -- unchanged. */
    --ok: #4ec98a;
    --warn: #e7b64b;
    --bad: #ef6f6f;
    --ok-tint: #12301f;
    --bad-tint: #3a1717;
    --warn-tint: #33280f;

    /* Brand blue, lightened from #175fad for contrast on the dark --bg. */
    --accent: #4a9fe0;

    --brand-text: #ed217c;

    --btn-bg: #232a4d;
    --log-fg: #c3cbe6;
    --input-fg: #eef0ff;

    /* DARK text on the lightened accent: white on #4a9fe0 is only 2.9:1. */
    --on-accent-text: #0b1520;

    --step-1: #22c3e6;
    --step-2: #6b9cff;
    --step-3: #8f8cff;
    --step-4: #b18cff;
    --step-5: #d08aff;
    --step-1-soft: #0f2f3d;
    --step-2-soft: #16244f;
    --step-3-soft: #1e1f52;
    --step-4-soft: #271d50;
    --step-5-soft: #2d1a4a;
    --on-step-1-text: #0b1020;
    --on-step-2-text: #0b1020;
    --on-step-3-text: #0b1020;
    --on-step-4-text: #0b1020;
    --on-step-5-text: #0b1020;
    --sky: #132a4a;
    /* Light in both themes, like a sticker: the body carries the silhouette here. */
    --plane: #eef1ff;
    --plane-line: #0b0f22;
    --move: #d94fd0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

* { box-sizing: border-box; }

/* `hidden` must win over every `display:` below -- a grid or flex rule would
   otherwise un-hide the developer view, a chip or an empty list. */
[hidden] { display: none !important; }

/* Reduced motion HOLDS THE MOVED POSE (design rule R4): the rule above stops every
   animation, and these put each moving part where the motion would have taken it, so
   the picture still shows which way. The motion goes; the meaning stays. */
@media (prefers-reduced-motion: reduce) {
  .a-up { animation: none !important; transform: translateY(-12px); }
  .a-down { animation: none !important; transform: translateY(12px); }
  .a-right { animation: none !important; transform: translateX(9px); }
  .a-stickR { animation: none !important; transform: translate(12px, 0); }
  .a-stickL { animation: none !important; transform: translate(-12px, 0); }
  .a-stickU { animation: none !important; transform: translate(0, -12px); }
  .a-stickD { animation: none !important; transform: translate(0, 12px); }
  .a-stickLR { animation: none !important; transform: translate(12px, 0); }
  .a-stickUD { animation: none !important; transform: translate(0, -12px); }
  .a-flip { animation: none !important; transform: rotate(28deg); }
  .a-cue { animation: none !important; opacity: 1; }
  .a-tiltR { animation: none !important; transform: rotate(18deg); }
  .a-noseU { animation: none !important; transform: rotate(-14deg); }
  .confetti i, .pulse, .listen i { animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--t-body)/1.5 var(--round);
  -webkit-font-smoothing: antialiased;
}

/* ---- header: the wordmark and the state chip, nothing else ---------------- */

.bar {
  display: flex;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  flex-wrap: wrap;
  padding: 14px 20px 10px;
  background: var(--bg);
}
.bar .spacer { flex: 1 1 auto; }

/* TEXT, not the logo file. web/assets/whoopmasters-logo.png is drawn for a light
   background and measures 1.16:1 against a dark one; docs/BRANDING.md says what to
   supply. 21px BOLD is WCAG "large text" (>= 18.66px bold), where brand pink's 3:1
   is the floor -- tools/check_contrast.py checks both the ratio and this rule's size. */
header .wordmark {
  font: 800 var(--t-lead)/1 var(--round);
  letter-spacing: -.01em;
  margin: 0;
  white-space: nowrap;
}
/* Pink is permitted HERE and nowhere else: only as `color:`, and only in a rule whose
   every selector starts with `header`. */
header .wordmark b { color: var(--brand-text); font-weight: 800; }
header .wordmark span { color: var(--fg); font-weight: 400; }

/* ---- buttons --------------------------------------------------------------- */

/* The base and `.small` are the Developer view's, unchanged. */
button {
  font: inherit;
  padding: .4rem .9rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--fg);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small { padding: .15rem .55rem; font-size: .8rem; font-weight: 400; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* The customer's buttons: full width, 60px, ONE primary (blue) per screen. */
button.primary, button.ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 12px 18px;
  border-radius: var(--r-control);
  border: 3px solid transparent;
  font: 700 var(--t-btn)/1.15 var(--round);
  text-align: center;
  transition: transform var(--m-fast) var(--m-ease),
              border-color var(--m-fast) var(--m-ease);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent-text); }
button.ghost { background: var(--panel); border-color: var(--line); color: var(--fg); }
button.primary:active:not(:disabled), button.ghost:active:not(:disabled) { transform: scale(.97); }
/* Disabled says so three ways: dashed, grey, and a label that is the reason. */
button.primary:disabled, button.ghost:disabled {
  opacity: 1;
  background: var(--panel2);
  border: 3px dashed var(--line);
  color: var(--dim);
}
.screens button:focus-visible, .foot button:focus-visible, .bar button:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}
/* An answer pair ("It moved the right way" / "Flip it"): one question, two tall buttons. */
button.answer { min-height: 84px; font-size: 1.1875rem; }
button svg { width: 26px; height: 26px; flex: none; }
button svg path, button svg rect {
  fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}

/* Small chrome buttons: Disconnect in the header, Developer in the footer. Still 44px. */
.bar button.ghost, .foot button.ghost {
  width: auto;
  min-height: 44px;
  padding: 8px 14px;
  border-width: 2px;
  font: 600 var(--t-small)/1 var(--round);
  color: var(--dim);
}
/* A toggle shows that it is ON, not only that it exists (the Developer button). */
button.ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* ---- state chip: icon + word + tone, in that order of importance ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 2.5px solid currentColor;
  border-radius: var(--r-chip);
  font: 700 var(--t-small)/1 var(--round);
  white-space: nowrap;
}
.chip-icon, .screen-icon { display: inline-grid; place-items: center; }
.chip-icon svg { width: 16px; height: 16px; }
.chip-icon svg, .screen-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Tone sets the colour of the ICON and the chip only -- never of body text. The safety
   colours appear only for real states (rule R5); "doing a step" is not one. */
.chip.tone-bad  { color: var(--bad);  background: var(--bad-tint); }
.chip.tone-warn { color: var(--warn); background: var(--warn-tint); }
.chip.tone-ok   { color: var(--ok);   background: var(--ok-tint); }
.chip.tone-accent, .chip.tone-neutral { color: var(--dim); background: var(--panel); border-color: var(--line); }
.screen.tone-bad     .screen-icon { color: var(--bad); }
.screen.tone-warn    .screen-icon { color: var(--warn); }
.screen.tone-ok      .screen-icon { color: var(--ok); }
.screen.tone-accent  .screen-icon { color: var(--step, var(--accent)); }
.screen.tone-neutral .screen-icon { color: var(--dim); }

/* ---- screens: one task each ----------------------------------------------- */

.screens {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--s-2) 16px 0;
}
.screen.enter { animation: screen-in var(--m-step) var(--m-ease); }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* The current step's colour. Set on the section; everything inside reads --step. */
.s1 { --step: var(--step-1); --step-soft: var(--step-1-soft); }
.s2 { --step: var(--step-2); --step-soft: var(--step-2-soft); }
.s3 { --step: var(--step-3); --step-soft: var(--step-3-soft); }
.s4 { --step: var(--step-4); --step-soft: var(--step-4-soft); }
.s5 { --step: var(--step-5); --step-soft: var(--step-5-soft); }

.screen-icon {
  width: 52px;
  height: 52px;
  border: 3px solid currentColor;
  border-radius: 50%;
  margin: var(--s-3) 0 0;
  transition: color var(--m-step) var(--m-ease);
}
.screen-icon svg { width: 26px; height: 26px; }
/* A screen with a picture shows the picture instead (rule R3: a picture of what to do). */
.screen[data-art] .screen-icon { display: none; }
/* A finished step shows the celebration's badge instead of the small tick. */
.screen[data-party] .screen-icon { display: none; }
.screen-title {
  font: 800 var(--t-hero)/1.15 var(--round);
  letter-spacing: -.01em;
  margin: 18px 0 8px;
}
.lead {
  font: 500 var(--t-lead)/1.35 var(--round);
  color: var(--fg);
  max-width: 32ch;
  margin: 0 0 6px;
}
.hint { margin: var(--s-3) 0 0; font-size: var(--t-small); color: var(--dim); }
.screens .actions { display: grid; gap: 12px; margin-top: var(--s-4); }
.screens .actions.pair { grid-template-columns: 1fr 1fr; }
.screens .actions.pair > :nth-child(n+3) { grid-column: 1 / -1; }

/* A note on the screen. Neutral by default: "Flipped! Look again." is not a warning.
   On a caution screen it takes the caution's edge; on a takeover, the takeover's. */
.block-note {
  margin: var(--s-3) 0 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--step-soft, var(--panel2));
  font-weight: 700;
  color: var(--fg);
}
.screen.tone-warn .block-note { border-left: 6px solid var(--warn); background: var(--warn-tint); }
.screen.tone-bad .block-note { border-left: 6px solid var(--bad); background: var(--panel); }

/* "Step 2 of 5", in words; the flap counter ("Flap 1 of 3"). */
.step-pill {
  display: inline-block;
  margin: var(--s-3) 0 0;
  padding: 4px 12px;
  border-radius: var(--r-chip);
  background: var(--step-soft, var(--panel2));
  font: 700 var(--t-small)/1.4 var(--round);
  color: var(--fg);
}

/* ---- progress, phone-setup style ------------------------------------------ */
/* Number, size and label carry it, so colour is never the only cue. Done is the step's
   colour, NOT green: finishing a step is progress, not a board state. */

.progress { margin: var(--s-2) 0 0; }
.progress ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; }
.progress li { display: flex; align-items: center; flex: 1; }
.progress li:last-child { flex: none; }
.progress .dot {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font: 800 16px/1 var(--round);
  border: 3px solid var(--line); color: var(--dim); background: var(--panel);
}
.progress .dot svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.progress li::after { content: ""; flex: 1; height: 4px; margin: 0 4px; border-radius: 2px;
  background: var(--line); }
.progress li:last-child::after { display: none; }
.progress li:nth-child(1) { --c: var(--step-1); --soft: var(--step-1-soft); }
.progress li:nth-child(2) { --c: var(--step-2); --soft: var(--step-2-soft); }
.progress li:nth-child(3) { --c: var(--step-3); --soft: var(--step-3-soft); }
.progress li:nth-child(4) { --c: var(--step-4); --soft: var(--step-4-soft); }
.progress li:nth-child(5) { --c: var(--step-5); --soft: var(--step-5-soft); }
.progress .done .dot { background: var(--c); border-color: var(--c); }
.progress li:nth-child(1).done .dot { color: var(--on-step-1-text); }
.progress li:nth-child(2).done .dot { color: var(--on-step-2-text); }
.progress li:nth-child(3).done .dot { color: var(--on-step-3-text); }
.progress li:nth-child(4).done .dot { color: var(--on-step-4-text); }
.progress li:nth-child(5).done .dot { color: var(--on-step-5-text); }
.progress .done::after { background: var(--c); }
.progress .now .dot { width: 42px; height: 42px; border-color: var(--c); color: var(--c);
  box-shadow: 0 0 0 5px var(--soft); font-size: 19px; }
.progress .label { margin: 10px 0 0; font: 700 var(--t-small)/1.2 var(--round); color: var(--step); }
.progress .label span { color: var(--dim); font-weight: 600; }

/* ---- the picture of what to do -------------------------------------------- */

.art {
  background: var(--step-soft, var(--sky));
  border-radius: var(--r-art);
  padding: 14px;
  margin-top: var(--s-3);
}
.art svg { display: block; width: 100%; height: auto; max-height: 280px; overflow: visible; }
.art .cap { text-align: center; font: 700 var(--t-small)/1.3 var(--round); margin: 6px 0 0; }

/* One character everywhere: a white body, a thick dark outline, the step's colour on
   the roundel. Flat, round joins, no gradients. */
.pf { fill: var(--plane); stroke: var(--plane-line); stroke-width: 4; stroke-linejoin: round; }
.pl { fill: none; stroke: var(--plane-line); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.pk { fill: var(--plane-line); }
.ps { fill: var(--step, var(--accent)); stroke: var(--plane-line); stroke-width: 3; }
.pd { fill: none; stroke: var(--dim); stroke-width: 3; stroke-dasharray: 7 6; stroke-linecap: round; }
/* The moving part is always --move, on every screen, and nothing else is. */
.mv { fill: var(--move); stroke: var(--plane-line); stroke-width: 3.5; stroke-linejoin: round; }
.mv-arrow { fill: none; stroke: var(--move); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.st-arrow { fill: none; stroke: var(--step, var(--accent)); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ink-line { fill: none; stroke: var(--fg); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rgim { fill: var(--plane); stroke: var(--plane-line); stroke-width: 3; }
.rknob { fill: var(--step, var(--accent)); stroke: var(--plane-line); stroke-width: 3.5; }
.art text { fill: var(--fg); font: 800 15px var(--round); }
.art text.dim { fill: var(--dim); font-weight: 700; font-size: 13px; }
/* A technical mark, small, after the friendly name (design v2 R2): the wiring screen's pad. */
.art tspan.dim { fill: var(--dim); font-weight: 700; font-size: 13px; }

/* ONE shared loop, so stick, flap and arrow move together: cause and effect. */
@keyframes flapUp   { 0%,14% { transform: translateY(0); } 34%,64% { transform: translateY(-12px); } 84%,100% { transform: translateY(0); } }
@keyframes flapDown { 0%,14% { transform: translateY(0); } 34%,64% { transform: translateY(12px); }  84%,100% { transform: translateY(0); } }
@keyframes flapRight { 0%,14% { transform: translateX(0); } 34%,64% { transform: translateX(9px); } 84%,100% { transform: translateX(0); } }
@keyframes stickR { 0%,14% { transform: translate(0,0); } 34%,64% { transform: translate(12px,0); } 84%,100% { transform: translate(0,0); } }
@keyframes stickL { 0%,14% { transform: translate(0,0); } 34%,64% { transform: translate(-12px,0); } 84%,100% { transform: translate(0,0); } }
@keyframes stickU { 0%,14% { transform: translate(0,0); } 34%,64% { transform: translate(0,-12px); } 84%,100% { transform: translate(0,0); } }
@keyframes stickD { 0%,14% { transform: translate(0,0); } 34%,64% { transform: translate(0,12px); } 84%,100% { transform: translate(0,0); } }
@keyframes stickLR { 0%,10%,90%,100% { transform: translate(0,0); } 25%,40% { transform: translate(-12px,0); } 60%,75% { transform: translate(12px,0); } }
@keyframes stickUD { 0%,10%,90%,100% { transform: translate(0,0); } 25%,40% { transform: translate(0,-12px); } 60%,75% { transform: translate(0,12px); } }
@keyframes flip { 0%,14% { transform: rotate(-28deg); } 34%,64% { transform: rotate(28deg); } 84%,100% { transform: rotate(-28deg); } }
@keyframes cue { 0%,14% { opacity: .25; } 34%,64% { opacity: 1; } 84%,100% { opacity: .25; } }
@keyframes tiltR { 0%,14% { transform: rotate(0); } 34%,64% { transform: rotate(18deg); } 84%,100% { transform: rotate(0); } }
@keyframes noseU { 0%,14% { transform: rotate(0); } 34%,64% { transform: rotate(-14deg); } 84%,100% { transform: rotate(0); } }
.a-up, .a-down, .a-right, .a-stickR, .a-stickL, .a-stickU, .a-stickD, .a-stickLR, .a-stickUD,
.a-flip, .a-tiltR, .a-noseU { transform-box: fill-box; }
.a-flip { transform-origin: 50% 100%; }
.a-tiltR, .a-noseU { transform-origin: 50% 50%; }
.a-up     { animation: flapUp    var(--m-loop) var(--m-ease) infinite; }
.a-down   { animation: flapDown  var(--m-loop) var(--m-ease) infinite; }
.a-right  { animation: flapRight var(--m-loop) var(--m-ease) infinite; }
.a-stickR { animation: stickR    var(--m-loop) var(--m-ease) infinite; }
.a-stickL { animation: stickL    var(--m-loop) var(--m-ease) infinite; }
.a-stickU { animation: stickU    var(--m-loop) var(--m-ease) infinite; }
.a-stickD { animation: stickD    var(--m-loop) var(--m-ease) infinite; }
.a-stickLR { animation: stickLR  var(--m-loop) var(--m-ease) infinite; }
.a-stickUD { animation: stickUD  var(--m-loop) var(--m-ease) infinite; }
.a-flip   { animation: flip      var(--m-loop) var(--m-ease) infinite; }
.a-cue    { animation: cue       var(--m-loop) var(--m-ease) infinite; }
.a-tiltR  { animation: tiltR     var(--m-loop) var(--m-ease) infinite; }
.a-noseU  { animation: noseU     var(--m-loop) var(--m-ease) infinite; }

/* ---- listening: pulsing dots WITH WORDS ("Watching for your stick…") ------- */

.listen { display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: var(--s-3); font: 700 1.0625rem/1.2 var(--round); color: var(--dim); }
.listen i { width: 10px; height: 10px; border-radius: 50%; background: var(--step, var(--accent));
  animation: pulse 1.4s ease-in-out infinite; }
.listen i:nth-child(2) { animation-delay: .2s; }
.listen i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---- the propeller-off gate: a caution, so amber frame, icon and words ------ */

.screen.is-gate {
  margin-top: var(--s-3);
  padding: 16px;
  border: 4px solid var(--warn);
  border-radius: var(--r-card);
  background: var(--warn-tint);
}
.gate-hd { display: flex; align-items: center; gap: 10px; color: var(--warn);
  font: 800 var(--t-small)/1.2 var(--round); text-transform: uppercase; letter-spacing: .06em; }
.gate-hd svg { width: 26px; height: 26px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
/* The gate's picture is neutral: never red, green or amber in a picture. */
.screen.is-gate .art { background: var(--panel); }
.screen.is-gate .screen-icon { display: none; }
/* A real checkbox (38px) inside a large label: the whole row is the tap target. */
.check { display: flex; align-items: center; gap: 14px; margin-top: var(--s-3); padding: 14px;
  background: var(--panel); border: 3px solid var(--line); border-radius: 18px; cursor: pointer;
  font: 700 var(--t-lead)/1.25 var(--round); color: var(--fg); }
.check input { appearance: none; -webkit-appearance: none; width: 38px; height: 38px; flex: none;
  margin: 0; border: 3.5px solid var(--fg); border-radius: 10px; background: var(--panel);
  display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--fg); }
.check input:checked::after { content: ""; width: 10px; height: 19px; border: solid var(--panel);
  border-width: 0 4.5px 4.5px 0; transform: translateY(-2px) rotate(45deg); }
.check:has(input:checked) { border-color: var(--fg); }
.check:focus-within { outline: 4px solid var(--accent); outline-offset: 3px; }

/* ---- danger: the motor made a sound on a flap port. Red, plain, unmissable --- */

.danger { display: flex; gap: 12px; align-items: flex-start; margin-top: var(--s-3);
  padding: 14px 16px; border: 4px solid var(--bad); border-radius: 18px;
  background: var(--bad-tint); color: var(--bad); font: 800 var(--t-lead)/1.3 var(--round); }
.danger svg { width: 34px; height: 34px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---- celebration: marks every finished step. Never says "ready to fly" ------- */

.party { position: relative; width: 230px; height: 170px; margin: var(--s-3) auto 0; }
.party > svg { position: absolute; inset: 0; margin: auto; width: 128px; height: 128px; }
.badge-fill { fill: var(--step, var(--accent)); }
.badge { color: var(--on-accent-text); }
.s1 .badge { color: var(--on-step-1-text); }
.s2 .badge { color: var(--on-step-2-text); }
.s3 .badge { color: var(--on-step-3-text); }
.s4 .badge { color: var(--on-step-4-text); }
.s5 .badge { color: var(--on-step-5-text); }
.badge path { fill: none; stroke: currentColor; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; border-radius: 3px;
  transform: translate(var(--x), var(--y)) rotate(var(--r));
  animation: burst 900ms var(--m-ease) both; }
.confetti i:nth-child(3n) { border-radius: 50%; }
.confetti i:nth-child(4n) { width: 8px; height: 16px; }
@keyframes burst { from { transform: translate(-50%, -50%) scale(.2) rotate(0); opacity: 0; }
                   to   { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 1; } }
.screen[data-party] .screen-title, .screen[data-party] .lead { text-align: center; margin-left: auto; margin-right: auto; }

/* ---- safety takeover: motor live, don't fly. No step colour, no confetti ---- */

.screen.tone-bad {
  margin: var(--s-3) -16px 0;
  padding: 22px 20px 26px;
  border-top: 10px solid var(--bad);
  background: var(--bad-tint);
}
.screen.tone-bad .screen-icon { width: 64px; height: 64px; border-width: 4px; }
.screen.tone-bad .screen-title { color: var(--bad); }
.screen.tone-bad .art, .screen.tone-bad .progress, .screen.tone-bad .party { display: none; }

/* ---- screen 1 --------------------------------------------------------------- */

.steps-list {
  list-style: none;
  counter-reset: step;
  margin: var(--s-4) 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.steps-list li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-body);
}
.steps-list li::before {
  content: counter(step);
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--c, var(--accent));
  border-radius: 50%;
  background: var(--panel);
  color: var(--c, var(--accent));
  font: 800 16px/1 var(--round);
}
.steps-list li[data-n="1"] { --c: var(--step-1); }
.steps-list li[data-n="2"] { --c: var(--step-2); }
.steps-list li[data-n="3"] { --c: var(--step-3); }
.steps-list li[data-n="4"] { --c: var(--step-4); }
.steps-list li[data-n="5"] { --c: var(--step-5); }
.steps-list li[data-status="done"] { color: var(--dim); }
.steps-list li[data-status="done"]::before { content: "\2713"; background: var(--c, var(--accent)); }
.steps-list li[data-n="1"][data-status="done"]::before { color: var(--on-step-1-text); }
.steps-list li[data-n="2"][data-status="done"]::before { color: var(--on-step-2-text); }
.steps-list li[data-n="3"][data-status="done"]::before { color: var(--on-step-3-text); }
.steps-list li[data-n="4"][data-status="done"]::before { color: var(--on-step-4-text); }
.steps-list li[data-n="5"][data-status="done"]::before { color: var(--on-step-5-text); }
.steps-list li[data-status="current"] { font-weight: 800; }
.steps-list li[data-status="current"]::before { width: 40px; height: 40px; margin: -3px;
  box-shadow: 0 0 0 4px var(--panel2); }
.steps-list li[data-status="todo"]::before { border-color: var(--line); color: var(--dim); }
.steps-list li[data-status="soon"] { counter-increment: none; color: var(--dim); font-size: var(--t-small); }
.steps-list li[data-status="soon"]::before { content: ""; border-style: dashed;
  border-color: var(--line); width: 26px; height: 26px; margin: 4px; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s-2) var(--s-4);
  margin: var(--s-4) 0 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 20px;
}
.facts dt { color: var(--dim); }
.facts dd { margin: 0; font-weight: 700; }

/* ---- screen 2: the live aircraft (the tilt check) ------------------------- */

.aircraft {
  max-width: 560px;
  margin: var(--s-5) auto 0;
  padding: 0 16px;
}
.section-title {
  font: 800 var(--t-title)/1.2 var(--round);
  letter-spacing: -.01em;
  margin: 0 0 var(--s-2);
}
.views {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: var(--s-3) 0 0;
}
.view {
  margin: 0;
  padding: var(--s-3);
  background: var(--sky);
  border-radius: var(--r-art);
  text-align: center;
}
/* overflow visible: a 90 deg roll stands the wings on end, past the viewBox. */
.view svg { width: 100%; height: auto; display: block; overflow: visible; }
.view figcaption { font: 700 var(--t-small)/1.3 var(--round); color: var(--fg); margin-top: var(--s-2); }
/* The fixed reference: the screen's level. Only the aircraft moves. */
.ref { stroke: var(--dim); stroke-width: 2; stroke-dasharray: 4 6; }
.ac-body {
  transform-box: view-box;
  transform-origin: 50% 50%;
  /* Eases TOWARD each 4 Hz report; never past it. Reduced motion snaps (see top). */
  transition: transform var(--m-step) var(--m-ease);
}
/* `.ac` line work, still used by the tuning page's drawings. */
.ac {
  fill: none;
  stroke: var(--fg);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ac.hull { fill: var(--panel); }
.ac.fin { stroke: var(--accent); }
.readout { grid-template-columns: max-content 1fr; }
.aside {
  margin: var(--s-3) 0 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--panel2);
  font-weight: 700;
}
/* A silent board's picture is its LAST reading: frozen, greyed, dashed, and labelled. */
.aircraft.is-stale .views, .aircraft.is-stale .readout { opacity: .4; }
.aircraft.is-stale .pf { stroke-dasharray: 8 6; }

/* ---- cards for choices (plane shape, which way the board sits) ------------- */

.af-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: var(--s-3);
}
.af-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 10px 10px 12px;
  background: var(--panel);
  color: var(--fg);
  border: 3px solid var(--line);
  border-radius: 20px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--m-step) var(--m-ease);
}
.af-card:hover { border-color: var(--accent); }
.af-card[aria-checked="true"] { border-color: var(--step, var(--accent));
  box-shadow: 0 0 0 4px var(--step-soft, var(--panel2)); }
.af-card .pic { display: block; background: var(--sky); border-radius: 14px; padding: 4px; margin-bottom: 6px; }
.af-card svg { width: 100%; height: auto; display: block; }
.af-card .n { font: 800 1.1875rem/1.2 var(--round); margin: 2px 2px 0; }
.af-card .d { font-size: var(--t-small); line-height: 1.3; color: var(--dim); margin: 0 2px; }
.af-card .in-use { font: 700 var(--t-small)/1.3 var(--round); color: var(--step, var(--accent)); margin: 4px 2px 0; }
.af-card .sel { position: absolute; top: -10px; right: -8px; width: 34px; height: 34px; display: none; }
.af-card[aria-checked="true"] .sel { display: block; }
.af-card .sel { border-radius: 50%; background: var(--step, var(--accent)); padding: 6px; }
.af-card .sel path { fill: none; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 380px) {
  .af-cards { grid-template-columns: 1fr; }
  .screen-title { font-size: 1.6875rem; }
}

/* ---- footer: the Developer button lives here, small ------------------------ */

.foot {
  margin-top: var(--s-6);
  padding: var(--s-3) 20px 20px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: var(--s-2);
}
.sub { color: var(--dim); font-size: .85rem; }

/* ---- banners ------------------------------------------------------------- */

.banner {
  margin: 1rem;
  padding: .8rem 1rem;
  border-radius: 8px;
  border: 1px solid;
  font-size: .9rem;
}
.banner-hard { border-color: var(--bad);  background: var(--bad-tint); }
.banner-warn { border-color: var(--warn); background: var(--warn-tint); }

/* ---- layout -------------------------------------------------------------- */

/* The developer view: the monitor exactly as it was before screen 1. */
.dev {
  /* The Developer view keeps v1's type: the system face at 15px. Only colours change. */
  font: 15px/1.5 var(--sans);
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-width: 1100px;
  margin: var(--s-6) auto 0;
  border-top: 1px solid var(--line);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem 1rem 1rem;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 0 0 .7rem;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--dim);
}
.card h2 .chk, .card h2 button { margin-left: auto; }
.card h2 .chk + button { margin-left: 0; }
.chk { font: 400 .8rem/1 var(--sans); color: var(--dim); text-transform: none; letter-spacing: 0; }

/* ---- key/value ----------------------------------------------------------- */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--dim); font-size: .85rem; }
.kv dd { margin: 0; font-family: var(--mono); }

/* ---- tiles --------------------------------------------------------------- */

.tiles {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.tile {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .85rem;
  min-height: 86px;
}
.tl { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.tv { font: 600 1.35rem/1.15 var(--mono); }
.tn { font-size: .74rem; color: var(--dim); font-family: var(--mono); }

/* status colours, shared by tiles and cells */
.ok  { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.na  { color: var(--dim); font-weight: 400; font-style: italic; }
.tv.na { font-size: 1.05rem; }

/* ---- vector table -------------------------------------------------------- */

.vec { border-collapse: collapse; font-family: var(--mono); }
.vec th, .vec td { padding: .3rem .9rem .3rem 0; text-align: right; }
.vec thead th { color: var(--dim); font-size: .75rem; font-weight: 600; }
.vec tbody th { color: var(--dim); text-align: left; font-weight: 400; }
.vec td { min-width: 5.5ch; }

/* ---- notes --------------------------------------------------------------- */

.note { margin: .7rem 0 0; font-size: .82rem; color: var(--dim); line-height: 1.55; }
.note code { font-family: var(--mono); font-size: .95em; color: var(--fg); }
.note b { color: var(--fg); }
.note.warn {
  color: var(--warn);
  border-left: 2px solid var(--warn);
  padding-left: .7rem;
}
.note.warn code, .note.warn b { color: var(--warn); }

/* ---- log ----------------------------------------------------------------- */

.log {
  margin: 0;
  height: 340px;
  overflow: auto;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .8rem;
  font: 12.5px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--log-fg);
}

/* ---- raw CLI -------------------------------------------------------------- */

/* Visually hidden but present for screen readers. The input has a placeholder,
   which is NOT a label: a placeholder disappears on focus and is not announced
   reliably. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#cli-form {
  display: flex;
  gap: .5rem;
  margin: .6rem 0;
}

#cli-input {
  flex: 1 1 auto;
  min-width: 0;                 /* so a long value cannot push Send off-screen */
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .6rem;
  font: 12.5px/1.5 var(--mono);
  color: var(--input-fg);
}
#cli-input:focus { outline: none; border-color: var(--accent); }
#cli-input:disabled { opacity: .5; cursor: not-allowed; }

/* Shorter than the raw log: this is a transcript of a few commands, and a
   340px empty box reads as something being broken. */
#cli-out { height: 200px; margin-top: .4rem; }

/* The echoed command, so a transcript can be read back. */
#cli-out .cli-cmd { color: var(--accent); }
#cli-out .cli-err { color: var(--warn); }
#cli-out .cli-note { color: var(--dim); }

/* ---- stale: port open, board silent -------------------------------------- */

body.is-stale .tiles,
body.is-stale #inertial,
body.is-stale #sticks-card { opacity: .45; }
body.is-stale .tiles { transition: opacity .2s; }
/* Screen 1's facts are a reading of the board: grey them when it goes silent.
   Not body-scoped, so the preview can mark a single frame stale. */
.is-stale .facts { opacity: .45; }

/* ---- the tuning page (tuning.html): flight card + log reader ---------------- */
/* Existing tokens only, so tools/check_contrast.py's measured palette covers it. */

.ghost-link {
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding: var(--s-2) var(--s-3);
  text-decoration: none;
  font-weight: 600;
}
.ghost-link:hover { border-color: var(--accent); }
.ghost-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tabs { display: flex; gap: var(--s-2); margin-bottom: var(--s-5); flex-wrap: wrap; }
.fc-h { margin-top: var(--s-5); }
.fc-list { margin: var(--s-3) 0 0; padding-left: 1.4em; display: grid; gap: var(--s-2); line-height: 1.5; }
.fc-flight .steps-list li { align-items: flex-start; line-height: 1.5; }
.illus { margin: var(--s-4) 0 0; }
.illus svg { width: 100%; max-width: 420px; height: auto; display: block; overflow: visible; }
.illus figcaption { font-size: var(--t-small); color: var(--dim); margin-top: var(--s-2); }
.fc-draw svg { max-width: 260px; }
.il-track { stroke: var(--line); stroke-width: 3; }
.il-tick  { stroke: var(--dim); stroke-width: 2; }
.il-zone  { fill: var(--panel2); stroke: var(--accent); stroke-width: 2; }
.il-knob  { fill: var(--accent); }
.il-no    { stroke: var(--bad); stroke-width: 3; stroke-linecap: round; fill: none; }
.il-wave  { stroke: var(--accent); stroke-width: 3; fill: none; stroke-linejoin: round; }
.il-text  { fill: var(--dim); font: 400 12px var(--sans); }
.il-strong { fill: var(--fg); font-weight: 600; }

.file-pick { position: relative; display: inline-block; }
.file-pick input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.file-pick span {
  display: inline-block;
  border-radius: var(--r-control);
  padding: var(--s-2) var(--s-4);
  background: var(--accent);
  color: var(--on-accent-text);
  font-weight: 600;
}
.file-pick:focus-within span { outline: 3px solid var(--accent); outline-offset: 3px; }
.tr-summary { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.tr-axis {
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--r-card);
  background: var(--panel);
  margin-top: var(--s-2);
}
.tr-axis.tone-ok      { border-left-color: var(--ok); }
.tr-axis.tone-warn    { border-left-color: var(--warn); }
.tr-axis.tone-neutral { border-left-color: var(--line); }
.tr-axis-title { margin: 0; font-weight: 600; }
.tr-axis-line  { margin: var(--s-1) 0 0; line-height: 1.5; }
.tr-axis .facts { margin-top: var(--s-3); background: var(--bg); }
.tr-log { margin-top: var(--s-5); }
.tr-file { font-family: var(--mono); font-size: var(--t-body); word-break: break-all; }
.foot-link { display: block; margin-top: var(--s-2); color: var(--accent); font-size: .85rem; }

/* The tuning page's tabs are chrome, not the screen's one action: not full width. */
.tabs button.ghost { width: auto; min-height: 44px; padding: 8px 16px; font-size: var(--t-small); }

/* The tuning page's "Apply to the board": your own values, three rows of two fields. */
.tw-manual { margin-top: var(--s-5); }
.tw-field { display: grid; grid-template-columns: 4em auto auto; justify-content: start;
            align-items: center; gap: var(--s-3); margin-top: var(--s-3); }
.tw-axis { font-weight: 600; }
.tw-board .facts dd { overflow-wrap: anywhere; }
.tw-in { display: inline-flex; align-items: center; gap: var(--s-2); }
.tw-in span { color: var(--dim); font-family: var(--mono); }
.tw-in input {
  width: 5.5em;
  min-height: 44px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .35rem .6rem;
  font: 1rem/1.5 var(--mono);
  color: var(--input-fg);
}
.tw-in input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.tw-detail { margin-top: var(--s-4); font-size: var(--t-small); color: var(--dim); }
.tw-detail pre { font: 12px/1.5 var(--mono); white-space: pre-wrap; margin: var(--s-2) 0 0; }

/* ---- screen 4: which way the board sits ------------------------------------ */
/* The plane from above is CONTEXT; the direction is the answer, in the step colour. */
.or-card .ac, .or-picture .ac { stroke: var(--line); stroke-width: 4; }
.or-card .sf, .or-picture .sf { fill: none; stroke: var(--step, var(--accent)); stroke-width: 5;
  stroke-linecap: round; stroke-linejoin: round; }
.or-verify { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: var(--s-4); }
.or-verify .or-step { grid-column: 1 / -1; color: var(--fg); font: 700 var(--t-small)/1.4 var(--round);
  justify-self: start; padding: 4px 12px; border-radius: var(--r-chip); background: var(--step-soft, var(--panel2)); }
.or-verify button { min-height: 84px; }

/* ---- screens 6/7: sticks and switches: what moved, live -------------------- */
.ch-bars { display: grid; gap: 6px; margin-top: var(--s-3); padding: 12px 14px;
  background: var(--step-soft, var(--panel2)); border-radius: var(--r-art); }
.ch-bar { display: grid; grid-template-columns: 1fr 9em; align-items: center; gap: var(--s-2);
  font-size: var(--t-small); color: var(--dim); }
.ch-track { height: 12px; border-radius: var(--r-chip); background: var(--panel);
  border: 2px solid var(--line); overflow: hidden; }
.ch-fill { display: block; height: 100%; width: 0; background: var(--line); }
.ch-bar.is-owned .ch-fill { background: var(--dim); }
.ch-bar.is-candidate .ch-fill { background: var(--step, var(--accent)); }
.ch-bar.is-candidate, .ch-bar.is-owned { color: var(--fg); font-weight: 700; }
.ch-bar.is-candidate .ch-track { border-color: var(--step, var(--accent)); }
.ch-owner { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ======================================== DESKTOP: THE PRIMARY LAYOUT (the user, 2026-10-09)
 *
 * Web Serial works in desktop Chrome and Edge, not on phones, so nearly every setup is
 * on a laptop. From 960 px wide: the picture (or the live plane) LARGE on one side, the
 * instruction and its one big button on the other. Below that, the phone column above,
 * unchanged.
 *
 * A CONTAINER query, not a media query: the layout follows the width the page is drawn
 * in. On the live page that is the window; in web/test/preview.html it is each frame,
 * so a 390 px frame shows the phone layout on any screen and tools/screenshots.mjs
 * draws every width from one stylesheet.
 *
 * NO MARKUP CHANGE. Each screen's parts keep their phone order in index.html; the grid
 * places them. The picture spans every row of the left column, and the last row is
 * `1fr`: a grid item spanning a flexible row puts its extra height into THAT row only,
 * so a tall picture never stretches the gaps between the title, the sentence and the
 * button on the right.
 */
body { container: page / inline-size; }
/* A container's background no longer propagates to the canvas (CSS containment stops
   it), so the page under short content would be WHITE in the dark theme. Paint the
   root itself. Found on the 390 px screenshot of the live page. */
html { background: var(--bg); }

/* Hover: something under the pointer answers it. Existing tokens only (no derived
   colour: its contrast would be unmeasured). The focus ring below is a different
   shape, so a hovered button never looks focused. */
button.primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 0 var(--line); }
button.ghost:hover:not(:disabled) { border-color: var(--accent); background: var(--panel2); }
.bar button.ghost:hover:not(:disabled), .foot button.ghost:hover:not(:disabled) { color: var(--fg); }
.af-card:hover { transform: translateY(-2px); }
.check:hover { border-color: var(--accent); }
.foot-link:hover { text-decoration-thickness: 3px; }

/* Focus: one thick ring in the accent, outside the control, in both themes (6.0:1 and
   6.4:1 on the page). Links and the tick box's row too. */
a:focus-visible, .af-card:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
.af-card:focus-visible { border-radius: 20px; }
.check:has(input:focus-visible) { outline: 4px solid var(--accent); outline-offset: 3px; }

@container page (min-width: 960px) {
  .bar {
    max-width: 1680px;
    margin: 0 auto;
    padding: 22px clamp(24px, 3.5cqi, 64px) 12px;
  }
  header .wordmark { font-size: 1.625rem; }
  .screens {
    max-width: 1680px;
    padding: var(--s-3) clamp(24px, 3.5cqi, 64px) 0;
    /* The picture panel's height: one for every drawing, so the page does not jump
       from step to step. The radio step's is lower: its live bars go under it. */
    --art-h: clamp(320px, 58vh, 620px);
  }
  .screens > .screen.channels { --art-h: clamp(240px, 34vh, 340px); }

  /* Read from arm's length: the instruction and the sentence grow. */
  .screen-title { font-size: 2.5rem; margin-top: 12px; }
  .lead { font-size: 1.5rem; max-width: 34ch; }
  .screens .hint { font-size: 1rem; }
  button.primary, button.ghost { min-height: 66px; font-size: 1.375rem; }
  button.answer { min-height: 96px; font-size: 1.3125rem; }
  .screens .actions { gap: 14px; }

  /* A screen with nothing to picture: one comfortable column in the middle, and the
     live plane's "waiting" line lined up under it. */
  .screen, .aircraft { max-width: 720px; margin-left: auto; margin-right: auto; }
  .aircraft { padding: 0; }

  /* ---- a screen WITH a picture: two columns ---------------------------------- */
  /* Left: the picture, the celebration, the cards to choose from, the live bars,
     screen 1's list of steps, or the radio step's list of what it found. Right:
     everything else, in its phone order. The progress row spans both. Not when
     the live plane is on screen too: then the live plane is the left column (below). */
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-rows: repeat(24, auto) 1fr;
    column-gap: clamp(32px, 4.5cqi, 88px);
    align-content: start;
  }
  .screens > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) > * { grid-column: 2; }
  /* A grid stretches its items: the pill keeps its own width. */
  .screens > .screen > .step-pill { justify-self: start; }
  .screens > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) > .progress {
    grid-column: 1 / -1;
  }
  .screens > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden]))
    > :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows) {
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: start;
  }
  .screens > .screen:has(> .progress:not([hidden])):has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden]))
    > :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows) {
    grid-row: 2 / -1;
  }
  /* The progress row: wide, and its label under the dots. */
  .screens > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) > .progress {
    margin-bottom: var(--s-3);
  }

  /* THE PICTURE: a big panel, the drawing scaled to fit it. One height for every
     drawing, so moving from one step to the next does not make the page jump. */
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .art:not([hidden])) > .art {
    height: var(--art-h);
    margin-top: var(--s-3);
    padding: 24px;
    display: flex;
    flex-direction: column;
  }
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .art:not([hidden])) > .art svg {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-height: none;
  }
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .art:not([hidden])) > .art .cap { font-size: 1.125rem; }

  /* The radio step shows the radio AND the live bars, one above the other on the left:
     both span the left column, and the bars start where the radio panel (a fixed
     height) ends. */
  .screens > .screen.channels:has(> .art:not([hidden])):has(> .ch-bars:not([hidden])) > .ch-bars {
    margin-top: calc(var(--s-3) + var(--art-h) + var(--s-3));
  }
  .screens > .screen.channels > .ch-bars { gap: 9px; padding: 18px 20px; }
  .ch-bar { font-size: 1.0625rem; grid-template-columns: 1fr 11em; }
  .ch-track { height: 16px; }

  /* The celebration: the badge as big as a picture, the burst scaled with it. */
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .party:not([hidden])) > .party {
    width: 100%;
    height: clamp(300px, 46vh, 460px);
    margin: var(--s-3) 0 0;
    background: var(--step-soft, var(--sky));
    border-radius: var(--r-art);
  }
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .party:not([hidden])) > .party > svg { width: 200px; height: 200px; }
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> .party:not([hidden])) .confetti { scale: 1.7; }
  .screens > .screen[data-party]:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden]))
    :is(.screen-title, .lead) { text-align: left; margin-left: 0; margin-right: 0; }

  /* Screen 1's list of the five steps, on a new board: the journey, drawn large. */
  .screens > .screen > .steps-list {
    margin-top: var(--s-3);
    padding: 24px 28px;
    gap: 16px;
    background: var(--panel);
    border: 3px solid var(--line);
    border-radius: var(--r-art);
  }
  .steps-list li { font-size: 1.25rem; }
  /* The radio step's list of what it found, on the left beside "Ready to save". */
  .screens > .screen > .ch-rows { margin-top: var(--s-3); padding: 24px 28px; font-size: 1.25rem; }
  /* Its notes (a radio that needs a grown-up) can be many: lighter, so a list of them
     still leaves Save in reach. */
  .screens > .screen.channels > div > .block-note { font-weight: 500; font-size: 1.0625rem; padding: 10px 16px; margin-top: 10px; }
  .steps-list li[data-status="soon"] { font-size: 1rem; }

  /* The cards to choose from: bigger, and three across when there are six. */
  .screens > .screen > .af-cards { gap: 18px; margin-top: var(--s-3); }
  .screens > .screen > .af-cards:has(> :nth-child(5)) { grid-template-columns: repeat(3, 1fr); }
  .af-card { padding: 14px 14px 16px; }
  .af-card .n { font-size: 1.375rem; }
  .af-card .d { font-size: 1rem; }

  /* The propeller gate and the takeovers: a frame round the whole screen. */
  .screen.is-gate { padding: 24px 32px 32px; }
  .screen.tone-bad {
    margin: var(--s-4) auto 0;
    padding: 28px 40px 36px;
    border-radius: var(--r-card);
  }

  /* ---- the live plane (screen 2) beside the screen it belongs to ------------- */
  /* Shown under screen 1 and under the board-sits checks. On a laptop it is the left
     column, as large as the column allows; the screen is the right column. */
  .screens:has(> .aircraft:not([hidden]) > .views:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    column-gap: clamp(32px, 4.5cqi, 88px);
    align-items: start;
  }
  .screens:has(> .aircraft:not([hidden]) > .views:not([hidden])) > section {
    grid-row: 1;
    grid-column: 2;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
  .screens:has(> .aircraft:not([hidden]) > .views:not([hidden])) > .aircraft {
    grid-column: 1;
    margin: var(--s-4) 0 0;
    padding: 0;
  }
  /* The "waiting for the board" line under a two-column screen: under its left edge. */
  .screens > .screen:not([hidden]):has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) ~ .aircraft {
    max-width: none;
  }
  .aircraft .views { gap: 16px; }
  .aircraft .view { padding: 20px; }
  .aircraft .view figcaption { font-size: 1.125rem; }
  .aircraft .section-title { font-size: 2rem; }
  .aircraft .readout { font-size: 1.375rem; }
}

/* A wide screen gets wider pictures, not wider gaps. */
@container page (min-width: 1600px) {
  .screens:not(:has(> .aircraft:not([hidden]) > .views:not([hidden])))
    > .screen:has(> :is(.art, .party, .af-cards, .ch-bars, .steps-list, .ch-rows):not([hidden])) {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  }
  .screen, .aircraft { max-width: 820px; }
  .screens:has(> .aircraft:not([hidden]) > .views:not([hidden])) {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  }
}
