.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
/* Dynamometry Lab: ForceIQ brand tokens (from ForceIQ's index.css / brand guide). Light and dark
 * follow the system (prefers-color-scheme), and text size follows the browser. Clinical chart colors
 * match ForceIQ's; peak / RFD strokes use darker shades in light mode for 3:1 contrast.
 * Two deliberate departures, both for text contrast on white: --muted stays #6B7280 (ForceIQ's
 * #8A94A2 is about 3:1), and the light theme keeps darker status colors, using Strength Green and
 * Alert Amber in the dark theme where they read. The dark ground is ForceIQ's neutral charcoal.
 * Radius follows the app: 6 px controls, 8 px callouts and panels, 12 px the instrument surface. */
@font-face { font-family: "Inter"; src: url("fonts/inter-var.woff") format("woff"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrainsmono-var.woff") format("woff"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --hdr-h: 48px; --nav-h: 44px;
  --band: #0C1F33;          /* force-blue-dark: header band in both themes */
  --band-ink: #F8F9FB;
  --brand: #1B3F6E;         /* force-blue */
  --cyan: #00C2D1;          /* signal-cyan */

  --page: #F8F9FB; --surface: #FFFFFF; --inset: #EFF1F5;
  --border: #E2E5EB; --border-strong: #CBD0D8;
  --ink: #1A1D23; --ink-2: #56616F; --muted: #6B7280;
  --grid: #EEF0F3; --axis: #8891A0;
  --accent: #1B3F6E; --accent-ink: #FFFFFF; --accent-soft: #E8EEF6;

  --trace: #2A5A9E; --raw: #A7AEBA; --truth: #6B7280; --second: #B45309;
  --onset: #16A34A; --plateau: #8B5CF6; --peak: #B45309; --rfd-early: #C2410C; --rfd-late: #0E7490;
  --threshold: #DC2626; --baseline: #6B7280; --fiq: #1B3F6E;
  --hl-fill: rgba(27, 63, 110, 0.10); --hl-fill-alt: rgba(139, 92, 246, 0.12);
  --win-fill: rgba(139, 92, 246, 0.10); --band-fill: rgba(107, 114, 128, 0.12);
  --good: #16A34A; --warning: #D97706; --critical: #DC2626;
  --good-soft: #E8F6EC; --warning-soft: #FDF3E4; --critical-soft: #FDECEC;
  /* LSI bands: ForceIQ's fixed clinical colors, the same in both themes */
  --lsi-red: #EF4444; --lsi-amber: #F39C12; --lsi-yellow-green: #84CC16; --lsi-green: #2ECC71;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #1E1F22; --surface: #25262A; --inset: #161719;
    --border: rgba(255, 255, 255, 0.09); --border-strong: rgba(255, 255, 255, 0.16);
    --ink: #F8F9FB; --ink-2: #9FB1C4; --muted: #7F93A8;
    --good: #2ECC71; --warning: #F39C12;
    --grid: #2D3340; --axis: #8891A0;
    --accent: #33D4E0; --accent-ink: #0C1F33; --accent-soft: #16303F;
    --trace: #33D4E0; --raw: #5B6475; --truth: #B0B7C3; --second: #F59E0B;
    --peak: #F59E0B; --rfd-early: #F97316; --rfd-late: #06B6D4; --threshold: #F87171; --baseline: #8891A0; --fiq: #9EC5FF;
    --hl-fill: rgba(51, 212, 224, 0.12); --hl-fill-alt: rgba(139, 92, 246, 0.20);
    --win-fill: rgba(139, 92, 246, 0.18); --band-fill: rgba(176, 183, 195, 0.12);
    --good-soft: #15291D; --warning-soft: #2E2413; --critical-soft: #331A1A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--page); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* --- header band (ui/shell.js): one 48 px row; below 1024 px a menu, and it hides while reading --- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 0 20px; height: var(--hdr-h); padding: 0 20px; background: var(--band); color: var(--band-ink); transition: transform 0.2s ease; }
.topbar.hdr-hidden { transform: translateY(-100%); }
.brand { display: inline-flex; align-items: center; }
.brand svg { height: 18px; width: auto; display: block; }
.brand-title { font-weight: 600; font-size: 1rem; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.25); white-space: nowrap; }
.current-tab, .menu-btn, .menu-only { display: none; }
.menu-btn svg path { stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.site-menu { display: flex; align-items: center; flex: 1 1 auto; gap: 20px; min-width: 0; align-self: stretch; }
.tabs { display: flex; gap: 22px; align-self: stretch; }
.tabs a { display: flex; align-items: center; color: rgba(248, 249, 251, 0.72); text-decoration: none; font-size: 0.92rem; border-bottom: 2px solid transparent; border-top: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--band-ink); }
.tabs a[aria-current="page"] { color: var(--band-ink); font-weight: 600; border-bottom-color: var(--cyan); }
.menu-extra { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.menu-link { font: inherit; font-size: 0.9rem; color: rgba(248, 249, 251, 0.75); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; }
.menu-link:hover { color: var(--band-ink); text-decoration: underline; }
.menu-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(10, 20, 35, 0.45); }
.menu-scrim[hidden] { display: none; }
@media (max-width: 1023px) {
  .topbar { padding: 0 6px 0 16px; gap: 12px; }
  .brand-title { display: none; }
  .current-tab { display: block; flex: 1 1 auto; min-width: 0; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.25); font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: auto; padding: 0; background: none; border: 0; border-radius: var(--r-sm); color: var(--band-ink); cursor: pointer; }
  .menu-btn .i-close, .topbar.menu-open .menu-btn .i-open { display: none; }
  .topbar.menu-open .menu-btn .i-close { display: inline; }
  .site-menu { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; padding: 4px 0 8px; background: var(--band); border-top: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25); }
  .topbar.menu-open .site-menu { display: flex; }
  .tabs { flex-direction: column; gap: 0; }
  .tabs a, .menu-link { display: flex; align-items: center; min-height: 44px; padding: 0 20px; border: 0; border-left: 3px solid transparent; font-size: 1rem; width: 100%; text-align: left; }
  .tabs a[aria-current="page"] { border-left-color: var(--cyan); background: rgba(255, 255, 255, 0.06); }
  .menu-extra { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.12); flex-direction: column; align-items: stretch; gap: 0; }
  .menu-only { display: flex; }
}
@media (prefers-reduced-motion: reduce) { .topbar { transition: none; } }

