/* Rewind dashboard — design tokens first, components after. */
:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --surface-3: #e8e6df;
  --ink: #16151a;
  --ink-2: #47464e;
  --ink-3: #615f69;
  --line: #e3e1da;
  --line-strong: #cfccc2;
  --accent: #5040d6;
  --accent-ink: #3a2cb0;
  --accent-tint: #ecebfd;
  --on-accent: #ffffff;
  /* Status palette (fixed, never themed); text never wears these, marks do. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #2a78d6;
  --good-tint: #e5f5e3;
  --warning-tint: #fdf2d6;
  --critical-tint: #fbe6e4;
  --info-tint: #e4eefb;
  --neutral-tint: #efeee9;
  --shadow: 0 1px 2px rgb(22 21 26 / 6%), 0 4px 16px rgb(22 21 26 / 5%);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #101013;
    --surface: #17171b;
    --surface-2: #1f1f24;
    --surface-3: #29292f;
    --ink: #f2f1ee;
    --ink-2: #c4c3c9;
    --ink-3: #9b99a3;
    --line: #2a2a30;
    --line-strong: #3a3a42;
    --accent: #9b8fff;
    --accent-ink: #b8afff;
    --accent-tint: #24213f;
    --on-accent: #15121f;
    --good-tint: #15301a;
    --warning-tint: #362a10;
    --critical-tint: #3a1a1a;
    --info-tint: #162a44;
    --neutral-tint: #232328;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 24px rgb(0 0 0 / 30%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101013;
  --surface: #17171b;
  --surface-2: #1f1f24;
  --surface-3: #29292f;
  --ink: #f2f1ee;
  --ink-2: #c4c3c9;
  --ink-3: #9b99a3;
  --line: #2a2a30;
  --line-strong: #3a3a42;
  --accent: #9b8fff;
  --accent-ink: #b8afff;
  --accent-tint: #24213f;
  --on-accent: #15121f;
  --good-tint: #15301a;
  --warning-tint: #362a10;
  --critical-tint: #3a1a1a;
  --info-tint: #162a44;
  --neutral-tint: #232328;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 24px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: .05em .4em; border-radius: 6px;
  overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.15; font-weight: 600; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .92rem; font-weight: 600; }
p, li, dd { text-wrap: pretty; }
h1, h2, h3, .lede { text-wrap: balance; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: .9rem; }
.skip:focus { top: 12px; text-decoration: none; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.ico { flex: none; display: inline-block; vertical-align: -2px; }
.back { display: inline-flex; align-items: center; gap: 6px; }

/* -- layout ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner, main, footer { max-width: 1200px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 700; font-size: 1.12rem;
  letter-spacing: -.025em; }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.crumb { color: var(--ink-3); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; display: inline-flex; align-items: center; gap: 4px; }
a.crumb:hover { color: var(--ink); text-decoration: none; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 8px; font-size: .9rem; white-space: nowrap; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.theme svg { display: none; }
.theme:not([data-mode]) .t-system, .theme[data-mode="system"] .t-system, .theme[data-mode="light"] .t-light,
.theme[data-mode="dark"] .t-dark { display: block; }
main { padding-top: 32px; padding-bottom: 64px; }
footer { color: var(--ink-3); font-size: .82rem; padding-top: 24px; padding-bottom: 40px; --gutter: 24px;
  background: linear-gradient(var(--line), var(--line)) top center / calc(100% - 2 * var(--gutter)) 1px no-repeat; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.stack > * + * { margin-top: 28px; }
section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap; }

/* -- hero ------------------------------------------------------------------ */
.hero { display: grid; gap: 12px; margin-bottom: 8px; }
.hero-center { justify-items: center; text-align: center; padding: 28px 0 4px; gap: 16px; }
.hero-center h1 { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.1rem); letter-spacing: -.025em; line-height: 1.08; }
.hero-center .lede { max-width: 64ch; font-size: 1.08rem; }
.undo-keys { display: inline-flex; align-items: center; gap: 3px; margin-right: 4px; color: var(--accent-ink);
  font-weight: 700; vertical-align: 1px; }
