/* ============================================================ tokens */
:root {
  color-scheme: light;
  --page: #f3f0e8;
  --surface: #fffdf8;
  --surface-2: #f2eee5;
  --surface-3: #e8e2d5;
  --ink: #17140f;
  --ink-2: #57524a;
  --muted: #6f6a62;            /* 4.6:1+ on every light surface (WCAG AA) */
  --brand-ink: #ae4f21;        /* brand orange dark enough for small text */
  --accent-ink: #256bbe;       /* accent blue for text and small filled controls */
  --on-accent: #ffffff;
  --control-border: #8d897e;   /* 3:1 so inputs and selects have a visible edge */
  --line: #e6e0d3;
  --line-strong: #d3ccbc;
  --header-bg: #14213d;
  --header-ink: #f6f2e9;
  --header-ink-2: #a8b2c6;
  --brand: #e8692c;
  --shadow: 0 1px 2px rgba(23, 20, 15, .05), 0 4px 16px rgba(23, 20, 15, .04);
  --shadow-pinned: 0 10px 30px rgba(23, 20, 15, .16);

  /* chart roles (validated categorical slots 1-2, diverging blue/red) */
  --grid: #ece7dc;
  --axis: #cfc8b8;
  --accent: #2a78d6;
  --accent-2: #eb6834;
  --accent-track: #dde9f8;
  --dim-dot: #cbc4b5;
  --pos: #2a78d6;
  --neg: #e34948;
  --good-text: #1d7a1d;
  --bad-text: #b3261e;

  --header-h: 60px;
  --pin-h: 0px;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Inter", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e1218; --surface: #151b23; --surface-2: #1c242e; --surface-3: #27313d;
    --ink: #eef1f4; --ink-2: #b3bcc7; --muted: #838d99; --brand-ink: #f07a3e; --accent-ink: #3987e5; --on-accent: #0e1218; --control-border: #5d6773; --line: #232c37; --line-strong: #344150;
    --header-bg: #090d12; --header-ink: #eef1f4; --header-ink-2: #8a95a5; --brand: #f07a3e;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-pinned: 0 10px 30px rgba(0,0,0,.5);
    --grid: #212a34; --axis: #3a4655; --accent: #3987e5; --accent-2: #d95926; --accent-track: #1d3352;
    --dim-dot: #3b4653; --pos: #3987e5; --neg: #e66767; --good-text: #3fbf3f; --bad-text: #ef7a7a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1218; --surface: #151b23; --surface-2: #1c242e; --surface-3: #27313d;
  --ink: #eef1f4; --ink-2: #b3bcc7; --muted: #838d99; --brand-ink: #f07a3e; --accent-ink: #3987e5; --on-accent: #0e1218; --control-border: #5d6773; --line: #232c37; --line-strong: #344150;
  --header-bg: #090d12; --header-ink: #eef1f4; --header-ink-2: #8a95a5; --brand: #f07a3e;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-pinned: 0 10px 30px rgba(0,0,0,.5);
  --grid: #212a34; --axis: #3a4655; --accent: #3987e5; --accent-2: #d95926; --accent-track: #1d3352;
  --dim-dot: #3b4653; --pos: #3987e5; --neg: #e66767; --good-text: #3fbf3f; --bad-text: #ef7a7a;
}

