:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --surface-2: #f0efec;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10); --accent: #2a78d6; --accent-ink: #184f95;
  --meter-track: #e1e0d9;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --sys-today: #6f6e69; --sys-1: #86b6ef; --sys-2: #2a78d6; --sys-3: #104281;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #262625;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255,255,255,0.10); --accent: #3987e5; --accent-ink: #9ec5f4;
    --meter-track: #2c2c2a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --sys-today: #a3a29b; --sys-1: #b7d3f6; --sys-2: #5598e7; --sys-3: #256abf;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #262625;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255,255,255,0.10); --accent: #3987e5; --accent-ink: #9ec5f4;
    --meter-track: #2c2c2a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --sys-today: #a3a29b; --sys-1: #b7d3f6; --sys-2: #5598e7; --sys-3: #256abf;
    --shadow: none;
  }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(30px, 4.6vw, 48px); max-width: 20ch; }
h2 { font-size: clamp(22px, 3vw, 30px); display: flex; align-items: center; gap: .5em; }
h3 { font-size: 17px; }
p { margin: 0 0 .8em; }
a { color: var(--accent-ink); }
.hero { padding-block: 40px 20px; }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); font-weight: 600; }
.lede { font-size: 18px; max-width: 70ch; color: var(--ink-2); }
.disclaimer { font-size: 14px; max-width: 78ch; color: var(--ink-2); border-left: 3px solid var(--axis); padding-left: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 18px; margin-block: 22px; }
.section-head p { color: var(--ink-2); max-width: 78ch; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: 15px; font-weight: 700; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 14px 18px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.chip[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* composition bar + sliders */
.city-controls { display: grid; gap: 14px; }
.comp-bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--surface); }
.comp-bar .seg { display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; white-space: nowrap; text-shadow: 0 0 2px rgba(0,0,0,.35); transition: flex .15s; }
.comp-bar .seg small { font-weight: 400; opacity: .9; margin-left: 4px; }
.slider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 22px; }
.slider-row { display: grid; grid-template-columns: 14px 1fr 3.2em; align-items: center; gap: 10px; font-size: 14px; }
.slider-row .swatch { width: 14px; height: 14px; border-radius: 4px; }
.slider-row label { display: flex; flex-direction: column; min-width: 0; }
.slider-row label span { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slider-row input[type=range] { width: 100%; accent-color: var(--ink); margin: 2px 0 0; }
.slider-row output { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }
.controls-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.btn { font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--axis); }
.district-details { margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 12px; }
.district-details summary { cursor: pointer; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); }
.district-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px 24px; margin-top: 8px; }
.district-card { border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; }
.district-card h4 { margin: 0 0 6px; font-size: 14px; display: flex; justify-content: space-between; }
.district-card h4 span { color: var(--muted); font-weight: 400; }
.district-card .comp-bar { height: 12px; margin-bottom: 8px; }
.district-card .comp-bar .seg { font-size: 0; }
.district-card .slider-row { grid-template-columns: 10px 1fr 3.2em; font-size: 12px; gap: 8px; }
.district-card .slider-row .swatch { width: 10px; height: 10px; }
.district-card .slider-row label span { font-size: 12px; }

/* viz blocks */
.viz { margin-block: 26px; }
.viz:first-child { margin-top: 10px; }
.viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.viz-head h3 { margin: 0; }
.viz-head p { margin: 0; color: var(--ink-2); font-size: 14px; max-width: 80ch; }
.viz-body { position: relative; }
svg text { font-family: inherit; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .key i.line { height: 3px; border-radius: 2px; width: 18px; }
.legend .key i.diamond { width: 10px; height: 10px; transform: rotate(45deg); border-radius: 1px; background: var(--ink); }

/* headline cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--grid); border-radius: 10px; padding: 12px 12px 10px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card.voters { background: var(--surface-2); border-color: transparent; }
.card.best { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.card h4 { margin: 0; font-size: 15px; line-height: 1.2; }
.card .sub { font-size: 12px; color: var(--muted); min-height: 2.4em; line-height: 1.2; }
.stv-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-ink); background: color-mix(in oklab, var(--accent) 14%, transparent); padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.card .donut { width: 100%; aspect-ratio: 1; max-width: 190px; margin: 4px auto 0; }
.card .score { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.card .score b { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.card .score span { font-size: 12px; color: var(--muted); }
.card .meter { height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; }
.card .meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.card .foot { font-size: 12px; color: var(--ink-2); line-height: 1.3; min-height: 2.6em; }
.card .foot .bad { color: var(--ink); font-weight: 600; }
.verdict { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 15px; }
.verdict b { font-weight: 700; }

/* small multiples */
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.multiple { min-width: 0; }
.multiple h4 { margin: 0 0 2px; font-size: 14px; }
.multiple h4 .stv-tag { font-size: 10px; }
.multiple .sub { font-size: 12px; color: var(--muted); margin: 0 0 4px; }
.multiple svg { width: 100%; height: auto; display: block; }

/* tooltip */
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12px; padding: 6px 9px; border-radius: 6px; z-index: 10; opacity: 0; transition: opacity .1s; max-width: 260px; }
.tip.show { opacity: 1; }

/* details / tables */
.sys-details { border: 1px solid var(--grid); border-radius: 10px; margin-block: 10px; }
.sys-details summary { padding: 10px 14px; cursor: pointer; font-weight: 600; }
.sys-details .inner { padding: 0 14px 12px; overflow-x: auto; }
table.grid { border-collapse: collapse; font-size: 13px; width: 100%; }
table.grid th, table.grid td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; white-space: nowrap; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.winners { display: inline-flex; gap: 3px; vertical-align: middle; }
.winners i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
details.rounds { margin: 4px 0 10px; }
details.rounds summary { font-size: 12px; color: var(--accent-ink); cursor: pointer; }
details.rounds table.grid { font-size: 12px; }
.assumptions { margin-top: 18px; }
.assumptions summary { font-weight: 600; cursor: pointer; }
.assumptions ul { padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.assumptions li { margin-bottom: 6px; }
.sources { font-size: 13px; color: var(--ink-2); margin-top: 16px; border-top: 1px solid var(--grid); padding-top: 12px; }
.sources h3 { font-size: 14px; }
.foot { color: var(--muted); font-size: 13px; padding-block: 10px 40px; }
select.sel { font: inherit; font-size: 14px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); }
@media (max-width: 640px) {
  .panel { padding: 16px 14px; }
  .card .score b { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .comp-bar .seg { transition: none; } }
