:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --ink: #141413;
  --ink-2: #55534e;
  --ink-3: #63615b;
  --rule: #d9d6cd;
  --rule-2: #e9e6de;
  --band: #efede6;
  --accent: #c2410c;
  --good: #1f6f3a;
  --bad: #a3271d;
  --warn: #8a5a00;
  --tip-bg: #141413;
  --tip-ink: #f7f6f2;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --ink: #edebe4;
    --ink-2: #a9a69d;
    --ink-3: #8c8980;
    --rule: #33322e;
    --rule-2: #24231f;
    --band: #1b1a18;
    --accent: #f0703a;
    --good: #5cb878;
    --bad: #ec6a5e;
    --warn: #d9a441;
    --tip-bg: #edebe4;
    --tip-ink: #111110;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --ink: #edebe4; --ink-2: #a9a69d; --ink-3: #8c8980;
  --rule: #33322e; --rule-2: #24231f; --band: #1b1a18; --accent: #f0703a;
  --good: #5cb878; --bad: #ec6a5e; --warn: #d9a441; --tip-bg: #edebe4; --tip-ink: #111110;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
.num, td, .v { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 40px 32px 64px; }

/* masthead */
.masthead { border-bottom: 1px solid var(--ink); padding-bottom: 20px; }
.mast-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
h1 { font-size: 44px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.mast-links { display: flex; gap: 20px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.lede { font-size: 19px; line-height: 1.4; letter-spacing: -0.01em; margin: 16px 0 6px; max-width: 60ch; }
.wip { margin: 0; color: var(--ink-2); font-size: 14px; }
.wip strong { color: var(--ink); font-weight: 600; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--rule); }
.kpi { padding: 18px 16px 16px; border-left: 1px solid var(--rule); display: flex; flex-direction: column; min-width: 0; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* status strip */
.status { border-bottom: 1px solid var(--rule); padding: 12px 0; font-family: var(--mono); font-size: 12.5px; }
.srow { display: grid; grid-template-columns: 112px 1fr auto; gap: 12px; padding: 4px 0; align-items: baseline; }
.sk { color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.sv { color: var(--ink); min-width: 0; }
.st { color: var(--ink-3); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); display: inline-block; flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot.on { animation: none; } }

/* figures */
.fig { padding-top: 40px; }
.fig-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; border-bottom: 1px solid var(--ink); padding-bottom: 8px; }
h2 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.fn { font-family: var(--mono); font-weight: 400; color: var(--ink-3); margin-right: 12px; }
.fig-meta { font-size: 12px; color: var(--ink-3); text-align: right; }

.legend { display: flex; gap: 18px; font-size: 12px; color: var(--ink-2); padding: 12px 0 4px; flex-wrap: wrap; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg-note { color: var(--ink-3); }
.lg-w { fill: var(--ink); }
.lg-l { fill: var(--bg); stroke: var(--ink); stroke-width: 1.5; }
.lg-peak { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; }

.chart { position: relative; width: 100%; height: 340px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--rule-2); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font: 400 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .band { fill: var(--band); }
.chart .band-l { fill: var(--ink-2); font: 500 11px var(--sans); }
.chart .band-sep { stroke: var(--rule); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.chart .w { fill: var(--ink); }
.chart .l { fill: var(--bg); stroke: var(--ink); stroke-width: 1.25; }
.chart .peak { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .peak-l { fill: var(--accent); font: 500 11px var(--sans); }
.chart .xh { stroke: var(--ink-3); stroke-width: 1; }
.chart .hl { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.chart .now { fill: var(--accent); }

.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--tip-bg); color: var(--tip-ink);
  font: 400 12px/1.45 var(--sans); font-variant-numeric: tabular-nums; padding: 8px 10px; border-radius: 4px; max-width: 240px;
}
.tip b { font-weight: 600; }
.tip .t2 { opacity: .7; }

/* tables */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-2); padding: 10px 12px 8px 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tbl td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.tbl .r { text-align: right; }
.tbl tr.cur td:first-child { font-weight: 600; }
.ladder td:first-child { white-space: nowrap; }
.ladder td.chg { color: var(--ink-2); min-width: 220px; }
.ladder .ci { color: var(--ink-3); white-space: nowrap; }
.ladder .tag { font-family: var(--mono); font-size: 11px; color: var(--accent); margin-left: 8px; font-weight: 400; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.tview { margin-top: 12px; font-size: 13px; }
.tview summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; }
.tview .tscroll { max-height: 360px; overflow: auto; }
.tview .tbl { font-size: 12.5px; }
.tview th { position: sticky; top: 0; background: var(--bg); }

/* ledger */
.filters { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 12px 0 4px; font-size: 13px; }
.filters button {
  font: inherit; color: var(--ink-3); background: none; border: 0; padding: 4px 0; cursor: pointer;
  border-bottom: 1px solid transparent;
}
.filters button:hover { color: var(--ink); }
.filters button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.filters .sort { margin-left: auto; color: var(--ink-2); }
.filters button:focus-visible, .tview summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ledger { table-layout: fixed; }
.ledger col.c-id, .ledger th:nth-child(1) { width: 64px; }
.ledger th:nth-child(2) { width: 52px; }
.ledger th:nth-child(3) { width: 25%; }
.ledger th:nth-child(4) { width: 34%; }
.ledger th:nth-child(5) { width: 96px; }
.ledger td { font-size: 13px; line-height: 1.45; }
.ledger td.id { font-family: var(--mono); font-size: 12px; white-space: nowrap; font-weight: 500; }
.ledger td.dt { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.ledger td.res { font-variant-numeric: tabular-nums; }
.ledger td.tk { color: var(--ink-2); }
.ledger .liveprog { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.vd { white-space: nowrap; font-size: 12.5px; font-weight: 500; }
.vd::before { display: inline-block; width: 14px; font-family: var(--mono); }
.vd.promoted { color: var(--good); } .vd.promoted::before { content: "▲"; font-size: 9px; }
.vd.null { color: var(--warn); } .vd.null::before { content: "○"; }
.vd.failed { color: var(--bad); } .vd.failed::before { content: "✕"; }
.vd.running { color: var(--accent); } .vd.running::before { content: "●"; font-size: 10px; }
.vd.baseline, .vd.merged, .vd.open, .vd.parked, .vd.shipped, .vd.active { color: var(--ink-2); }
.vd.baseline::before, .vd.merged::before, .vd.shipped::before { content: "■"; font-size: 9px; }
.vd.active::before { content: "◐"; font-size: 11px; }
.vd.open::before { content: "□"; font-size: 11px; }
.vd.parked::before { content: "‖"; }

/* spec */
.spec { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; margin: 0; }
.spec div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule-2); }
.spec dt { color: var(--ink-2); font-size: 13px; }
.spec dd { margin: 0; font-size: 13.5px; }
.spec dd .num { font-weight: 600; }

.foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--ink); font-size: 12px; color: var(--ink-3); }
.foot p { margin: 0 0 6px; max-width: 90ch; }
.foot .src { font-family: var(--mono); font-size: 11.5px; }

