/* ==========================================================================
   Medical Report Generator — INSTRUMENT
   A clinical batch console. Ink, paper, hairline, and exactly one accent.

   ACCENT INVARIANT — grep-checkable, do not add a fourth site:
     --accent       fills exactly 3 surfaces: submit button, focus ring,
                    dropzone .drag-over armed state.
     --accent-text  colours exactly 2 links: the example-workbook link and
                    the documentation link.
   Everything else is text, surface, or border. Data is NEVER chromatic.
   ========================================================================== */

@layer reset, tokens, base, components, utilities;

/* ==========================================================================
   FONT — self-hosted. app.py sends `font-src 'self'`, so a Google Fonts
   link would fail silently and fall back to the system stack in production.
   static/fonts/inter-vn.woff2 is Inter 4.1 subset to Latin + Vietnamese with
   ccmp/mark/mkmk (diacritic positioning) and tnum/zero (tabular figures).
   format("woff2") — NOT "woff2-variations", which Safari rejects.
   ========================================================================== */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-vn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Metric-matched fallback so `swap` does not reflow the matrix. */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@layer tokens {
  :root {
    color-scheme: light;

    /* ---- NEUTRALS ---------------------------------------------------- */
    --bg-canvas:      #F5F7FA;
    --bg-surface:     #FFFFFF;
    --bg-raised:      #FFFFFF;
    --bg-subtle:      #EEF1F5;
    --bg-inset:       #E7EBF0;

    /* ---- BORDERS ----------------------------------------------------- */
    --border-subtle:  #E7EBF0;   /* decorative dividers only               */
    --border:         #D8DEE6;   /* card hairlines                         */
    --border-strong:  #7C8697;   /* control boundaries — >=3:1 on all four
                                    light surfaces (3.68/3.42/3.24/3.07)   */

    /* ---- TEXT (ratio vs surface / subtle) ----------------------------- */
    --text-primary:   #111823;   /* 17.82 / 15.73 */
    --text-secondary: #48525F;   /*  7.93 /  7.00 */
    --text-tertiary:  #616B7A;   /*  5.40 /  4.76 */

    /* ---- ACCENT — instrument teal ------------------------------------ */
    --accent:         #0E6E7D;   /* white on it = 5.92 */
    --accent-hover:   #0C606E;   /* white on it = 7.21 */
    --accent-active:  #0A5261;   /* white on it = 8.78 */
    --accent-fg:      #FFFFFF;
    --accent-text:    #0B5C6B;   /* links only — 7.62 on surface */
    --accent-surface: #EAF6F8;
    --accent-border:  #B7DFE6;
    --focus:          #0E6E7D;

    /* ---- STATUS ------------------------------------------------------- */
    --danger-text:    #B32218;
    --danger-surface: #FEF2F1;
    --danger-border:  #F2C4BF;
    --warn-text:      #8A4B00;   /* amber+white is impossible at AA —
                                    never invert to white-on-amber        */
    --warn-surface:   #FFF6E8;
    --warn-border:    #EBCFA6;
    --success-text:   #14663C;
    --success-surface:#EDF8F1;
    --success-border: #BFE3CD;

    /* ---- TYPE --------------------------------------------------------- */
    --font-sans: "Inter", "Inter Fallback", -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
                 /* 'Helvetica Neue' deliberately omitted: incomplete
                    Vietnamese coverage renders mixed-face words. */
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --fs-50:  0.6875rem;  /* 11 micro-label, ASCII only  */
    --fs-100: 0.75rem;    /* 12 hints, meta              */
    --fs-200: 0.8125rem;  /* 13 matrix, chips, list      */
    --fs-300: 0.875rem;   /* 14 default UI               */
    --fs-400: 1rem;       /* 16 prose + every input      */
    --fs-500: 1.25rem;    /* 20 section headings         */
    --fs-600: 1.5rem;     /* 24 panel titles             */
    --fs-700: 1.75rem;    /* 28 /logic h1                */
    --fs-800: 2.5rem;     /* 40 readout figure only      */

    --lh-display: 1.1;    /* all-digit strings ONLY */
    --lh-heading: 1.3;
    --lh-ui:      1.5;
    --lh-dense:   1.45;
    --lh-body:    1.55;
    --lh-vn-min:  1.4;    /* HARD FLOOR for anything holding Vietnamese */

    --tracking-micro:  0.06em;
    --tracking-500:   -0.006em;
    --tracking-600:   -0.011em;
    --tracking-700:   -0.015em;
    --tracking-800:   -0.02em;

    /* ---- SPACE — 4pt ------------------------------------------------- */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
    --gutter: 24px;

    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;

    /* ---- ELEVATION — always paired with a border --------------------- */
    --shadow-1: 0 1px 1px rgb(17 24 35 / .04), 0 1px 3px rgb(17 24 35 / .06);
    --shadow-2: 0 1px 2px rgb(17 24 35 / .05), 0 6px 16px -4px rgb(17 24 35 / .08);
    --shadow-3: 0 1px 2px rgb(17 24 35 / .05), 0 16px 32px -12px rgb(17 24 35 / .10);

    --dur-1: 120ms; --dur-2: 180ms; --dur-3: 320ms;
    --dur-4:      640ms;   /* one-shot draws: receipt curve, dropzone anneal.
                              Longer than --dur-3 because a draw must read
                              as a draw.                                     */
    --helix-turn: 18s;     /* one 240px tile = 2 turns = 9s per revolution.
                              Deliberately NOT harmonised with --pcr-cycle:
                              the molecule's rotation and the block's
                              programme are different clocks on one object.  */
    --pcr-cycle:  4s;      /* one two-step PCR cycle. Real: 95C 15s hold,
                              cool 35C at 3C/s, 60C 60s hold, heat 35C at
                              4C/s = 95.5s. Screen time 4s -> 24x compression.
                              The button glyph, the thermal profile and the
                              melt/anneal cross-fade all read this one value,
                              which is what phase-locks them.                */
    --ease:   cubic-bezier(.2, 0, 0, 1);
    --spring: cubic-bezier(.16, 1, .3, 1);

    --z-base: 0; --z-sticky-col: 1; --z-sticky-head: 2;
    --z-sticky-corner: 3; --z-appbar: 20; --z-skiplink: 100;

    --appbar-h: 56px;
    --helix-opacity: .88;   /* light: molecule is darker than the ground */
  }

  /* ---- DARK — tokens only. Not one component rule changes. ----------- */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg-canvas:#0A0D12; --bg-surface:#141920; --bg-raised:#1B212A;
      --bg-subtle:#101419; --bg-inset:#1F262F;
      --border-subtle:#21272F; --border:#2A313B; --border-strong:#6E7887;
      --text-primary:#E9EDF3; --text-secondary:#A3AEBE; --text-tertiary:#8A94A4;
      --accent:#12798A; --accent-hover:#177E90; --accent-active:#106F82;
      --accent-fg:#FFFFFF; --accent-text:#5FCDE4;
      --accent-surface:#0E2A32; --accent-border:#1E4A56; --focus:#7DD9EC;
      --danger-text:#FF9B90; --danger-surface:#2A1412; --danger-border:#5A2620;
      --warn-text:#F5C173; --warn-surface:#2A1E0B; --warn-border:#5A431A;
      --success-text:#63D397; --success-surface:#0C2418; --success-border:#1E4A32;
      --helix-opacity: .55;   /* dark: molecule is lighter than the ground */
      --shadow-1: 0 1px 2px rgb(0 0 0 / .40);
      --shadow-2: 0 1px 2px rgb(0 0 0 / .40), 0 8px 20px -6px rgb(0 0 0 / .55);
      --shadow-3: 0 1px 2px rgb(0 0 0 / .45), 0 20px 40px -14px rgb(0 0 0 / .65);
    }
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg-canvas:#0A0D12; --bg-surface:#141920; --bg-raised:#1B212A;
    --bg-subtle:#101419; --bg-inset:#1F262F;
    --border-subtle:#21272F; --border:#2A313B; --border-strong:#6E7887;
    --text-primary:#E9EDF3; --text-secondary:#A3AEBE; --text-tertiary:#8A94A4;
    --accent:#12798A; --accent-hover:#177E90; --accent-active:#106F82;
    --accent-fg:#FFFFFF; --accent-text:#5FCDE4;
    --accent-surface:#0E2A32; --accent-border:#1E4A56; --focus:#7DD9EC;
    --danger-text:#FF9B90; --danger-surface:#2A1412; --danger-border:#5A2620;
    --warn-text:#F5C173; --warn-surface:#2A1E0B; --warn-border:#5A431A;
    --success-text:#63D397; --success-surface:#0C2418; --success-border:#1E4A32;
    --helix-opacity: .55;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .40);
    --shadow-2: 0 1px 2px rgb(0 0 0 / .40), 0 8px 20px -6px rgb(0 0 0 / .55);
    --shadow-3: 0 1px 2px rgb(0 0 0 / .45), 0 20px 40px -14px rgb(0 0 0 / .65);
  }

  :root[data-theme="light"] { color-scheme: light; }

  /* The stats panel is a plausible batch record. Someone will print it. */
  @media print {
    :root, :root[data-theme="dark"] {
      color-scheme: light;
      --bg-canvas:#FFF; --bg-surface:#FFF; --bg-raised:#FFF;
      --bg-subtle:#FFF; --bg-inset:#FFF;
      --border-subtle:#CCC; --border:#BBB; --border-strong:#777;
      --text-primary:#000; --text-secondary:#333; --text-tertiary:#555;
      --accent:#000; --accent-fg:#FFF; --accent-text:#000;
      --accent-surface:#FFF; --accent-border:#BBB; --focus:#000;
      --danger-text:#000; --warn-text:#000; --success-text:#000;
      --danger-surface:#FFF; --warn-surface:#FFF; --success-surface:#FFF;
      --shadow-1:none; --shadow-2:none; --shadow-3:none;
    }
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, h4, p, figure, ul, ol, dd { margin: 0; }
  ul[class] { padding: 0; }
  img, svg { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; }
}

