/* Layout: one centred column; the map is the centrepiece, tables below. */
:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --fg: #17201c;
  --muted: #5b6660;
  --line: #dde2de;
  --accent: #0f5f73;
  --bad: #c2362f;
  --warn: #b36b00;
  --ok: #2c7a4b;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111614; --panel: #19201d; --fg: #e8ece9; --muted: #9aa6a0; --line: #2c3532;
    --accent: #5fb7cc; --bad: #f0736a; --warn: #e3a54a; --ok: #6cc28f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111614; --panel: #19201d; --fg: #e8ece9; --muted: #9aa6a0; --line: #2c3532;
  --accent: #5fb7cc; --bad: #f0736a; --warn: #e3a54a; --ok: #6cc28f; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font-body); }
.wrap { max-width: 1200px; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.top { padding-block: 40px 20px; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 5vw, 48px); line-height: 1.1; margin: 8px 0 12px; text-wrap: balance; }
.lede { margin: 0; max-width: 68ch; color: var(--muted); font-size: 17px; }
.lede b { color: var(--fg); font-weight: 600; }
.live { margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--bad); border-radius: var(--radius); color: var(--fg); font-size: 14px; max-width: 68ch; }
.live b { color: var(--bad); }
main { display: grid; gap: 20px; padding-bottom: 40px; }
h2 { font-family: var(--font-display); font-weight: 500; font-size: 22px; margin: 0; text-wrap: balance; }
h3 { font-size: 15px; margin: 16px 0 6px; }
.note { margin: 4px 0 14px; color: var(--muted); font-size: 13px; max-width: 75ch; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tile .v { font-family: var(--font-display); font-size: 36px; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }

.card, .mapcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.mapcard { padding: 0; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; }

.mapbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: transparent; color: var(--fg); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-selected="true"] { background: var(--accent); color: var(--panel); }
.zoomto { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
select, input[type="search"] { font: inherit; font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg); min-width: 0; max-width: 100%; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.mapwrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 560px; }
#map { min-height: 560px; background: var(--bg); }
.panel { border-left: 1px solid var(--line); padding: 16px; overflow: auto; max-height: 560px; }
.panel .hint { color: var(--muted); font-size: 14px; margin: 0; }
.panel h3 { font-family: var(--font-display); font-weight: 500; font-size: 20px; margin: 0 0 2px; }
.panel .sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.panel .call { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 4px; }
.panel .call b { font-size: 16px; }
.panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.panel dt { color: var(--muted); }
.panel dd { margin: 0; }
.bars { display: grid; gap: 4px; margin-top: 8px; }
.bar { display: grid; grid-template-columns: 70px 1fr 42px; align-items: center; gap: 8px; font-size: 12px; }
.bar .track { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 5px; }
.bar .val { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ramp { width: 160px; height: 10px; border-radius: 5px; }
.leaflet-container { font: inherit; background: var(--bg); }

.tscroll { overflow: auto; }
.tscroll.tall { max-height: 520px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; z-index: 1; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.n { font-family: var(--font-data); font-size: 12px; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.party { display: inline-flex; align-items: center; gap: 6px; }
.rate { display: inline-block; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); font-size: 12px; }
.rate.Toss-up { color: var(--bad); border-color: currentColor; }
.rate.Lean { color: var(--warn); }
.rate.Likely { color: var(--fg); }
.rate.Safe { color: var(--ok); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.controls input { flex: 1 1 200px; }
.count { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

#bt { display: grid; gap: 12px; }
.btrow { display: grid; gap: 4px; font-size: 13px; }
.btrow .track { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; }
.btrow .fill { height: 100%; border-radius: 6px; background: var(--muted); }
.btrow.model .fill { background: var(--accent); }
.btrow .lab { display: flex; justify-content: space-between; gap: 8px; }
.btrow .lab span:last-child { font-family: var(--font-data); }
.prose { font-size: 14px; }
.prose ol, .prose ul { padding-left: 20px; margin: 8px 0; display: grid; gap: 6px; }

.foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 4px; }
.foot p { margin: 0; max-width: 90ch; }

@media (max-width: 820px) {
  .mapwrap { grid-template-columns: 1fr; }
  #map { min-height: 440px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .zoomto { margin-left: 0; }
  .wide { display: none; }
}
