/* Open-model staircase — shared styles. Palette: dataviz reference instance. */
:root {
  color-scheme: light;
  --surface-0: #f6f5f1;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --line: #e8e7e3;
  --line-strong: #d6d4cd;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7c7a73;
  --series-1: #2a78d6;   /* blue  — the staircase */
  --series-2: #eb6834;   /* orange — alternative / own */
  --series-3: #1baf7a;   /* aqua  — closed frontier reference */
  --context: #b4b2ab;    /* gray  — everything else */
  --accent-soft: #e6f0fc;
  --warn: #b25e00;
  --warn-soft: #fdf1e1;
  --good: #137a4b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #222220;
    --line: #2f2f2c; --line-strong: #44443f;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --context: #5d5c57;
    --accent-soft: #1b2a3d; --warn: #f0a548; --warn-soft: #2e2416; --good: #4cc38a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #222220;
  --line: #2f2f2c; --line-strong: #44443f;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --context: #5d5c57;
  --accent-soft: #1b2a3d; --warn: #f0a548; --warn-soft: #2e2416; --good: #4cc38a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 16px/1.6 var(--sans); font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--series-1); text-decoration-thickness: 1px; text-underline-offset: 3px; }
code { font: .88em var(--mono); background: var(--surface-2); border: 1px solid var(--line); padding: .05em .35em; border-radius: 5px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(1.4) blur(12px);
  background: color-mix(in srgb, var(--surface-0) 82%, transparent); border-bottom: 1px solid var(--line);
}
.nav-inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 58px; display: flex; align-items: center; gap: 28px; }
.brand { font: 600 15px var(--sans); color: var(--text-primary); text-decoration: none; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(4, 5px); align-items: end; gap: 2px; height: 18px; }
.brand-mark i { display: block; background: var(--series-1); border-radius: 1.5px 1.5px 0 0; }
.brand-mark i:nth-child(1){height:6px}.brand-mark i:nth-child(2){height:10px}.brand-mark i:nth-child(3){height:14px}.brand-mark i:nth-child(4){height:18px}
.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a { color: var(--text-secondary); text-decoration: none; font-size: 14px; padding: 7px 12px; border-radius: 8px; }
.nav-links a:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-links a[aria-current="page"] { color: var(--text-primary); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.theme-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text-secondary); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.prose { max-width: 720px; margin: 0 auto; }
.hero { padding: 72px 0 40px; border-bottom: 1px solid var(--line); }
.kicker { font: 600 12px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--series-1); }
h1 { font: 600 clamp(36px, 5.2vw, 60px)/1.05 var(--serif); letter-spacing: -.02em; margin: 14px 0 18px; text-wrap: balance; }
h2 { font: 600 30px/1.2 var(--serif); letter-spacing: -.01em; margin: 64px 0 14px; text-wrap: balance; }
h3 { font: 600 19px/1.35 var(--sans); margin: 28px 0 8px; letter-spacing: -.01em; }
.dek { font: 400 20px/1.55 var(--serif); color: var(--text-secondary); max-width: 720px; margin: 0; }
.byline { margin-top: 26px; font-size: 13.5px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.prose p, .prose li { font: 18px/1.72 var(--serif); color: var(--text-primary); }
.prose p { margin: 0 0 1.1em; }
.prose strong { font-weight: 650; }
.muted { color: var(--text-muted); }
.small { font-size: 13.5px; }

/* ---------- cards / tiles ---------- */
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.grid { display: grid; gap: 16px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.tile-label { font-size: 12.5px; color: var(--text-secondary); }
.tile-value { font: 600 26px/1.15 var(--sans); letter-spacing: -.02em; margin-top: 6px; }
.tile-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ---------- staircase hero figure ---------- */
.figure { margin: 36px 0; }
.figure-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.figure-title { font: 600 15px var(--sans); }
.figure-note { font-size: 12.5px; color: var(--text-muted); }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--text-secondary); }
.chart .axis line, .chart .axis path { stroke: var(--line-strong); }
.chart .grid line { stroke: var(--line); }
.chart .label-strong { fill: var(--text-primary); font-weight: 600; }

/* segmented controls */
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: transparent; color: var(--text-secondary); padding: 6px 12px; font: 500 13px var(--sans); border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.06); }