@layer base {
  body {
    font-family: var(--font-sans);
    font-size: var(--fs-400);
    line-height: var(--lh-body);
    color: var(--text-primary);
    background: var(--bg-canvas);
    min-height: 100vh;
    min-height: 100svh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1, h2, h3, h4 {
    line-height: var(--lh-heading);
    font-weight: 600;
    text-wrap: balance;
    color: var(--text-primary);
  }
  h2 { font-size: var(--fs-500); letter-spacing: var(--tracking-500); }
  h3 { font-size: var(--fs-300); }

  a { color: var(--accent-text); }

  /* ONE focus rule. The inner spacer is painted in the surface colour so the
     identical declaration reads on white, on --bg-subtle, and on teal.
     The transparent outline is retained so forced-colors still paints. */
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--focus);
    border-radius: inherit;
  }

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

  @media (forced-colors: active) {
    .panel, .file-input-wrapper, .btn-submit, .btn-example,
    .test-count, .matrix-scroll, .alert, .table-scroll {
      border: 1px solid CanvasText;
    }
    .btn-submit {
      forced-color-adjust: none;
      background: ButtonFace; color: ButtonText; border-color: ButtonText;
    }
  }
}

@layer components {

  /* ---- SKIP LINK ---------------------------------------------------- */
  .skip-link {
    position: absolute; left: var(--s-2); top: var(--s-2);
    z-index: var(--z-skiplink);
    padding: var(--s-2) var(--s-3);
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    font-size: var(--fs-200); font-weight: 500; text-decoration: none;
    transform: translateY(-200%);
  }
  .skip-link:focus-visible { transform: translateY(0); }

  /* ---- APP BAR ------------------------------------------------------ */
  .appbar {
    position: sticky; top: 0; z-index: var(--z-appbar);
    display: flex; align-items: center; gap: var(--s-4);
    min-height: var(--appbar-h);
    padding-inline: var(--gutter);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
  }
  .appbar__brand {
    display: inline-flex; align-items: center; gap: var(--s-3);
    color: var(--text-primary); text-decoration: none; border-radius: var(--r-sm);
  }
  .appbar__mark { color: var(--accent-text); flex-shrink: 0; }
  .appbar__name {
    font-size: var(--fs-300); font-weight: 600;
    letter-spacing: var(--tracking-600); line-height: var(--lh-ui);
  }
  .appbar__brand:hover .appbar__name { text-decoration: underline; text-underline-offset: 3px; }
  .appbar__nav { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
  .appbar__nav a {
    display: inline-flex; align-items: center; min-height: 36px;
    padding-inline: var(--s-3); border-radius: var(--r-sm);
    font-size: var(--fs-200); font-weight: 500;
    color: var(--text-secondary); text-decoration: none;
    transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
  }
  .appbar__nav a:hover { color: var(--text-primary); text-decoration: underline; text-underline-offset: 3px; }

  .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--r-sm);
    color: var(--text-secondary); cursor: pointer;
    transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  }
  .icon-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
  .icon-btn:active { background: var(--bg-inset); }
  .icon-btn .icon-moon { display: none; }
  :root[data-theme="dark"] .icon-btn .icon-sun { display: none; }
  :root[data-theme="dark"] .icon-btn .icon-moon { display: block; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-btn .icon-sun { display: none; }
    :root:not([data-theme="light"]) .icon-btn .icon-moon { display: block; }
  }

  /* ---- WORKBENCH LAYOUT --------------------------------------------- */
  .workbench {
    max-width: 1180px; margin-inline: auto;
    padding: var(--s-6) var(--gutter) var(--s-7);
    display: grid; grid-template-columns: 1fr; gap: var(--s-6);
    align-items: start;
  }
  @media (min-width: 1080px) {
    .workbench { grid-template-columns: minmax(450px, 1fr) minmax(450px, 1.05fr); gap: var(--s-7); }
    .workbench > .reference, .workbench > .footer { grid-column: 1 / -1; }
  }
  .lane { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }

  .lane__title {
    display: flex; align-items: baseline; gap: var(--s-3);
    padding-bottom: var(--s-3); border-bottom: 1px solid var(--border);
  }

  .panel {
    background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: var(--shadow-1);
    padding: var(--s-5);
  }
  @media (min-width: 1080px) {
    .panel--sticky {
      position: sticky; top: calc(var(--appbar-h) + var(--s-5));
      /* .lane is flex-direction:column, so align-self is the HORIZONTAL
         axis here — `start` made the panel shrink-to-fit. It only ever
         looked right because the SVG helix caption propped it open. */
      align-self: stretch;
      max-height: calc(100svh - var(--appbar-h) - var(--s-6));
      overflow-y: auto; overscroll-behavior-y: contain;
    }
  }

  /* ---- STATUS LOG / ALERTS ------------------------------------------ */
  .messages { display: flex; flex-direction: column; gap: var(--s-2); }
  .messages:not(:has(.alert)) { display: none; }
  .alert {
    display: flex; gap: var(--s-3); align-items: flex-start;
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-sm); border: 1px solid; border-left-width: 3px;
    font-size: var(--fs-300); line-height: var(--lh-vn-min);
    color: var(--text-secondary); background: var(--bg-surface);
    border-color: var(--border);
  }
  .alert svg { flex-shrink: 0; margin-top: 2px; }
  .alert-error   { color: var(--danger-text);  background: var(--danger-surface);  border-color: var(--danger-border); }
  .alert-success { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
  .alert-warn    { color: var(--warn-text);    background: var(--warn-surface);    border-color: var(--warn-border); }
  .alert__time { font-size: var(--fs-100); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
  @media (prefers-reduced-motion: no-preference) {
    .alert { animation: settle var(--dur-3) var(--spring) both; }
  }

  /* ---- DROPZONE ------------------------------------------------------ */
  .file-label { display: block; cursor: pointer; }
  /* Visually hidden but FOCUSABLE — display:none removed the app's only
     primary control from the tab order and the accessibility tree. */
  #xlsx_file {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .file-input-wrapper {
    position: relative;   /* positioning context for .dz-anneal */
    display: grid; justify-items: start; align-content: center;
    gap: var(--s-2);
    padding: var(--s-6) var(--gutter);
    min-height: 150px;
    background: var(--bg-subtle);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    transition: background-color var(--dur-2) var(--ease),
                border-color var(--dur-2) var(--ease),
                box-shadow var(--dur-2) var(--ease);
  }
  .file-input-wrapper svg { color: var(--text-tertiary); }
  .file-text { font-size: var(--fs-300); font-weight: 500; line-height: var(--lh-ui); color: var(--text-primary); }
  .file-subtext { font-size: var(--fs-200); line-height: var(--lh-vn-min); color: var(--text-tertiary); }

  @media (hover: hover) and (pointer: fine) {
    .file-label:hover .file-input-wrapper { background: var(--bg-inset); border-color: var(--accent-border); }
    .file-label:hover .file-input-wrapper svg { color: var(--accent-text); }
  }
  .file-label:active .file-input-wrapper { background: var(--bg-inset); }
  /* :has() first, :focus-within as the fallback. The input is the LAST child
     of .file-label, so an `input + .wrapper` sibling selector matches nothing. */
  .file-label:focus-within .file-input-wrapper,
  .file-label:has(#xlsx_file:focus-visible) .file-input-wrapper {
    border-style: solid; border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--focus);
  }
  /* One of the three legal --accent sites. Inset ring: nothing grows outward. */
  .file-label.drag-over .file-input-wrapper {
    background: var(--accent-surface);
    border-style: solid; border-color: var(--accent);
    box-shadow: inset 0 0 0 3px var(--accent-border);
  }
  .file-label[data-state="error"] .file-input-wrapper {
    border-color: var(--danger-border); background: var(--danger-surface);
  }

  .intake-help {
    margin-top: var(--s-3);
    font-size: var(--fs-200); color: var(--text-tertiary);
    display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  }

  /* ---- FILE CHIP ----------------------------------------------------- */
  .file-name {
    display: flex; align-items: center; gap: var(--s-2);
    margin-top: var(--s-3);
    padding: var(--s-2) var(--s-3);
    font-size: var(--fs-200); font-weight: 500; line-height: var(--lh-vn-min);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--bg-subtle); color: var(--text-secondary);
    overflow-wrap: anywhere;
    transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease),
                border-color var(--dur-1) var(--ease);
  }
  .file-name__dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; flex-shrink: 0;
  }
  .file-name__meta { margin-left: auto; color: var(--text-tertiary); font-weight: 400; white-space: nowrap; }
  .file-name[data-state="ok"]    { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
  .file-name[data-state="error"] { color: var(--danger-text);  background: var(--danger-surface);  border-color: var(--danger-border); }
  .chip-clear {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; flex-shrink: 0;
    border-radius: var(--r-sm); cursor: pointer; color: inherit;
    transition: background-color var(--dur-1) var(--ease);
  }
  .chip-clear:hover { background: var(--bg-inset); }
  @media (pointer: coarse) { .chip-clear { width: 44px; height: 44px; } }

  /* ---- DATE FIELD ---------------------------------------------------- */
  .form-group + .form-group { margin-top: var(--s-5); }
  .date-group label {
    display: block; margin-bottom: var(--s-2);
    font-size: var(--fs-200); font-weight: 500; color: var(--text-secondary);
  }
  .date-input {
    width: 100%; max-width: 22rem; min-height: 44px;
    padding: var(--s-3) var(--s-4);
    font-size: var(--fs-400);           /* 16px — stops iOS zoom-on-focus */
    background: var(--bg-surface);
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  }
  @media (hover: hover) and (pointer: fine) { .date-input:hover { border-color: var(--text-tertiary); } }
  .date-input[aria-invalid="true"] { border-color: var(--danger-border); }
  :root[data-theme="dark"] .date-input::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.75); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .date-input::-webkit-calendar-picker-indicator { filter: invert(1) opacity(.75); }
  }
  .date-hint { margin-top: var(--s-2); font-size: var(--fs-100); color: var(--text-tertiary); line-height: var(--lh-vn-min); }
  .date-echo { margin-top: var(--s-1); font-size: var(--fs-200); color: var(--text-secondary); line-height: var(--lh-vn-min); }
  .date-echo:empty { display: none; }

  /* ---- INTAKE VERDICT ------------------------------------------------ */
  .verdict {
    font-size: var(--fs-200); color: var(--text-secondary);
    line-height: var(--lh-vn-min);
  }
  .verdict:empty { display: none; }

  /* ---- READOUT ------------------------------------------------------- */
  .readout {
    padding-bottom: var(--s-4); margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
  }
  .readout__figure {
    font-size: var(--fs-800); font-weight: 600;
    line-height: var(--lh-display);       /* legal here — ASCII digits only */
    letter-spacing: var(--tracking-800);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums slashed-zero lining-nums;
  }
  .readout__detail { font-size: var(--fs-200); color: var(--text-secondary); line-height: var(--lh-vn-min); }
  .readout[data-tone="empty"] .readout__figure { color: var(--danger-text); }
  #statsPanel[data-state="idle"] .readout__figure,
  #statsPanel[data-state="reading"] .readout__figure { color: var(--text-tertiary); }

  /* ---- SKELETON ------------------------------------------------------ */
  .skeleton { display: none; flex-direction: column; gap: var(--s-2); }
  #statsPanel[data-state="idle"] .skeleton,
  #statsPanel[data-state="reading"] .skeleton { display: flex; }
  #statsPanel[data-state="idle"] .stats-live,
  #statsPanel[data-state="reading"] .stats-live { display: none; }
  .skeleton__bar { height: 28px; border-radius: var(--r-sm); background: var(--bg-inset); }
  @media (prefers-reduced-motion: no-preference) {
    #statsPanel[data-state="reading"] .skeleton__bar {
      background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-subtle) 50%, var(--bg-inset) 75%);
      background-size: 200% 100%;
      animation: sweep 1.6s var(--ease) infinite;
    }
  }

  /* ---- MATRIX -------------------------------------------------------- */
  .matrix-scroll {
    overflow-x: auto; overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
    border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--bg-surface);
  }
  .stats-table {
    width: 100%;
    /* separate, NOT collapse — position:sticky tears on collapsed borders */
    border-collapse: separate; border-spacing: 0;
    font-size: var(--fs-200);
  }
  .stats-table th, .stats-table td {
    padding: var(--s-2) var(--s-3);
    padding-block: calc(var(--s-2) + 2px);   /* clears the dot-below */
    line-height: var(--lh-dense);
    text-align: center;
  }
  .stats-table thead th {
    position: sticky; top: 0; z-index: var(--z-sticky-head);
    background: var(--bg-subtle);
    font-size: var(--fs-50); font-weight: 600;
    text-transform: uppercase; letter-spacing: var(--tracking-micro);
    color: var(--text-tertiary); white-space: nowrap;
    border-bottom: 1px solid var(--border);
  }
  .stats-table th:first-child, .stats-table td:first-child {
    position: sticky; left: 0; z-index: var(--z-sticky-col);
    text-align: left; padding-left: var(--gutter); min-width: 168px;
    background: var(--bg-surface);
    box-shadow: 1px 0 0 var(--border);
  }
  .stats-table thead th:first-child { z-index: var(--z-sticky-corner); background: var(--bg-subtle); }
  .stats-table tbody tr + tr > * { border-top: 1px solid var(--border-subtle); }
  .stats-table td {
    color: var(--text-primary);
    font-variant-numeric: tabular-nums slashed-zero lining-nums;
  }
  .stats-table abbr { text-decoration: none; }
  @media (hover: hover) {
    .stats-table tbody tr:hover > * { background: var(--bg-subtle); }
  }
  .region-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); min-width: 0; }
  .region-label > span:first-child { min-width: 0; overflow-wrap: anywhere; font-weight: 500; color: var(--text-primary); }
  .region-total {
    font-size: var(--fs-100); font-weight: 500; color: var(--text-tertiary);
    font-variant-numeric: tabular-nums slashed-zero lining-nums;
  }
  /* Neutral chips — data is never chromatic. 15.73:1. */
  .test-count {
    display: inline-block; min-width: 2.75ch; padding: 2px var(--s-2);
    text-align: center;
    background: var(--bg-subtle); color: var(--text-primary);
    border: 1px solid var(--border-subtle); border-radius: var(--r-pill);
    font-size: var(--fs-100); font-weight: 500;
    font-variant-numeric: tabular-nums slashed-zero lining-nums;
  }
  .test-count-zero {
    background: none; border-color: transparent;
    color: var(--text-tertiary); font-weight: 400; padding: 2px 0;
  }

  /* ---- STAT LISTS ---------------------------------------------------- */
  .stats-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-5); }
  .stats-grid-row { display: grid; grid-template-columns: 1fr; gap: var(--s-5); }
  @media (min-width: 560px) { .stats-grid-row { grid-template-columns: 1fr 1fr; } }
  .stats-section { min-width: 0; }
  .stats-list { display: flex; flex-direction: column; gap: var(--s-1); }
  .stat-item {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    font-size: var(--fs-200); line-height: var(--lh-vn-min);
    border-bottom: 1px solid var(--border-subtle);
  }
  .stat-item:last-child { border-bottom: none; }
  @media (hover: hover) and (pointer: fine) { .stat-item:hover { background: var(--bg-subtle); } }
  .stat-label { color: var(--text-secondary); font-weight: 400; overflow-wrap: anywhere; }
  .stat-count {
    color: var(--text-primary); font-weight: 500;
    font-variant-numeric: tabular-nums slashed-zero lining-nums;
  }
  .stat-empty {
    padding: var(--s-4); text-align: center;
    color: var(--text-tertiary); font-size: var(--fs-200); line-height: var(--lh-vn-min);
    border: 1px dashed var(--border); border-radius: var(--r-md);
  }
  @media (prefers-reduced-motion: no-preference) {
    .stats-table tbody tr, .stat-item {
      animation: settle var(--dur-3) var(--spring) both;
      animation-delay: calc(var(--i, 0) * 24ms);
    }
  }
  @keyframes settle { from { opacity: 0; transform: translateY(4px); } }

  /* ---- WARNINGS — the safety-critical component ---------------------- */
  .stat-warnings {
    margin: var(--s-4) 0;
    padding: var(--s-3) var(--s-4);
    background: var(--warn-surface);
    border: 1px solid var(--warn-border); border-left-width: 3px;
    border-radius: var(--r-sm);
  }
  .stat-warnings-header {
    display: flex; align-items: center; gap: var(--s-2);
    margin-bottom: var(--s-2);
    font-size: var(--fs-50); font-weight: 600;
    letter-spacing: var(--tracking-micro); text-transform: uppercase;
    line-height: 1.45; color: var(--warn-text);
  }
  .stat-warnings .stat-item { border-bottom-color: var(--warn-border); }
  .stat-item.stat-warning .stat-label,
  .stat-item.stat-warning .stat-count { color: var(--warn-text); }
  .stat-warnings[data-tone="blocking"] { background: var(--danger-surface); border-color: var(--danger-border); }
  .stat-warnings[data-tone="blocking"] .stat-warnings-header { color: var(--danger-text); }
  .stat-warnings[data-tone="blocking"] .stat-item .stat-label,
  .stat-warnings[data-tone="blocking"] .stat-item .stat-count { color: var(--danger-text); }
  .stat-unknown-list {
    margin-top: var(--s-2);
    padding: var(--s-2) var(--s-3);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle); border-radius: var(--r-sm);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary); overflow-wrap: anywhere;
  }
  .stat-unknown-list summary { cursor: pointer; font-weight: 500; }

  /* ---- SUBMIT -------------------------------------------------------- */
  .btn-submit {
    position: relative; overflow: hidden;
    width: 100%; max-width: 26rem; min-height: 48px;
    padding: var(--s-3) var(--s-5);
    background: var(--accent); color: var(--accent-fg);
    border: 1px solid transparent; border-radius: var(--r-md);
    font-size: var(--fs-300); font-weight: 600; line-height: var(--lh-ui);
    cursor: pointer; box-shadow: var(--shadow-1);
    transition: background-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  }
  .btn-submit:hover:not([aria-disabled="true"]):not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-2); }
  .btn-submit:active:not([aria-disabled="true"]):not(:disabled) { background: var(--accent-active); box-shadow: none; }
  /* Busy is NOT disabled — disabled removes it from the a11y tree so
     "Processing" is never announced, and destroys focus. Full opacity. */
  .btn-submit[aria-disabled="true"] { cursor: progress; }
  .btn-submit:disabled { background: var(--bg-inset); color: var(--text-tertiary); cursor: not-allowed; box-shadow: none; }
  .btn-loading { display: none; align-items: center; gap: var(--s-2); }
  .btn-submit.is-loading .btn-text { display: none; }
  .btn-submit.is-loading .btn-loading { display: inline-flex; }
  .btn-submit.is-loading::after {
    content: ""; position: absolute; inset-inline-start: 0; inset-block-end: 0;
    height: 3px; width: calc(var(--progress, 0) * 1%);
    background: var(--accent-fg); opacity: .9;
    transition: width var(--dur-2) var(--ease);
  }
  .spinner {
    width: 14px; height: 14px; flex-shrink: 0;
    border: 2px solid rgb(255 255 255 / .35);
    border-top-color: var(--accent-fg);
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .btn-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
  .btn-cancel {
    min-height: 44px; padding: 0 var(--s-3);
    color: var(--text-secondary); font-size: var(--fs-200); font-weight: 500;
    border-radius: var(--r-sm); cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
  }
  .btn-cancel:hover { color: var(--text-primary); background: var(--bg-subtle); }
  .btn-note { margin-top: var(--s-2); font-size: var(--fs-200); line-height: var(--lh-vn-min); color: var(--danger-text); }
  .btn-note:empty { display: none; }

  /* ---- RECEIPT ------------------------------------------------------- */
  .receipt {
    padding: var(--s-4);
    background: var(--success-surface);
    border: 1px solid var(--success-border); border-left-width: 3px;
    border-radius: var(--r-sm);
    font-size: var(--fs-200); line-height: var(--lh-vn-min);
    color: var(--success-text);
  }
  .receipt__title { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; margin-bottom: var(--s-2); }
  .receipt dl { display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3); margin: 0 0 var(--s-3); }
  .receipt dt { color: var(--text-secondary); }
  .receipt dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .receipt__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
  .receipt__actions button {
    min-height: 40px; padding: 0 var(--s-3);
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    background: var(--bg-surface); color: var(--text-primary);
    font-size: var(--fs-200); font-weight: 500; cursor: pointer;
    transition: background-color var(--dur-1) var(--ease);
  }
  .receipt__actions button:hover { background: var(--bg-subtle); }

  /* ---- REFERENCE ----------------------------------------------------- */
  .reference summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
    min-height: 44px; padding: var(--s-3) var(--s-4);
    cursor: pointer; list-style: none;
    background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--r-md);
    transition: background-color var(--dur-1) var(--ease);
  }
  .reference summary::-webkit-details-marker { display: none; }
  .reference summary:hover { background: var(--bg-subtle); }
  .reference details[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .chevron { color: var(--text-tertiary); transition: transform var(--dur-2) var(--ease); }
  .reference details[open] .chevron { transform: rotate(180deg); }
  .columns-grid {
    display: grid; grid-template-columns: 1fr; gap: var(--s-5); align-items: start;
    padding: var(--s-5) var(--s-4);
    border: 1px solid var(--border); border-top: 0;
    border-radius: 0 0 var(--r-md) var(--r-md);
    background: var(--bg-surface);
  }
  @media (min-width: 768px) { .columns-grid { grid-template-columns: repeat(2, 1fr); } }
  .column-group { min-width: 0; }
  .column-group h3 { margin-bottom: var(--s-2); font-size: var(--fs-300); font-weight: 600; }
  .column-group ul { list-style: none; }
  .column-group li {
    position: relative;
    padding: var(--s-2) 0 var(--s-2) var(--s-5);
    font-size: var(--fs-200); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-wrap: anywhere;
  }
  .column-group li:last-child { border-bottom: none; }
  .column-group li::before {
    content: ""; position: absolute; left: var(--s-3); top: .9em;
    width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong);
  }
  .col-chip {
    font-family: var(--font-sans);
    font-size: var(--fs-200); padding: 1px 6px;
    background: var(--bg-subtle); border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm); color: var(--text-primary);
  }
  .region-note { margin-top: var(--s-3); font-size: var(--fs-100); color: var(--text-tertiary); line-height: var(--lh-vn-min); }

  /* ---- EXAMPLE LINK — secondary, never primary ----------------------- */
  .btn-example {
    display: inline-flex; align-items: center; gap: var(--s-2);
    min-height: 44px; padding: var(--s-2) var(--s-3);
    color: var(--accent-text); background: none;
    border: 1px solid transparent; border-radius: var(--r-sm);
    font-size: var(--fs-200); font-weight: 500;
    text-decoration: underline; text-underline-offset: 3px;
    transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
  }
  .btn-example:hover { background: var(--bg-subtle); border-color: var(--border); }
  .btn-example:active { background: var(--bg-inset); }
  @media (pointer: coarse) { .btn-example { min-height: 48px; } }

  /* ---- FOOTER -------------------------------------------------------- */
  .footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-5) 0 0;
    margin-top: var(--s-6);
    border-top: 1px solid var(--border);
    color: var(--text-tertiary); font-size: var(--fs-200);
  }
  .footer__credit { line-height: var(--lh-vn-min); }
  .footer__doc {
    display: inline-flex; align-items: center; gap: var(--s-2);
    min-height: 44px; padding: 0 var(--s-3);
    color: var(--accent-text); font-size: var(--fs-200); font-weight: 500;
    text-decoration: underline; text-underline-offset: 3px;
    border-radius: var(--r-sm);
    transition: color var(--dur-1) var(--ease);
  }
  .footer__doc:hover { color: var(--text-primary); }

  /* ---- /logic — .prose ----------------------------------------------- */
  /* ---- /logic — LAYOUT -----------------------------------------------
     Rail beside the prose on a wide screen, above it on a narrow one.
     860px rather than the 560px used elsewhere: the breakpoint is set by
     the rail plus a readable measure, not by the phone.
     -------------------------------------------------------------------- */
  .doc-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 74ch);
    gap: var(--s-7);
    justify-content: center;
    padding: var(--s-6) var(--gutter) var(--s-8);
  }
  .doc-rail {
    position: sticky;
    top: calc(var(--appbar-h) + var(--s-4));
    align-self: start;
    max-height: calc(100vh - var(--appbar-h) - var(--s-6));
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .doc-rail__group { margin: var(--s-4) 0 var(--s-2); }
  .doc-rail__group:first-child { margin-top: 0; }
  .doc-rail__list { list-style: none; margin: 0; padding: 0; }
  .doc-rail__list li { margin: 0; }
  .doc-rail__list a {
    display: block;
    padding: var(--s-1) var(--s-2);
    border-left: 2px solid var(--border-subtle);
    font-size: var(--fs-200);
    line-height: var(--lh-vn-min);
    color: var(--text-secondary);
    text-decoration: none;
  }
  .doc-rail__list a:hover {
    color: var(--text-primary);
    border-left-color: var(--border-strong);
  }

  /* ---- ZONE DIVIDER --------------------------------------------------- */
  .zone-rule {
    border: 0; border-top: 2px solid var(--border-strong);
    margin: var(--s-8) 0 var(--s-5);
  }
  .prose .zone-title { margin-top: 0; }

  @media (max-width: 860px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
    .doc-rail {
      position: static; max-height: none;
      padding-bottom: var(--s-4);
      border-bottom: 1px solid var(--border);
    }
    .doc-rail__list { display: flex; flex-wrap: wrap; gap: var(--s-1); }
    .doc-rail__list a { border-left: 0; padding: var(--s-1) var(--s-2); }
  }

  .prose { line-height: var(--lh-body); color: var(--text-secondary); }
  .prose > :first-child { margin-top: 0; }
  .prose h1 {
    font-size: var(--fs-700); letter-spacing: var(--tracking-700); line-height: 1.25;
    color: var(--text-primary);
    margin: 0 0 var(--s-5); padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
  }
  .prose h2 { font-size: var(--fs-600); letter-spacing: var(--tracking-600); margin: var(--s-7) 0 var(--s-3); }
  .prose h3 { font-size: var(--fs-500); letter-spacing: var(--tracking-500); margin: var(--s-6) 0 var(--s-3); }
  .prose h4 { font-size: var(--fs-300); font-weight: 600; margin: var(--s-5) 0 var(--s-2); }
  .prose p, .prose li { font-size: var(--fs-400); }
  .prose p { margin: var(--s-3) 0; }
  .prose ul, .prose ol { padding-left: var(--s-5); margin: var(--s-3) 0; }
  .prose li { margin: var(--s-2) 0; }
  .prose a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
  .prose strong { color: var(--text-primary); font-weight: 600; }
  .prose code {
    font-family: var(--font-mono); font-size: .9em; padding: 1px 5px;
    background: var(--bg-subtle); border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm); color: var(--text-primary); overflow-wrap: anywhere;
  }
  .prose pre {
    background: var(--bg-subtle); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: var(--s-4);
    overflow-x: auto; margin: var(--s-4) 0;
  }
  .prose pre code { background: none; border: 0; padding: 0; }
  .prose blockquote {
    border-left: 3px solid var(--warn-border); background: var(--warn-surface);
    color: var(--warn-text); padding: var(--s-3) var(--s-4);
    margin: var(--s-4) 0; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  }
  .prose hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
  .prose table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: var(--fs-200); line-height: var(--lh-dense);
  }
  .prose th {
    background: var(--bg-subtle); color: var(--text-secondary);
    font-size: var(--fs-50); font-weight: 600;
    text-transform: uppercase; letter-spacing: var(--tracking-micro);
    text-align: left; padding: var(--s-2) var(--s-3);
    border-bottom: 1px solid var(--border);
  }
  .prose td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
  .table-scroll {
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
    border: 1px solid var(--border); border-radius: var(--r-md);
    margin: var(--s-4) 0;
  }

  /* ---- /logic — FIGURES ----------------------------------------------
     Ink, hairline and surface only. No accent: the accent invariant at the
     top of this file allows exactly three accent surfaces and two accent
     links, and a figure is neither. --danger-* appears in exactly one place
     (a template missing from disk), because the system already reserves
     status colour for status.
     -------------------------------------------------------------------- */
  .fig {
    margin: var(--s-5) 0;
    padding: var(--s-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
  }
  .fig__cap {
    margin-top: var(--s-3);
    padding-top: var(--s-3);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--fs-100);
    line-height: var(--lh-vn-min);
    color: var(--text-tertiary);
  }
  .figure-error {
    margin: var(--s-4) 0;
    padding: var(--s-3) var(--s-4);
    background: var(--danger-surface);
    border: 1px solid var(--danger-border);
    border-radius: var(--r-sm);
    color: var(--danger-text);
    font-size: var(--fs-200);
  }

  /* ---- PIPELINE ------------------------------------------------------
     Wraps naturally: a row of stages on a wide screen, a column on a narrow
     one, with no media query and no JS. The connector is a ::after chevron
     that is suppressed on the last stage of each visual row by :last-child.
     -------------------------------------------------------------------- */
  .pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--s-2);
    list-style: none; margin: 0; padding: 0;
  }
  .pipeline__stage {
    min-width: 0; margin: 0;
    padding: var(--s-3);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
  }
  .pipeline__stage--fans {
    border-style: dashed;
    border-color: var(--border-strong);
  }
  .pipeline__label {
    display: block;
    font-size: var(--fs-200); font-weight: 600;
    line-height: var(--lh-vn-min);
    color: var(--text-primary);
  }
  .pipeline__detail {
    display: block; margin-top: var(--s-1);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
  }
  .pipeline__fn {
    display: block; margin-top: var(--s-2);
    font-family: var(--font-mono); font-size: var(--fs-50);
    color: var(--text-tertiary);
    overflow-wrap: break-word;
  }
  .pipeline__fanout {
    display: block; margin-top: var(--s-2);
    font-size: var(--fs-50); font-weight: 600;
    letter-spacing: var(--tracking-micro); text-transform: uppercase;
    color: var(--text-tertiary);
  }

  /* ---- TEMPLATE MATRIX -------------------------------------------------
     Presence is a filled disc, absence a hollow one -- form, not hue, so it
     survives CVD, greyscale printing and forced-colors. --danger-* is layered
     on top for absence only, as a second channel and never the only one.
     -------------------------------------------------------------------- */
  .fig--matrix { padding: 0; overflow: hidden; }
  .fig--matrix .matrix-scroll { border: 0; border-radius: 0; }
  .fig--matrix .fig__cap {
    margin: 0; padding: var(--s-3) var(--s-4);
    border-top: 1px solid var(--border);
  }
  .fig-matrix__assay { font-weight: 600; color: var(--text-primary); }
  .fig-matrix__default,
  .fig-matrix__pattern {
    display: block;
    font-size: var(--fs-50); font-weight: 400;
    text-transform: none; letter-spacing: 0;
    color: var(--text-tertiary);
  }
  .fig-matrix__mark { font-size: 12px; line-height: 1; color: var(--text-secondary); }
  .fig-matrix__cell--missing { background: var(--danger-surface); }
  .fig-matrix__cell--missing .fig-matrix__mark { color: var(--danger-text); }

  /* ---- REGION LADDER --------------------------------------------------- */
  .ladder { list-style: none; margin: var(--s-3) 0 0; padding: 0; }
  .ladder__rung {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2);
    margin: 0; padding: var(--s-2) var(--s-3);
    border-left: 2px solid var(--border);
    line-height: var(--lh-vn-min);
  }
  .ladder__rung + .ladder__rung { border-top: 1px solid var(--border-subtle); }
  .ladder__rung--fallback {
    border-left-style: dashed;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
  }
  .ladder__test { flex: 1 1 260px; font-size: var(--fs-200); color: var(--text-secondary); }
  .ladder__arrow { color: var(--text-tertiary); }
  .ladder__result { display: flex; align-items: baseline; gap: var(--s-2); }
  .ladder__code {
    font-family: var(--font-mono); font-size: var(--fs-200); font-weight: 600;
    color: var(--text-primary);
  }
  .ladder__label { font-size: var(--fs-100); color: var(--text-tertiary); }

  /* ---- COLUMN MAP ------------------------------------------------------
     A header strip that wraps. The left border weight encodes state: solid
     strong = must have a value, solid = must exist, hairline = read,
     dashed = ignored. Weight and style, not hue.
     -------------------------------------------------------------------- */
  .colmap {
    display: flex; flex-wrap: wrap; gap: var(--s-2);
    list-style: none; margin: 0; padding: 0;
  }
  .colmap__col {
    flex: 1 1 150px; margin: 0;
    padding: var(--s-2) var(--s-3);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    line-height: var(--lh-vn-min);
  }
  /* Width and style carry the state; colour only reinforces it. Three states
     differing solely by border COLOUR would collapse into one another under
     greyscale printing and forced-colors -- the same failure the matrix figure
     avoids at .fig-matrix__mark. */
  .colmap__col--must_have_value { border-left: 5px solid var(--text-primary); }
  .colmap__col--must_exist      { border-left: 3px solid var(--text-secondary); }
  .colmap__col--read            { border-left: 1px solid var(--border-strong); }
  .colmap__col--ignored         { border-left: 3px dashed var(--border); background: none; }
  .colmap__name {
    display: block;
    font-size: var(--fs-200); font-weight: 600; color: var(--text-primary);
  }
  .colmap__state {
    display: block; margin-top: var(--s-1);
    font-size: var(--fs-50); font-weight: 600;
    letter-spacing: var(--tracking-micro); text-transform: uppercase;
    color: var(--text-tertiary);
  }
  .colmap__purpose {
    display: block; margin-top: var(--s-1);
    font-size: var(--fs-100); color: var(--text-secondary);
  }
  .colmap__purpose--none { font-style: italic; color: var(--text-tertiary); }

  /* ---- FAN-OUT ---------------------------------------------------------- */
  .fanout {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4);
  }
  .fanout__in { flex: 1 1 240px; }
  .fanout__in code { display: inline-block; margin-top: var(--s-1); }
  .fanout__arrow { color: var(--text-tertiary); font-size: var(--fs-500); }
  .fanout__out { flex: 1 1 240px; list-style: none; margin: 0; padding: 0; }
  .fanout__out li { margin: 0 0 var(--s-1); }

  /* ---- FILENAME ANATOMY -------------------------------------------------
     Segments sit on one wrapping line so the filename still reads as a
     filename, with the labels hung beneath each part.
     -------------------------------------------------------------------- */
  .filename {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-2);
    margin: 0; font-family: var(--font-mono);
  }
  .filename__seg {
    display: flex; flex-direction: column; gap: 2px;
    padding: var(--s-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-sm);
    background: var(--bg-subtle);
  }
  .filename__seg--conditional { border-style: dashed; background: none; }
  .filename__value { font-size: var(--fs-200); color: var(--text-primary); }
  .filename__label {
    font-family: var(--font-sans); font-size: var(--fs-50); font-weight: 600;
    letter-spacing: var(--tracking-micro); text-transform: uppercase;
    color: var(--text-tertiary);
  }
  .filename__cond {
    font-family: var(--font-sans); font-size: var(--fs-50);
    color: var(--text-tertiary); max-width: 22ch;
    line-height: var(--lh-vn-min);
  }
  .filename__sep, .filename__ext {
    align-self: center; color: var(--text-tertiary); font-size: var(--fs-200);
  }

  /* ---- DATES ------------------------------------------------------------ */
  .dates { margin: 0; }
  .dates__row {
    display: flex; flex-wrap: wrap; gap: var(--s-3);
    padding: var(--s-2) 0;
  }
  .dates__row + .dates__row { border-top: 1px solid var(--border-subtle); }
  .dates dt { flex: 0 0 160px; font-weight: 600; color: var(--text-primary); }
  .dates dd { flex: 1 1 240px; margin: 0; }
  .dates__source { display: block; font-size: var(--fs-200); color: var(--text-primary); }
  .dates__note {
    display: block; margin-bottom: var(--s-2);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
  }
  .dates__row--discard s { color: var(--text-tertiary); }

  /* ---- PLACEHOLDER MAP / CHECKLIST -------------------------------------- */
  .phmap, .checklist { display: flex; flex-wrap: wrap; gap: var(--s-5); }
  .phmap__half, .checklist__half { flex: 1 1 260px; }
  .phmap__list { list-style: none; margin: var(--s-2) 0 0; padding: 0; }
  .phmap__list li {
    display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-1);
    font-size: var(--fs-200);
  }
  .phmap__list span { color: var(--text-secondary); }
  .phmap__explain {
    margin: var(--s-2) 0 0;
    font-size: var(--fs-200); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
  }
  .checklist ul { margin: var(--s-2) 0 0; padding-left: var(--s-5); }
  .checklist li { font-size: var(--fs-200); margin: 0 0 var(--s-1); }
}