/* --- controls --- */
.btn { font: inherit; font-size: 0.88rem; padding: 5px 11px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.changed { border-color: var(--warning); box-shadow: inset 0 0 0 1px var(--warning); }
select, input[type="number"] { font: inherit; font-size: 0.88rem; padding: 4px 6px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); }
input[type="number"] { width: 5.2em; font-family: var(--mono); }
input[type="range"] { accent-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 5px; font-size: 0.88rem; cursor: pointer; }
/* Segmented choices: separate small buttons that wrap, so long options never clip. */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { font: inherit; font-size: 0.85rem; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); cursor: pointer; }
.seg button:hover { border-color: var(--ink-2); }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg.stack { display: flex; flex-direction: column; align-items: stretch; }
.seg.stack button { text-align: left; }
.field[hidden] { display: none; }
.field { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink-2); }
.field > span:first-child { white-space: nowrap; }
@media (pointer: coarse) {
  .btn, .seg button, select { min-height: 44px; }
  input[type="range"] { height: 44px; }
}

/* --- one callout style (the app's in-app note): 1 px border at 30 % of the color, a 5 % fill --- */
.callout { --c: var(--muted); font-size: 0.875rem; padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--inset);
  border-color: color-mix(in srgb, var(--c) 30%, transparent); background: color-mix(in srgb, var(--c) 5%, transparent); }
.callout-warn { --c: var(--warning); }
.callout-error { --c: var(--critical); }
.callout-good { --c: var(--good); }
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin-bottom: 0; }

/* --- readouts: a row of instrument cells divided by hairlines --- */
.readout { display: flex; flex-wrap: wrap; border-top: 1px solid var(--border); }
.ro-cell { flex: 1 1 0; min-width: 120px; padding: 8px 14px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.ro-cell:first-child { border-left: 0; }
button.ro-cell { font: inherit; text-align: left; background: none; border-top: 0; border-right: 0; border-bottom: 0; color: inherit; cursor: pointer; }
button.ro-cell.cur { box-shadow: inset 0 -2px 0 var(--accent); }
.ro-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); white-space: nowrap; }
.ro-value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.375rem; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.ro-unit { font-family: var(--font); font-size: 0.8rem; font-weight: 500; color: var(--ink-2); margin-left: 3px; }
.ro-ref, .ro-true { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.8rem; white-space: nowrap; }
.ro-ref { color: var(--fiq); }
.ro-ref::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2px dashed var(--fiq); margin-right: 5px; vertical-align: middle; }
.ro-true { color: var(--ink-2); }

/* --- disclosure: the definition and the worked numbers, closed by default --- */
.disc { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 10px; font-size: 0.875rem; }
.disc summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.disc p { margin: 6px 0 0; }
.disc .formula, .disc .worked { font-family: var(--mono); font-size: 0.82rem; }
.disc .formula { background: var(--inset); border-radius: var(--r-sm); padding: 6px 9px; margin-top: 6px; }

/* --- sign-up line at the end of a section (ui/cta.js) --- */
.cta-line { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-size: 0.875rem; color: var(--ink-2); }
.cta-line a { font-weight: 600; margin-left: 4px; white-space: nowrap; }
@media print { .cta-line { display: none; } }