/* step cards */
.steps { display: grid; gap: 18px; margin: 28px 0; }
.step { display: grid; grid-template-columns: 88px 1fr; gap: 0; overflow: hidden; }
.step-rail { background: var(--accent-soft); display: flex; flex-direction: column; align-items: center; padding: 22px 0; gap: 6px; }
.step-num { font: 600 34px/1 var(--serif); color: var(--series-1); }
.step-rail small { font-size: 11px; color: var(--text-secondary); letter-spacing: .08em; text-transform: uppercase; }
.step-body { padding: 22px 26px 24px; }
.step-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.step-title h3 { margin: 0; font: 600 23px/1.25 var(--serif); }
.pill { font: 500 12px var(--sans); color: var(--text-secondary); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: var(--surface-2); }
.step-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin: 16px 0 14px; }
.stat { border-left: 2px solid var(--line); padding: 2px 0 2px 10px; }
.stat b { display: block; font: 600 18px/1.2 var(--sans); }
.stat span { font-size: 12px; color: var(--text-muted); }
.step p { font: 16.5px/1.65 var(--serif); margin: 0 0 .8em; }
.runs { font-size: 14.5px !important; font-family: var(--sans) !important; color: var(--text-secondary); }
.runs b { color: var(--text-primary); }
.bar-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-secondary); margin: 4px 0; }
.bar-track { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 999px; }
.bar-fill.ref { background: var(--series-3); }
.bar-row .v { text-align: right; color: var(--text-primary); font-weight: 600; }

.callout { border-radius: 14px; padding: 18px 20px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 15px; line-height: 1.6; }
.callout b { color: var(--warn); }
.note { border-left: 3px solid var(--series-1); padding: 4px 0 4px 16px; margin: 18px 0; color: var(--text-secondary); font-size: 15px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-1); max-height: 640px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: inherit; }
thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-secondary); cursor: pointer; user-select: none; z-index: 1; }
thead th:first-child { z-index: 2; background: var(--surface-2); }
#cost-table th { white-space: normal; vertical-align: bottom; }
thead th[aria-sort="descending"]::after { content: " ↓"; } thead th[aria-sort="ascending"]::after { content: " ↑"; }
tbody tr { background: var(--surface-1); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--series-1); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }

/* ---------- dashboard / calculator controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: end; padding: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.field label, .field .lab { font: 500 12.5px var(--sans); color: var(--text-secondary); }
select, input[type="number"], input[type="search"], input[type="text"] {
  font: 14px var(--sans); color: var(--text-primary); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 10px; min-height: 38px;
}
input[type="range"] { accent-color: var(--series-1); width: 100%; }
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-secondary); }
.calc { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
.calc-panel { position: sticky; top: 76px; padding: 20px; display: grid; gap: 16px; }
.calc-panel h3 { margin: 4px 0 -4px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.range-row { display: grid; grid-template-columns: 1fr 64px; gap: 10px; align-items: center; }
.range-row output { font: 600 14px var(--sans); text-align: right; }
.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; font-size: 14.5px; line-height: 1.5; }
.verdict.ok { background: color-mix(in srgb, var(--good) 12%, transparent); }
.verdict.bad { background: var(--warn-soft); }
.verdict .ic { font-weight: 700; font-size: 16px; }
.verdict.ok .ic { color: var(--good); } .verdict.bad .ic { color: var(--warn); }
.gpu-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.gpu { width: 46px; height: 30px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); position: relative; overflow: hidden; }
.gpu .w { position: absolute; left: 0; bottom: 0; top: 0; background: var(--series-1); opacity: .9; }
.gpu .k { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--series-1) 35%, transparent); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* tooltip */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow); opacity: 0; transition: opacity .08s; max-width: 280px; }
.tip b { font-weight: 600; }
.tip .t-h { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.tip .t-r { display: flex; justify-content: space-between; gap: 18px; color: var(--text-secondary); }
.tip .t-r span:last-child { color: var(--text-primary); font-weight: 600; }

.sources { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; }
.sources li { font: 14px/1.7 var(--sans) !important; color: var(--text-secondary) !important; }
footer { margin-top: 90px; padding: 34px 0 60px; border-top: 1px solid var(--line); color: var(--text-muted); font-size: 13px; }

@media (max-width: 900px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .calc-panel { position: static; }
  .step { grid-template-columns: 1fr; }
  .step-rail { flex-direction: row; justify-content: flex-start; padding: 12px 22px; }
  .nav-links a { padding: 7px 7px; font-size: 13px; white-space: nowrap; }
  .nav-inner { gap: 10px; padding: 0 14px; }
  .brand-text { display: none; }
  .wrap { padding: 0 16px; }
  .card-pad { padding: 16px; }
  .step-body { padding: 18px; }
  .toolbar .field { min-width: 0; flex: 1 1 100%; }
}
@media (forced-colors: active) { .bar-fill, .gpu .w { background: Highlight; } }
@media print { .nav, .theme-btn { display: none; } body { background: #fff; } }
