:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --banner: #eef4fc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #141413;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #95948b;
    --grid: #2f2f2d;
    --axis: #4a4a46;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --banner: #1f2a38;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141413;
  --surface: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #95948b;
  --grid: #2f2f2d;
  --axis: #4a4a46;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --banner: #1f2a38;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
code { font-size: 0.9em; background: var(--grid); padding: 1px 5px; border-radius: 4px; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); padding-top: 28px; }
.eyebrow { margin: 0; color: var(--text-muted); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
h1 { margin: 6px 0 8px; font-size: clamp(22px, 3.2vw, 32px); line-height: 1.2; text-wrap: balance; }
.lede { margin: 0 0 12px; max-width: 780px; color: var(--text-secondary); }
.banner { margin: 0 0 16px; max-width: 780px; background: var(--banner); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 8px 12px; font-size: 13.5px; color: var(--text-secondary); }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; align-items: center; }
.tabs a, .theme-toggle {
  color: var(--text-secondary); text-decoration: none; font-weight: 600; padding: 10px 14px; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--text-primary); border-bottom-color: var(--accent); }
.tabs a:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.theme-toggle { appearance: none; background: none; border: 0; font: inherit; font-size: 13px; cursor: pointer; margin-left: auto; color: var(--text-muted); }
.theme-toggle:hover { color: var(--text-primary); }

main { padding-top: 24px; padding-bottom: 24px; }
.section { display: grid; gap: 16px; margin-bottom: 36px; }
.section-title { margin: 8px 0 0; font-size: 20px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2 > .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 18px 12px; min-width: 0;
}
.card h2 { margin: 0; font-size: 16px; }
.card .sub { margin: 2px 0 8px; color: var(--text-secondary); font-size: 13px; max-width: 900px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.controls { display: flex; gap: 12px; flex-wrap: wrap; }
.fig { margin: 4px 0 6px; }
.fig img { display: block; width: 100%; height: auto; border-radius: 8px; }
.fig .png { display: inline-block; font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.fig .png:hover { color: var(--accent); }
.fallback { color: var(--text-muted); font-size: 13px; }

.plot { width: 100%; height: 340px; }
.plot-auto { height: auto; min-height: 200px; }
#ladder { height: 250px; }
@media (max-width: 900px) { .plot { height: 300px; } .plot-auto { height: auto; } #ladder { height: 240px; } }
.plot .modebar { background: none !important; }
.plot .modebar-btn path { fill: var(--text-muted) !important; }
.plot .modebar-btn:hover path { fill: var(--text-primary) !important; }

.note { color: var(--text-muted); font-size: 13px; }
.findings { padding-left: 20px; margin: 8px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
@media (max-width: 900px) { .findings { grid-template-columns: minmax(0, 1fr); } }
.findings li { margin-bottom: 10px; color: var(--text-secondary); }

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 30px; font-weight: 650; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .detail { color: var(--text-muted); font-size: 12.5px; }

.control { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
select {
  font: inherit; font-size: 14px; color: var(--text-primary); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 6px 10px; min-width: 150px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.table-wrap { overflow-x: auto; margin: 8px 0 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td.left, th.left { text-align: left; white-space: normal; min-width: 6em; }
.ladder-table td:nth-child(2) { min-width: 9em; }
.ladder-table td:nth-child(3) { min-width: 18em; }
th { color: var(--text-secondary); font-weight: 600; background: var(--surface); }
th button { appearance: none; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; text-align: inherit; }
th button::after { content: ""; display: inline-block; width: 1em; color: var(--text-muted); }
th[aria-sort="ascending"] button::after { content: " \2191"; }
th[aria-sort="descending"] button::after { content: " \2193"; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
td .sd { color: var(--text-muted); }
details { margin: 6px 0; font-size: 13px; }
summary { cursor: pointer; color: var(--text-secondary); font-weight: 600; }

.footer { color: var(--text-muted); font-size: 13px; padding-bottom: 32px; border-top: 1px solid var(--border); padding-top: 12px; }
