/* Layered map-first layout: list panel (left) + map (right). Light theme to match the basemap. */
:root {
  --ink: #121212;
  --text: #2e2e2e;
  --muted: #5c5c5c;
  --faint: #8a8a8a;
  --line: #ececec;
  --soft: #f2f2f2;
  --bg: #ffffff;
  --amber: #f2b632;
  --amber-soft: #fdf3dc;
  --amber-ink: #7a5600;
  --blue: #1a73e8;
  --blue-soft: #eef4fd;
  --link: #1a5fb4;
  --sea: #cfe3ee;
  --header-h: 64px;
  --sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.5 var(--sans); color: var(--ink); background: var(--bg); }
a { color: var(--link); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- header ---------- */
.top {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 5;
}
.logo { font: 700 22px/1 var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; }
.search {
  flex: 0 1 440px; min-width: 0; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px;
  border: 1px solid #dcdcdc; border-radius: 999px; color: var(--muted); background: var(--bg);
}
.search:focus-within { border-color: var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 15px; color: var(--ink); background: transparent; }
.link-btn { background: none; border: 0; padding: 8px 0; font-size: 14px; font-weight: 500; white-space: nowrap; }
.search-status { margin: 0; padding: 8px 24px; font-size: 14px; background: var(--amber-soft); border-bottom: 1px solid #f0d189; }

/* ---------- layout ---------- */
.app { height: calc(100% - var(--header-h)); display: flex; min-height: 0; position: relative; }
.panel { flex: 0 0 52%; min-width: 0; overflow-y: auto; padding: 32px 40px 120px; }
.mapwrap { flex: 0 0 48%; min-width: 0; position: relative; background: var(--sea); }
#map { position: absolute; inset: 0; }
.map-toggle { display: none; }

/* ---------- panel: landing ---------- */
.landing { max-width: 560px; display: flex; flex-direction: column; gap: 18px; }
.landing h1 { margin: 0; font: 700 44px/1.05 var(--serif); text-wrap: balance; }
.landing p { margin: 0; font-size: 17px; color: var(--text); }
.countdown { font-size: 14px; font-weight: 600; color: var(--muted); }
.landing .disclaimer { border-top: 1px solid var(--line); padding-top: 14px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.landing .disclaimer strong { color: var(--text); }
.landing .disclaimer .linkish { font-size: 13px; cursor: pointer; text-decoration: underline; }
.browse { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.browse label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
select { font: inherit; font-size: 15px; height: 44px; padding: 0 10px; border: 1px solid #dcdcdc; border-radius: 10px; background: var(--bg); color: var(--ink); min-width: 0; }
.chip-group { display: flex; flex-direction: column; gap: 6px; }
.ward-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ward-chip { font: 500 14px/1 var(--mono); min-width: 48px; height: 38px; padding: 0 10px; border: 1px solid #dcdcdc; border-radius: 8px; background: var(--bg); }
.ward-chip:hover { border-color: var(--ink); background: var(--amber-soft); }
.city-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.city-card { text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.city-card:hover { border-color: var(--ink); }
.city-card strong { font-size: 15px; }
.city-card span { font-size: 13px; color: var(--muted); }

/* ---------- panel: ward ---------- */
.ward-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.ward-head h1 { margin: 0; font: 700 44px/1 var(--serif); }
.ward-sub { font-size: 16px; color: #4a4a4a; }
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 16px; color: #4a4a4a; padding-top: 4px; }
.summary strong { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.summary .plans { display: inline-flex; align-items: center; gap: 6px; }
.amber-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; background: var(--amber); flex-shrink: 0; vertical-align: middle; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.seg { display: flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button { height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.seg button[aria-selected="true"] { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.chip { height: 38px; padding: 0 14px; border: 1px solid #dcdcdc; border-radius: 999px; background: var(--bg); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--amber-soft); }
.filters { position: relative; }
.filters > summary { list-style: none; }
.filters > summary::-webkit-details-marker { display: none; }
.filters .count { font: 600 12px/1 var(--mono); background: var(--ink); color: #fff; border-radius: 999px; padding: 3px 6px; }
.filters-pop {
  position: absolute; z-index: 10; top: calc(100% + 8px); left: 0; width: min(320px, 80vw); padding: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .14);
  display: flex; flex-direction: column; gap: 14px;
}
.filters-pop label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.filters-pop label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; color: var(--ink); }
.filters-pop input[type="search"] { font: inherit; font-size: 15px; height: 40px; padding: 0 10px; border: 1px solid #dcdcdc; border-radius: 10px; }
.filters-pop .reset { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--link); font-size: 14px; }

.list { display: flex; flex-direction: column; margin-top: 8px; }
.row {
  border-top: 1px solid var(--line); margin: 0 -12px; width: calc(100% + 24px); border-radius: 10px;
  display: flex; align-items: flex-start; gap: 8px;
}
.row:last-child { border-bottom: 1px solid var(--line); }
.row:hover { background: #fafafa; }
.row.active { background: var(--blue-soft); }
.row-main {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit; font: inherit;
  padding: 14px 0 14px 12px; display: flex; flex-direction: column; gap: 4px; border-radius: 10px;
}
.row-top { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.row-name { font-weight: 600; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-line { font-size: 14px; color: #3c3c3c; }
.row-line.none { color: var(--faint); }
.row-says {
  font-size: 14px; line-height: 1.4; color: var(--text); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-says b { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.row-says.plan { background: var(--amber-soft); border-radius: 6px; padding: 4px 8px; }
.row-says.plan b { color: var(--amber-ink); }
.row-says.none { color: var(--faint); font-style: italic; }
.row-says .more { font-size: 12px; color: var(--faint); white-space: nowrap; }
.row-cmp {
  flex-shrink: 0; margin: 12px 12px 0 0; height: 32px; padding: 0 12px; border: 1px solid #dcdcdc; border-radius: 999px;
  background: var(--bg); color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.row-cmp:hover { border-color: var(--ink); }
.row-cmp[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.lens { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lens select { height: 38px; font-size: 14px; border-radius: 999px; padding: 0 12px; }
.list-foot { font-size: 13px; color: var(--faint); margin-top: 12px; }
.notice { background: var(--amber-soft); border: 1px solid #f0d189; border-radius: 10px; padding: 12px 14px; font-size: 15px; }

.pchip { flex-shrink: 0; font: 700 11px/1 var(--sans); border-radius: 4px; padding: 3px 6px; background: #6b7280; color: #fff; white-space: nowrap; }

/* ---------- map extras ---------- */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; vertical-align: middle; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.tip-lead { display: flex; align-items: center; gap: 6px; font-weight: 400; margin-top: 2px; }
.map-legend {
  position: absolute; z-index: 2; left: 12px; bottom: 12px; max-width: 280px;
  background: rgba(255, 255, 255, .96); border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, .14); padding: 10px 12px; font-size: 13px;
}
.map-legend summary { cursor: pointer; font-weight: 600; list-style: none; }
.map-legend summary::-webkit-details-marker { display: none; }
.map-legend summary::after { content: " ▾"; color: var(--muted); }
.map-legend:not([open]) summary::after { content: " ▸"; }
.map-legend .seg-sm { margin-top: 8px; width: max-content; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 13px; }
.seg-sm button[aria-pressed="true"] { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.tip-lead.dim { opacity: .7; }
.hovertip .swatch { box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.map-legend ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.map-legend li { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.map-legend p { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.hovertip {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(12px, 12px);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- detail panel ---------- */
.detail {
  position: absolute; z-index: 4; left: 52%; top: 0; bottom: 0; width: min(460px, 44%); overflow-y: auto;
  background: var(--bg); box-shadow: 8px 0 30px rgba(0, 0, 0, .12); padding: 24px 28px 110px;
  display: flex; flex-direction: column; gap: 18px; animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(-16px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .detail { animation: none; } }
.back { align-self: flex-start; background: none; border: 0; padding: 0; font-size: 14px; font-weight: 500; color: #4a4a4a; }
.detail h2 { margin: 0; font: 700 32px/1.08 var(--serif); }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; color: #4a4a4a; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 0; }
.eyebrow.amber { color: var(--amber-ink); }
.detail ul { margin: 0; padding-left: 18px; font-size: 15px; display: flex; flex-direction: column; gap: 8px; }
.detail section { display: flex; flex-direction: column; gap: 8px; }
.detail section + section { border-top: 1px solid var(--line); padding-top: 16px; }
.src { font-size: 12px; color: var(--muted); white-space: nowrap; text-decoration: none; }
.src:hover { text-decoration: underline; }
.src::before { content: "↗ "; }
.empty { color: var(--faint); font-size: 15px; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn { height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--ink); background: var(--bg); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.subtle { border-color: #dcdcdc; font-weight: 500; }
.linkish { background: none; border: 0; padding: 0; color: var(--link); font-size: 15px; font-weight: 600; text-align: left; }
.tag { font-size: 12px; border: 1px solid var(--line); background: var(--soft); border-radius: 4px; padding: 1px 6px; text-transform: capitalize; }
.corrected-tag { font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.4; color: var(--amber-ink); background: var(--amber-soft); border: 1px solid #f0d189; border-radius: 4px; padding: 0 6px; cursor: pointer; white-space: nowrap; vertical-align: 1px; }
#corrections { scroll-margin-top: 84px; }
.corrections { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.corrections p { margin: 0; }
.manifesto-line { font-size: 14px; color: #4a4a4a; margin: 0; }

/* ---------- compare tray + dialog ---------- */
.tray {
  position: fixed; z-index: 20; left: 24px; bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 48px);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 8px 8px 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
#tray-text { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-clear { background: none; border: 0; color: #bdbdbd; font-size: 14px; padding: 0 4px; }
.tray-open { height: 38px; padding: 0 16px; border-radius: 999px; border: 0; background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; flex-shrink: 0; }
.tray-open:disabled { opacity: .5; cursor: not-allowed; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 40px); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); }
dialog#how { width: min(620px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font: 700 22px/1.2 var(--serif); }
.ghost { height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid #dcdcdc; background: var(--bg); font-size: 14px; font-weight: 500; }
.prose { padding: 8px 24px 20px; font-size: 15px; }
.prose h3 { font: 700 18px/1.3 var(--serif); margin: 20px 0 6px; }
.prose li { margin: 4px 0; }
#compare-body { padding: 0 20px 20px; }
.cmp-scroll { overflow-x: auto; }
.cmp-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.cmp-table th, .cmp-table td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; min-width: 220px; }
.cmp-table thead th { position: sticky; top: 0; background: var(--bg); }
.cmp-table tbody th { min-width: 110px; width: 110px; position: sticky; left: 0; background: var(--bg); font-size: 13px; color: var(--muted); z-index: 1; }
.cmp-table thead th:first-child { min-width: 110px; left: 0; z-index: 2; }
.cmp-table ul { padding-left: 16px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.cmp-name { font: 700 18px/1.2 var(--serif); display: block; margin-bottom: 4px; }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .map-legend { bottom: auto; top: 12px; right: 12px; max-width: none; }
  :root { --header-h: 112px; }
  .top { flex-wrap: wrap; height: auto; min-height: var(--header-h); padding: 10px 16px; row-gap: 8px; }
  .search { order: 3; flex: 1 1 100%; }
  .logo { font-size: 18px; }
  .panel { flex: 1 1 100%; padding: 22px 18px 120px; }
  .mapwrap { flex: 1 1 100%; }
  .mapwrap { display: none; }
  body.show-map .panel { display: none; }
  body.show-map .mapwrap { display: block; }
  .map-toggle {
    display: flex; align-items: center; gap: 8px; position: fixed; z-index: 15; left: 50%; transform: translateX(-50%);
    bottom: calc(22px + env(safe-area-inset-bottom, 0px)); height: 48px; padding: 0 22px; border-radius: 999px; border: 0;
    background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  }
  .tray { left: 12px; right: 12px; max-width: none; bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
  .detail { position: fixed; z-index: 30; inset: 0; width: auto; box-shadow: none; padding: 18px 18px 120px; }
  .ward-head h1, .landing h1 { font-size: 36px; }
  .browse { grid-template-columns: 1fr; }
  .cmp-table th, .cmp-table td { min-width: 200px; }
  .cmp-table tbody th, .cmp-table thead th:first-child { min-width: 84px; width: 84px; }
}

/* ---------- search-first landing ---------- */
.hero-search {
  display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 8px 0 20px;
  border: 1px solid #cfcfcf; border-radius: 999px; box-shadow: 0 4px 18px rgba(0, 0, 0, .08); color: var(--muted); background: var(--bg);
}
.hero-search:focus-within { border-color: var(--ink); }
.hero-search input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 17px; color: var(--ink); background: transparent; }
.hero-search button { height: 44px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; flex-shrink: 0; }
.locate { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid #dcdcdc; background: var(--bg); font-weight: 500; font-size: 15px; color: var(--link); }
.locate:hover { border-color: var(--ink); }
.browse-more { border-top: 1px solid var(--line); padding-top: 14px; }
.browse-more > summary { cursor: pointer; font-weight: 600; font-size: 15px; list-style: none; display: flex; align-items: center; gap: 8px; }
.browse-more > summary::-webkit-details-marker { display: none; }
.browse-more > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.browse-more[open] > summary::before { transform: rotate(90deg); }
.browse-more .browse { margin-top: 12px; }

/* ---------- candidate facts ---------- */
.row-line .fact-strong, .facts .fact-strong { font-weight: 600; color: var(--ink); }
.detail ul.facts { list-style: none; padding: 0; gap: 6px; }
.detail ul.facts li { padding-left: 18px; position: relative; }
.detail ul.facts li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 999px; background: #b5b5b5; }
body.on-landing .top .search { visibility: hidden; }

/* ---------- 2021 results (single-series bar list, neutral ink) ---------- */
.history { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; max-width: 560px; }
.history > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.h-lines { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.h-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.h-line .eyebrow { min-width: 104px; }
.h-set { display: flex; flex-direction: column; gap: 6px; }
.history > summary::-webkit-details-marker { display: none; }
.history > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.history[open] > summary::after { transform: rotate(90deg); }
.h-pill { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.h-pill b { color: var(--ink); font-weight: 600; }
.h-body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.h-bars { display: flex; flex-direction: column; gap: 4px; }
.h-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 13px; padding: 2px 0; }
.h-row:hover .h-bar { background: var(--ink); }
.h-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-track { height: 10px; }
.h-bar { display: block; height: 100%; min-width: 2px; background: #6b6b6b; border-radius: 0 4px 4px 0; }
.h-val { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }

/* The name is too long to share a row with both header buttons on small phones. */
@media (max-width: 420px) {
  .top { justify-content: flex-start; column-gap: 20px; }
  .logo { flex: 1 1 100%; }
}