/* ============================================================ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-top: calc(var(--header-h) + var(--pin-h) + 56px); }
body { background: var(--page); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================ top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--header-bg); color: var(--header-ink); height: var(--header-h); }
.topbar-inner { max-width: 1280px; height: 100%; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 24px/1 var(--display); letter-spacing: .02em; text-transform: uppercase; }
.brand b { color: var(--brand); font-weight: 700; margin-left: 2px; }
.brand-ball { width: 28px; height: 28px; flex: none; }
.tabs { display: flex; gap: 6px; flex: 1; height: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: flex; align-items: center; padding: 0 12px; text-decoration: none; color: var(--header-ink-2); font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.tabs a:hover { color: var(--header-ink); }
.tabs a.active { color: var(--header-ink); border-bottom-color: var(--brand); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle { background: transparent; border-color: rgba(255,255,255,.18); color: var(--header-ink-2); }
.theme-toggle:hover { background: rgba(255,255,255,.08); color: var(--header-ink); }
.theme-toggle .moon { fill: currentColor; stroke: none; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: inline; }
}

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 24px; }
.loading { color: var(--muted); }

/* ============================================================ headings */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: 2px; }
.page-head h1, .hero h1 { margin: 0; font: 700 44px/1 var(--display); letter-spacing: .005em; text-transform: uppercase; }
.page-head p { margin: 8px 0 0; color: var(--ink-2); max-width: 68ch; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* ============================================================ toolbar / filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.toolbar .spacer { flex: 1; }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.select, .input {
  height: 38px; border: 1px solid var(--control-border); background: var(--surface); border-radius: 10px; padding: 0 12px; color: var(--ink);
}
.select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.input.num { width: 76px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* search combobox */
.combo { position: relative; flex: 1 1 280px; max-width: 380px; }
.combo .input { width: 100%; padding-left: 36px; }
.combo .search-ico { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; pointer-events: none; }
.combo ul { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-pinned); max-height: 360px; overflow: auto; }
.combo li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.combo li img { width: 24px; height: 24px; object-fit: contain; }
.combo li .c-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo li .c-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.combo li[aria-selected="true"] { background: var(--surface-2); }
.combo li.empty { color: var(--muted); cursor: default; }

/* ============================================================ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card h2 { margin: 0; font: 700 22px/1.1 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.card .sub { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.section-title h2 { margin: 0; font: 700 26px/1 var(--display); text-transform: uppercase; }
.section-title span { color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* chart card: pinnable + resizable */
.chart-card { padding-bottom: 0; position: relative; }
.chart-card .tools { display: flex; gap: 6px; flex: none; }
/* The 8px page-colored halo hides table rows scrolling through the gaps above and below the pinned card. */
.chart-card.pinned { position: sticky; top: calc(var(--header-h) + 8px); z-index: 12; box-shadow: 0 0 0 8px var(--page), var(--shadow-pinned); }
.chart-card.pinned .sub { display: none; }
.chart-body { position: relative; width: 100%; min-height: 200px; }
.chart-body svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chart-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 6px 0 2px; }
.hint { color: var(--muted); font-size: 12px; }
.resize-handle { height: 16px; margin: 0 -20px; display: grid; place-items: center; cursor: ns-resize; border-top: 1px solid transparent; touch-action: none; }
.resize-handle::before { content: ""; width: 44px; height: 4px; border-radius: 4px; background: var(--line-strong); transition: background .15s; }
.resize-handle:hover::before, .resize-handle:focus-visible::before, .resize-handle.dragging::before { background: var(--muted); }
.resize-handle:focus-visible { outline: none; }
.stack-gap { margin-bottom: 18px; }
.btn-quiet { height: 32px; padding: 0 12px; font-size: 13px; color: var(--ink-2); background: transparent; }

