/* HELIOS-9 demo: clean engineering schematic. Color encodes state only:
   neutral = normal, amber = warning, red = failure, blue = the agent's touch points. */
:root {
  --bg: #f2f3f5; --panel: #ffffff; --panel-2: #f7f8fa; --ink: #11161e; --ink-2: #3a4351; --mute: #5f6a7a;
  --line: #d6dbe3; --line-2: #e6e9ee; --grid: rgba(17, 22, 30, .045);
  --stroke: #4b5563; --fill-mod: #fbfbfc;
  --warn: #a95a00; --warn-2: #d98a1c; --warn-bg: #fff3df;
  --fail: #c0271d; --fail-bg: #fdeceb;
  --accent: #1d5bd0; --accent-bg: #e7eefc;
  --pass: #20704b; --pass-bg: #e4f3ec;
  --bare: #8a94a3;
  --shadow: 0 1px 2px rgba(16, 22, 30, .05), 0 4px 16px rgba(16, 22, 30, .05);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e13; --panel: #131820; --panel-2: #0f141b; --ink: #e9edf3; --ink-2: #c2c9d4; --mute: #8f99a9;
    --line: #2a323f; --line-2: #1d242e; --grid: rgba(233, 237, 243, .04);
    --stroke: #9aa4b2; --fill-mod: #161c25;
    --warn: #f2a33a; --warn-2: #f2a33a; --warn-bg: #33240d;
    --fail: #ff6a5c; --fail-bg: #3b1613;
    --accent: #72a5ff; --accent-bg: #15233c;
    --pass: #56c690; --pass-bg: #12301f;
    --bare: #636e7e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0e13; --panel: #131820; --panel-2: #0f141b; --ink: #e9edf3; --ink-2: #c2c9d4; --mute: #8f99a9;
  --line: #2a323f; --line-2: #1d242e; --grid: rgba(233, 237, 243, .04);
  --stroke: #9aa4b2; --fill-mod: #161c25;
  --warn: #f2a33a; --warn-2: #f2a33a; --warn-bg: #33240d;
  --fail: #ff6a5c; --fail-bg: #3b1613;
  --accent: #72a5ff; --accent-bg: #15233c;
  --pass: #56c690; --pass-bg: #12301f;
  --bare: #636e7e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); overflow-x: hidden; }
a { color: var(--accent); }
code, kbd, pre { font-family: var(--mono); }
code { font-size: .88em; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; }
kbd { font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }
.small { font-size: 13px; color: var(--mute); }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-2); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: .06em; white-space: nowrap; flex: none; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.storynav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.storynav a { color: var(--mute); text-decoration: none; font-size: 13px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.storynav a:hover { background: var(--panel); color: var(--ink); }
.storynav a[aria-current="page"] { color: var(--ink); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
@media (max-width: 640px) {
  .storynav { gap: 6px; }
  .storynav .full { display: none; }
  .storynav a { min-width: 34px; min-height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; border: 1px solid var(--line); }
}
.iconbtn { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.iconbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.iconbtn:hover { background: var(--panel); }

main { max-width: 1480px; margin: 0 auto; padding: 0 24px; }
main:focus { outline: none; }

/* ---------------------------------------------------------------- landing */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 48px; align-items: center; padding: 48px 0 40px; }
.hero h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 18px; font-weight: 700; text-wrap: balance; }
.hero .eyebrow { color: var(--accent); }
.lede { font-size: 18px; color: var(--ink-2); max-width: 640px; margin: 0; }
.hero-links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 24px; }
.btn-cta { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; background: var(--accent);
  color: var(--panel); font-weight: 600; text-decoration: none; }
