/* PrecinctChairs.com — USA War Map. Civic/editorial system in kinship with the YRT War Map:
   deep navy, authoritative crimson, warm bone, serif display headings, tabular UI numerals, square edges. */
:root {
  --navy: #07192f;
  --navy-2: #0f2a4a;
  --navy-3: #1b3a60;
  --crimson: #c8102e;
  --crimson-dark: #9b0c24;
  --crimson-tint: rgba(200, 16, 46, 0.07);
  --gold: #b8862b;
  --civic-blue: #1f4d8a;
  --steel: #2f4a6d;
  --bone: #f6f3ec;
  --paper: #fbf9f4;
  --card: #ffffff;
  --ink: #0b1626;
  --muted: #5b6574;
  --soft: #7b8592;
  --line: rgba(7, 25, 47, 0.12);
  --line-2: rgba(7, 25, 47, 0.22);
  --head: "DM Serif Display", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --bar: 58px;
  --tick: 34px;
  --top: calc(var(--bar) + var(--tick));
  --map-h: 44vh;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bone); color: var(--ink); font: 14px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
a { color: var(--navy-3); }
code { font: 12px var(--mono); background: rgba(7, 25, 47, 0.06); padding: 1px 5px; }
button { font: inherit; color: inherit; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 3px solid var(--crimson); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* ------------------------------------------------------------------ Masthead */
.masthead { position: sticky; top: 0; z-index: 40; background: var(--navy); color: #fff; }
.masthead-bar {
  height: var(--bar); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 18px; border-bottom: 3px solid var(--crimson);
}
.brand-wrap { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; background: var(--crimson); color: #fff;
  display: grid; place-items: center; font-size: 17px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text strong { font: 400 21px/1 var(--head); letter-spacing: -0.01em; }
.brand-text strong span { color: #f3a6b1; }
.brand-text small { margin-top: 4px; font: 800 10px/1.2 var(--ui); color: #b8c7dc; text-transform: uppercase; letter-spacing: 0.16em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-powered-mobile { display: none; }

.powered {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 0 0 0 18px; border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff; text-decoration: none; line-height: 1.1; white-space: nowrap;
}
.powered-kicker { font: 800 9.5px/1 var(--ui); letter-spacing: 0.18em; text-transform: uppercase; color: #f3a6b1; }
.powered-name { font: 400 16px/1.1 var(--head); color: #fff; }
.powered:hover .powered-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--crimson); }

.companion-pill {
  font: 600 11px var(--mono); color: #b8c7dc; padding: 4px 9px; white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.ticker {
  height: var(--tick); display: flex; align-items: center; gap: 0; padding: 0 18px;
  background: #0c2240; border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  font: 700 11px/1 var(--ui); letter-spacing: 0.1em; text-transform: uppercase; color: #9fb1c9;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.ticker::-webkit-scrollbar { display: none; }
.tk-item { display: inline-flex; align-items: baseline; gap: 7px; padding: 0 16px; border-left: 1px solid rgba(255, 255, 255, 0.12); }
.tk-item:first-child { padding-left: 0; border-left: 0; }
.tk-item strong { font: 700 14px/1 var(--ui); letter-spacing: 0; color: #fff; font-variant-numeric: tabular-nums; }
.tk-open strong { color: #ff8a9a; }
.tk-updated { margin-left: auto; color: #7f93ad; font-weight: 600; border-left: 0; padding-right: 0; }

.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ------------------------------------------------------------------ Buttons */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 0;
  font: 800 11.5px/1.1 var(--ui); letter-spacing: 0.1em; text-transform: uppercase; text-decoration: none;
  cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--crimson); color: #fff; }
.btn-primary:hover { background: var(--crimson-dark); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-3); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: #fff; }
.modal-card .btn-ghost, .guide-pane .btn-ghost { color: var(--ink); border-color: var(--line-2); background: #fff; }
.modal-card .btn-ghost:hover, .guide-pane .btn-ghost:hover { border-color: var(--ink); background: #fff; }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; font: 700 12px var(--ui); color: var(--navy-3); text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--crimson); }

/* ------------------------------------------------------------------ Workspace */
.workspace {
  display: grid; grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); min-height: 520px;
}
.guide-pane {
  background: var(--paper); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}

/* Search */
.search-box { position: sticky; top: 0; z-index: 15; background: var(--paper); border-bottom: 1px solid var(--line); padding: 14px 16px 8px; }
.search-row { display: flex; align-items: center; height: 48px; background: #fff; border: 1px solid var(--line-2); transition: border-color 0.15s; }
.search-row:focus-within { border-color: var(--ink); }
.search-icon { flex: none; width: 19px; height: 19px; margin: 0 2px 0 14px; fill: none; stroke: var(--soft); stroke-width: 1.8; stroke-linecap: round; }
.search-row input { flex: 1; min-width: 0; height: 100%; padding: 0 10px; border: 0; background: transparent; font: 500 15px var(--ui); color: var(--ink); outline: none; }
.search-row input::placeholder { color: var(--soft); }
.search-btn { height: 100%; padding: 0 20px; border: 0; background: var(--crimson); color: #fff; font: 800 11.5px var(--ui); letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer; }
.search-btn:hover { background: var(--crimson-dark); }
.search-suggestions { margin-top: 6px; border: 1px solid var(--line-2); background: #fff; box-shadow: 0 14px 30px -14px rgba(7, 25, 47, 0.35); }
.sugg-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 42px;
  text-align: left; border: 0; border-top: 1px solid var(--line); background: #fff; padding: 8px 12px; cursor: pointer; font: 13.5px var(--ui); color: var(--ink);
}
.sugg-item:first-child { border-top: 0; }
.sugg-item:hover { background: var(--crimson-tint); }
.sugg-tag { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.search-status { margin: 6px 0 0; font-size: 12px; color: var(--muted); min-height: 16px; }

/* Breadcrumb */
.crumb-bar {
  display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; padding: 9px 16px;
  font: 700 11px/1.3 var(--ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft);
  border-bottom: 1px solid var(--line); background: var(--bone);
}
.crumb-bar button { border: 0; background: none; padding: 0; color: var(--navy-3); font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.crumb-bar button:hover { color: var(--crimson); text-decoration: underline; text-underline-offset: 3px; }
.crumb-bar .sep { color: var(--crimson); }
.crumb-bar .cur { color: var(--ink); }

.guide-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.guide-body.view-enter > * { animation: view-in 0.32s var(--ease) both; }
.guide-body.view-enter > *:nth-child(2) { animation-delay: 0.05s; }
.guide-body.view-enter > *:nth-child(3) { animation-delay: 0.1s; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 10px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--crimson); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Cards */
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-top: 2px solid var(--navy); padding: 16px 16px 15px; }
.card-hero { border-top-color: var(--crimson); }
.card-selected { border: 1px solid rgba(200, 16, 46, 0.35); border-top: 3px solid var(--crimson); background: linear-gradient(180deg, var(--crimson-tint), #fff 120px); scroll-margin-top: 104px; }
.card h1, .card h2, .card h3 { margin: 0 0 4px; font-family: var(--head); font-weight: 400; line-height: 1.08; letter-spacing: -0.015em; color: var(--ink); }
.card h1 { font-size: 30px; }
.card h2 { font-size: 22px; }
.card h3 { font-size: 17px; }
.card-hero h1 { font-size: 32px; margin: 6px 0 8px; }
.eyebrow { margin: 0 0 4px; font: 800 10.5px/1.3 var(--ui); text-transform: uppercase; letter-spacing: 0.15em; color: var(--crimson); }
.subcopy { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.lede { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-kicker { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.count-note { font: 700 11px var(--ui); letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); }
.mini-label { margin: 0 0 6px; font: 800 10px var(--ui); letter-spacing: 0.15em; text-transform: uppercase; color: var(--soft); }

/* KPI stats — editorial numerals */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.kpi { padding: 11px 10px 10px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi strong { display: block; font: 400 27px/1 var(--head); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { display: block; margin-top: 5px; font: 700 10.5px/1.25 var(--ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi.kpi-open strong { color: var(--crimson); }
.kpi.kpi-live strong { color: var(--navy-3); }
.kpi strong.is-pending { font: 700 14px/27px var(--ui); color: var(--soft); letter-spacing: 0.04em; }

/* Badges & seat pips */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; white-space: nowrap;
  font: 800 10px/1 var(--ui); letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-live, .b-open { background: var(--crimson); color: #fff; }
.b-open .dot, .b-live .dot { background: #fff; animation: pulse 1.8s ease-in-out infinite; }
.b-partial { background: #fff2ea; color: #a4410f; border-color: #f3c1a4; }
.b-partial .dot { background: #e8743b; }
.b-pcts { background: #eaf0f8; color: var(--civic-blue); border-color: #c9d6ea; }
.b-chairs { background: #f8f0de; color: #7a5712; border-color: #e7d3a7; }
.b-t1 { background: #fff; color: var(--navy-3); border-color: var(--line-2); }
.b-t2, .b-t3 { background: #fff; color: var(--soft); border-color: var(--line); }
.b-filled { background: #e8edf4; color: var(--steel); border-color: #cdd7e4; }
.b-onfile { background: #f1f2f4; color: #5f6773; border-color: #dfe2e6; }
.b-pending { background: #fff; color: var(--soft); border-color: var(--line-2); }
.b-ready { background: #e8f3ee; color: #1f6447; border-color: #c4e0d2; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.pips { display: inline-flex; gap: 3px; margin-top: 6px; }
.pip { width: 9px; height: 9px; background: #dfe3e9; box-shadow: inset 0 0 0 1px rgba(7, 25, 47, 0.12); }
.pip-open { background: var(--crimson); }
.pip-filled { background: var(--steel); }
.pip-on_file { background: #9aa3af; }

/* Coverage chips & filters */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font: 700 12px var(--ui); font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pill-btn:hover { border-color: var(--ink); }
.pill-btn .sw { width: 9px; height: 9px; background: var(--cov, var(--soft)); }
.pill-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill-btn.pill-hot { border-color: rgba(200, 16, 46, 0.4); background: var(--crimson-tint); color: var(--crimson-dark); }
.pill-btn.pill-hot:hover { background: var(--crimson); border-color: var(--crimson); color: #fff; }
.pill-btn.pill-hot:hover .sw { background: #fff; }
.cov-strip { margin-top: 14px; }
.filter-tabs { display: flex; flex-wrap: wrap; border: 1px solid var(--line-2); margin-bottom: 10px; }
.filter-tabs .pill-btn { flex: 1 1 auto; justify-content: center; min-height: 34px; padding: 0 8px; border: 0; border-left: 1px solid var(--line); font-size: 11.5px; }
.filter-tabs .pill-btn:first-child { border-left: 0; }
.filter-tabs .pill-btn.active { border-color: var(--navy); }
.inline-filter { height: 34px; width: 160px; padding: 0 10px; border: 1px solid var(--line-2); background: #fff; font: 500 13px var(--ui); color: var(--ink); }
.inline-filter:focus { outline: none; border-color: var(--ink); }

/* Directory rows */
.list-wrap { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row-btn {
  position: relative; width: 100%; min-height: 54px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line);
  padding: 10px 4px 10px 14px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  transition: background 0.15s;
}
.row-btn::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; background: var(--cov, transparent); }
.row-btn:hover { background: rgba(7, 25, 47, 0.035); }
.row-btn:hover .row-title-text { color: var(--crimson); text-decoration: underline; text-underline-offset: 3px; }
.row-btn.selected { background: var(--crimson-tint); }
.row-btn.selected::before { background: var(--crimson); top: 0; bottom: 0; width: 4px; }
.row-main { min-width: 0; flex: 1; }
.row-title { font: 700 14.5px/1.3 var(--ui); color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-right { text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-num { font: 400 21px/1 var(--head); color: var(--ink); display: block; }
.row-num.open { color: var(--crimson); }
.row-unit { font-size: 11px; color: var(--soft); white-space: nowrap; }
.meter { height: 4px; margin-top: 6px; background: rgba(7, 25, 47, 0.08); max-width: 220px; }
.meter i { display: block; height: 100%; background: var(--crimson); }
.list-more { padding: 10px 4px 0; font-size: 12px; color: var(--soft); }

/* Detail key-value table */
.meta-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; font-size: 13px; border-top: 1px solid var(--line); }
.meta-list li { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 8px 0; }
.meta-list .mk { color: var(--muted); flex-shrink: 0; font: 700 10.5px/1.6 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; }
.meta-list .mv { color: var(--ink); font-weight: 600; text-align: right; }

/* Seat roster (multi-seat precincts) */
.seat-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line-2); }
.seat { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.seat-mark { width: 9px; height: 9px; background: #cfd5dd; }
.seat-open .seat-mark { background: var(--crimson); }
.seat-filled .seat-mark { background: var(--steel); }
.seat-on_file .seat-mark { background: #9aa3af; }
.seat-role { display: block; font: 700 10.5px/1.3 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.seat-holder { display: block; font: 600 14px/1.3 var(--ui); color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.seat-open .seat-holder { color: var(--crimson-dark); }
.seat-summary { margin: 10px 0 0; font: 700 12px var(--ui); color: var(--muted); }
.seat-summary b { color: var(--crimson); font: 400 18px var(--head); }

/* Provenance */
.prov-box { margin-top: 14px; padding: 9px 11px; background: var(--bone); border-left: 2px solid var(--line-2); font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.prov-box button { border: 0; background: none; padding: 0; margin-left: 2px; color: var(--crimson); font: 700 11.5px var(--ui); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.cta-stack { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.cta-stack .btn { flex: 1 1 auto; min-height: 44px; }

/* Footer */
.guide-footer { margin-top: auto; padding: 16px 16px 18px; border-top: 2px solid var(--navy); background: var(--bone); font-size: 12px; color: var(--muted); }
.guide-footer p { margin: 0 0 5px; line-height: 1.5; }
.guide-footer strong { color: var(--ink); }
.guide-footer .fine { margin: 8px 0 0; font-size: 11px; color: var(--soft); }
.footer-powered { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; color: var(--ink); text-decoration: none; }
.footer-powered .powered-kicker { color: var(--crimson); }
.footer-powered-name { font: 400 22px/1.05 var(--head); letter-spacing: -0.01em; }
.footer-powered:hover .footer-powered-name { color: var(--crimson); }

/* ------------------------------------------------------------------ Map pane */
.map-pane { position: relative; background: #eceae4; overflow: hidden; }
.map-canvas { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font: 500 10px var(--ui); }
.map-hud { position: absolute; z-index: 10; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(7, 25, 47, 0.12); }
.map-hud.top-right { top: 14px; right: 14px; }
.hud-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--navy); font: 800 15px var(--ui); cursor: pointer; display: grid; place-items: center; }
.hud-btn:first-child { font-size: 11px; letter-spacing: 0.08em; }
.hud-btn + .hud-btn { border-top: 1px solid var(--line); }
.hud-btn:hover { background: #f2eee6; color: var(--crimson); }

.map-tip {
  position: absolute; z-index: 11; top: 0; left: 0; pointer-events: none; max-width: 250px;
  background: var(--navy); color: #fff; padding: 9px 12px 10px; border-left: 3px solid var(--crimson);
  box-shadow: 0 12px 28px -10px rgba(7, 25, 47, 0.55); font-size: 12px; line-height: 1.35;
  will-change: transform; transition: opacity 0.12s ease;
}
.map-tip[hidden] { display: block; opacity: 0; visibility: hidden; }
.map-tip strong { display: block; font: 400 16px/1.15 var(--head); letter-spacing: -0.005em; }
.map-tip span { display: block; margin-top: 3px; font-weight: 700; color: #ffd1d8; font-variant-numeric: tabular-nums; }
.map-tip em { display: block; margin-top: 2px; font-style: normal; color: #a9bad0; }
.map-tip .tip-hint { margin-top: 6px; padding-top: 5px; border-top: 1px solid rgba(255, 255, 255, 0.14); font: 800 9.5px var(--ui); letter-spacing: 0.14em; text-transform: uppercase; color: #8ea2bd; }

.map-legend {
  position: absolute; bottom: 16px; left: 16px; z-index: 10; max-width: min(620px, calc(100% - 32px));
  background: rgba(255, 255, 255, 0.96); border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(7, 25, 47, 0.12);
  padding: 9px 13px 10px; font: 600 11.5px/1.3 var(--ui); color: var(--ink);
}
.leg-title { margin: 0 0 6px; font: 800 9.5px var(--ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--soft); }
.leg-items { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.leg-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.leg-item em { font-style: normal; font-weight: 500; color: var(--soft); }
.leg-item.is-primary { font-weight: 800; }
.leg-sep { width: 1px; height: 14px; background: var(--line-2); }
.swatch { width: 11px; height: 11px; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgba(7, 25, 47, 0.18); }
.ramp { display: inline-flex; align-items: center; gap: 6px; }
.ramp i { display: block; width: 92px; height: 9px; }

.map-toast {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 12;
  background: var(--navy); color: #fff; padding: 9px 15px; border-left: 3px solid var(--crimson);
  font-size: 12.5px; font-weight: 700; box-shadow: 0 10px 26px -10px rgba(7, 25, 47, 0.55); max-width: calc(100% - 120px);
}

/* ------------------------------------------------------------------ Modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(7, 25, 47, 0.62); display: grid; place-items: center; padding: 16px; animation: fade-in 0.18s ease both; }
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: #fff; border-top: 3px solid var(--crimson); box-shadow: 0 30px 70px -20px rgba(7, 25, 47, 0.6); padding: 20px 22px 18px;
  animation: modal-in 0.24s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font: 400 26px/1.1 var(--head); letter-spacing: -0.015em; }
.modal-close { flex: none; border: 1px solid var(--line); background: #fff; width: 38px; height: 38px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); }
.modal-close:hover { border-color: var(--ink); }
.modal-form { display: flex; flex-direction: column; gap: 11px; }
.form-context { background: var(--bone); border-left: 3px solid var(--navy); padding: 10px 12px; font-size: 13px; line-height: 1.5; color: var(--ink); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font: 700 10.5px/1.3 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.modal-form input, .modal-form select, .modal-form textarea {
  border: 1px solid var(--line-2); border-radius: 0; padding: 0 11px; min-height: 42px; background: #fff;
  font: 500 14px var(--ui); letter-spacing: 0; text-transform: none; color: var(--ink);
}
.modal-form textarea { padding: 9px 11px; resize: vertical; }
.modal-form input:focus, .modal-form select:focus, .modal-form textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

.consent-group { margin: 2px 0 0; padding: 0; border: 0; display: grid; gap: 8px; }
.consent-group legend { padding: 0; margin-bottom: 6px; font: 800 10px var(--ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--soft); }
.modal-form .check-row {
  flex-direction: row; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line);
  font: 400 12.5px/1.5 var(--ui); letter-spacing: 0; text-transform: none; color: var(--ink); cursor: pointer;
}
.modal-form .check-row input { flex: none; min-height: 0; width: 18px; height: 18px; margin: 1px 0 0; padding: 0; accent-color: var(--crimson); box-shadow: none; }
.consent-required { border-left: 3px solid var(--crimson) !important; background: var(--crimson-tint); }
.consent-optional { border-left: 3px solid var(--line-2) !important; background: #fff; }
.check-row:has(input:checked) { border-color: var(--ink); }
.consent-tag { display: inline-block; margin-right: 2px; padding: 2px 5px; font: 800 9px/1.2 var(--ui); letter-spacing: 0.12em; text-transform: uppercase; vertical-align: 1px; background: var(--crimson); color: #fff; }
.consent-optional .consent-tag { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }
.hp-field { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.form-msg { padding: 10px 12px; font-size: 13px; font-weight: 600; border-left: 3px solid; }
.form-msg.ok { background: #e8f3ee; color: #1f6447; border-color: #1f6447; }
.form-msg.err { background: #fdecee; color: var(--crimson-dark); border-color: var(--crimson); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ------------------------------------------------------------------ Responsive */
@supports (height: 1dvh) {
  :root { --map-h: 44dvh; }
}
@media (max-width: 1180px) {
  .companion-pill { display: none; }
}
@media (max-width: 1020px) {
  .powered { display: none; }
  .brand-powered-mobile { display: inline; }
}
@media (max-width: 960px) {
  :root { --bar: 56px; --tick: 32px; }
  .masthead-bar { padding: 0 12px; gap: 10px; }
  .brand-text strong { font-size: 19px; }
  .brand-text small { letter-spacing: 0.1em; font-size: 9px; }
  .brand-mark { width: 30px; height: 30px; font-size: 15px; }
  #btn-reset-us { display: none; }
  .top-actions .btn { min-height: 36px; padding: 0 12px; font-size: 10.5px; }
  .ticker { padding: 0 12px; }
  .tk-item { padding: 0 12px; }
  .tk-updated { display: none; }

  /* Sticky map stays on top; the guide sheet scrolls beneath it so a tapped precinct is always in view. */
  .workspace { display: flex; flex-direction: column; height: auto; min-height: calc(100vh - var(--top)); }
  .map-pane {
    order: -1; position: sticky; top: var(--top); height: var(--map-h); min-height: 260px; z-index: 7; flex: none;
    border-bottom: 1px solid var(--line-2); box-shadow: 0 12px 26px -16px rgba(7, 25, 47, 0.55);
  }
  .guide-pane { border-right: 0; overflow: visible; }
  .search-box { position: relative; padding: 12px 14px 6px; }
  .guide-body { padding: 14px; }
  .card h1 { font-size: 27px; }
  .card-hero h1 { font-size: 28px; }
  .card-selected { scroll-margin-top: calc(var(--top) + var(--map-h) + 12px); }
  .map-hud.top-right { top: 10px; right: 10px; }
  .map-legend { left: 10px; bottom: 10px; right: 40px; max-width: none; padding: 7px 10px; font-size: 11px; }
  .map-legend .leg-items { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .map-legend .leg-items::-webkit-scrollbar { display: none; }
  .leg-title { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal-card { max-height: 94vh; max-height: 94dvh; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
}
@media (max-width: 520px) {
  .brand-sub, .brand-dot, .hide-sm { display: none; }
  .brand-text small { letter-spacing: 0.06em; font-size: 8.5px; }
  .kpi strong { font-size: 23px; }
  .inline-filter { width: 100%; }
  .card-head { align-items: stretch; }
}
@media (hover: none) {
  .map-tip { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