/* --- layout --- */
main { max-width: 1560px; margin: 0 auto; padding: 16px 20px 28px; }
.tab-panel[hidden] { display: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
.toolbar .grow { flex: 1 1 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 0.8rem; padding: 2px 9px; border-radius: var(--r-full); background: var(--inset); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.sim { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.fixture-summary { font-size: 0.9rem; color: var(--ink-2); margin: -4px 0 10px; max-width: 80ch; }
select { max-width: 100%; }
.field { flex-wrap: wrap; max-width: 100%; }

/* --- charts --- */
.charts { display: flex; flex-direction: column; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 6px 8px 2px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 0 4px 2px; }
.panel-title { font-weight: 600; font-size: 0.92rem; }
.panel-caption { font-size: 0.8rem; color: var(--ink-2); }
.panel-plot { width: 100%; position: relative; }
.uplot { font-family: var(--font); color: var(--ink-2); }
.uplot .u-legend { font-size: 0.8rem; text-align: left; padding: 0 0 2px 60px; }
.uplot .u-legend .u-series { padding: 1px 6px; }
.uplot .u-legend .u-marker { width: 14px; height: 3px; border: 0 !important; border-radius: 2px; margin-right: 4px; }
.uplot .u-legend .u-value { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.uplot .u-select { background: rgba(127, 127, 127, 0.18); }
.chart-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 6px 2px 0; font-size: 0.85rem; color: var(--ink-2); }
.vmark { position: absolute; top: 0; bottom: 0; width: 20px; margin-left: -10px; z-index: 6; }
.vmark.drag { cursor: ew-resize; touch-action: none; }
.vmark.locked { pointer-events: none; }
.vmark-line { position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--onset); opacity: 0.9; }
.vmark.drag .vmark-line { width: 3px; left: 8.5px; opacity: 1; }
.vmark-grip { position: absolute; left: 2px; top: 50%; width: 16px; height: 28px; margin-top: -14px; border-radius: var(--r-sm); background: var(--onset); box-shadow: 0 0 0 2px var(--surface); }
.vmark-grip::before { content: ""; position: absolute; left: 4px; right: 4px; top: 8px; bottom: 8px; border-left: 2px solid rgba(255, 255, 255, 0.85); border-right: 2px solid rgba(255, 255, 255, 0.85); }
.vmark.locked .vmark-line { width: 1px; left: 9.5px; background: var(--ink-2); opacity: 0.8; }
.vmark.locked[data-id="onset"] .vmark-line { width: 2px; left: 9px; background: var(--onset); opacity: 1; }
.vmark.locked[data-id="onset"] .vmark-label { border-color: var(--onset); color: var(--ink); }
.vmark.peak .vmark-line { background: var(--peak); width: 1.5px; opacity: 0.8; }
.vmark.fiq .vmark-line { width: 2px; left: 9px; opacity: 1; background: repeating-linear-gradient(to bottom, var(--fiq) 0 6px, transparent 6px 10px); }
.vmark.truth .vmark-line { width: 2px; left: 9px; background: repeating-linear-gradient(to bottom, var(--ink-2) 0 3px, transparent 3px 6px); }
.vmark.active .vmark-line { width: 3px; left: 8.5px; opacity: 1; }
.vmark.dragging .vmark-line, .vmark.drag:hover .vmark-line, .vmark.dragging .vmark-grip, .vmark.drag:hover .vmark-grip { background: var(--accent); }
.vmark-label { position: absolute; left: 12px; font-size: 0.74rem; line-height: 1.35; white-space: nowrap; padding: 1px 6px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); color: var(--ink); pointer-events: auto; }
.vmark.drag .vmark-label { font-weight: 600; border-color: var(--onset); }
.vmark.fiq .vmark-label { border: 1px dashed var(--fiq); color: var(--fiq); font-weight: 600; }
.vmark.locked .vmark-label { color: var(--ink-2); }
.hmark { position: absolute; left: 0; right: 0; height: 20px; margin-top: -10px; z-index: 6; cursor: ns-resize; touch-action: none; }
.hmark-line { position: absolute; top: 9px; left: 0; right: 0; height: 2px; background: var(--threshold); opacity: 0.75; }
.hmark.dragging .hmark-line, .hmark:hover .hmark-line { background: var(--accent); opacity: 1; }
.hmark-label { position: absolute; right: 6px; top: -22px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface); border: 2px solid var(--threshold); color: var(--ink); }
.boxmark { position: absolute; bottom: 2px; height: 28px; z-index: 6; cursor: grab; touch-action: none; font-size: 0.8rem; font-weight: 600; line-height: 24px; text-align: center; white-space: nowrap; overflow: hidden; border-radius: var(--r-sm); border: 2px solid var(--ink-2); background: var(--surface); color: var(--ink); }
.boxmark[data-id="plateau"] { border-color: var(--plateau); }
.boxmark.active { border-color: var(--ink); }
.boxmark.dragging, .boxmark:hover { cursor: grabbing; border-color: var(--accent); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--second); pointer-events: none; z-index: 4; }

/* --- notes: quality notes in the callout style --- */
.notes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.note { --c: var(--muted); display: flex; gap: 8px; align-items: baseline; font-size: 0.875rem; padding: 7px 10px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--inset);
  border-color: color-mix(in srgb, var(--c) 30%, transparent); background: color-mix(in srgb, var(--c) 6%, transparent); }
.note-warn { --c: var(--warning); }
.note-error { --c: var(--critical); }
.note-icon { flex: 0 0 auto; display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; font-size: 0.72rem; font-weight: 700; background: var(--c); color: var(--surface); }

/* --- metrics --- */
.badge { font-size: 0.68rem; letter-spacing: 0.02em; text-transform: none; padding: 1px 6px; border-radius: var(--r-full); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* --- a metric's definition and numbers (ui.metricDetail, in the explorer's disclosure) --- */
.lab-detail { font-size: 0.88rem; }
.lab-detail h2 { font-size: 1rem; margin: 6px 0 2px; }
.lab-detail .big { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; margin: 2px 0 8px; }
.lab-detail h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); margin: 12px 0 4px; }
.lab-detail .formula { font-family: var(--mono); font-size: 0.85rem; background: var(--inset); border-radius: var(--r-sm); padding: 7px 9px; }
.lab-detail .worked { font-family: var(--mono); font-size: 0.85rem; }
.lab-detail .try { background: var(--accent-soft); border-radius: var(--r-sm); padding: 8px 10px; }
.lab-detail .cite { font-size: 0.78rem; color: var(--ink-2); margin-top: 10px; }
.lab-detail ul { margin: 4px 0; padding-left: 18px; }
.lab-detail .truthrow { font-family: var(--mono); font-size: 0.85rem; }