.btn-cta:hover { filter: brightness(1.08); }
.btn-ghost { font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; background: var(--panel); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero-chart { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 22px 18px; }
.chart-title { margin: 0 0 10px; font-size: 19px; line-height: 1.3; letter-spacing: -.01em; }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.chart-key span { display: inline-flex; align-items: center; gap: 7px; }
.chart-key i { width: 16px; height: 10px; border-radius: 0 3px 3px 0; }
.key-bare { background: var(--bare); }
.key-red { background: var(--accent); }
.chart-wrap { width: 100%; min-height: 200px; }
.chart { display: block; overflow: visible; font-family: var(--font); }
.c-grid line { stroke: var(--line-2); stroke-width: 1; }
.c-axis { font-size: 11.5px; fill: var(--mute); }
.c-name { font-size: 14px; }
.c-model { font-weight: 600; fill: var(--ink); }
.c-note { fill: var(--mute); font-size: 13px; }
.c-bare { fill: var(--bare); }
.c-red { fill: var(--accent); }
.c-val { font-size: 13px; font-weight: 600; }
.c-val-bare { fill: var(--ink-2); }
.c-val-red { fill: var(--ink); }
.c-budget { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.c-budget-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .7; }
.c-budget-t { font-size: 12px; font-weight: 500; fill: var(--ink-2); }
.c-name, .c-val, .c-budget-t { paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.hero-chart figcaption { margin-top: 10px; }
.chart-note { margin: 0; font-size: 12.5px; }
.punch { margin: 10px 0 0; font-weight: 700; font-size: 15.5px; line-height: 1.4; }

.sec-h { font-size: clamp(22px, 2.2vw, 28px); letter-spacing: -.015em; margin: 0 0 6px; }
.sec-sub { margin: 0; color: var(--ink-2); max-width: 760px; }
.how { padding: 32px 0 36px; border-top: 1px solid var(--line); }
.steps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.steps svg { width: 40px; height: 40px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.steps svg .dot { fill: var(--accent); stroke: none; }
.steps p { margin: 2px 0 0; font-size: 16px; line-height: 1.4; color: var(--ink); }
.step-n { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--mute); text-transform: uppercase; }
.step-n::before { content: "Step "; }
.why-station { margin: 16px 0 0; color: var(--ink-2); max-width: 820px; }

.ways { padding: 32px 0 8px; border-top: 1px solid var(--line); }
.ways:focus { outline: none; }
.ways { scroll-margin-top: 64px; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 20px 0 36px; }
.scard { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.scard:hover { border-color: var(--accent); transform: translateY(-2px); }
.scard .glyph { height: 92px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 14px 14px; display: flex; align-items: center; justify-content: center; }
.scard .glyph svg { width: 100%; height: 100%; }
.scard .num { font-size: 12px; font-weight: 600; color: var(--mute); letter-spacing: .08em; text-transform: uppercase; }
.scard h3 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.scard .hook { margin: 0; color: var(--ink-2); }
.scard .meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 6px; }
.scard .cta { font-size: 14px; font-weight: 600; color: var(--accent); }
.outcomes { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 13px; }
.outcomes li { display: block; padding-left: 18px; text-indent: -18px; }
.outcomes li > span:first-child { display: inline-block; width: 18px; text-indent: 0; }
.outcomes b { font-weight: 600; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.tag-fail { color: var(--fail); }
.tag-pass { color: var(--pass); }
.guide { scroll-margin-top: 64px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 12px 16px 0; }
.guide-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guide-top h2 { font-size: 16px; margin: 0; }
.guide-body { padding: 0; }
.guide-btn { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0 0 0 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.guide-btn::after { content: " ▾"; text-decoration: none; display: inline-block; margin-left: 2px; }
.guide-btn[aria-expanded="true"]::after { content: " ▴"; }
.guide-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.guide-keys { margin-top: 20px; }
.guide-keys p { margin: 0; }
.explain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 12px; }
.guide h3 { font-size: 15px; margin: 0 0 12px; }
.defs { margin: 0; }
.defs dt { font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; color: var(--ink-2); }
.legend-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 7px; }
.legend-list li { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.sw { width: 26px; height: 12px; border-radius: 3px; flex: none; border: 2px solid; }
.sw-ok { border-color: var(--stroke); background: var(--fill-mod); }
.sw-warn { border-color: var(--warn-2); background: var(--warn-bg); }
.sw-fail { border-color: var(--fail); background: var(--fail-bg); }
.sw-accent { border-color: var(--accent); background: var(--accent-bg); }
.method { max-width: 900px; padding: 20px 0 24px; margin: 0; }
.terms { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel); }
.terms summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.terms .defs { font-size: 14px; }
.terms .defs dt { margin-top: 8px; }
@media (max-width: 1080px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .hero-text { max-width: 760px; }
}

/* ---------------------------------------------------------------- story header */
.story { padding: 14px 0 24px; }
.story-head { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.story-title { flex: 1 1 380px; min-width: 0; }
.runpick { flex: none; }
.story-title h1 { margin: 0; font-size: clamp(24px, 2.6vw, 30px); letter-spacing: -.015em; line-height: 1.15; }
.task { margin: 4px 0 0; color: var(--ink-2); max-width: 760px; font-size: 14px; }
.runpick { display: grid; gap: 6px; justify-items: end; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 7px 14px; cursor: pointer; text-align: left; display: grid; gap: 0; }
.seg button .r1 { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.seg button .r2 { font-size: 12px; color: var(--mute); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.seg button[aria-checked="true"] .r2 { color: color-mix(in srgb, var(--bg) 70%, var(--ink)); }
.seg .vd { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 0 6px; border-radius: 4px; }
.vd.fail { background: var(--fail); color: #fff; }
.vd.pass { background: var(--pass); color: #fff; }
/* dark theme: the bright fail/pass fills need dark text (white on them is < 3:1) */
:root[data-theme="dark"] .vd.fail, :root[data-theme="dark"] .vd.pass, :root[data-theme="dark"] .status[data-state="fail"] .pill { color: #0b0e13; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .vd.fail, :root:not([data-theme="light"]) .vd.pass,
  :root:not([data-theme="light"]) .status[data-state="fail"] .pill { color: #0b0e13; }
}
.verdict { margin: 0; font-size: 13px; color: var(--ink-2); text-align: right; max-width: 520px; }

/* ---------------------------------------------------------------- stage */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: 16px; align-items: start; }
.schem[data-mode="tall"] { max-width: 440px; margin: 0 auto; }
.left { display: grid; gap: 10px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.schem-card { position: relative; overflow: hidden; }
.schem { display: block; width: 100%; height: auto; }
.status { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; min-height: 64px; border-bottom: 1px solid var(--line-2);
  background: var(--panel); transition: background .3s; }
.status .pill { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; border-radius: 6px;
  padding: 3px 8px; margin-top: 1px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.status-body { min-width: 0; }
.status-t { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.status-t .when { font-weight: 500; color: var(--mute); font-size: 12.5px; font-variant-numeric: tabular-nums; }
/* desktop: fixed height (title + two lines of "why") so the page does not jump when the accident banner appears */
@media (min-width: 900px) {
  .status { height: 84px; min-height: 0; overflow: hidden; }
  .status-t { flex-wrap: nowrap; white-space: nowrap; }
  .status-t > :not(.when) { overflow: hidden; text-overflow: ellipsis; }
  .status-why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
.status-why { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.status[data-state="warn"] .pill { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-2); }
.status[data-state="fail"] { background: var(--fail-bg); }
.status[data-state="fail"] .pill { background: var(--fail); color: #fff; border-color: var(--fail); }
.status[data-state="fail"] .status-t { color: var(--fail); }
.status[data-state="fail"].fresh { animation: flash .9s ease-out; }
.status[data-state="pass"] .pill { background: var(--pass-bg); color: var(--pass); border-color: var(--pass); }
.status[data-state="agent"] .pill { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
@keyframes flash { 0% { box-shadow: inset 0 0 0 3px var(--fail); } 100% { box-shadow: inset 0 0 0 0 var(--fail); } }

.schem[data-mode="wide"] ~ .envstrip { display: none; }
.envr-bg { fill: transparent; }
.envr[data-state="warn"] .envr-bg { fill: var(--warn-bg); }
.envr[data-state="warn"] .lbl-val { fill: var(--warn); }
.envr[data-state="fail"] .envr-bg { fill: var(--fail-bg); }
.envr[data-state="fail"] .lbl-val { fill: var(--fail); }
.envstrip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.env { padding: 6px 12px 7px; min-width: 0; border-left: 1px solid var(--line-2); }
.env:first-child { border-left: 0; }
.env .k { font-size: 10.5px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.env .v small { font-size: 11px; color: var(--mute); font-weight: 500; margin-left: 3px; }
.env[data-state="warn"] { background: var(--warn-bg); }
.env[data-state="warn"] .v { color: var(--warn); }
.env[data-state="fail"] { background: var(--fail-bg); }
.env[data-state="fail"] .v { color: var(--fail); }

.tl-card { padding: 10px 12px 8px; }
.ctlrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 4px; }
.controls, .opts { display: contents; }
.opts > * { order: 1; }
.controls .clock { order: 2; }
.mini { display: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 14px; font-weight: 500; min-height: 36px; }
.btn svg { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; stroke-width: 0; }
.btn.icon svg { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon { padding: 6px 8px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); min-width: 92px; justify-content: center; }
.btn:hover { border-color: var(--accent); }
.speed { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--mute); }
.speed select { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 8px; min-height: 36px; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.chk input { accent-color: var(--accent); width: 16px; height: 16px; }
.clock { margin-left: auto; display: flex; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; }
#clockT { font-size: 20px; font-weight: 700; letter-spacing: .01em; }
#clockUtc { font-size: 13px; color: var(--mute); }
.tl { display: block; width: 100%; cursor: pointer; touch-action: none; user-select: none; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--mute); padding: 2px 2px 2px; }
.tl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; }
.lg-tick { width: 2px; height: 12px; background: var(--mute); }
.lg-dec { width: 2px; height: 14px; background: var(--accent); box-shadow: 0 -4px 0 1px var(--accent); }
.lg-cap { width: 2px; height: 12px; background: var(--warn-2); }
.lg-apply { width: 9px; height: 9px; background: var(--accent); transform: rotate(45deg); }
.lg-alarm { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--warn-2); }
.lg-inc { width: 10px; height: 10px; border-radius: 50%; background: var(--fail); }
.lg-dl { width: 12px; border-top: 2px dashed var(--ink-2); }
.lg-drift { width: 9px; height: 9px; border-radius: 2px; background: var(--warn-2); }
.lg-ghost { width: 10px; height: 10px; border-radius: 50%; border: 1.5px dashed var(--mute); }

/* ---------------------------------------------------------------- agent panel */
.agent { position: sticky; top: 64px; display: flex; flex-direction: column; max-height: calc(100vh - 80px); min-height: 420px; overflow: hidden; }
.agent-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line-2); display: grid; gap: 3px; }
.agent-model { font-weight: 700; }
.agent-stat { font-size: 12.5px; color: var(--mute); font-variant-numeric: tabular-nums; }
.callout { margin: 10px 10px 8px; border: 1.5px solid var(--accent); border-radius: 10px; background: var(--accent-bg); padding: 10px 12px;
  max-height: 52%; overflow: auto; flex: none; }
.callout.fail { border-color: var(--fail); background: var(--fail-bg); }
.callout .ch { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.callout .ch b { color: var(--accent); text-transform: uppercase; letter-spacing: .07em; font-size: 11px; }
.callout.fail .ch b { color: var(--fail); }
.callout .cap { margin: 6px 0 8px; font-size: 14px; font-weight: 500; line-height: 1.45; }
.callout .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--mute); margin: 8px 0 3px; }
.callout pre, .obs pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.45; background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; max-height: 240px; overflow: auto; }
pre.tbl { white-space: pre; overflow-x: auto; }
.callout .lbl .hint { text-transform: none; letter-spacing: 0; color: var(--accent); font-weight: 600; }
/* scroll shadows on wide tables: visible only where there is more to scroll to */
pre.scrollx { background:
  linear-gradient(to right, var(--panel) 30%, transparent) left / 24px 100% no-repeat local,
  linear-gradient(to left, var(--panel) 30%, transparent) right / 24px 100% no-repeat local,
  linear-gradient(to right, rgba(0, 0, 0, .14), transparent) left / 10px 100% no-repeat scroll,
  linear-gradient(to left, rgba(0, 0, 0, .14), transparent) right / 10px 100% no-repeat scroll, var(--panel); }
.callout pre.args { max-height: 96px; }
pre .dl-del { color: var(--mute); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--mute) 60%, transparent); display: block; }
pre .dl-del.bad { color: var(--fail); background: var(--fail-bg); text-decoration: none; font-weight: 600; }
pre.tbl .dl-warn, pre.tbl .dl-note { white-space: pre-wrap; }
pre .dl-add { color: var(--accent); background: var(--accent-bg); display: block; font-weight: 600; }
pre .dl-note { color: var(--accent); font-weight: 600; display: block; }
pre .dl-warn { color: var(--warn); background: var(--warn-bg); display: block; font-weight: 600; }
pre .dl-ok { color: var(--ink); font-weight: 700; }
.calls { list-style: none; margin: 0; padding: 4px 0 10px; border-top: 1px solid var(--line-2); overflow-y: auto; flex: 1; min-height: 120px; position: relative; }
.call { border-left: 3px solid transparent; }
.call > button { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 26px 52px minmax(0, 1fr); gap: 2px 8px; width: 100%;
  padding: 5px 12px 5px 10px; cursor: pointer; font-size: 13px; }
.call > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.call .i { color: var(--mute); font-variant-numeric: tabular-nums; text-align: right; }
.call .t { color: var(--mute); font-variant-numeric: tabular-nums; }
.call .l { font-weight: 600; display: flex; gap: 6px; align-items: center; min-width: 0; }
.call .a { grid-column: 3; font-family: var(--mono); font-size: 11.5px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* not reached yet: lighter label weight and muted color, but still >= 4.5:1 */
.call.future .l { color: var(--mute); font-weight: 500; }
.call.now { background: var(--panel-2); border-left-color: var(--ink); }
.call.decisive .l::after { content: "key"; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; }
.call.decisive.fail .l::after { color: var(--fail); border-color: var(--fail); }
.call .flag { font-size: 10.5px; font-weight: 600; border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.flag.cap { color: var(--warn); background: var(--warn-bg); }
.flag.commit { color: var(--accent); background: var(--accent-bg); }
.flag.err { color: var(--mute); background: var(--panel-2); border: 1px solid var(--line); }
.call .obs { display: none; grid-column: 1 / -1; padding: 2px 12px 10px 13px; }
.call.open .obs { display: block; }
.call.sys { font-size: 12.5px; color: var(--ink-2); padding: 6px 12px 6px 46px; border-left-color: var(--warn-2); background: var(--warn-bg); margin: 4px 0; }
.call.sys.future { color: var(--mute); background: var(--panel-2); }
.call.endrow { font-size: 12.5px; color: var(--ink-2); padding: 8px 12px 8px 46px; border-top: 1px dashed var(--line); margin-top: 6px; }
.call.endrow q { font-style: italic; }

/* ---------------------------------------------------------------- takeaway */
.takeaway { margin-top: 22px; padding: 24px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.takeaway h2 { font-size: clamp(22px, 2.6vw, 30px); margin: 0 0 8px; letter-spacing: -.01em; }
.takeaway p { max-width: 900px; color: var(--ink-2); margin: 0; font-size: 16px; }
.takeaway .tfoot { margin-top: 10px; font-size: 13.5px; color: var(--mute); }
.tnav { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.tnav a { text-decoration: none; }
.foot { max-width: 1480px; margin: 0 auto; padding: 18px 24px 32px; color: var(--mute); font-size: 13px; border-top: 1px solid var(--line-2); }
.foot p { margin: 4px 0; }
.noscript { padding: 24px; }

/* ---------------------------------------------------------------- SVG: schematic */
svg text { font-family: var(--font); }
.grid-line { fill: none; stroke: var(--grid); stroke-width: 1; }
.hatch-line { stroke: var(--fail); stroke-width: 2; opacity: .35; }
.bus { stroke: var(--ink-2); stroke-width: 4; stroke-linecap: round; }
.feeder { stroke: var(--stroke); stroke-width: 2; }
.node { fill: var(--ink-2); }
.lbl-id { fill: var(--mute); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.lbl-val { fill: var(--ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lbl-note { fill: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.big-val { fill: var(--ink); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.schem[data-mode="tall"] .big-val { font-size: 19px; }
/* desktop schematic: larger labels so the smallest stays >= 9 px on screen at ~830 px wide */
.schem[data-mode="wide"] .lbl-id { font-size: 13.5px; }
.schem[data-mode="wide"] .lbl-val { font-size: 15px; }
.schem[data-mode="wide"] .lbl-note, .schem[data-mode="wide"] .mod-sub, .schem[data-mode="wide"] .mod-state { font-size: 13.5px; }
.schem[data-mode="wide"] .mod-name { font-size: 18px; }
.schem[data-mode="wide"] .big-val { font-size: 24px; }
.schem[data-mode="wide"] .dot-lbl { font-size: 13.5px; }
.schem[data-mode="wide"] .touch-txt { font-size: 13.5px; }
.schem[data-mode="tall"] .dot-lbl { font-size: 11.5px; }
/* phones: 11.2 units keeps the smallest label >= 9 px at 360 px wide */
.schem[data-mode="tall"] .lbl-id, .schem[data-mode="tall"] .lbl-note, .schem[data-mode="tall"] .mod-sub, .schem[data-mode="tall"] .mod-state { font-size: 11.2px; }
.brk-box { fill: var(--panel); stroke: var(--stroke); stroke-width: 1.6; }
.brk-wire, .brk-blade { stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; transition: transform .3s; }
.brk[data-state="warn"] .brk-box { stroke: var(--warn-2); fill: var(--warn-bg); stroke-width: 2; }
.brk[data-state="fail"] .brk-box { stroke: var(--fail); fill: var(--fail-bg); stroke-width: 2.2; }
.brk[data-state="fail"] .brk-blade { stroke: var(--fail); }
.tbar-bg { fill: var(--line-2); }
.tbar-fill { fill: var(--stroke); transition: width .2s linear; }
.tbar[data-state="warn"] .tbar-fill { fill: var(--warn-2); }
.tbar[data-state="fail"] .tbar-fill { fill: var(--fail); }
.mod-box { fill: var(--fill-mod); stroke: var(--stroke); stroke-width: 1.6; transition: stroke .3s, fill .3s; }
.mod-dark { opacity: 0; transition: opacity .3s; pointer-events: none; }
.mod[data-state="warn"] .mod-box { stroke: var(--warn-2); stroke-width: 2; }
.mod[data-state="fail"] .mod-box { stroke: var(--fail); stroke-width: 2.4; fill: var(--fail-bg); }
.mod-name { fill: var(--ink); font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.mod-sub { fill: var(--mute); font-size: 11px; }
.mod-state { fill: var(--fail); font-size: 11px; font-weight: 700; letter-spacing: .05em; }
.hatch { fill: var(--panel); stroke: var(--stroke); stroke-width: 1.4; }
.hatch-outer { fill: none; stroke: var(--stroke); stroke-width: 2.4; }
.reader-body { fill: var(--panel); stroke: var(--stroke); stroke-width: 1.6; }
.reader-led { fill: var(--stroke); }
.reader[data-state="fail"] .reader-body { stroke: var(--fail); fill: var(--fail-bg); stroke-width: 2.2; }
.reader[data-state="fail"] .reader-led { fill: var(--fail); }
.reader[data-state="denied"] .reader-led { fill: var(--ink); }
.reader[data-state="denied"] .reader-body { stroke: var(--ink); stroke-width: 2.2; }
.pipe { fill: none; stroke: var(--stroke); stroke-width: 3; transition: stroke .3s; }
.pipe-stub { stroke: var(--stroke); stroke-width: 2; stroke-dasharray: 3 3; }
.loop[data-state="warn"] .pipe { stroke: var(--warn-2); stroke-width: 3.6; }
.loop[data-state="fail"] .pipe { stroke: var(--fail); stroke-width: 4; }
.loop[data-state="warn"] .big-val { fill: var(--warn); }
.loop[data-state="fail"] .big-val { fill: var(--fail); }
.pump-c { fill: var(--panel); stroke: var(--stroke); stroke-width: 1.6; }
.pump-t { fill: var(--stroke); }
.rad-box { fill: var(--panel); stroke: var(--stroke); stroke-width: 1.6; }
.rad-fin { stroke: var(--stroke); stroke-linecap: round; transition: stroke-width .4s; }
.loop[data-state="fail"] .rad-box { stroke: var(--fail); }
.crew-dot { transition: transform 1.1s cubic-bezier(.4, 0, .2, 1); }
.crew-dot .dot { fill: var(--ink-2); stroke: var(--panel); stroke-width: 2; }
.crew-dot .dot-lbl { fill: var(--panel); font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none; }
.crew-dot.focus .dot { fill: var(--ink); stroke: var(--ink); stroke-width: 1; }
.crew-dot[data-state="warn"] .dot { fill: var(--warn-2); }
.crew-dot[data-state="fail"] .dot { fill: var(--fail); stroke: var(--fail-bg); stroke-width: 3; }
/* asleep: hollow dot with dark number instead of a faded one (faded labels were < 3:1) */
.crew-dot[data-act="sleep"][data-state="ok"] .dot { fill: var(--panel); stroke: var(--ink-2); stroke-width: 1.6; stroke-dasharray: 3 2; }
.crew-dot[data-act="sleep"][data-state="ok"] .dot-lbl { fill: var(--ink); }
.touch-ring { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.touch-tag { fill: var(--accent); }
.touch-txt { fill: #fff; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
:root[data-theme="dark"] .touch-txt { fill: #0b0e13; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .touch-txt { fill: #0b0e13; } }
.touch.pulse .touch-ring { animation: pulse 1.6s ease-out 2; }
@keyframes pulse { 0% { stroke-width: 6; } 100% { stroke-width: 2; } }
.focus-ring { fill: none; stroke: var(--fail); stroke-width: 3; }

/* ---------------------------------------------------------------- SVG: timeline */
.lane { fill: var(--panel-2); stroke: var(--line-2); }
.lane-lbl { fill: var(--mute); font-size: 11.5px; font-weight: 500; paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.gridv { stroke: var(--line-2); }
.axis { fill: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.past { fill: var(--ink); opacity: .04; pointer-events: none; }
.tick { stroke: var(--mute); stroke-width: 1.6; }
.tick.k-write, .tick.k-commit, .tick.commit { stroke: var(--accent); stroke-width: 2; }
.tick.capped { stroke: var(--warn-2); stroke-width: 2.2; }
.tick.decisive { stroke: var(--accent); stroke-width: 2.6; }
.dec-dot { fill: var(--accent); }
.m-apply path { fill: var(--accent); stroke: var(--panel); stroke-width: 1.5; }
.m-alarm path { fill: var(--warn-2); stroke: var(--panel); stroke-width: 1; }
.m-drift rect { fill: var(--warn-2); }
.m-incident circle { fill: var(--fail); stroke: var(--panel); stroke-width: 2; }
.inc-line { stroke: var(--fail); stroke-width: 1.5; opacity: .5; }
.m-ghost line { stroke: var(--mute); stroke-dasharray: 3 3; opacity: .7; }
.m-ghost circle { fill: none; stroke: var(--mute); stroke-width: 1.5; stroke-dasharray: 2 2; }
.stop-line { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 1 3; }
.deadline { stroke: var(--ink-2); stroke-width: 1.6; stroke-dasharray: 5 4; }
.deadline-lbl { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.head-line { stroke: var(--ink); stroke-width: 2; }
.head-knob { fill: var(--ink); stroke: var(--panel); stroke-width: 2; }
.th-fail { stroke: var(--fail); stroke-dasharray: 4 3; stroke-width: 1.2; }
.th-warn { stroke: var(--warn-2); stroke-dasharray: 4 3; stroke-width: 1.2; }
.th-lbl { fill: var(--mute); font-size: 10.5px; paint-order: stroke; stroke: var(--panel-2); stroke-width: 3px; stroke-linejoin: round; }
.th-lbl.th-fail { fill: var(--fail); }
.th-lbl.th-warn { fill: var(--warn); }
.sig-line { fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linejoin: round; }
.sig-area { fill: var(--ink); opacity: .05; }
.sig-dot { fill: var(--ink); stroke: var(--panel); stroke-width: 1.5; }
.grant-bar { fill: var(--stroke); opacity: .65; }
.grant-lost { fill: var(--fail); opacity: .18; stroke: var(--fail); stroke-dasharray: 3 2; }
.grant-revoked { fill: none; stroke: var(--mute); stroke-dasharray: 3 2; opacity: .6; }
.acc-bad { fill: var(--fail); stroke: var(--panel); stroke-width: 1.5; }
.acc-ok { fill: var(--stroke); }
.acc-denied { fill: var(--panel); stroke: var(--ink); stroke-width: 2; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1239px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .agent { position: relative; top: 0; max-height: 640px; }
}
@media (max-width: 1180px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
/* short desktop screens: tighter header so schematic, controls and timeline fit together */
@media (min-width: 1240px) and (max-height: 820px) {
  .story { padding-top: 8px; }
  .story-head { margin-bottom: 8px; }
  .story-title .eyebrow { margin-bottom: 2px; font-size: 11px; }
  .story-title h1 { font-size: 24px; }
  .task { margin-top: 2px; font-size: 13.5px; }
  .seg button { padding: 5px 12px; }
  .tl-card .btn, .tl-card .speed select { min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .left { gap: 8px; }
  .tl-card { padding-top: 8px; }
}
/* phones and tablets: playback bar fixed to the bottom of the screen, so Play/step stay reachable next to the schematic */
@media (max-width: 899px) {
  .controls { display: flex; align-items: center; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    padding: 9px 16px calc(9px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(16, 22, 30, .08); }
  .controls .clock { margin-left: auto; width: auto; order: 0; }
  #clockT { font-size: 18px; }
  .mini { display: block; position: absolute; left: 0; right: 0; top: -1px; height: 4px; background: var(--line-2); cursor: pointer; }
  .mini-fill { height: 100%; width: 0; background: var(--accent); }
  .opts { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
  body:has(#story:not([hidden])) { padding-bottom: 64px; }
  html { scroll-padding-bottom: 72px; }
}
@media (max-width: 760px) {
  main { padding: 0 16px; }
  .topbar { padding: 8px 16px; gap: 10px; }
  .hero { padding: 28px 0 28px; }
  .lede { font-size: 16px; }
  .hero-chart { padding: 16px 14px 14px; }
  .cards { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 10px; }
  .steps li { padding: 12px 14px; }
  .steps p { font-size: 15px; }
  .explain-grid { grid-template-columns: 1fr; gap: 20px; }
  .runpick { justify-items: stretch; width: 100%; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; }
  .seg button { padding: 7px 10px; }
  .verdict { text-align: left; }
  .envstrip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .env:nth-child(4) { border-left: 0; }
  .env:nth-child(n+4) { border-top: 1px solid var(--line-2); }
  .env .v { font-size: 14px; }
  .status { min-height: 0; padding: 8px 12px; }
  .status-t { font-size: 13.5px; }
  .speed span, .speed { font-size: 12px; }
  .chk { font-size: 12px; }
  .agent { max-height: 70vh; }
  .takeaway { padding: 18px; }
}
@media (max-width: 420px) {
  #themeLbl { display: none; }
  #clockUtc { display: none; }
}
/* keyboard hints are noise on touch screens */
@media (hover: none) { .kbd-hints { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* polish: loop labels stay readable where a pipe stub crosses them; opaque top bar on small screens */
.loop .lbl-id { paint-order: stroke; stroke: var(--panel); stroke-width: 5px; stroke-linejoin: round; }
@media (max-width: 720px) { .topbar { background: var(--bg); backdrop-filter: none; } }