/* modules: a 12-column row; each module sets --off and --span (see resizable() in app.js) */
.modules { --mg: 18px; display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: var(--mg); }
.mod { margin-bottom: 24px; }
.mod-break { flex-basis: 100%; height: 0; }
.mod {
  --off: 0; --span: 12; flex: none; min-width: 0;
  width: calc((100% - 11 * var(--mg)) * var(--span) / 12 + (var(--span) - 1) * var(--mg));
  margin-left: calc(((100% - 11 * var(--mg)) / 12 + var(--mg)) * var(--off));
}
.resizable { position: relative; }
.rz { position: absolute; z-index: 4; touch-action: none; }
.rz-n, .rz-s { left: 18px; right: 18px; height: 14px; cursor: ns-resize; }
.rz-n { top: -7px; } .rz-s { bottom: -7px; }
.rz-e, .rz-w { top: 18px; bottom: 18px; width: 14px; cursor: ew-resize; }
.rz-e { right: -7px; } .rz-w { left: -7px; }
.rz-ne, .rz-nw, .rz-se, .rz-sw { width: 22px; height: 22px; }
.rz-ne { top: -8px; right: -8px; cursor: nesw-resize; } .rz-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.rz-nw { top: -8px; left: -8px; cursor: nwse-resize; } .rz-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
@media (pointer: coarse) { /* fingers need bigger targets */
  .rz-n, .rz-s { height: 26px; } .rz-n { top: -13px; } .rz-s { bottom: -13px; }
  .rz-e, .rz-w { width: 26px; } .rz-e { right: -13px; } .rz-w { left: -13px; }
  .rz-ne, .rz-nw, .rz-se, .rz-sw { width: 32px; height: 32px; }
}
/* Grips: faint marks on each edge and corner while the pointer is over the module... */
.rz::before { content: ""; position: absolute; opacity: 0; transition: opacity .15s, background .15s, border-color .15s; }
.rz-e::before, .rz-w::before { top: calc(50% - 22px); height: 44px; width: 4px; left: calc(50% - 2px); border-radius: 4px; background: var(--line-strong); }
.rz-n::before { left: calc(50% - 22px); width: 44px; height: 4px; top: calc(50% - 2px); border-radius: 4px; background: var(--line-strong); }
.rz-ne::before, .rz-nw::before, .rz-se::before, .rz-sw::before { width: 9px; height: 9px; border: 0 solid var(--line-strong); }
.rz-se::before { right: 8px; bottom: 8px; border-right-width: 3px; border-bottom-width: 3px; border-bottom-right-radius: 5px; }
.rz-sw::before { left: 8px; bottom: 8px; border-left-width: 3px; border-bottom-width: 3px; border-bottom-left-radius: 5px; }
.rz-ne::before { right: 8px; top: 8px; border-right-width: 3px; border-top-width: 3px; border-top-right-radius: 5px; }
.rz-nw::before { left: 8px; top: 8px; border-left-width: 3px; border-top-width: 3px; border-top-left-radius: 5px; }
.resizable:hover > .rz::before, .resizable:focus-within > .rz::before, .resizing > .rz::before { opacity: 1; }
/* ...and the one you're on turns orange, with a line along that edge. */
.rz:hover::before, .rz.dragging::before { background: var(--brand); border-color: var(--brand); }
.rz::after { content: ""; position: absolute; background: var(--brand); border-radius: 3px; opacity: 0; transition: opacity .12s; }
.rz-n::after, .rz-s::after { left: 0; right: 0; height: 2px; top: calc(50% - 1px); }
.rz-e::after, .rz-w::after { top: 0; bottom: 0; width: 2px; left: calc(50% - 1px); }
.rz-n:hover::after, .rz-s:hover::after, .rz-e:hover::after, .rz-w:hover::after, .rz.dragging::after { opacity: .6; }
.rz-ne::after, .rz-nw::after, .rz-se::after, .rz-sw::after { display: none; }
.resizing, .resizing * { user-select: none; }
.chart-card.pinned > .rz-n, .chart-card.pinned > .rz-ne, .chart-card.pinned > .rz-nw { display: none; } /* top edge is locked under the header */
.table-wrap.fit.scroll { overflow-x: auto; }
.table-wrap.fit.scroll table.data th { position: static; }