.undo-keys kbd { font: 600 .9em var(--mono); color: var(--accent-ink); background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-bottom-width: 2px; border-radius: 6px;
  padding: 1px 7px; line-height: 1.35; }
.cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .95rem; }
.btn:hover { text-decoration: none; border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 1px 2px rgb(22 21 26 / 10%), 0 6px 18px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.featured { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.facts { list-style: none; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: flex;
  flex-wrap: wrap; justify-content: center; gap: 8px 32px; color: var(--ink-2); font-size: .9rem; }
.facts b { color: var(--ink); font-size: 1.05rem; margin-right: 4px; }
.tiles.centered .tile { justify-items: center; text-align: center; }
.tiles.centered .tile .meter { width: 100%; }
.lede { color: var(--ink-2); max-width: 70ch; font-size: 1.02rem; }

/* -- cards & tiles ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; display: grid; gap: 2px; align-content: start; }
.tile .value { font-size: 2rem; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 1rem; color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.tile .label { font-size: .86rem; color: var(--ink-2); font-weight: 500; }
.tile .context { font-size: .8rem; color: var(--ink-3); }
.tile .mark { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 1px; }
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.high > span { background: var(--warning); }

/* -- badges (icon + label + tone, never color alone) ----------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 99px;
  font-size: .8rem; font-weight: 600; color: var(--ink); background: var(--neutral-tint); white-space: nowrap;
  border: 1px solid transparent; }
.badge .i, .chip .i, .stage .i, .alert > .i, .ok-line .i, .h-ico { display: inline-flex; line-height: 1; }
.tone-good { background: var(--good-tint); } .tone-good .i { color: var(--good); }
.tone-warning { background: var(--warning-tint); } .tone-warning .i { color: #b67d00; }
.tone-critical { background: var(--critical-tint); } .tone-critical .i { color: var(--critical); }
.tone-info { background: var(--info-tint); } .tone-info .i { color: var(--info); }
.tone-accent { background: var(--accent-tint); } .tone-accent .i { color: var(--accent); }
.tone-neutral .i { color: var(--ink-3); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--ink-2);
  padding: 1px 8px; border-radius: 6px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.chip.tone-good .i { color: var(--good); } .chip.tone-warning .i { color: #b67d00; } .chip.tone-critical .i { color: var(--critical); }
.chip.zero { color: var(--ink-3); }
.chip.zero .i { color: var(--line-strong); }

/* -- runs table ------------------------------------------------------------ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .title { font-weight: 500; color: var(--ink); }
.table .title:hover { color: var(--accent-ink); }
.table .sub { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* -- run track (signature visual) ------------------------------------------ */
.track { position: relative; padding: 16px 8px 8px; }
.track.has-arc { padding-top: 64px; }
.track ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(9, 1fr); position: relative; }
.track ol::before { content: ""; position: absolute; left: calc(100% / 18); right: calc(100% / 18); top: 11px;
  height: 2px; background: var(--line-strong); }
.track .rail { position: relative; }
.track .progress { position: absolute; left: calc(100% / 18); top: 11px; height: 2px; background: var(--accent);
  border-radius: 2px; z-index: 1; }
.station { position: relative; display: grid; justify-items: center; text-align: center; gap: 8px; padding: 0 4px; }
.station .node { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; position: relative;
  z-index: 2; background: var(--surface); border: 2px solid var(--line-strong); color: var(--ink-3); }
.station.done .node { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.station.current .node { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-tint); }
.station.current .node::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.station.stopped .node { background: var(--critical); border-color: var(--critical); color: #fff; }
.station .name { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.station.pending .name { color: var(--ink-3); font-weight: 500; }
.station .when { font-size: .75rem; color: var(--ink-3); font-family: var(--mono); }
.station .note { display: block; font-family: var(--font); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
/* after a rewind: the checkpoint it returned to, what it took back, and where production broke */
.station.restored .node { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 0 5px var(--accent-tint); }
.station.restored .note { color: var(--accent-ink); }
.station.undone .node { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong)); }
.station.undone .name { color: var(--ink-3); font-weight: 500; text-decoration: line-through 1.5px;
  text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.station.regressed .node { background: var(--critical); border-color: var(--critical); color: #fff;
  box-shadow: 0 0 0 5px var(--critical-tint); }
.station.regressed .name { color: var(--ink); }
.track.rolled .progress { height: 0; background: none; border-top: 2px dashed color-mix(in srgb, var(--accent) 55%, var(--line-strong)); }
.station.outcome .node { width: 28px; height: 28px; margin-top: -2px; }
.station.outcome.tone-good .node { background: var(--good); border-color: var(--good); color: #fff; }
.station.outcome.tone-accent .node { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  width: 32px; height: 32px; margin-top: -4px; box-shadow: 0 0 0 5px var(--accent-tint); }
.station.outcome.tone-accent .name { color: var(--accent-ink); }
.station.outcome.tone-critical .node { background: var(--critical); border-color: var(--critical); color: #fff; }
.station.outcome { background: none; }
.track .arc { position: absolute; left: 8px; top: 8px; width: calc(100% - 16px); height: 56px; pointer-events: none;
  overflow: visible; }
.track .arc path { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.track .arc-head { position: absolute; top: 50px; left: calc(8px + (100% - 16px) * var(--x) / 100 - 7px); width: 0;
  height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 11px solid var(--accent); }
.track .arc-label { position: absolute; top: 9px; left: calc(8px + (100% - 16px) * var(--x) / 100);
  transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600;
  color: var(--on-accent); background: var(--accent); padding: 4px 12px 4px 10px; border-radius: 99px; white-space: nowrap;
  box-shadow: 0 0 0 4px var(--surface); }
.track .ret { display: none; }

/* -- lifecycle strip ------------------------------------------------------- */
.stages { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.stage { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 8px; text-align: center;
  background: var(--surface); }
.stage .n { font-weight: 600; font-size: .85rem; text-transform: capitalize; }
.stage .c { font-size: .75rem; color: var(--ink-3); display: flex; gap: 4px; align-items: center; justify-content: center; }
.stage.on { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: var(--good-tint); }
.stage.on .c { color: var(--ink-2); }
.stage.on .i { color: var(--good); }
.stage.tone-critical { border-color: color-mix(in srgb, var(--critical) 45%, var(--line)); }
.stage.tone-warning { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); }
.stage.tone-critical .c, .stage.tone-warning .c { color: var(--ink-2); font-weight: 600; }

/* -- run page grid --------------------------------------------------------- */
.run-head { display: grid; gap: 12px; }
.run-head .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--ink-3); font-size: .86rem; }
.run-head .meta b { color: var(--ink-2); font-weight: 500; }
.alert { border-radius: var(--radius); padding: 14px 16px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.tone-critical { border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.alert.tone-warning { border-color: color-mix(in srgb, var(--warning) 50%, transparent); }
.alert.tone-info { border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert > .i { padding-top: 3px; }
.alert-body { display: grid; gap: 4px; min-width: 0; }
.alert-body p:not(:first-child) { color: var(--ink-2); font-size: .92rem; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.aside { position: sticky; top: 84px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* -- lists ----------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.list .grow { flex: 1; min-width: 0; }
.by { display: block; font-size: .78rem; color: var(--ink-3); margin-top: 2px; }
.cmd-row { display: flex; align-items: stretch; gap: 6px; margin-top: 8px; }
code.cmd { flex: 1; min-width: 0; display: block; font-size: .8rem; padding: 6px 10px; white-space: nowrap; overflow-x: auto;
  overflow-wrap: normal; scrollbar-width: thin; }
.copy { position: relative; flex: none; display: inline-grid; place-items: center; width: 34px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.copy:hover { color: var(--ink); border-color: var(--line-strong); }
.copy .copied { position: absolute; bottom: calc(100% + 6px); right: 0; background: var(--ink); color: var(--bg);
  font-size: .75rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; opacity: 0; transition: opacity .15s;
  pointer-events: none; white-space: nowrap; }
.copy.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.copy.done .copied { opacity: 1; }
.control h3 { font-size: 1rem; }
.control > p.small { margin-top: 2px; }
.control .by { margin-top: 8px; }
.control .by.why { padding-top: 10px; margin-top: 12px; border-top: 1px solid var(--line); }
.control details.disclosure { margin-top: 10px; }
.next { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.next h3 { margin-bottom: 4px; }
.next .by { margin-top: 8px; }
.ok-line { display: flex; gap: 8px; align-items: center; }
.ok-line .i, .tile .value.verified .i { color: var(--good); }
.tile .value.verified { display: inline-flex; align-items: center; gap: 6px; }
.h-ico { color: var(--accent); vertical-align: -2px; margin-right: 6px; }
.rewind-card { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.legend.key { margin: 0 0 12px; gap: 8px 18px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .86rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.class-group + .class-group { margin-top: 18px; }
.class-group > header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.finding { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.finding + .finding { margin-top: 8px; }
.finding pre { margin: 8px 0 0; font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; color: var(--ink-2); }

/* -- rewind timeline chart ------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tl { position: relative; margin: 30px 0 8px; }
.tl .bar { position: relative; height: 34px; background: var(--surface-2); border-radius: 8px; }
.tl .seg { position: absolute; top: 0; bottom: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 35%); }
.tl .seg.tone-good { background: var(--good); }
.tl .seg.tone-warning { background: var(--warning); }
.tl .seg.tone-critical { background: var(--critical); }
.tl .seg.tone-neutral { background: var(--line-strong); }
.tl .seg.tone-info { background: var(--info); }
.tl .seg:hover { filter: brightness(1.08); z-index: 2; }
.tl .tip { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); display: none;
  background: var(--ink); color: var(--bg); font-size: .78rem; line-height: 1.35; padding: 8px 10px; border-radius: 8px;
  width: max-content; max-width: 260px; text-align: left; opacity: 0; pointer-events: none; transition: opacity .12s;
  box-shadow: var(--shadow); z-index: 5; }
.tl .tip b { display: flex; align-items: center; gap: 5px; font-weight: 600; margin-bottom: 2px; }
.tl .seg:hover .tip { display: block; opacity: 1; }
.tl .marker { position: absolute; top: -26px; bottom: -6px; width: 2px; background: var(--accent); border-radius: 2px; }
.tl .marker span { position: absolute; top: 0; left: 6px; font-size: .78rem; font-weight: 600; color: var(--accent-ink);
  white-space: nowrap; }
.tl .marker.flip span { left: auto; right: 6px; }
.tl .axis { position: relative; height: 22px; margin-top: 6px; }
.tl .axis span { position: absolute; transform: translateX(-50%); font-size: .75rem; color: var(--ink-3);
  font-family: var(--mono); }
.tl .axis span:first-child { transform: none; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--ink-2); margin-top: 4px; }
section.legend { margin-top: 16px; gap: 10px 18px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* -- steps table ----------------------------------------------------------- */
details.disclosure > summary { cursor: pointer; color: var(--ink-2); font-size: .88rem; padding: 6px 0; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .12s; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }

/* -- timeline -------------------------------------------------------------- */
.events { list-style: none; margin: 0; padding: 0 0 0 14px; position: relative; }
.events::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 8px; width: 2px; background: var(--line);
  border-radius: 2px; }
.events li { position: relative; padding: 0 0 12px 12px; font-size: .84rem; color: var(--ink-2); }
.events li::before { content: ""; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); }
.events li.k-rewinding::before, .events li.k-rewound::before { border-color: var(--accent); background: var(--accent); }
.events li.k-shipped::before { border-color: var(--good); background: var(--good); }
.events li.k-blocked::before, .events li.k-failed::before { border-color: var(--critical); background: var(--critical); }
.events time { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); display: block; }

/* -- how it works and connect ---------------------------------------------- */
/* A centred reading column; the diagram may use the full width. */
.reading > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.reading p, .reading li, .reading dd { font-size: 1rem; }
.reading .small, .reading .by, .reading .rule p { font-size: .9rem; }
.reading .card-pad > p { max-width: 66ch; }
.reading > .hero { max-width: 880px; }
.reading > .diagram { max-width: none; }
.reading > section > header { flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-bottom: 16px; }
.reading > .card > header { align-items: flex-start; text-align: left; flex-direction: row; justify-content: space-between; }
.reading .steps, .reading ul.plain { max-width: none; }
.reading .rules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .reading .rules { grid-template-columns: minmax(0, 1fr); } }
.reading .links { text-align: center; }
.diagram { margin: 0; }
.diagram svg { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.diagram figcaption { margin-top: 10px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 80ch; }
.steps > li { counter-increment: step; position: relative; padding: 14px 16px 14px 56px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink-2); }
.steps > li b { color: var(--ink); }
.steps > li::before { content: counter(step); position: absolute; left: 16px; top: 13px; width: 26px; height: 26px;
  border-radius: 50%; display: grid; place-items: center; background: var(--accent-tint); color: var(--accent-ink);
  font-weight: 700; font-size: .85rem; }
.steps > li:last-child::before { background: var(--accent); color: var(--on-accent); }
ul.plain { margin: 0; padding-left: 20px; color: var(--ink-2); display: grid; gap: 6px; max-width: 80ch; }
.card-pad > p + p, .card-pad > p { max-width: 80ch; }
.codeblock { position: relative; margin-top: 10px; }
.codeblock pre { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 52px 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: .82rem; line-height: 1.6; }
.codeblock code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }
.codeblock .copy { position: absolute; top: 8px; right: 8px; height: 32px; }
.kv.tools { margin-top: 16px; }

/* -- policy page ----------------------------------------------------------- */
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.rule { padding: 14px 16px; }
.rule .k { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); }
.rule p { font-size: .88rem; color: var(--ink-2); margin-top: 6px; }

/* -- empty state ----------------------------------------------------------- */
.empty { text-align: center; padding: 48px 24px; display: grid; gap: 8px; justify-items: center; }
.empty .big { font-size: 2.2rem; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--ink-3); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* -- responsive ------------------------------------------------------------ */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar-inner, main, footer { padding-left: 16px; padding-right: 16px; }
  footer { --gutter: 16px; }
  .crumb { display: none; }
  .nav a.hide-sm { display: none; }
  .nav { gap: 0; }
  .nav a { padding: 6px 7px; font-size: .84rem; }
  .brand span { display: none; }  /* the mark alone on phones; the nav needs the room */
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .track, .track.has-arc { padding: 8px 0 0; }
  .track .arc-head { display: none; }
  .tl .tip { left: 0; transform: none; max-width: 70vw; }
  .track .arc { display: none; }
  .track .arc-label { position: static; transform: none; margin-bottom: 14px; white-space: normal; box-shadow: none; }
  /* the return arc becomes a bracket from where production broke back up to the checkpoint */
  .track.has-arc .rail { padding-left: 22px; }
  .track .ret { display: block; position: absolute; left: 2px; width: 10px; top: calc(100% / 18);
    height: calc(100% * var(--ret) / 9); border: 3px solid var(--accent); border-right: 0; border-radius: 10px 0 0 10px; }
  .track .ret::after { content: ""; position: absolute; top: -8px; right: -10px; border-top: 6.5px solid transparent;
    border-bottom: 6.5px solid transparent; border-left: 10px solid var(--accent); }
  .track ol { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; gap: 0; }
  .track ol::before { left: 11px; right: auto; top: 12px; bottom: 12px; width: 2px; height: auto; }
  .track .progress { display: none; }
  .station { grid-template-columns: 24px 1fr auto; justify-items: start; text-align: left; align-items: center;
    gap: 12px; padding: 8px 0; }
  .table .hide-sm { display: none; }
  .table td, .table th { padding: 12px 12px; }
}
@media print {
  .topbar, footer, .icon-btn { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