@layer utilities {
  /* The `hidden` attribute comes from the UA sheet, which ANY author rule beats
     — `.file-name{display:flex}` was defeating it. utilities is the last layer,
     so this wins on layer order without !important. */
  [hidden] { display: none; }

  .vh {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .num { font-variant-numeric: tabular-nums slashed-zero lining-nums; }
  .micro {
    font-size: var(--fs-50); font-weight: 600;
    letter-spacing: var(--tracking-micro); text-transform: uppercase;
    line-height: 1.45; color: var(--text-tertiary);
  }
  /* The one legal !important. Uppercasing Vietnamese lifts the marks on
     Ế/Ữ/Ộ above cap height into the previous line box. .micro is applied
     widely; this makes it impossible to ever hit a lab name. */
  [lang="vi"], [lang="vi"] * { text-transform: none !important; }
  code:lang(vi) { font-family: var(--font-sans); }
}

/* ==========================================================================
   ≤560px — the matrix stops being a grid and becomes one card per lab.
   ========================================================================== */
@media (max-width: 560px) {
  .workbench { padding: var(--s-5) var(--s-4) var(--s-6); }
  .panel { padding: var(--s-4); }
  .matrix-scroll { border: 0; }
  .stats-table, .stats-table tbody, .stats-table tr,
  .stats-table td, .stats-table th { display: block; }
  .stats-table thead { display: none; }
  .stats-table tr {
    border: 1px solid var(--border); border-radius: var(--r-md);
    margin-bottom: var(--s-2); padding: var(--s-3);
  }
  .stats-table tbody tr + tr > * { border-top: 0; }
  .stats-table td {
    display: flex; justify-content: space-between; align-items: center;
    position: static; border: 0; padding: var(--s-1) 0; text-align: right;
  }
  .stats-table td::before {
    content: attr(data-assay);
    font-size: var(--fs-50); letter-spacing: var(--tracking-micro);
    text-transform: uppercase; color: var(--text-tertiary);
  }
  .stats-table th[scope="row"] {
    position: static; box-shadow: none; padding: 0 0 var(--s-3); min-width: 0;
  }
}

/* Landscape phones exceed 768px in width but have almost no height. */
@media (max-height: 500px) and (min-width: 561px) {
  .workbench { padding-block: var(--s-4); }
  .file-input-wrapper { min-height: 96px; padding-block: var(--s-4); }
}


/* ==========================================================================
   THERMAL CYCLE — one qPCR run, told in order: programme, reaction, result.

   Re-opens @layer components, so these rules sit LATER in the same layer and
   win on source order without a single !important.

   Every stroke resolves through a token that already exists and is already
   redefined in both dark blocks, so NOT ONE RULE BELOW IS THEME-AWARE.
   Nothing here encodes a value: the figures are identical for a 1-row file
   and a 150-row file, which is what makes the whole feature deletable with
   one `display: none` at zero information loss.
   ========================================================================== */
@layer components {

  .dna-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

  /* ---- shared viewport + drift ------------------------------------- */
  .helix__viewport {
    position: relative; overflow: hidden; height: 76px;
    color: var(--text-tertiary);          /* the ONLY colour declaration */
    /* A duplex has no ends: it leaves the frame, it does not stop.
       #000 here is an alpha carrier for the mask, not a palette value. */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  }
  .helix__drift {
    position: absolute; inset-block-start: 0; inset-inline-start: 0;
    width: 1200px; height: 76px;
    max-width: none;    /* beats the reset's `svg { max-width: 100% }` — without
                           this the 1200px sprite is crushed to panel width */
  }
  /* A helix rotating about its own axis is, by screw symmetry, that same helix
     translating along it. So this IS the rotation — geometrically exact, and
     one compositor transform on a replaced element (an <svg> box), never an
     inner <g>, which Chromium does not composite. 240px closes the helical
     lattice (2 turns) AND the base lattice (21 bp) — the only length at which
     both close, so the loop has no seam. */
  @keyframes dna-drift { to { transform: translateX(-240px); } }

  /* ---- 1. IDLE BAND — the longest-lived animation in the app -------- */
  .helix--idle { display: none; margin: var(--s-3) 0 var(--s-4); }
  #statsPanel[data-state="idle"]    .helix--idle,
  #statsPanel[data-state="reading"] .helix--idle { display: block; }
  /* The six grey bars now belong to `reading` alone, where "a table is being
     built" is actually true. Same specificity as the earlier rule, later in
     source order. */
  #statsPanel[data-state="idle"] .skeleton { display: none; }

  .helix__cap { display: block; margin-top: var(--s-2); }
  .helix__cap .micro { display: block; }
  .helix__note {
    display: block; margin-top: var(--s-1);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
  }
  .helix__note--reading { display: none; }
  #statsPanel[data-state="reading"] .helix__note--idle    { display: none; }
  #statsPanel[data-state="reading"] .helix__note--reading { display: inline; }

  @media (prefers-reduced-motion: no-preference) {
    .helix__drift { animation: dna-drift var(--helix-turn) linear infinite; }
  }

  /* ---- 2. READING — compositor transform, not a background repaint -- */
  .skeleton__bar { position: relative; overflow: hidden; }
  .skeleton__bar::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, var(--bg-subtle), transparent);
    transform: translateX(-100%);
    opacity: 0;
  }
  #statsPanel[data-state="reading"] .skeleton__bar {
    background: var(--bg-inset);
    background-size: auto;
    animation: none;
  }
  @media (prefers-reduced-motion: no-preference) {
    #statsPanel[data-state="reading"] .skeleton__bar::after {
      opacity: 1;
      animation: sweep-scan 1.6s var(--ease) infinite;
    }
  }
  @keyframes sweep-scan { to { transform: translateX(100%); } }

  /* ---- 3. THE RUN STRIP -------------------------------------------- */
  .pcr-strip {
    display: none;
    max-width: 26rem;                     /* matches .btn-submit exactly */
    margin-top: var(--s-4);
    padding: var(--s-3);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
  }
  #uploadForm[data-run] .pcr-strip { display: block; }
  @media (prefers-reduced-motion: no-preference) {
    .pcr-strip { animation: settle var(--dur-3) var(--spring) both; }
  }
  .pcr-strip .helix__viewport { height: 76px; }
  .pcr-strip__note {
    margin-top: var(--s-2);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary);         /* 7.00:1 on --bg-subtle: real text */
  }

  /* the programme: profile scrolls, block stands still */
  .pcr-thermal { display: flex; align-items: stretch; gap: var(--s-2); margin-top: var(--s-2); }
  .pcr-thermal__scale { flex: 0 0 26px; width: 26px; height: 20px; color: var(--text-tertiary); }
  .pcr-tick { fill: currentColor; font-family: var(--font-sans); font-size: 7px; font-weight: 500; opacity: .8; }
  .pcr-thermal__viewport {
    position: relative; flex: 1 1 auto; min-width: 0;
    height: 20px; overflow: hidden;
    color: var(--text-tertiary);
    /* Hard left edge — that is the axis, the past is known. The future fades. */
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 86%, transparent);
            mask-image: linear-gradient(90deg, #000 0, #000 86%, transparent);
  }
  .pcr-thermal__prog {
    position: absolute; inset-block-start: 0; inset-inline-start: 0;
    width: 624px; height: 20px; max-width: none;
  }
  /* 119px is chosen so that at transform:none the marker sits at local x = 23
     inside tile 2 — dead centre of the 95C hold (local 19.50..27.04). That
     makes the reduced-motion still correct with ZERO extra declarations. */
  .pcr-thermal__mark {
    position: absolute; inset-block: 0; inset-inline-start: 119px;
    width: 1px; background: var(--border-strong); opacity: .75;
    pointer-events: none;
  }
  @keyframes pcr-run { to { transform: translateX(-48px); } }
  @media (prefers-reduced-motion: no-preference) {
    .pcr-thermal__prog { animation: pcr-run var(--pcr-cycle) linear infinite; }
  }

  /* the reaction: GLOBAL melting at 95C, not a travelling bubble.
     A ~10bp bubble that opens, travels and closes behind itself is a helicase
     or an RNA polymerase and happens in NO PCR tube. */
  .pcr-strip .helix__drift--duplex { opacity: 0; }
  .pcr-strip .helix__drift--melt   { opacity: 1; }
  /* PHASE DERIVATION — marker at viewport x=119, profile scrolls 48u/cycle, so
     content under the marker runs local 23 -> 71. Segment boundaries at local
     19.50 / 27.04 / 32.92 / 63.08 / 67.50 give:
       95C hold ends 27.04 -> (27.04-23)/48 =  8.4%
       cool ramp ends 32.92 -> 20.7%
       60C hold ends 63.08 -> 83.5%
       heat ramp ends 67.50 -> 92.7%
     The picture and the temperature therefore cannot drift apart. */
  @keyframes pcr-denatured { 0%,8% { opacity: 1; } 21%,84% { opacity: 0; } 93%,100% { opacity: 1; } }
  @keyframes pcr-annealed  { 0%,8% { opacity: 0; } 21%,84% { opacity: 1; } 93%,100% { opacity: 0; } }
  @media (prefers-reduced-motion: no-preference) {
    .pcr-strip .helix__drift {
      animation: dna-drift var(--helix-turn) linear infinite,
                 var(--pcr-phase) var(--pcr-cycle) linear infinite;
    }
    .pcr-strip .helix__drift--duplex { --pcr-phase: pcr-annealed; }
    .pcr-strip .helix__drift--melt   { --pcr-phase: pcr-denatured; }
  }

  /* ---- 4. BUTTON GLYPH — same cycle, same token, phase-locked ------- */
  .spinner--pcr {
    width: 26px; height: 14px;
    border: 0; border-radius: 0;
    animation: none;                      /* kills the old `spin` ring */
    color: var(--accent-fg);              /* white on the button's own accent
                                             ground — NOT a fourth accent site */
    overflow: hidden;
  }
  .spinner--pcr svg { width: 26px; height: 14px; max-width: none; }
  .spinner__prog {
    fill: none; stroke: currentColor; stroke-width: 1.5;
    stroke-linecap: round; stroke-linejoin: round; opacity: .92;
  }
  .spinner__block { stroke: rgb(255 255 255 / .40); stroke-width: 1; }
  @media (prefers-reduced-motion: no-preference) {
    .btn-submit.is-loading .spinner__prog { animation: pcr-run var(--pcr-cycle) linear infinite; }
  }

  /* ---- 5. ARMED DROPZONE — one-shot perimeter anneal ---------------- */
  .dz-anneal {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none; opacity: 0;
  }
  .file-label.drag-over .dz-anneal { opacity: 1; }
  .dz-anneal__line {
    fill: none;
    stroke: var(--accent);              /* inside .drag-over — already the third
                                           and last legal accent SURFACE */
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 100;              /* the rect carries pathLength="100" */
    stroke-dashoffset: 100;
  }
  @keyframes dz-anneal { to { stroke-dashoffset: 0; } }
  @media (prefers-reduced-motion: no-preference) {
    .file-label.drag-over .dz-anneal__line { animation: dz-anneal var(--dur-4) var(--ease) forwards; }
  }

  /* ---- 6. RECEIPT — the only plateau in the interface --------------- */
  .amp { margin: 0 0 var(--s-3); }
  .amp__svg { width: 100%; max-width: 240px; height: auto; }
  .amp__rule { fill: none; stroke: currentColor; stroke-width: 1; opacity: .38; vector-effect: non-scaling-stroke; }
  .amp__thr  { fill: none; stroke: currentColor; stroke-width: 1; opacity: .38;
               stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
  .amp__lab  { fill: currentColor; opacity: .70; font-family: var(--font-sans);
               font-size: 7px; font-weight: 500; letter-spacing: var(--tracking-micro); }
  .amp__curve {
    fill: none; stroke: currentColor;   /* inherits .receipt's --success-text */
    stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  .amp__cap {
    margin-top: var(--s-1);
    font-size: var(--fs-100); line-height: var(--lh-vn-min);
    color: var(--text-secondary);
  }
  @keyframes amp-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
  @media (prefers-reduced-motion: no-preference) {
    .amp__curve { stroke-dasharray: 100; animation: amp-draw var(--dur-4) var(--ease) 1 both; }
  }

  /* ---- 7. GLOBAL PAUSE while the tab is hidden ---------------------- */
  :root[data-bg] .helix__drift,
  :root[data-bg] .pcr-thermal__prog,
  :root[data-bg] .spinner__prog,
  :root[data-bg] .skeleton__bar::after { animation-play-state: paused; }

  /* ---- 8. REDUCED MOTION — deliberate stills, never frozen frames ---
     The blanket rule in @layer base only !important's animation-duration and
     animation-iteration-count; it never sets animation-name. `animation: none`
     from this later layer therefore wins cleanly and no keyframe ever ticks.
     Each still is a COMPLETE composition:
       idle band  -> a whole static B-form duplex at phase 0
       run strip  -> the two SEPARATED strands, profile parked on the 95C hold
                     (marker at 119px falls inside local 19.50..27.04)
       button     -> a fully drawn profile, marker on 95C — replacing the
                     frozen partial ring that shipped before
       reading    -> six flat still bars, an honest placeholder
       receipt    -> the complete curve, appearing rather than drawing
       dropzone   -> a complete solid accent ring
     Critically the idle and run stills are VISUALLY DIFFERENT, so a
     reduced-motion user keeps the idle-vs-generating distinction. */
  @media (prefers-reduced-motion: reduce) {
    .helix__drift,
    .pcr-strip .helix__drift,
    .pcr-thermal__prog,
    .btn-submit.is-loading .spinner__prog,
    .pcr-strip { animation: none; transform: none; }
    .skeleton__bar::after { animation: none; opacity: 0; }
    .amp__curve { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
    .dz-anneal__line { animation: none; stroke-dashoffset: 0; }
  }

  /* ---- 9. PRINT + FORCED COLORS —----------------------------------—
     The panel is a plausible batch record. Forced-colors discards the opacity
     gradient that carries depth, so the figure would flatten to a solid mass. */
  @media print {
    .helix, .pcr-strip, .amp, .dz-anneal { display: none !important; }
  }
  @media (forced-colors: active) {
    .helix, .pcr-strip, .amp, .dz-anneal { display: none; }
  }
}

/* ==========================================================================
   GLASS DNA BACKGROUND — page structure

   The layering contract, in one place:
     #helixStage   fixed, z-index 0, pointer-events:none   — the molecule
     .appbar       sticky, --z-appbar (20)                 — opaque surface
     main          relative, z-index 1                     — all content
   Every panel that holds text already paints an opaque --bg-surface, so the
   only text at risk is what sits directly on the canvas. The scrim below
   guarantees that ground, and the helix is composed to the right so the
   Operations lane never competes with it.
   ========================================================================== */
@layer components {

  #helixStage {
    position: fixed; inset: 0; z-index: 0;
    overflow: hidden; pointer-events: none;
    opacity: 0;                       /* fades in only once WebGL confirms */
    transition: opacity 600ms var(--ease);
  }
  #helixStage canvas { display: block; width: 100%; height: 100%; }
  :root[data-webgl] #helixStage { opacity: var(--helix-opacity); }

  /* THE LEGIBILITY SCRIM. A single gradient in the page ground colour,
     strongest on the left where the Operations lane lives and fading out to
     the right where the molecule is composed. Cheap (one paint, no filter),
     and it means body text never sits on a moving image. */
  #helixStage::after {
    content: ""; position: absolute; inset: 0;
    background:
      linear-gradient(90deg,
        var(--bg-canvas) 0%,
        color-mix(in srgb, var(--bg-canvas) 82%, transparent) 26%,
        color-mix(in srgb, var(--bg-canvas) 22%, transparent) 50%,
        transparent 68%),
      linear-gradient(0deg,
        var(--bg-canvas) 0%,
        transparent 22%, transparent 78%,
        color-mix(in srgb, var(--bg-canvas) 60%, transparent) 100%);
  }

  /* Content must out-paint a positioned, z-indexed background layer. */
  .workbench { position: relative; z-index: 1; }
  .appbar { position: sticky; z-index: var(--z-appbar); }

  /* FROZEN while real data is on screen. The JS stops the rAF loop outright;
     this drops it back visually so the matrix owns the eye. */
  :root[data-helix="ready"] #helixStage,
  :root[data-helix="error"] #helixStage { opacity: calc(var(--helix-opacity) * .3); }
  :root[data-helix="run"]   #helixStage { opacity: calc(var(--helix-opacity) * 1.12); }

  /* Below two lanes everything stacks, so the molecule would sit behind ALL
     the text. Pull it right down and lean on the scrim. */
  @media (max-width: 1079px) {
    :root[data-webgl] #helixStage { opacity: calc(var(--helix-opacity) * .55); }
    :root[data-helix="ready"] #helixStage,
    :root[data-helix="error"] #helixStage { opacity: calc(var(--helix-opacity) * .18); }
    #helixStage::after {
      background: linear-gradient(180deg,
        color-mix(in srgb, var(--bg-canvas) 55%, transparent) 0%,
        color-mix(in srgb, var(--bg-canvas) 88%, transparent) 45%,
        var(--bg-canvas) 100%);
    }
  }

  /* THE FALLBACK CHAIN. WebGL succeeded -> the static SVG duplex in the idle
     panel is redundant, so retire it. No WebGL, reduced motion, forced
     colours or print -> helix.js never runs, data-webgl is never set, and
     the SVG duplex stays exactly as it was. Nothing is ever lost. */
  /* Must out-specify #statsPanel[data-state="idle"] .helix--idle (1,2,0) from
     the motion layer — an attribute selector on :root alone loses to it. */
  :root[data-webgl] #statsPanel .helix--idle,
  :root[data-webgl] #statsPanel[data-state="idle"] .helix--idle,
  :root[data-webgl] #statsPanel[data-state="reading"] .helix--idle { display: none; }
  /* The skeleton returns to idle: with the SVG duplex retired, it is what
     shows the SHAPE of the answer before a file exists. */
  :root[data-webgl] #statsPanel[data-state="idle"] .skeleton { display: flex; }

  @media (prefers-reduced-motion: reduce) { #helixStage { display: none; } }
  @media (forced-colors: active)          { #helixStage { display: none; } }
  @media print {
    #helixStage { display: none; }
    .doc-rail { display: none; }
    .doc-layout { grid-template-columns: 1fr; }
  }
}