/* ============================================================ chart internals */
.chart-body .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-body .axis-line, .chart .axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.axis-title.has-help { cursor: help; }
.axis-title.has-help:hover, .axis-title.has-help:focus { fill: var(--ink); outline: none; }
.axis-title .info { fill: var(--accent-ink); font-weight: 700; }
.iso { stroke: var(--grid); stroke-width: 1; }
.iso-label { fill: var(--muted); font-size: 10px; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot-label { fill: var(--ink); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.sel-ring { fill: var(--surface); stroke: var(--accent-2); stroke-width: 2.5; }
.zero { stroke: var(--axis); stroke-width: 1; }
.median-line { stroke: var(--ink-2); stroke-width: 1.25; stroke-dasharray: 5 4; opacity: .7; }
.median-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend .key.bar { border-radius: 2px; }
.legend .key.key-dash { width: 18px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--ink-2); vertical-align: 3px; }

/* tooltip */
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; box-shadow: var(--shadow-pinned); max-width: 300px; }
.tooltip .tt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tooltip .tt-head img { width: 26px; height: 26px; object-fit: contain; }
.tooltip .tt-title { font-weight: 700; font-size: 13px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; line-height: 1.6; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip .tt-row span { color: var(--ink-2); }
.tooltip .tt-hint { margin-top: 6px; color: var(--muted); font-size: 11px; }
.tooltip.help { max-width: 340px; }
.tooltip .tt-plain { color: var(--ink-2); margin: 0 0 8px; line-height: 1.45; }
.tooltip .tt-label { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.tooltip .tt-formula { font: 12px/1.5 var(--mono); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; white-space: pre-wrap; color: var(--ink); }

/* ============================================================ tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
/* "fit" tables don't scroll sideways on desktop, so their header can stick to the page while you scroll. */
.table-wrap.fit { overflow: visible; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line-strong); }
.table-wrap.fit table.data th { position: sticky; top: calc(var(--header-h) + var(--pin-h)); z-index: 5; }
table.data thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
table.data thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
table.data th.has-help { text-decoration: underline dotted var(--line-strong); text-underline-offset: 4px; }
table.data th:hover { color: var(--ink); }
table.data th.l, table.data td.l { text-align: left; }
table.data th[aria-sort] { color: var(--ink); }
table.data th[aria-sort="descending"]::after { content: " ↓"; color: var(--brand-ink); }
table.data th[aria-sort="ascending"]::after { content: " ↑"; color: var(--brand-ink); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background-color: var(--surface-2); }
table.data tbody tr.selected td { background-color: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
table.data tbody tr.selected td:first-child { box-shadow: inset 4px 0 0 var(--brand); }
table.data tbody tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background-color: color-mix(in srgb, var(--brand) 38%, var(--surface)); } 100% { background-color: color-mix(in srgb, var(--brand) 12%, var(--surface)); } }
table.data td .rk { color: var(--muted); font-size: 11px; margin-left: 5px; display: inline-block; min-width: 24px; text-align: left; }
table.data td.rank { color: var(--muted); font-weight: 600; width: 44px; }
table.data .team-cell { display: inline-flex; align-items: center; gap: 10px; }
table.data .team-cell img { width: 26px; height: 26px; object-fit: contain; flex: none; }
table.data a { text-decoration: none; font-weight: 600; }
table.data a:hover { color: var(--brand-ink); }
table.data .muted { color: var(--muted); }
.conf-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500; }
td.em { font-weight: 700; }
.pill-w { color: var(--good-text); font-weight: 700; }
.pill-l { color: var(--bad-text); font-weight: 700; }
.more { margin-top: 12px; text-align: center; }
.btn { height: 38px; border: 1px solid var(--control-border); background: var(--surface); border-radius: 10px; padding: 0 16px; cursor: pointer; font-weight: 500; }
.btn:hover { background: var(--surface-2); }

