:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #e2e6ed;
  --accent: #1d6b63;              /* neutral teal: blue/red are reserved for party */
  --accent-tint: #e6f2f0;
  --accent-line: #c4e0db;
  --dem: #2f6fd6;
  --dem-fill: #a9c3ef;
  --rep: #cf3a3a;
  --rep-fill: #efb0aa;
  --split-fill: #c9b6e4;
  --oth: #8a6d1d;
  --open-fill: #d9dde4;
  --law: #1e7d4f;
  --law-bg: #e3f4ea;
  --prog: #8a5a00;
  --prog-bg: #fdf1d8;
  --died: #6b7280;
  --died-bg: #eef0f3;
  --veto: #a3361f;
  --veto-bg: #fbe5df;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.8rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.65rem; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 1.1rem;
}
.brand-name { display: block; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { display: block; font-size: 0.8rem; color: var(--muted); }
.ai-badge {
  font-size: 0.78rem; padding: 0.3rem 0.65rem; border-radius: 999px;
  background: var(--accent-tint); color: var(--accent); border: 1px solid var(--accent-line); white-space: nowrap;
}

.crumbs { padding: 0.6rem 1.5rem 0; font-size: 0.9rem; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { margin: 0 0.4rem; color: #a0a7b4; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 1fr);
  gap: 1rem;
  padding: 0.8rem 1.5rem 1.5rem;
  align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 0.6rem 0.75rem 1rem; }
  .site-header, .crumbs { padding-left: 0.75rem; padding-right: 0.75rem; }
}

.map-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.map-card { position: sticky; top: 0.75rem; overflow: hidden; }
@media (max-width: 960px) { .map-card { position: static; } }

.map-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); min-height: 3rem;
}
.map-toolbar:empty { display: none; }
.map-toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a, .seg button {
  border: 0; background: transparent; padding: 0.4rem 0.75rem; font: inherit; font-size: 0.88rem;
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current="true"] { background: var(--accent); color: #fff; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px;
  padding: 0.35rem 0.7rem; font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--ink);
}
.btn:hover { background: var(--bg); }

.map-wrap { position: relative; }
#map { display: block; width: 100%; height: auto; max-height: 72vh; background: #fbfcfd; touch-action: none; }