/* --- misc --- */
.footer { max-width: 1560px; margin: 0 auto; padding: 14px 20px 28px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.8rem; color: var(--ink-2); border-top: 1px solid var(--border); }
.selftest { margin-left: auto; }
.selftest.ok { color: var(--ink-2); }
.selftest.fail { color: var(--critical); font-weight: 600; }
dialog { max-width: min(680px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: 18px 22px; }
dialog::backdrop { background: rgba(10, 20, 35, 0.55); }
dialog h2 { margin-top: 0; font-size: 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 640px) {
  main { padding: 12px 16px 24px; }
  .toolbar > * { max-width: 100%; }
  .chip { white-space: normal; }
  .headline { grid-template-columns: 1fr; }
  .footer { padding: 14px 16px 24px; }
  .selftest { margin-left: 0; }
}
@media print { .topbar, .menu-scrim, .experiment, .chart-actions, .footer { display: none; } }

/* --- plot toolbar (ForceIQ-style) --- */
.plotbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px 6px; background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--r-md) var(--r-md) 0 0; }
.plotbar + .charts .panel:first-child { border-top-left-radius: 0; border-top-right-radius: 0; }
.overlay-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ochip { font: inherit; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; opacity: 0.5; }
.ochip.on { opacity: 1; border-color: var(--border-strong); }
.ochip-swatch { width: 11px; height: 11px; border-radius: 3px; border: 2px solid transparent; }
.ochip-swatch.dashed { border-style: dashed; }
.plotpill { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--inset); }
.pbtn { font: inherit; font-size: 0.82rem; padding: 4px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; }
.pbtn:hover { background: var(--surface); color: var(--ink); }
.pbtn.on { background: var(--accent); color: var(--accent-ink); }
.pbtn.icon { font-size: 1rem; line-height: 1; padding: 3px 10px; font-weight: 600; }
.pdiv { width: 1px; height: 18px; background: var(--border-strong); margin: 0 3px; }
.plothint { flex-basis: 100%; font-size: 0.75rem; color: var(--muted); }
.u-over.pan-mode { cursor: grab; }
.u-over.no-tools { touch-action: pan-y; }
.vmark.emph .vmark-line { width: 3px; left: 8.5px; opacity: 1; }
.vmark.emph .vmark-label { font-weight: 700; border-width: 2px; }
.u-over.panning { cursor: grabbing; }
.panel-subhead { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 8px 4px 0; margin-top: 4px; border-top: 1px dashed var(--border); }
.panel-subtitle { font-weight: 600; font-size: 0.85rem; }
.tile-fiq, .card-fiq { font-family: var(--mono); font-size: 0.76rem; color: var(--fiq); }
.card-fiq { grid-column: 1 / -1; }
.mode-lede { font-size: 0.9rem; color: var(--ink-2); margin: 0 0 10px; }
.btn-link { border-color: transparent; background: transparent; color: var(--accent); text-decoration: underline; }
.btn[disabled] { opacity: 0.45; cursor: default; }