/* ============================================================ team / player pages */
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin-bottom: 20px; }
.hero img { width: 76px; height: 76px; object-fit: contain; }
.hero .meta { color: var(--ink-2); margin-top: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.stat .value { font: 700 36px/1.05 var(--display); letter-spacing: .01em; margin-top: 2px; }
.stat .note { color: var(--ink-2); font-size: 12px; }

.meters { display: grid; gap: 9px; }
.meter { display: grid; grid-template-columns: 120px minmax(0, 1fr) 96px; align-items: center; gap: 12px; font-size: 13px; }
.meter .m-label { color: var(--ink-2); }
.meter .m-track { height: 8px; border-radius: 999px; background: var(--accent-track); overflow: hidden; }
.meter .m-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter .m-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter .m-val small { color: var(--muted); margin-left: 5px; font-weight: 400; }
.meters h3 { margin: 10px 0 2px; font: 700 15px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }

/* matchup */
.vs { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 16px; align-items: center; padding: 8px 0; }
.vs .side { text-align: center; }
.vs .side img { width: 84px; height: 84px; object-fit: contain; }
.vs .side a { font-weight: 700; text-decoration: none; font-size: 17px; }
.vs .score { font: 700 72px/1 var(--display); letter-spacing: .01em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.vs .vs-mid { color: var(--ink-2); text-align: center; }
.vs .vs-mid .line { font: 700 22px/1.1 var(--display); text-transform: uppercase; color: var(--ink); }
.prob-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 8px 0 4px; }
.prob-bar div { min-width: 3px; }
.prob-legend { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; color: var(--ink-2); font-size: 13px; }
.prob-side { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.prob-side.r { justify-content: flex-end; text-align: right; }
.prob-side b { font: 700 30px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.prob-legend .key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }

/* about */
.prose { max-width: 76ch; }
.prose h2 { font: 700 24px/1.1 var(--display); text-transform: uppercase; margin: 32px 0 8px; }
.prose dt { font-weight: 700; margin-top: 12px; }
.prose dd { margin: 2px 0 0; color: var(--ink-2); }
.prose code, .prose .formula { font: 13px var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.prose p, .prose li { color: var(--ink-2); }

.foot { max-width: 1280px; margin: 0 auto; padding: 8px 24px 40px; color: var(--muted); font-size: 12px; }

/* ============================================================ small screens */
@media (max-width: 1000px) {
  .table-wrap.fit { overflow-x: auto; }               /* sideways scroll wins over a sticky header */
  .table-wrap.fit table.data th { position: static; }
}
/* Phones (narrow AND touch): stack every module full width; only the height can change.
   A narrow desktop window, like a side panel, keeps full resizing. */
@media (max-width: 760px) and (pointer: coarse) {
  .mod { width: 100%; margin-left: 0; }
  .rz-e, .rz-w, .rz-ne, .rz-nw, .rz-se, .rz-sw, .rz-n { display: none; }
}
@media (max-width: 640px) {
  :root { --header-h: 54px; }
  .topbar-inner { padding: 0 16px; gap: 14px; }
  .brand { font-size: 20px; }
  .brand span { display: none; }
  main { padding: 20px 16px; }
  .foot { padding: 8px 16px 32px; }
  .page-head h1, .hero h1 { font-size: 34px; }
  .card { padding: 14px 14px 0; }
  .card:not(.chart-card) { padding-bottom: 14px; }
  .resize-handle { margin: 0 -14px; }
  .combo { max-width: none; flex-basis: 100%; }
  .meter { grid-template-columns: 92px minmax(0, 1fr) 84px; }
  .vs .score { font-size: 48px; }
  .prob-side b { font-size: 24px; }
  .vs .side img { width: 56px; height: 56px; }
}
.prose .prose-h3 { font: 700 16px/1.2 var(--display); letter-spacing: .04em; text-transform: uppercase; margin: 22px 0 8px; color: var(--ink); }
.impact-note { margin: -4px 0 12px; max-width: 90ch; }
.seg { flex-wrap: wrap; max-width: 100%; }

/* ============================================================ modular cards: grip, drag, chips */
.mod-title { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.grip { flex: none; width: 24px; height: 28px; margin: -1px 0 0 -6px; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: grab; display: grid; place-items: center; color: var(--muted); touch-action: none; }
.grip svg { width: 10px; height: 16px; fill: currentColor; }
.grip:hover, .grip:focus-visible { color: var(--ink); background: var(--surface-2); }
.mod.plain { position: relative; }
.mod.plain > .card-head { margin-bottom: 10px; align-items: center; }
.mod.plain > .card-head h2 { margin: 0; font: 700 26px/1 var(--display); text-transform: uppercase; }
.mod.plain > .card-head .grip { margin-top: 0; }
.mod.plain > .resize-handle { margin: 0; }
.mod-body .stat-row { margin-bottom: 0; }
.mod.fixed-h > .mod-body { overflow: auto; overscroll-behavior: contain; }
.mod.fixed-h .table-wrap.fit table.data th { top: 0; }
.card:not(.chart-card) > .resize-handle { margin: 4px -20px -18px; }
.hero .spacer { flex: 1; }

.sortable-item { cursor: grab; user-select: none; }
table.data th[data-key] { cursor: pointer; }
.sort-dragging { position: relative; z-index: 40; cursor: grabbing !important; box-shadow: var(--shadow-pinned); opacity: .96; transition: none !important; }
tr.sort-dragging td, th.sort-dragging { background: var(--surface) !important; }
.meter.sort-dragging, .var-chip.sort-dragging { background: var(--surface); border-radius: 8px; }
body.sorting, body.sorting * { cursor: grabbing !important; user-select: none !important; }
.meter.sortable-item { border-radius: 8px; padding: 2px 4px; margin: 0 -4px; }
.meter.sortable-item:hover { background: var(--surface-2); }
tbody tr.sortable-item:hover td { background: var(--surface-2); }
.stat.sortable-item:hover { border-color: var(--line-strong); }

.explorer-controls { display: grid; gap: 8px; margin: 2px 0 8px; }
.axis-slot { padding: 3px 4px 3px 10px; border: 1.5px dashed transparent; border-radius: 12px; font-weight: 700; color: var(--ink-2); }
body.vars-dragging .axis-slot { border-color: var(--line-strong); }
.axis-slot.drop-over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.var-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 3px 2px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 12.5px; color: var(--ink-2); cursor: grab; touch-action: none; user-select: none; }
.var-chip:hover { border-color: var(--muted); color: var(--ink); }
.var-chip .vc-name { padding-right: 4px; }
.var-chip .vc-ax { width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: 700 11px/1 var(--sans, inherit); cursor: pointer; }
.var-chip .vc-ax:hover, .var-chip .vc-ax:focus-visible { background: var(--surface-2); color: var(--ink); }
.var-chip.on-x, .var-chip.on-y { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.var-chip.on-x .vc-ax:first-of-type, .var-chip.on-y .vc-ax:last-of-type { background: var(--accent-ink); color: var(--on-accent); }
.drop-zone { position: absolute; z-index: 6; display: none; align-items: center; justify-content: center; border: 2px dashed var(--line-strong); border-radius: 12px; background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--ink-2); font-size: 13px; font-weight: 700; pointer-events: none; }
.drop-zone.drop-x { left: 64px; right: 8px; bottom: 0; height: 64px; }
.drop-zone.drop-y { left: 0; top: 6px; bottom: 72px; width: 84px; }
.drop-zone.drop-y span { writing-mode: vertical-rl; transform: rotate(180deg); }
body.vars-dragging .drop-zone { display: flex; }
.drop-zone.drop-over { border-color: var(--brand); color: var(--ink); background: color-mix(in srgb, var(--brand) 14%, var(--surface)); }
.var-palette { display: flex; align-items: flex-start; gap: 6px; }
.var-palette .var-chips { flex: 1; min-width: 0; }
.var-chip.vc-hidden { display: none; }
.vc-toggle { flex: none; height: 28px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.combo li.c-group { padding: 8px 10px 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: default; }
.combo li .c-conf { flex: none; min-width: 64px; text-align: center; }
.field.check { gap: 6px; cursor: pointer; user-select: none; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ============================================================ accessibility */
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-pinned); }
.skip-link:focus { top: 10px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
.topbar :focus-visible { outline-color: var(--header-ink); }
main:focus { outline: none; }
.chart-body svg:focus-visible { outline-offset: -2px; }
.kbd-ring { fill: none; stroke: var(--ink); stroke-width: 2; stroke-dasharray: 3 2; pointer-events: none; }
details.chart-table { margin: 6px 0 4px; }
details.chart-table > summary { cursor: pointer; color: var(--ink-2); font-size: 12.5px; font-weight: 600; padding: 4px 0; width: max-content; }
details.chart-table > summary:hover { color: var(--ink); }
details.chart-table .table-wrap { max-height: 360px; overflow: auto; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .meter .m-fill, .prob-bar div, .key { forced-color-adjust: none; }
  .card, .table-wrap, .stat { border: 1px solid CanvasText; }
}

/* ============================================================ Stat Lab */
.btn-primary { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); filter: brightness(1.08); }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-top: 10px; }
@media (max-width: 760px) { .lab-grid { grid-template-columns: minmax(0, 1fr); } }
.lab-form .toolbar .input { flex: 1 1 200px; }
.formula-input { width: 100%; height: auto; min-height: 58px; padding: 10px 12px; font: 14px/1.5 var(--mono); resize: vertical; }
.lab-ops { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.lab-op { height: 30px; min-width: 34px; padding: 0 8px; font: 600 13px var(--mono); }
.lab-status { font-size: 13px; padding: 4px 0; min-height: 22px; }
.lab-status.ok { color: var(--good-text); }
.lab-status.bad { color: var(--bad-text); }
.lab-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
.lab-preview h3 { margin: 0 0 4px; font: 700 13px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.lab-preview ol { margin: 0; padding-left: 20px; font-size: 13px; }
.lab-preview li { display: list-item; }
.lab-preview li span { color: var(--ink-2); }
.lab-preview li b { float: right; font-variant-numeric: tabular-nums; }
.lab-varbox { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lab-vars { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.lab-var { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
.lab-var:hover, .lab-var:focus-visible { background: var(--surface-2); color: var(--ink); }
.lab-var code { font: 600 12.5px var(--mono); color: var(--ink); min-width: 92px; }
.lab-mine { display: grid; gap: 8px; }
.lab-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lab-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.lab-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--control-border); border-radius: 999px; background: var(--surface); font-size: 12.5px; color: var(--ink); }
.lab-chip.from-link { border-style: dashed; }
.lab-example { padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.lab-example:hover { color: var(--ink); border-color: var(--ink-2); }
.lab-mini { min-height: 24px; padding: 0 8px; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; cursor: pointer; }
.lab-mini:hover { color: var(--ink); }

/* AP Top 25 rank before team names (ESPN-style small number) */
.ap-rank { display: inline-block; min-width: 1.1em; margin-right: 5px; color: var(--muted); font-size: .78em; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; cursor: help; }
.vs .side .ap-rank, .sim-team-head .ap-rank { font-size: .9em; }

.foot p { margin: 0 0 6px; }
.foot .foot-ai { color: var(--ink-2); }
.foot .foot-ai a { color: inherit; }
.btn-lab { height: 32px; padding: 0 12px; font-size: 13px; font-weight: 700; color: var(--accent-ink); border-color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.btn-lab[aria-expanded="true"] { color: var(--ink-2); border-color: var(--control-border); background: var(--surface); }
.lab-embed { border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.lab-embed-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.lab-embed-head h3 { margin: 0; font: 700 18px/1 var(--display); text-transform: uppercase; }
.lab-embed-head .muted { font-size: 12.5px; }
.lab-embed .input, .lab-embed .lab-vars, .lab-embed .lab-chip { background: var(--surface); }

/* share any chart */
.share-wrap { position: relative; display: inline-flex; }
.mod .share-btn { display: none; }
.mod:has(> .chart-body svg, > .mod-body svg) .share-btn { display: inline-flex; }
.share-btn { align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--control-border); }
.share-btn:hover, .share-btn[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }
.share-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-pinned); display: grid; gap: 2px; }
.share-menu[hidden] { display: none; }
.share-item { text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: 500 13.5px var(--font); cursor: pointer; }
.share-item:hover, .share-item:focus-visible { background: var(--surface-2); }
@keyframes modflash { 0% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 55%, transparent); } 100% { box-shadow: var(--shadow); } }
.mod-flash { animation: modflash 2s ease-out; }

/* Share button shrinks to its icon when its card is narrow (per card, not per window).
   The word stays available to screen readers. */
.mod { container-type: inline-size; container-name: mod; }
@container mod (max-width: 520px) {
  .share-btn { padding: 0; width: 34px; justify-content: center; }
  .share-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ============================================================ brand + static pages (pipeline/seo.py) */
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-pre { font: 600 10px/1 var(--font); letter-spacing: .3em; color: var(--header-ink-2); margin: 0 0 3px 1px; }
/* Before the app takes over (and for crawlers), <main> holds plain HTML with the same facts. */
.prerender { max-width: 1100px; }
.prerender .pr-h1 { font: 700 44px/1 var(--display); text-transform: uppercase; margin: 0 0 12px; }
.prerender .pr-logo { float: right; margin: 0 0 12px 16px; }
.prerender p { color: var(--ink-2); max-width: 76ch; }
.prerender .table-wrap { margin: 0 0 20px; overflow-x: auto; }
.prerender caption, .prerender h2 { text-align: left; font: 700 18px/1.1 var(--display); text-transform: uppercase; padding: 16px 0 8px; color: var(--ink); }
.prerender table.data td small { color: var(--muted); }
.pr-crumbs { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.pr-crumbs a { color: inherit; }
.pr-cols { columns: 3 200px; column-gap: 24px; padding-left: 18px; margin: 0; }
.pr-cols li { break-inside: avoid; }
.page-summary { max-width: 1280px; margin: 0 auto; padding: 4px 24px 24px; }
.page-summary > .prose { border-top: 1px solid var(--line); padding-top: 8px; }
.page-summary .pr-faq dt { color: var(--ink); }
.page-summary .pr-updated { font-size: 12px; margin-top: 20px; }
@media (max-width: 640px) {
  .prerender .pr-h1 { font-size: 32px; }
  .page-summary { padding: 4px 16px 20px; }
}