.shape {
  stroke: #fff; stroke-width: 0.8; vector-effect: non-scaling-stroke; cursor: pointer;
  transition: filter 0.12s ease;
}
.shape:hover, .shape:focus { filter: brightness(0.88); outline: none; }
.shape.selected { stroke: var(--ink); stroke-width: 2.4; }
.shape.inactive { cursor: default; }
.shape.inactive:hover { filter: none; }
.fill-dem { fill: var(--dem-fill); }
.fill-rep { fill: var(--rep-fill); }
.fill-split { fill: var(--split-fill); }
.fill-open { fill: var(--open-fill); }
.fill-live { fill: #3f9e8f; }
.fill-soon { fill: #e4e7ec; }
.map-label {
  pointer-events: none; text-anchor: middle; dominant-baseline: central;
  font-weight: 600; fill: #1d2433; paint-order: stroke; stroke: rgba(255,255,255,0.85);
  stroke-width: 3px; vector-effect: non-scaling-stroke;
}

.tooltip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 280px;
  background: rgba(29, 36, 51, 0.95); color: #fff; padding: 0.5rem 0.65rem;
  border-radius: 8px; font-size: 0.82rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.tooltip strong { display: block; margin-bottom: 0.15rem; }
.map-status {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 2rem;
  text-align: center; color: var(--muted); background: rgba(251,252,253,0.9);
}

.legend {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted);
}
.legend:empty { display: none; }
.legend .sw { display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 3px; vertical-align: -0.12rem; margin-right: 0.3rem; }

/* Panel */
.panel { padding: 1.1rem 1.25rem 1.4rem; min-height: 300px; }
.panel h1 { font-size: 1.45rem; margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.panel h2 { font-size: 1.05rem; margin: 1.4rem 0 0.6rem; }
.panel h3 { font-size: 0.98rem; margin: 0; }
.lede { margin: 0.2rem 0 0.8rem; color: var(--muted); }

.stats { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.7rem 0; }
.stat { background: var(--bg); border-radius: 8px; padding: 0.45rem 0.7rem; min-width: 5.5rem; }
.stat b { display: block; font-size: 1.15rem; }
.stat span { font-size: 0.78rem; color: var(--muted); }

.notes { margin: 0.6rem 0; padding: 0.6rem 0.8rem; background: #f3f5f5; border-radius: 8px; font-size: 0.88rem; }
.notes ul { margin: 0; padding-left: 1.1rem; }

.search { width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.search:focus { outline: 2px solid var(--accent-line); border-color: var(--accent); }
.results { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.results li a { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.results li a:hover { background: var(--bg); }

.district-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); gap: 0.35rem; }
.district-grid a {
  display: grid; place-items: center; height: 2.3rem; border-radius: 6px; text-decoration: none;
  color: var(--ink); font-size: 0.88rem; font-weight: 600; border: 1px solid var(--line);
}
.district-grid a:hover { border-color: var(--accent); }

.state-list { list-style: none; padding: 0; margin: 0.6rem 0; }
.state-list a {
  display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0.9rem;
  border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: inherit; margin-bottom: 0.5rem;
}
.state-list a:hover { border-color: var(--accent); background: #f2f8f7; }

/* Races & candidates */
.race { border: 1px solid var(--line); border-radius: var(--radius); margin: 0.8rem 0; overflow: hidden; }
.race-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding: 0.6rem 0.85rem; background: #fafbfc; border-bottom: 1px solid var(--line); }
.race-note { margin: 0; padding: 0.45rem 0.85rem; font-size: 0.8rem; color: var(--prog); background: var(--prog-bg); }
.cands { list-style: none; margin: 0; padding: 0; }
.cands li + li { border-top: 1px solid var(--line); }
.cand { display: block; padding: 0.7rem 0.85rem; text-decoration: none; color: inherit; }
.cand:hover { background: #f5f7f7; }
.cand-top { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.cand-name { font-weight: 650; }
.cand-headline { margin: 0.35rem 0 0; font-size: 0.88rem; color: #39404f; }
.cand-meta { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--muted); }
.cand-more { font-size: 0.8rem; color: var(--accent); margin-left: auto; }

.pill {
  display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.12rem 0.45rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.party { color: #fff; }
.party.dem { background: var(--dem); }
.party.rep { background: var(--rep); }
.party.oth { background: var(--oth); }
.party.none { background: #9aa1ad; }
.pill.inc { background: #eef0f3; color: #39404f; }
.pill.veteran { background: #eef0f3; color: #2f3644; border-color: #dfe3e9; }
.pill.rookie { background: #fbf4e6; color: #7a5617; border-color: #f0e0bd; }
.pill.ai { background: #f4effd; color: #5b3aa6; border-color: #e2d6f7; }
.pill.out-law { background: var(--law-bg); color: var(--law); }
.pill.out-pending, .pill.out-passed_chamber { background: var(--prog-bg); color: var(--prog); }
.pill.out-died { background: var(--died-bg); color: var(--died); }
.pill.out-vetoed { background: var(--veto-bg); color: var(--veto); }

/* Candidate profile */
.back { display: inline-block; margin-bottom: 0.6rem; font-size: 0.88rem; text-decoration: none; }
.profile-sub { margin: 0.1rem 0 0.5rem; color: var(--muted); }
.ai-card { border: 1px solid #e2d6f7; background: #fcfaff; border-radius: var(--radius); padding: 0.9rem 1rem; margin: 1rem 0; }
.ai-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.ai-card .headline { font-weight: 650; margin: 0.2rem 0 0.5rem; }
.ai-card p { margin: 0 0 0.6rem; }
.themes { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.themes li { padding: 0.5rem 0; border-top: 1px dashed #e2d6f7; }
.themes .bills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.bill-chip { font-size: 0.75rem; text-decoration: none; padding: 0.12rem 0.45rem; border-radius: 6px; }
.ai-foot { font-size: 0.76rem; color: var(--muted); margin-top: 0.5rem; }
.empty-card { border: 1px dashed var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; color: var(--muted); margin: 1rem 0; font-size: 0.9rem; }

.outcome-bar { display: flex; height: 0.65rem; border-radius: 999px; overflow: hidden; background: var(--died-bg); margin: 0.5rem 0 0.4rem; }
.outcome-bar span { display: block; height: 100%; }
.outcome-bar .law { background: var(--law); }
.outcome-bar .prog { background: #e2a63b; }
.outcome-bar .veto { background: var(--veto); }
.outcome-bar .died { background: #b9bfca; }
.outcome-key { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.8rem; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.6rem 0; }
.filters button { font-size: 0.78rem; }
.filters button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.bill-list { list-style: none; padding: 0; margin: 0; }
.bill-list li { display: grid; grid-template-columns: 6.6rem 1fr auto; gap: 0.5rem; padding: 0.45rem 0; border-top: 1px solid var(--line); font-size: 0.86rem; align-items: start; }
.bill-list .bid { font-weight: 600; white-space: nowrap; }
.bill-list .bdesc { color: #39404f; }
.bill-list .bdesc small { display: block; color: var(--muted); }

.facts { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.35rem 0.75rem; margin: 0.4rem 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.sources { padding-left: 1.1rem; font-size: 0.88rem; }

details.explain { margin: 1rem 0; font-size: 0.88rem; }
details.explain summary { cursor: pointer; color: var(--accent); }

.site-footer { padding: 0 1.5rem 1.5rem; font-size: 0.78rem; color: var(--muted); }

/* Same party colors for legend swatches and the district buttons */
.sw.fill-dem, .district-grid a.fill-dem { background: var(--dem-fill); }
.sw.fill-rep, .district-grid a.fill-rep { background: var(--rep-fill); }
.sw.fill-split, .district-grid a.fill-split { background: var(--split-fill); }
.sw.fill-open, .district-grid a.fill-open { background: var(--open-fill); }
.sw.fill-live { background: #3f9e8f; }
.sw.fill-soon { background: #e4e7ec; }

.quote { margin: 0.4rem 0 0.8rem; padding: 0.6rem 0.9rem; border-left: 3px solid var(--line); background: #fafbfc; border-radius: 0 8px 8px 0; font-size: 0.92rem; }
.quote p { margin: 0 0 0.5rem; }
.quote p:last-child { margin-bottom: 0; }
.statement .facts { grid-template-columns: 10rem 1fr; }
@media (max-width: 520px) { .facts, .statement .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 0.4rem; } }

/* Candidate photos / initials */
.avatar { flex: none; border-radius: 50%; object-fit: cover; object-position: center 20%; background: var(--bg); display: inline-grid; place-items: center; }
.avatar.initials { color: #fff; font-weight: 700; letter-spacing: 0.02em; }
.avatar.initials.dem { background: #6d93d8; }
.avatar.initials.rep { background: #d8746d; }
.avatar.initials.oth { background: #a88c45; }
.avatar.initials.none { background: #9aa1ad; }
.cand-row { display: flex; gap: 0.75rem; align-items: flex-start; }
.cand-body { flex: 1; min-width: 0; }
.profile-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 0.4rem; }
.profile-photo { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: 9rem; }
.profile-photo figcaption { font-size: 0.66rem; color: var(--muted); text-align: center; margin-top: 0.3rem; line-height: 1.25; }
.profile-photo figcaption a { color: inherit; }
.mini { display: inline-flex; align-items: center; gap: 0.35rem; }

.fill-federal { fill: #b9ddd6; }
.sw.fill-federal { background: #b9ddd6; }
.state-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.8rem, 1fr)); gap: 0.35rem; margin: 0.4rem 0 0.6rem; }
.state-chips a { display: grid; place-items: center; height: 2.1rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink); font-size: 0.85rem; font-weight: 600; }
.state-chips a:hover { border-color: var(--accent); background: #f2f8f7; }

/* Report-a-problem dialog */
.report { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(32rem, 94vw); }
.report::backdrop { background: rgba(29, 36, 51, 0.45); }
.report form { display: flex; flex-direction: column; gap: 0.35rem; padding: 1.1rem 1.25rem; }
.report h2 { margin: 0 0 0.2rem; font-size: 1.15rem; }
.report label { font-size: 0.85rem; font-weight: 600; margin-top: 0.4rem; }
.report label.check { font-weight: 400; display: flex; gap: 0.4rem; align-items: center; }
.report select, .report textarea, .report input[type=email] {
  font: inherit; padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: 8px; width: 100%;
}
.report .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.report-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.4rem; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:disabled { opacity: 0.6; }
#report-status.error { color: var(--veto); }
#report-status.ok { color: var(--law); }
.report-profile { margin-top: 1rem; }
.turnstile { min-height: 65px; margin: 0.6rem 0 0.2rem; }