/* --- lesson panel type --- */
.g-crumb { font-size: 0.78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.g-title { font-size: 1.5rem; font-weight: 600; line-height: 1.3; margin: 2px 0 6px; }
.g-title:focus { outline: none; }
.g-rec { font-size: 0.88rem; color: var(--ink-2); margin: 0 0 8px; max-width: 90ch; }
.g-rec b { color: var(--ink); }

/* --- chips and small buttons --- */
.chip[title] { cursor: help; }
.chip:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.btn-inline { padding: 1px 8px; font-size: 0.8rem; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .btn-inline { margin: 0; }

/* --- tables --- */
.cmp-table { border-collapse: collapse; font-size: 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 8px; }
.cmp-table th, .cmp-table td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cmp-table thead th { font-size: 0.8rem; color: var(--ink-2); font-weight: 600; }
.cmp-table td.num { text-align: right; white-space: nowrap; }
.cmp-table.decide { font-size: 0.85rem; }
.cmp-table.decide th, .cmp-table.decide td { padding: 6px 8px; }

/* --- Testing 101: the knee diagram, the accuracy bars, the checklist and the trial review --- */
.knee-svg { display: block; width: 100%; height: auto; max-height: 380px; overflow: hidden; }
.kd-label { font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.kd-angle { font-family: var(--mono); font-size: 17px; font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.stage-setup .diagram { height: 100%; display: flex; align-items: center; justify-content: center; }
.stage-setup .diagram .knee-svg { height: 100%; max-height: none; }
.beat-msg { margin: 0; font-size: 0.9rem; color: var(--ink-2); padding-left: 10px; border-left: 2px solid var(--border-strong); }


.stage-checklist .stage-plot { overflow-y: auto; padding: 10px 18px 14px; }
.cl-group + .cl-group { margin-top: 14px; }
.cl-title { font-size: 1rem; font-weight: 600; margin: 0 0 6px; }
.checklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.checklist li { padding: 7px 2px; border-bottom: 1px solid var(--border); }
.cl-row { display: flex; gap: 10px; align-items: flex-start; }
.cl-row input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--good); }
.cl-row label { cursor: pointer; font-size: 0.93rem; }
.checklist li.done label { color: var(--ink-2); }
.cl-why { margin: 2px 0 0 28px; font-size: 0.86rem; }
.cl-why summary { cursor: pointer; color: var(--accent); width: max-content; }
.cl-why p { margin: 4px 0 2px; max-width: 80ch; color: var(--ink-2); }

.triage-dots { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.tdot { position: relative; width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.tdot::after { content: ""; position: absolute; inset: -6px; }
.tdot.cur { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tdot.ok { background: var(--good); border-color: var(--good); }
.tdot.miss { background: var(--warning); border-color: var(--warning); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle { font: inherit; font-size: 0.8rem; line-height: 1.3; padding: 2px 8px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; }
.toggle.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggle:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.ro-cell.ro-text { min-width: 0; font-size: 0.85rem; line-height: 1.4; }
.triage-fb { padding: 10px 12px; border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); background: color-mix(in srgb, var(--good) 5%, transparent); }
.triage-fb.miss { border-color: color-mix(in srgb, var(--warning) 30%, transparent); background: color-mix(in srgb, var(--warning) 5%, transparent); }
.triage-fb h2 { margin: 0 0 6px; font-size: 1rem; }
.triage-fb p { margin: 0 0 6px; font-size: 0.88rem; }
.triage-fb .ctl-row { margin-top: 8px; }
input:disabled + *, label.check:has(input:disabled) { cursor: default; }

/* The parked Symmetry deep dive (ui.SymmetryView) keeps its earlier layout. */
.g-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--r-md); }
.g-control[hidden] { display: none; }
.g-control-label { font-weight: 600; font-size: 0.9rem; }
.g-control-help { font-size: 0.85rem; color: var(--ink-2); flex-basis: 100%; }
.knee-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 12px; margin-bottom: 8px; }
.knee-read { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; align-self: start; }
.kr-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.kr-msg { font-size: 0.9rem; margin: 10px 0 0; }
.kr-warn { background: var(--warning-soft); border-left: 3px solid var(--warning); border-radius: var(--r-sm); padding: 6px 8px; }

@media (max-width: 760px) {
  .knee-grid { grid-template-columns: minmax(0, 1fr); }
  .cmp-table { display: block; overflow-x: auto; }
}
@media print {
  .stepnav-wrap, .guide, .stage-chart > .readout, .no-print, .g-crumb { display: none !important; }
  .stage { display: block; height: auto; }
  .stage-chart { border: 0; box-shadow: none; }
}

/* The checklist's print sheet (ui-setup.js): plain text, two columns, one page. */
.print-sheet { display: none; }
@media print {
  @page { margin: 12mm; }
  body.has-print-sheet { background: #fff; }
  body.has-print-sheet > :not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; font-size: 10pt; line-height: 1.35; }
  .print-sheet, .print-sheet * { color: #000; }
  .print-sheet h1 { font-size: 14pt; font-weight: 700; margin: 0 0 8pt; }
  .ps-cols { columns: 2; column-gap: 8mm; }
  .ps-group { margin: 0 0 6pt; }
  .ps-group h2 { font-size: 11pt; font-weight: 700; margin: 0 0 3pt; break-after: avoid; }
  .print-sheet ul { list-style: none; margin: 0; padding: 0; }
  .print-sheet li { display: grid; grid-template-columns: 9pt minmax(0, 1fr); gap: 5pt; margin: 0 0 4pt; break-inside: avoid; }
  .ps-box { width: 8.5pt; height: 8.5pt; border: 1pt solid #000; margin-top: 2pt; }
  .print-sheet p { margin: 0; max-width: none; }
  .ps-item { font-weight: 600; }
  .print-sheet .ps-why { margin-top: 1pt; font-size: 8.5pt; color: #333; }
  .print-sheet .ps-foot { margin-top: 6pt; font-size: 7.5pt; color: #555; }
}

/* --- Overview (ui/ui-overview.js): the opening slides. A page on the lesson's grid, not a stage: it
   ends on one screen on a laptop, and the footer may scroll into view, as under a lesson. --- */
.overview { max-width: 1180px; margin: 4px auto 0; display: flex; flex-direction: column;
  min-height: clamp(440px, calc(100vh - var(--hdr-h) - 40px), 680px); min-height: clamp(440px, calc(100dvh - var(--hdr-h) - 40px), 680px); }
.overview > .g-title { margin: 2px 0 14px; }
.ov-cols { display: grid; gap: 20px 40px; align-items: start; }
.ov-cols-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.ov-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ov-intro { font-size: 1.0625rem; margin: 0 0 14px; max-width: 62ch; }
.ov-lead { margin: 0 0 6px; font-weight: 600; }
.ov-objectives { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; max-width: 62ch; }
.ov-objectives a, .ov-row a.ov-plain { color: var(--ink); font-weight: 400; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.ov-objectives a:hover, .ov-row a.ov-plain:hover { text-decoration-color: var(--accent); }
.ov-h2 { font-size: 1.125rem; font-weight: 600; line-height: 1.3; margin: 0 0 8px; }
.ov-routes, .ov-outline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ov-routes li { padding-left: 12px; border-left: 2px solid var(--border-strong); }
.ov-who { font-weight: 600; }
.ov-byline { margin: 18px 0 0; color: var(--ink-2); font-size: 0.95rem; }
.ov-group + .ov-group { margin-top: 18px; }
.ov-row { font-size: 0.95rem; margin: 0; }
.ov-row a { font-weight: 600; }
.ov-notes { border-left: 1px solid var(--border); padding-left: 24px; }
.ov-block + .ov-block { margin-top: 14px; }
.ov-block p { margin: 0; font-size: 0.95rem; max-width: 60ch; }
.ov-foot { padding-top: 18px; }
@media (max-width: 1023px) {
  .ov-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-notes { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
}
@media (max-width: 699px) {
  .overview { min-height: 0; }
  .ov-cols-2, .ov-cols-3 { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

/* --- The six metrics (ui-gallery.js): a cell per trial, then a better/worse strip --- */
.stage-gallery .stage-chart > .readout { min-height: 96px; }
.ro-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.ro-desc { text-transform: none; letter-spacing: 0; }
.ro-zone { font-size: 0.8rem; font-weight: 600; padding-left: 6px; border-left: 3px solid var(--border-strong); white-space: nowrap; }
.ro-zone.good { border-left-color: var(--good); }
.ro-zone.warn { border-left-color: var(--warning); }
.ro-zone.bad { border-left-color: var(--critical); }
button.ro-cell:hover { background: var(--inset); }
button.ro-cell:focus-visible { outline: 3px solid var(--cyan); outline-offset: -3px; }
.gb-strip { flex: 1 0 100%; display: flex; align-items: center; gap: 12px; padding: 8px 14px 10px; border-top: 1px solid var(--border); }
.gb-dir { font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; }
.gb-track { position: relative; flex: 1 1 auto; height: 8px; margin: 0 10px; border-radius: var(--r-full); background: var(--inset); }
.gb-zone { position: absolute; top: 0; bottom: 0; }
.gb-zone.good { background: color-mix(in srgb, var(--good) 35%, transparent); }
.gb-zone.warn { background: color-mix(in srgb, var(--warning) 35%, transparent); }
.gb-zone.bad { background: color-mix(in srgb, var(--critical) 35%, transparent); }
.gb-zone.plain.to-right { background: linear-gradient(to right, color-mix(in srgb, var(--good) 35%, transparent), var(--inset)); }
.gb-zone.plain.to-left { background: linear-gradient(to left, color-mix(in srgb, var(--good) 35%, transparent), var(--inset)); }
.gb-mark { position: absolute; top: 50%; margin-top: -9px; width: 18px; height: 18px; border-radius: 50%; color: var(--surface); font-size: 0.68rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.gb-mark.cur { box-shadow: 0 0 0 2px var(--ink); z-index: 1; }
.gb-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gb-chip { font-size: 0.78rem; padding: 2px 8px; border-radius: var(--r-sm); border-left: 3px solid var(--border-strong); background: var(--inset); }
.gb-chip.good { border-left-color: var(--good); }
.gb-chip.warn { border-left-color: var(--warning); }
.gb-chip.bad { border-left-color: var(--critical); }

/* --- Metric walkthrough: Meet the metrics, then the deep dives --- */
.g-rail-group { margin-top: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border-strong); display: flex; flex-direction: column; gap: 2px; }
.g-rail-group b { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.g-rail-group span { font-size: 0.8rem; color: var(--ink-2); }
@media (max-width: 960px) {
  .g-rail-group { margin: 0; padding: 4px 10px; border-top: 0; border-left: 2px solid var(--border-strong); min-width: 150px; justify-content: center; }
}

/* Compare limbs: LSI radar, chips and table */
.lsi-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; align-items: start; margin: 10px 0; }
.lsi-radar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 8px 10px; }
.radar-wrap { position: relative; max-width: 400px; margin: 0 auto; }
.radar-svg { width: 100%; height: auto; display: block; font-family: var(--font); }
.radar-hit { cursor: pointer; outline: none; }
.radar-hit:focus-visible { stroke: var(--accent); stroke-width: 3px; }
.radar-tip { position: absolute; width: 160px; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 6px 8px; font-size: 0.8rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); pointer-events: none; z-index: 2; }
.radar-tip .small { color: var(--ink-2); font-size: 0.75rem; margin-top: 3px; }
.radar-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 0.8rem; color: var(--ink-2); margin-top: 4px; }
.radar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lsi-side { min-width: 0; }
.lsi-head { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 10px; }
.lsi-overall, .lsi-lowest { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.lsi-overall > span:first-child, .lsi-lowest > span:first-child { font-size: 0.85rem; color: var(--ink-2); min-width: 14ch; }
.lsi-overall .lsi-chip { font-size: 1.15rem; }
.lsi-chip { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lsi-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.lsi-red .lsi-dot { background: var(--lsi-red); }
.lsi-amber .lsi-dot { background: var(--lsi-amber); }
.lsi-yellow-green .lsi-dot { background: var(--lsi-yellow-green); }
.lsi-green .lsi-dot { background: var(--lsi-green); }
.lsi-table { width: 100%; }
.lsi-table td.muted { color: var(--ink-2); }
.lsi-bands { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; margin: 2px 0 6px; }
.lsi-bands .lsi-chip { font-weight: 500; color: var(--ink-2); }
.lsi-bars-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px; }
.lsi-bars { width: 100%; height: auto; display: block; font-family: var(--font); }
@media (max-width: 760px) { .lsi-grid { grid-template-columns: minmax(0, 1fr); } }
/* The LSI page on the stage: the radar beside the per-metric table, both fitted to the plot */
.lsi-stage { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: center; padding: 2px 6px 6px; }
.lsi-stage .lsi-radar { height: 100%; min-height: 0; display: flex; flex-direction: column; background: none; border: 0; padding: 0; }
.lsi-stage .radar-wrap { flex: 1 1 0; min-height: 0; max-width: none; width: 100%; }
.lsi-stage .radar-svg { height: 100%; }
.lsi-tablebox { min-width: 0; max-height: 100%; overflow: auto; }
.lsi-table tr.emph th, .lsi-table tr.emph td { background: var(--accent-soft); }
.lsi-table .fiq-col { color: var(--fiq); }
.ro-value .lsi-dot { display: inline-block; width: 11px; height: 11px; margin-right: 7px; vertical-align: 2px; }
.table-scroll { overflow-x: auto; }
.phone-only { display: none; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* --- Torque explorer (ui-lab.js): the recording bar, then a stage whose panel holds the settings --- */
.lab-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: var(--nav-h); margin-bottom: 8px; }
.lab-rec { max-width: min(330px, 100%); font-weight: 600; }
.lab-nav { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lab-nav .seg button { font-weight: 600; }
.lab-tail { margin-left: auto; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lab-bar .chip.sim { display: inline-flex; align-items: center; gap: 6px; }
.lab-bar .chip .btn-link { font-size: inherit; }
.lab-head { font-size: 1.3rem; font-weight: 600; margin: 0 0 4px; }
.lab-intro { font-size: 0.9rem; color: var(--ink-2); margin: 0 0 12px; }
.ctl-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.ctl-pair select { width: 100%; }
.lab-group { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); font-weight: 600; margin: 4px 0 0; }
.lab-group ~ .lab-group { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.ctl-stack { display: flex; flex-direction: column; gap: 6px; }
.ctl-stack .field, .lab-adv .field { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.85rem; }
.lab-disc { margin-top: 12px; }
.lab-disc .disc { margin-top: 0; padding: 5px 0; }
.guide .lab-disc .disc + .disc { margin-top: 0; }
.lab-adv { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.lab-more { width: 100%; font-size: 0.82rem; margin-top: 6px; }
.lab-more th, .lab-more td { padding: 4px 8px; }
.lab-more .btn-link { text-align: left; }
.lab-more tr.emph th, .lab-more tr.emph td { background: var(--accent-soft); }
.lab-more .fiq-col { color: var(--fiq); }
.stage-lab .guide > .cta-line { margin-top: auto; padding-top: 10px; }

/* --- lessons: the step navigator, then the stage (the instrument beside the guide panel) --- */
.stepnav-wrap { min-height: var(--nav-h); margin-bottom: 8px; }
.stepnav { display: flex; align-items: center; gap: 12px; min-height: var(--nav-h); }
.stepnav-select { max-width: min(420px, 60vw); font-weight: 600; }
.pips { display: inline-flex; align-items: center; gap: 8px; }
.pip { position: relative; width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 1.5px solid var(--border-strong); background: transparent; cursor: pointer; }
.pip::after { content: ""; position: absolute; inset: -8px; }
.pip.done { background: var(--border-strong); }
.pip.cur { background: var(--accent); border-color: var(--accent); }
.pips-count { display: none; font-size: 0.85rem; color: var(--ink-2); }
.stepnav-arrows { margin-left: auto; display: inline-flex; gap: 4px; }
.icon-btn { min-width: 36px; font-size: 1.1rem; line-height: 1; padding: 4px 10px; }

.lesson[hidden], .g-main[hidden] { display: none; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 400px); gap: 24px;
  height: clamp(440px, calc(100vh - var(--hdr-h) - var(--nav-h) - 44px), 640px); height: clamp(440px, calc(100dvh - var(--hdr-h) - var(--nav-h) - 44px), 640px); }
.stage-chart { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.stage-plot { flex: 1 1 0; min-height: 0; position: relative; padding: 6px 8px 0; }
.stage-plot .plotbar { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 4px 2px 6px; background: transparent; }
.stage-plot .plotbar[hidden] { display: none; }
.stage-plot .plothint { display: none; }
.stage-plot .plotbar { gap: 6px 8px; }
.stage-plot .plotbar .seg button { padding: 3px 8px; font-size: 0.8rem; }
.stage-plot .ochip { padding: 2px 7px; font-size: 0.75rem; }
.stage-plot .plotpill { margin-left: auto; }
.stage-plot .pbtn { padding: 3px 8px; font-size: 0.78rem; }
.stage-plot .panel { border: 0; padding: 0; background: transparent; }
.stage-chart > .readout { flex: 0 0 auto; min-height: 64px; }
.guide { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: auto; border-left: 1px solid var(--border); padding: 2px 4px 0 20px; }
.guide .g-title { font-size: 1.5rem; margin: 2px 0 10px; }
.beat-say { font-size: 1rem; margin: 0 0 14px; max-width: 60ch; }
.beat-controls { display: flex; flex-direction: column; gap: 12px; }
.ctl, .ctl-group { display: flex; flex-direction: column; gap: 6px; }
.ctl-group { gap: 12px; }
.ctl-label { font-size: 0.85rem; font-weight: 600; }
.ctl-row { display: flex; align-items: center; gap: 10px; }
.ctl-row input[type="range"] { flex: 1 1 auto; min-width: 0; }
.ctl-row output { font-family: var(--mono); font-size: 0.85rem; min-width: 4.5em; text-align: right; white-space: nowrap; }
.ctl-help { font-size: 0.8rem; line-height: 1.4; color: var(--ink-2); }
.ctl-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.ctl-inline { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.ro-msg { flex: 1 0 100%; padding: 7px 14px 9px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--ink-2); }
.ro-msg .beat-msg { padding: 0; border: 0; font-size: inherit; }
.beat-note { margin-top: 12px; }
.beat-note .disc { margin-top: 0; }
.guide .disc + .disc, .beat-note + .disc { margin-top: 8px; }
.beat-note .notes { margin-bottom: 0; }
.beat-note .g-rec { font-size: 0.85rem; }
.beat-links { margin: 8px 0 0; font-size: 0.9rem; }
.btn-link { font: inherit; padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; cursor: pointer; }
.beat-foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 8px; }
.beat-dots { display: inline-flex; gap: 6px; margin-right: auto; }
.beat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.beat-dot.done { background: var(--ink-2); }
.beat-dot.on { background: var(--accent); }
.beat-next { white-space: normal; text-align: left; }

/* short laptop screens: the same panel, set tighter */
@media (min-width: 700px) and (max-height: 720px) {
  .guide .g-title { font-size: 1.3rem; margin: 0 0 6px; }
  .beat-say { font-size: 0.95rem; line-height: 1.45; margin-bottom: 10px; }
  .beat-controls { gap: 9px; }
  .ctl { gap: 4px; }
  .beat-foot { padding-top: 10px; }
  .guide .cta-line { margin-top: 8px; padding-top: 8px; }
  .beat-links { margin-top: 6px; }
  .lab-head { font-size: 1.15rem; margin-bottom: 2px; }
  .lab-intro { font-size: 0.85rem; margin-bottom: 8px; }
}
/* tablet: the stage stays two columns with a narrower panel */
@media (max-width: 1023px) { .stage { grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; } .guide { padding-left: 16px; } }
/* phone: the chart pins under the header and the panel scrolls beneath it, so a control always
   sits right under the chart it moves */
@media (max-width: 699px) {
  .stepnav { gap: 8px; }
  .stepnav-select { flex: 1 1 0; min-width: 0; max-width: none; }
  .pips { display: none; }
  .pips-count { display: inline; white-space: nowrap; }
  .stepnav-arrows { margin-left: 0; }
  .stage { display: block; height: auto; }
  .stage-chart { position: sticky; top: var(--hdr-offset, var(--hdr-h)); z-index: 5; margin: 0 -16px; border-left: 0; border-right: 0; border-radius: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); transition: top 0.2s ease; }
  .stage-plot { flex: none; height: clamp(170px, 30vh, 260px); height: clamp(170px, 30svh, 260px); padding: 4px 4px 0; }
  .stage-chart > .readout { min-height: 56px; }
  .ro-cell { min-width: 0; padding: 6px 10px; }
  .ro-value { font-size: 1.15rem; }
  .ro-label { white-space: normal; }
  .ro-ref, .ro-true { white-space: normal; }
  .guide { border-left: 0; padding: 14px 0 0; overflow: visible; }
  .guide .g-title { font-size: 1.3rem; }
  .beat-foot { position: sticky; bottom: 0; z-index: 4; margin-top: 16px; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--page); border-top: 1px solid var(--border); }
  .beat-foot .btn { min-height: 44px; }
  .stage-gallery .stage-chart > .readout { min-height: 0; }
  .stage-gallery .stage-plot { height: clamp(150px, 26vh, 240px); height: clamp(150px, 26svh, 240px); }
  .ro-desc { display: none; }
  .gb-strip { padding: 5px 10px 7px; gap: 8px; }
  .stage-lsi .stage-plot { height: clamp(150px, 26vh, 240px); height: clamp(150px, 26svh, 240px); }
  .lsi-stage { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .lsi-tablebox { display: none; }
  .phone-only { display: block; }
  .stage-checklist .stage-chart { position: static; margin: 0; border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: none; }
  .stage-checklist .stage-plot { height: auto; overflow: visible; padding: 8px 12px 12px; }
  .stage-trials .stage-plot, .stage-capacity .stage-plot, .stage-resolution .stage-plot { height: clamp(150px, 26vh, 240px); height: clamp(150px, 26svh, 240px); }
  .stage-triage .stage-plot { height: clamp(150px, 25vh, 230px); height: clamp(150px, 25svh, 230px); }
  .stage-weight .stage-plot, .stage-strap .stage-plot { height: clamp(150px, 26vh, 240px); height: clamp(150px, 26svh, 240px); }
  .ro-msg { display: none; }
  /* A lesson's chart on a phone keeps the view its beat set: the pinned chart has no room for the
     toolbar (the Torque explorer is the place for free play), and the cursor legend has nothing to
     report on touch. */
  .stage-plot .plotbar, .stage-plot .u-legend { display: none; }
  .ro-cell.ro-text { font-size: 0.78rem; }
  .stage-accuracy .stage-plot { height: auto; }
  .lab-rec { flex: 1 1 100%; max-width: none; }
  .lab-tail { margin-left: 0; }
  .stage-lab .stage-plot { height: clamp(140px, 22vh, 220px); height: clamp(140px, 22svh, 220px); }
  .stage-lab .stage-chart > .readout { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
  .stage-lab .ro-cell { border-left: 0; border-top: 1px solid var(--border); padding: 4px 10px; gap: 0; }
  .stage-lab .ro-cell:nth-child(odd) { border-right: 1px solid var(--border); }
  .stage-lab .ro-value { font-size: 1.05rem; }
  .stage-lab .ro-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) { .stage-chart { transition: none; } }
