:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --accent: #2a78d6;
  --series-scn: #2a78d6;
  --series-base: #8a8984;
  --series-b: #eb6834;
  --series-c: #14937a;
  --series-d: #8e5ac8;
  --good: #0ca30c;
  --critical: #d03b3b;
  --grid: #e8e7e2;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #9a998f;
    --accent: #3987e5; --series-scn: #3987e5; --series-base: #8f8e86; --series-b: #d95926; --series-c: #1f9a82; --series-d: #9468d6;
    --grid: #2c2c29;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #33332f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #9a998f;
  --accent: #3987e5; --series-scn: #3987e5; --series-base: #8f8e86; --series-b: #d95926; --series-c: #1f9a82; --series-d: #9468d6;
  --grid: #2c2c29;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
header.site { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
header.site h1 { font-size: 18px; margin: 0; font-weight: 650; }
header.site nav { display: flex; gap: 18px; flex-wrap: wrap; }
header.site nav a { text-decoration: none; color: var(--text-2); font-weight: 500; }
header.site nav a[aria-current="page"] { color: var(--text); border-bottom: 2px solid var(--accent); }
.wrap { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }
.intro { color: var(--text-2); max-width: 900px; margin: 0 0 16px; }
.layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.layout > * { min-width: 0; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } .wrap { padding: 16px; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.controls { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
@media (max-width: 960px) { .controls { position: static; max-height: none; } }
.controls h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin: 18px 0 8px; }
.controls h2:first-child { margin-top: 0; }
.ctl { margin: 10px 0 14px; }
.ctl label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 500; }
.ctl label output { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; white-space: nowrap; }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctl select { width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.ctl .help { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
button, .btn { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .name { font-size: 13px; color: var(--text-2); }
.kpi .val { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
.kpi .sub { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.delta-up::before { content: "▲ "; } .delta-down::before { content: "▼ "; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; }
.chart-card .cap { color: var(--text-3); font-size: 13px; margin: 0 0 8px; }
.chart-box { position: relative; height: 280px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.mini-h { font-size: 14px; margin: 4px 0 6px; font-weight: 600; }
.status { font-size: 13px; color: var(--text-3); min-height: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc { max-width: 900px; }
.doc h2 { margin-top: 32px; } .doc h3 { margin-top: 22px; }
.doc code, .doc pre { background: var(--surface-2); border-radius: 4px; padding: 1px 4px; font-size: 13px; }
.doc pre { padding: 10px 12px; overflow-x: auto; }
.callout { border-left: 3px solid var(--accent); background: var(--surface); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin: 14px 0; }
.callout.warn { border-left-color: var(--critical); }
details summary { cursor: pointer; font-weight: 600; }
.table-scroll { overflow-x: auto; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
footer { color: var(--text-3); font-size: 13px; margin-top: 30px; }

[hidden] { display: none !important; }
.pass { color: var(--good); font-weight: 600; white-space: nowrap; }
.fail { color: var(--critical); font-weight: 600; white-space: nowrap; }
.na { color: var(--text-3); white-space: nowrap; }

/* blog */
.blog article { max-width: 980px; margin: 0 auto; }
.blog article > p, .blog article > ul, .blog .lede { max-width: 760px; }
.blog h1 { font-size: 34px; line-height: 1.2; margin: 6px 0 12px; letter-spacing: -0.01em; }
.blog h2 { margin-top: 40px; font-size: 23px; }
.blog p, .blog li { font-size: 16.5px; line-height: 1.65; }
.blog .kicker { color: var(--text-3); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; margin: 0; }
.blog .lede { font-size: 19px; color: var(--text-2); }
.blog figure { margin: 18px 0; }
.blog .chart-card details { margin-top: 8px; font-size: 13px; }
.blog .chart-card details summary { font-weight: 500; color: var(--text-2); }
.blog details.chart-card summary { font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 22px 0; }
.chart-box.tall { height: 380px; }
@media (max-width: 760px) { .blog h1 { font-size: 27px; } .chart-box.tall { height: 340px; } .blog .lede { font-size: 17px; } }
.legend span.dash::before { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.chart-box.bars { height: 560px; }

/* ---------- simulator page: results hierarchy, change labels, controls ---------- */
@media (max-width: 760px) {
  header.site { padding: 10px 16px; gap: 6px; }
  header.site h1 { font-size: 16px; }
  header.site nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; gap: 16px; padding-bottom: 2px; scrollbar-width: none; }
  header.site nav a { white-space: nowrap; }
}
.preset-group h2 { margin: 0 0 6px; }
.preset-group h2 + .presets + h2 { margin-top: 10px; }
.presets button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
details.sec { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 10px; }
details.sec > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 0; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::before { content: "▸"; color: var(--text-3); font-size: 12px; transition: transform .15s; }
details.sec[open] > summary::before { transform: rotate(90deg); }
details.sec > summary h2 { margin: 0 !important; }
.sec-count { font-size: 12px; color: var(--accent); font-weight: 600; }
.ctl { position: relative; }
.ctl-head { display: flex; align-items: center; gap: 6px; }
.ctl-head label { flex: 1; font-size: 14px; font-weight: 500; display: block; }
.ctl-head output { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ctl-head .num-in { width: 92px; font: inherit; font-size: 14px; font-weight: 600; text-align: right; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-variant-numeric: tabular-nums; }
.ctl .info, .ctl .undo { width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 12px; line-height: 20px; flex: none;
  color: var(--text-2); background: transparent; }
.ctl .info { font-style: italic; font-family: Georgia, serif; font-weight: 700; }
.ctl .info[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.ctl .undo { visibility: hidden; }
.ctl.changed .undo { visibility: visible; }
.ctl.changed::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--accent); }
.ctl .help { margin-top: 4px; }
.ctl-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.seg { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg-label { font-size: 12px; color: var(--text-3); padding: 0 8px 0 10px; }
.seg button { border: 0; border-left: 1px solid var(--border); border-radius: 0; background: transparent; padding: 6px 10px; }
.seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
.seg-help { font-size: 12px; padding: 0 10px; border-left: 1px solid var(--border); }
.sys-note { font-size: 13px; color: var(--text-3); margin: 0 0 10px; }
.headline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) { .headline { grid-template-columns: 1fr; } }
.kpi.big { padding: 16px 18px; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.kpi.big .name { font-size: 14px; font-weight: 600; color: var(--text); }
.kpi.big .val { font-size: 38px; line-height: 1.1; margin: 4px 0 2px; }
.kpi .unit { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.kpi .range { color: var(--text-3); white-space: nowrap; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis .kpi .val { font-size: 22px; }
.chg { display: inline-block; font-size: 12.5px; font-weight: 500; margin-top: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chg.better { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.chg.worse { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.chg b { font-weight: 700; }
#resultsBody, #sweepCard, .mbar { transition: opacity .15s; }
#resultsBody.stale, #sweepCard.stale { opacity: .45; }
.status { font-weight: 500; }
.chart-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { font-size: 13px; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
#inputsTable tr.diff td { background: color-mix(in srgb, var(--accent) 9%, transparent); font-weight: 600; }
.mbar { display: none; }
@media (max-width: 960px) {
  .mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; gap: 8px; align-items: center;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgb(0 0 0 / .08); transform: translateY(0); transition: transform .2s, opacity .15s; }
  .mbar.hide { transform: translateY(110%); }
  .mbar.stale { opacity: .55; }
  .mbar-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; flex: 1; min-width: 0; }
  .mbar-items > div { min-width: 0; display: flex; flex-direction: column; font-size: 11px; color: var(--text-3); }
  .mbar-items b { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
  .mbar-items .chg { font-size: 11px; line-height: 1.25; margin-top: 2px; padding: 1px 0; background: none; }
  .mbar-go { font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; }
  body { padding-bottom: 84px; }
}
@media (max-width: 520px) { .seg-label { display: none; } .seg button { padding: 6px 9px; } }

/* blog narrative: summary box, bridging sentences between sections, folded secondary material */
.callout.brief ul { margin: 6px 0 0; padding-left: 20px; }
.callout.brief li { margin: 4px 0; }
.blog .bridge { font-style: italic; color: var(--text-2); }
details.more { margin: 12px 0; }
details.more > summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; }