/* responsive */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(4) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--rule); }
  .spec { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding: 24px 16px 48px; }
  h1 { font-size: 36px; }
  .mast-links { gap: 14px; font-size: 12px; }
  .lede { font-size: 17px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px 12px 12px; }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 0; }
  .kpi:nth-child(4) { border-left: 1px solid var(--rule); padding-left: 12px; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .kpi:last-child { grid-column: 1 / -1; }
  .kpi .v { font-size: 26px; }
  .srow { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .srow .sv { grid-column: 1 / -1; grid-row: 2; }
  .fig { padding-top: 32px; }
  .fig-head { flex-direction: column; gap: 2px; }
  .fig-meta { text-align: left; }
  .chart { height: 260px; }
  .spec div { grid-template-columns: 1fr; gap: 2px; }
  /* ledger -> stacked rows */
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; }
  .ledger thead { display: none; }
  .ledger tr { display: grid; grid-template-columns: auto auto 1fr; column-gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule-2); }
  .ledger td { border: 0; padding: 0; }
  .ledger td.id { grid-column: 1; }
  .ledger td.dt { grid-column: 2; align-self: center; }
  .ledger td.vdc { grid-column: 3; grid-row: 1; text-align: right; }
  .ledger td.mt, .ledger td.res, .ledger td.tk { grid-column: 1 / -1; margin-top: 6px; }
  .ledger td.mt { font-weight: 500; }
  .filters .sort { margin-left: 0; }
}
.spec code { font-family: var(--mono); font-size: 12px; }
.ladder td.r { white-space: nowrap; }
@media (max-width: 720px) { .ladder td.chg { min-width: 200px; } }
