:root {
  /* legacy names aliased to design tokens (tokens.css) */
  --ink-3: var(--ink-2);
  --line: var(--rule);
  --surface-2: var(--surface-sunk);
  --accent: var(--lens-blue);
  --model: var(--survey-red);
  --ctl-border: var(--rule);
  /* map-mirror colour used by the landmark legend key (same value as the plant dots painted in app.js) */
  --lm-plant: #8a4b33;
  --map-outside: #8d949b; /* same as OUTSIDE in app.js: beyond the basemap extent */
  font-family: var(--font-sans);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; color: var(--ink); background: var(--paper); font-size: 15px; line-height: 22px; }
#app { display: flex; height: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- shared controls (Button, SegmentedControl) ---------- */
button { font: inherit; cursor: pointer; }
.btn, .wide {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--target-min); padding: 0 var(--space-4);
  font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md);
}
.wide { width: 100%; }
.btn:hover, .wide:hover { background: var(--surface-sunk); }
.btn:disabled { color: var(--ink-2); background: var(--surface-sunk); cursor: not-allowed; opacity: 0.7; }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-sunk); border-radius: var(--radius-md); }
.seg button { flex: 1; min-height: var(--target-min); min-width: var(--target-min); padding: 0 var(--space-3); font: 600 13px/16px var(--font-sans); color: var(--ink-2); background: transparent; border: 0; border-radius: calc(var(--radius-md) - 2px); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop); }
select, input[type="search"], input[role="combobox"] {
  width: 100%; min-height: var(--target-min); padding: 0 var(--space-3); font: 500 14px/20px var(--font-sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-md);
}
select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
a:hover { color: var(--ink); }

/* ---------- top app bar ---------- */
#topbar { display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { flex: none; }
.lg-ring { fill: none; stroke: var(--ink); stroke-width: 6; }
.lg-arc { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.lg-ray { stroke: var(--survey-red); stroke-width: 4; stroke-linecap: round; }
.lg-dot { fill: var(--survey-red); }
.wordmark { font: 600 22px/28px var(--font-display); color: var(--ink); white-space: nowrap; }
.wordmark i { font-style: italic; color: var(--survey-red); }
.cswitch { position: relative; display: flex; flex-direction: column; }
#city-btn { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--target-min); padding: 0 var(--space-3) 0 14px; font: 700 14px/20px var(--font-sans); color: var(--ink); text-align: left; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); cursor: pointer; }
#city-btn .cs-model { font-weight: 500; color: var(--ink-2); white-space: pre; }
#city-btn .cs-beta { font: 700 10px/12px var(--font-sans); color: var(--survey-red); border: 1px solid var(--survey-red); border-radius: var(--radius-sm); padding: 2px 5px; }
#city-btn .cs-caret { margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translate(-2px, -2px); flex: none; }
#city-btn:hover, #city-btn[aria-expanded="true"] { border-color: var(--accent); }
#city-btn:focus-visible, #city-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.brand-home { display: flex; align-items: center; gap: 10px; min-height: var(--target-min); min-width: var(--target-min); padding: 0; background: none; border: 0; border-radius: var(--radius-md); color: inherit; cursor: pointer; }
.brand-home:disabled { cursor: default; }
#city-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: 4px; padding: 6px; display: flex; flex-direction: column; gap: 4px; max-height: min(420px, 70vh); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-float); }
#city-list[hidden] { display: none; }
#city-q { flex: none; }
#city-opts { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
#city-none { margin: 0; padding: 10px 9px; font-size: 13px; color: var(--ink-2); }
#city-list .cs-ghead { padding: 8px 9px 3px; font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
#city-list .cs-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--target-min); padding: 4px 9px; border-radius: var(--radius-sm); font-size: 14px; color: var(--ink); cursor: pointer; }
#city-list .cs-main { display: flex; flex-direction: column; min-width: 0; }
#city-list .cs-nm { font-weight: 600; line-height: 18px; }
#city-list .cs-sub { font-size: 12px; line-height: 16px; color: var(--ink-2); }
#city-list .cs-opt.active, #city-list .cs-opt:hover { background: var(--lens-blue-tint); color: var(--accent); }
#city-list .cs-opt.active .cs-sub, #city-list .cs-opt:hover .cs-sub { color: inherit; }
#city-list .cs-opt[aria-selected="true"] .cs-nm { font-weight: 700; }
#city-list .cs-opt[aria-selected="true"]::after { content: "\2713"; flex: none; }
#city-list .cs-tag { margin-left: auto; flex: none; padding: 1px 7px; font-size: 11px; font-weight: 700; color: var(--model); border: 1px solid var(--model); border-radius: var(--radius-pill); }
#city-list .cs-opt[aria-selected="true"] .cs-tag { margin-left: 0; }

/* ---------- home page (no city in the URL) ---------- */
#home { position: fixed; inset: 0; z-index: 200; overflow-y: auto; background: var(--paper); color: var(--ink); opacity: 1; transition: opacity 0.4s ease; }
#home::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5; background: repeating-radial-gradient(circle at 88% -8%, transparent 0 46px, var(--rule) 46px 47px); -webkit-mask-image: linear-gradient(200deg, #000, transparent 60%); mask-image: linear-gradient(200deg, #000, transparent 60%); }
#home.out { opacity: 0; pointer-events: none; }
.home-inner { position: relative; max-width: 1040px; margin: 0 auto; padding: 56px var(--space-5) 64px; }
#home h1 { display: flex; align-items: center; gap: 12px; margin: 0; font-weight: inherit; }
#home h1:focus { outline: none; }
#home .wordmark { font-size: 40px; line-height: 48px; }
.home-beta { align-self: center; font: 700 11px/14px var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--survey-red); border: 1px solid var(--survey-red); border-radius: var(--radius-pill); padding: 2px 8px; }
.home-lede { max-width: 640px; margin: var(--space-4) 0 0; font: 400 17px/26px var(--font-sans); color: var(--ink-2); }
.home-pick { margin: var(--space-5) 0 0; font: 600 13px/18px var(--font-sans); color: var(--ink-2); }
.home-sec { margin-top: var(--space-4); }
.home-sec h2 { margin: 0 0 var(--space-2); font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.home-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--space-3); }
.hc-card { position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 108px; height: 100%; padding: var(--space-4); overflow: hidden; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); transition: border-color 0.15s, transform 0.15s; }
.hc-card:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-2px); }
.hc-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hc-glyph { position: absolute; right: 10px; top: 10px; color: var(--accent); opacity: 0.22; pointer-events: none; }
.hc-name { font: 600 22px/28px var(--font-display); letter-spacing: -0.01em; }
.hc-state { font: 400 13px/18px var(--font-sans); color: var(--ink-2); }
.hc-tags { display: flex; gap: 6px; margin-top: auto; padding-top: var(--space-2); }
.hc-tag { padding: 1px 8px; font: 700 11px/16px var(--font-sans); text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid currentColor; border-radius: var(--radius-pill); }
.hc-beta { color: var(--survey-red); }
.hc-state-tag { color: var(--accent); }
@media (max-width: 820px) { .home-inner { padding: 32px 16px 40px; } #home .wordmark { font-size: 32px; line-height: 40px; } .home-lede { font-size: 16px; line-height: 24px; } }
@media (prefers-reduced-motion: reduce) { #home, .hc-card { transition: none; } .hc-card:hover { transform: none; } }
html[data-motion="reduce"] #home, html[data-motion="reduce"] .hc-card { transition: none; }
.combo { position: relative; }
.combo input { width: 100%; padding-left: 40px; }
.search-ico { position: absolute; left: 12px; top: 13px; color: var(--ink-2); pointer-events: none; }
#places { list-style: none; margin: 4px 0 0; padding: 4px; max-height: 240px; overflow-y: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-float); }
#places li { display: flex; align-items: center; min-height: var(--target-min); padding: 0 9px; border-radius: var(--radius-sm); font-size: 14px; color: var(--ink); cursor: pointer; }
#places li[aria-selected="true"], #places li:hover { background: var(--lens-blue-tint); color: var(--accent); }
#places li.none { color: var(--ink-2); cursor: default; }
.tb-actions { display: flex; gap: var(--space-2); }

/* ---------- left rail ---------- */
#rail { display: flex; flex-direction: column; gap: 9px; }
.block { display: flex; flex-direction: column; gap: var(--space-2); }
.sec { margin: 0; font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--target-min); }
.iconbtn { display: flex; align-items: center; justify-content: center; flex: none; width: var(--target-min); height: var(--target-min); min-width: var(--target-min); padding: 0; color: var(--ink-2); background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; }
.iconbtn:hover { background: var(--surface-sunk); color: var(--ink); }
.iconbtn[aria-expanded="true"] { color: var(--lens-blue); border-color: var(--lens-blue); }
.mini .iconbtn { padding: 0; min-width: var(--target-min); }
.sechead { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: var(--target-min); padding: 0; color: var(--ink-2); background: none; border: 0; border-radius: var(--radius-md); cursor: pointer; }
.sechead:hover { color: var(--ink); }
.sechead svg { flex: none; transition: transform 0.15s ease; }
.sechead[aria-expanded="false"] svg { transform: rotate(-90deg); }
.secbody { display: flex; flex-direction: column; gap: 2px; }
.secbody[hidden] { display: none; }
.brand-sub { margin: 0; font-size: 13px; line-height: 19px; color: var(--ink-2); }
#view { display: flex; flex-direction: column; gap: 2px; }
.view { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: var(--target-min); padding: 0 var(--space-3); text-align: left; font: 500 14px/20px var(--font-sans); color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-md); }
.view:hover { background: var(--surface-sunk); }
.view[aria-pressed="true"] { background: var(--lens-blue-tint); color: var(--lens-blue); font-weight: 700; }
.vramp { display: flex; flex: none; width: 44px; height: var(--bar-height); border-radius: 4px; overflow: hidden; }
.vramp span { flex: 1; }
#overlays { display: flex; flex-direction: column; gap: 9px; }
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.note { margin: 0; font-size: 12px; line-height: 17px; color: var(--ink-2); }
.mini { display: flex; gap: 6px; }
.mini button { min-height: var(--target-min); min-width: var(--target-min); padding: 2px 12px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.mini button:hover { background: var(--surface-sunk); }
.check { display: flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); padding: 2px 4px; border-radius: var(--radius-sm); font-size: 13px; line-height: 17px; color: var(--ink); cursor: pointer; }
.check:hover { background: var(--surface-sunk); }
.check input { width: 18px; height: 18px; min-width: 18px; margin: 0; accent-color: var(--lens-blue); flex: none; }
.gradkey { padding: 2px 4px 8px; }
.gradbar { position: relative; height: 12px; border-radius: 6px; border: 1px solid var(--rule); }
.gradbar i { position: absolute; top: 7px; bottom: -1px; width: 1px; background: var(--ink); }
.gradlab { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink-2); margin-top: 3px; }
.gradsub { font-size: 12px; line-height: 16px; color: var(--ink-2); margin-top: 4px; }
.swatch { width: 22px; height: 14px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); flex: none; }
.check .count { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.linekey { width: 22px; height: 0; flex: none; border-top: 3px solid var(--ink); }
.linekey.model { border-top: 2px dashed var(--survey-red); }
.linekey.road { border-top: 4px solid var(--road); }
.linekey.ave { border-top: 2px solid var(--road); }
.linekey.mile { border-top: 2px solid var(--road-case); }
.linekey.county { border-top: 2px dotted var(--ink-2); }
.dotkey { width: 12px; height: 12px; margin: 0 5px; border-radius: 6px; background: var(--lm-plant); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); flex: none; }
.dotkey.ctr { background: var(--ink); }
.ptkey { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin: 0 1px; border-radius: 10px; background: var(--ink); color: var(--surface); font: 700 11px/1 var(--font-sans); flex: none; }
.ptkey-ring { width: 12px; height: 12px; margin: 0 5px; background: var(--surface); border: 2px solid var(--ink); }
.ptsrc { margin: 0 0 6px 34px; font: 400 12px/17px var(--font-sans); color: var(--ink-2); }
.ptsrc .vin { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.ptsrc .note { margin-top: 4px; }
.pt-src { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--space-3) 0; font: 400 12px/17px var(--font-sans); color: var(--ink-2); }
.ptfacts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: var(--space-3) 0 0; font: 400 14px/20px var(--font-sans); color: var(--ink); }
.ptfacts dt { color: var(--ink-2); }
.ptfacts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kindlegend { list-style: none; margin: 0 0 6px 34px; padding: 0; font-size: 12px; color: var(--ink-2); }
.kindlegend li { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.kdot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--surface); box-shadow: 0 0 0 1px var(--ink); flex: none; }
.txtkey { width: 22px; text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-2); flex: none; }
#opacity-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
#opacity-row input { flex: 1; accent-color: var(--lens-blue); }
input[type="range"] { min-height: var(--target-min); }
.about summary { font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; display: flex; align-items: center; min-height: var(--target-min); }
.about div { font-size: 12px; line-height: 18px; color: var(--ink-2); }
.about p { margin: 0 0 8px; }

/* ---------- map and overlays ---------- */
#mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--map-outside); }
/* Census Bureau notices on the front page: a strip between the scale bar and the zoom buttons, never taking taps */
#census-note { position: absolute; z-index: 4; left: 128px; right: 72px; bottom: 4px; margin: 0; text-align: center; font: 400 11px/14px var(--font-sans); color: var(--ink-2); pointer-events: none; }
#census-note span { background: var(--surface); padding: 0 4px; border-radius: var(--radius-md); -webkit-box-decoration-break: clone; box-decoration-break: clone; }
#about-census a { color: var(--lens-blue); }
@media (min-width: 821px) { #mapwrap:has(#detail:not([hidden])) #census-note { right: calc(var(--panel-width) + 72px); } }
@media (max-width: 820px) {
  #census-note { left: var(--space-2); right: 68px; bottom: calc(var(--sheet-peek) + 4px); text-align: left; font-size: 10px; line-height: 13px; }
  #mapwrap:has(#sheet[data-state="half"]) #census-note { bottom: calc(52% + 4px); }
  #mapwrap:has(#sheet[data-state="full"]) #census-note, #mapwrap:has(#bubble:not([hidden])) #census-note { display: none; }
}
@media print { #census-note { display: none; } }
#menu { display: none; position: absolute; left: 12px; top: 12px; z-index: 5; min-height: var(--target-min); padding: 8px 16px; font-size: 14px; font-weight: 700; color: var(--on-lens-blue); background: var(--ink); border: 0; border-radius: var(--radius-md); box-shadow: var(--shadow-float); }
#tip { position: absolute; z-index: 4; pointer-events: none; max-width: 260px; padding: 7px 10px; font-size: 12px; line-height: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-float); }
#tip b { display: block; font-size: 13px; }
#fatal { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; padding: 32px; text-align: center; font-size: 15px; line-height: 23px; background: var(--surface); }
#fatal[hidden] { display: none; }
#loading { position: absolute; z-index: 6; left: 50%; top: 14px; transform: translateX(-50%); max-width: calc(100% - 140px); padding: 12px; font-size: 14px; font-weight: 700; line-height: 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-pill); box-shadow: var(--shadow-float); pointer-events: none; }
#loading[hidden] { display: none; }
#loading.err { color: var(--survey-red-deep); border-color: var(--survey-red-deep); }
body.is-loading #map { cursor: progress; }
#empty { position: absolute; z-index: 6; left: 50%; bottom: 40px; transform: translateX(-50%); max-width: min(420px, calc(100% - 24px)); padding: 10px 16px; font-size: 13px; line-height: 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-float); pointer-events: none; }
#empty[hidden] { display: none; }
/* shown while a tiled entry runs on the JS bundle because its tiles did not load (never mistaken for the tiled map) */
#tile-note { position: absolute; z-index: 6; left: 50%; top: 14px; transform: translateX(-50%); max-width: min(460px, calc(100% - 140px)); padding: 8px 14px; font-size: 13px; line-height: 18px; color: var(--ink); background: var(--surface); border: 1px solid var(--survey-red-deep); border-radius: var(--radius-md); box-shadow: var(--shadow-float); pointer-events: none; }

/* floating legend (MapLegend), bottom-left */
#legend-card { position: absolute; z-index: 5; left: var(--space-4); bottom: 44px; width: var(--legend-width); max-height: 45%; display: flex; flex-direction: column; padding: var(--space-2) var(--space-4) var(--space-3); background: color-mix(in srgb, var(--surface) 96%, transparent); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
#legend-card .block-head { align-items: center; flex: none; }
.legend-h { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.legend-h b { font: 600 14px/20px var(--font-sans); white-space: normal; overflow-wrap: anywhere; }
.legend-h span { font: 400 12px/16px var(--font-sans); color: var(--ink-2); white-space: normal; }
#legend-card .mini { align-items: center; gap: 0; flex: none; }
#legend-card .mini button { min-height: var(--target-min); min-width: var(--target-min); padding: 0 var(--space-2); font: 600 12px/16px var(--font-sans); color: var(--lens-blue); background: none; border: 0; border-radius: var(--radius-md); }
#legend-card .mini button:hover { background: var(--surface-sunk); }
#legend-card .mini #legend-toggle { display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
#legend-toggle svg { transition: transform 0.15s ease; transform: rotate(180deg); }
#legend-card.open #legend-toggle svg { transform: none; }
#legend-all, #legend-none { display: none; }
#legend-card.open #legend-all, #legend-card.open #legend-none { display: inline-flex; align-items: center; justify-content: center; }
#legend-key { flex: none; }
#legend { padding: 6px 0; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
#legend[hidden] { display: none; }
.lrow { width: 100%; min-height: var(--target-min); margin: -6px 0; padding: 0 var(--space-2); position: relative; background: none; border: 0; text-align: left; font: 500 13px/16px var(--font-sans); color: var(--ink); }
.lrow:hover { background: none; }
.lrow:hover::before { content: ""; position: absolute; inset: 6px 0; border-radius: var(--radius-sm); background: var(--surface-sunk); z-index: -1; }
.lrow .ltx { flex: 1; min-width: 0; }
.lrow .swatch { transition: background-color 0.1s; }
.lrow[aria-pressed="false"] { color: var(--ink-2); }
.lrow[aria-pressed="false"] .swatch { background: transparent !important; border-style: dashed; }
.lrow[aria-pressed="false"] .ltx { text-decoration: line-through; text-decoration-thickness: 1px; }

/* active-zone chip (ModelBadge chip form), top-left */
#zonechip { position: absolute; z-index: 5; left: var(--space-4); top: var(--space-4); display: flex; align-items: center; gap: var(--space-2); max-width: min(420px, calc(100% - 2 * var(--space-4))); padding: 6px 12px 6px 8px; font: 600 13px/18px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-pill); box-shadow: var(--shadow-pop); pointer-events: none; }
.mbadge { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px; border: 2px solid var(--survey-red); border-radius: 50%; font: 700 11px/1 var(--font-sans); color: var(--survey-red); background: var(--surface); }

/* map controls: zoom group above the credits button, bottom-right */
#mapwrap .maplibregl-ctrl-bottom-right { display: flex; flex-direction: column-reverse; align-items: flex-end; }
#mapwrap .maplibregl-ctrl-bottom-right .maplibregl-ctrl { float: none; margin: 0 var(--space-4) var(--space-2) 0; }
#mapwrap .maplibregl-ctrl-group { border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); background: var(--surface); }
#mapwrap .maplibregl-ctrl-group button { width: var(--target-min); height: var(--target-min); }
#mapwrap .maplibregl-ctrl-group button + button { border-top: 1px solid var(--rule); }
.cm-info { position: relative; background: none !important; box-shadow: none !important; margin-bottom: var(--space-4) !important; }
.info-btn { display: flex; align-items: center; justify-content: center; width: var(--target-min); height: var(--target-min); min-width: var(--target-min); margin-left: auto; padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); cursor: pointer; }
.info-btn:hover { background: var(--surface-sunk); }
.info-btn[aria-expanded="true"] { color: var(--lens-blue); border-color: var(--lens-blue); }
.info-panel { position: absolute; right: 0; bottom: 52px; width: min(460px, calc(100vw - 24px)); max-height: min(60vh, 420px); overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-float); font-size: 12px; line-height: 17px; text-align: left; }
.info-panel[hidden] { display: none; }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.info-close { min-height: var(--target-min); padding: 0 14px; font-size: 13px; font-weight: 600; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); cursor: pointer; }
.info-panel .ogl { display: block; margin: 0 0 8px; color: var(--ink-2); }
.info-panel a { color: var(--accent); }

/* ---------- detail panel ---------- */
#detail { position: absolute; z-index: 6; overflow-y: auto; padding: var(--space-4); background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--shadow-float); }
#detail.skel { pointer-events: none; overflow: hidden; }
#detail .sk { background: linear-gradient(90deg, var(--surface-sunk) 25%, var(--paper) 50%, var(--surface-sunk) 75%); background-size: 200% 100%; border-radius: 6px; animation: skpulse 1.4s linear infinite; margin-bottom: 12px; }
#detail .sk-kick { height: 12px; width: 40%; } #detail .sk-title { height: 26px; width: 75%; margin-bottom: 18px; } #detail .sk-hero { height: 64px; }
#detail .sk-row { height: 16px; } #detail .sk-text { height: 90px; }
@keyframes skpulse { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #detail .sk { animation: none; } }
#detail .kicker, #bubble .kicker { font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); padding-right: 52px; }
#detail h2 { font-family: var(--font-display); margin: 6px 52px 0 0; font-size: 34px; line-height: 40px; font-weight: 600; letter-spacing: -0.01em; }
#detail .close { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; justify-content: center; width: var(--target-min); height: var(--target-min); font-size: 24px; line-height: 1; color: var(--ink-2); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
#detail .close:hover { background: var(--surface-sunk); color: var(--ink); }
.hero { margin-top: var(--space-4); padding: var(--space-4) 18px; background: var(--paper); border-radius: var(--radius-lg); display: flex; flex-direction: column; gap: var(--space-2); }
.herotop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-1) var(--space-2); }
.hero .lab { font: 500 13px/18px var(--font-sans); color: var(--ink-2); }
.tier { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--space-3); border-radius: var(--radius-pill); font: 600 12px/16px var(--font-sans); white-space: nowrap; }
.tier.t1 { background: var(--lens-blue-tint); color: var(--lens-blue); }
.tier.t2 { background: var(--estimate-gold-tint); color: var(--estimate-gold); }
.tier.t3 { background: var(--survey-red-tint); color: var(--survey-red-deep); }
.hero .val { font: 700 40px/44px var(--font-sans); font-variant-numeric: tabular-nums; }
.hero .moe { font-size: 16px; font-weight: 500; color: var(--ink-2); }
.hero .cls { display: flex; align-items: center; gap: 8px; font: 500 13px/18px var(--font-sans); color: var(--ink-2); }
.hero .cmp { font: 500 13px/18px var(--font-sans); color: var(--ink-2); }
.stats { margin: var(--space-4) 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-4); }
.stats li { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 6px; font: 500 14px/20px var(--font-sans); }
.stats .k { color: var(--ink); }
.stats .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.stats .v small { font-weight: 400; font-size: 13px; color: var(--ink-2); }
.bar { grid-column: 1 / -1; position: relative; overflow-x: clip; height: var(--bar-height); background: var(--surface-sunk); border-radius: 4px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--data-4); border-radius: 4px; }
.bar u { position: absolute; top: -4px; width: 2px; height: 16px; border-radius: 1px; background: var(--ink); text-decoration: none; }
.bar u::after { content: ''; position: absolute; left: -6px; right: -6px; top: -2px; bottom: -2px; }
.barkey { margin: var(--space-3) 0 0; font: 500 12px/16px var(--font-sans); color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.barkey u { display: inline-block; width: 2px; height: 12px; background: var(--ink); text-decoration: none; }
.cmpkey { list-style: none; padding: 0; flex-wrap: wrap; gap: 4px var(--space-4); }
.cmpkey li { display: inline-flex; align-items: center; gap: 6px; }
.cmpctl { margin: var(--space-3) 0 0; font-size: 12px; line-height: 17px; color: var(--ink-2); }
.cmpctl summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); padding: 0 var(--space-4); font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); cursor: pointer; list-style: none; }
.cmpctl summary::-webkit-details-marker { display: none; }
.cmpctl summary::before { content: '+'; font-weight: 700; color: var(--lens-blue); }
.cmpctl[open] summary::before { content: '\2212'; }
.cmpctl summary:hover { background: var(--surface-sunk); }
.cmpopt { display: flex; align-items: center; gap: 8px; padding: 4px 4px; min-height: var(--target-min); font-size: 13px; color: var(--ink); }
.cmpopt input { margin: 0; width: 18px; height: 18px; min-width: 18px; accent-color: var(--lens-blue); }
.cmpopt u { display: inline-block; width: 2px; height: 14px; text-decoration: none; }
.cmpopt small, .cmpnote { color: var(--ink-2); font-size: 12px; line-height: 16px; }
.cmpnote { margin: 6px 0 0; }
.facts { margin: var(--space-4) 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.facts div { padding: var(--space-3) 14px; background: var(--paper); border-radius: var(--radius-md); font: 500 12px/16px var(--font-sans); color: var(--ink-2); }
.facts b { display: block; font: 700 18px/24px var(--font-sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.callout { margin: var(--space-4) 0 0; font: 400 13px/20px var(--font-sans); color: var(--ink-2); }
.history { margin: var(--space-4) 0 0; }
.history h3, .srcs h3, .zlinks h3, .kids h3 { margin: 0 0 4px; font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.history p { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.history .draft { display: inline-block; margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--ink-2); }

/* landmark bubble (LandmarkBubble): 320px card, 14px tail, glyph chip + kicker + close, name, 3-line text, status pill, sources, position note, actions */
#bubble, #explain { position: absolute; z-index: 7; top: 0; left: 0; width: var(--bubble-width); max-width: calc(100% - 16px); background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
#bubble { padding: var(--space-4); }
#explain .tail { position: absolute; bottom: -8px; width: 14px; height: 14px; margin-left: -7px; background: var(--surface); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); transform: rotate(45deg); }
/* Bubble tail: a triangle whose base centre sits on the bubble edge; app.js sets left/top and rotates it about that point to aim at the dot. */
#bubble .tail { position: absolute; left: 0; top: 0; width: 22px; height: 12px; transform-origin: 50% 0; pointer-events: none; }
#bubble .tail::before, #bubble .tail::after { content: ''; position: absolute; clip-path: polygon(0 0, 100% 0, 50% 100%); }
#bubble .tail::before { inset: 0; background: var(--rule); }
#bubble .tail::after { left: 2px; right: 2px; top: -2px; bottom: 2px; background: var(--surface); }
.bhead { display: flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); margin: -6px 0 0; }
.bhead .kicker { flex: 1; min-width: 0; padding: 0 !important; font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.lmchip { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 50%; color: var(--lens-blue); background: var(--surface); border: 1.5px solid var(--lens-blue); }
.bhead .close { flex: none; display: flex; align-items: center; justify-content: center; width: var(--target-min); height: var(--target-min); margin-right: -8px; padding: 0; color: var(--ink-2); background: transparent; border: 0; border-radius: var(--radius-md); cursor: pointer; }
.bhead .close:hover { background: var(--surface-sunk); color: var(--ink); }
#bubble h2 { font-family: var(--font-display); margin: 2px 0 var(--space-2); font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
#bubble .zdesc { margin: 0 0 var(--space-2); font-size: 14px; line-height: 21px; }
#bubble .zdesc.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#bubble.exp .zdesc.clamp { display: block; overflow: visible; }
.readmore { display: inline-flex; align-items: center; min-height: var(--target-min); margin: -6px 0 -2px; padding: 0; font: 500 14px/20px var(--font-sans); color: var(--accent); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.readmore[hidden] { display: none; }
#bubble .status { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 var(--space-3); font-size: 12px; line-height: 16px; color: var(--ink-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 24px; padding: 0 var(--space-3); border-radius: var(--radius-pill); font: 600 12px/16px var(--font-sans); white-space: nowrap; }
.pill.draft { color: var(--ink-2); background: transparent; border: 1px dashed var(--ink-2); }
.pill.checked { color: var(--lens-blue); background: var(--lens-blue-tint); border: 1px solid transparent; }
#bubble .more { border-top: 1px solid var(--rule); padding-top: var(--space-3); margin-top: var(--space-1); }
#bubble .more:empty { display: none; }
#bubble .srcs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
#bubble .srcs h3 { margin: 0; }
#bubble .srcs ul { display: contents; list-style: none; padding: 0; }
#bubble .srcs li { display: inline-flex; }
#bubble .srcs a { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 var(--space-3); font: 500 12px/16px var(--font-sans); color: var(--accent); text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius-pill); }
#bubble .srcs a:hover { background: var(--surface-sunk); }
/* source chip (landmark schema): a book/record is plain text (no link, no icon); a link chip keeps a 44px target and wraps long labels */
#bubble .srcs .srcbook { display: inline-block; min-width: 0; max-width: 100%; padding: 4px 0; font: 500 12px/16px var(--font-sans); color: var(--ink-2); overflow-wrap: anywhere; }
#bubble .srcs li { min-width: 0; max-width: 100%; }
#bubble .srcs a.srcchip { min-height: 44px; max-width: 100%; text-align: left; overflow-wrap: anywhere; }
#bubble .poinote { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--space-3); font-size: 12px; line-height: 16px; color: var(--ink-2); }
#bubble .actions { margin-top: var(--space-3); align-items: stretch; }
#bubble .actions .zoom { flex: 1; color: var(--on-lens-blue); background: var(--lens-blue); border-color: var(--lens-blue); }
#bubble .actions .zoom:hover { filter: brightness(1.08); background: var(--lens-blue); }
.report { display: flex; align-items: center; justify-content: center; flex: none; width: var(--target-min); height: var(--target-min); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.report:hover { background: var(--surface-sunk); }
#bubble :focus-visible, #explain :focus-visible, .sechead:focus-visible, .iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* "How to read this map" bubble: right of the rail, tail pointing left at the info button */
#explain { z-index: 9; left: var(--space-4); top: 0; width: 340px; }
#explain .exbody { max-height: calc(100vh - var(--header-height) - 24px); overflow-y: auto; padding: var(--space-4); border-radius: var(--radius-lg); }
#explain .tail { left: -8px; bottom: auto; margin: -7px 0 0; border: 0; border-left: 1px solid var(--rule); border-bottom: 1px solid var(--rule); transform: rotate(45deg); }
#explain h2 { margin: 2px 0 0; font: 600 22px/28px var(--font-display); letter-spacing: -0.01em; }
#explain h3 { margin: var(--space-3) 0 4px; font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
#explain .ex-level { margin: 2px 0 var(--space-3); font: 700 12px/16px var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
#explain .note { margin: 0 0 var(--space-2); font-size: 14px; line-height: 20px; color: var(--ink); }
#explain #units-note, #explain #scale-note, #explain #geo-note { color: var(--ink-2); font-size: 13px; line-height: 19px; }
#explain[hidden], #bubble[hidden] { display: none; }
.actions { margin-top: var(--space-4); display: flex; gap: 8px; }
.actions button { min-height: var(--target-min); padding: 0 var(--space-4); font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.actions button:hover { background: var(--surface-sunk); }

/* Filled model zones */
.zbadge { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; border-radius: 50%; color: var(--on-lens-blue); font: 700 11px/1 var(--font-sans); border: 1.5px solid var(--surface); box-shadow: var(--shadow-pop); }
.zhead { display: flex; align-items: center; gap: 8px; }
.zhead .zbadge { width: 26px; height: 26px; font-size: 13px; }
.zdesc { margin: 8px 0; line-height: 1.45; }
.zdraft { display: inline-block; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.zlegend { list-style: none; margin: 2px 0 6px 26px; padding: 0; }
.zlegend button, .zlink { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 3px 4px; min-height: var(--target-min); font: inherit; font-size: 13px; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }
.zlegend button:hover, .zlink:hover { background: var(--surface-sunk); }
.zdesc, #detail h2, .srcs { overflow-wrap: anywhere; }
.srcs { margin: 8px 0; }
.srcs ul { margin: 0; padding-left: 18px; font-size: 12px; line-height: 18px; }
.lurow { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; padding: 3px 0; min-height: var(--target-min); font: inherit; color: inherit; cursor: pointer; }
.lurow:hover { background: var(--surface-sunk); }
.zlinks { margin: var(--space-3) 0; }
.kids { margin: var(--space-3) 0 0; }
.kids p { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-2); }

/* ---------- View as table ---------- */
#tblview { position: absolute; z-index: 7; display: flex; flex-direction: column; padding: var(--space-4); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
#tblview[hidden] { display: none; }
#tblview .tbl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#tblview h2 { font-family: var(--font-display); margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
#tblview .tbl-head button, #tbl-more { min-height: var(--target-min); min-width: var(--target-min); padding: 0 var(--space-4); font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.tbl-tools { display: flex; align-items: center; gap: 10px; margin: var(--space-3) 0; }
#tbl-search { flex: 1; }
#tbl-count { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
#tbl-wrap { flex: 1; overflow-y: auto; overflow-x: auto; scrollbar-gutter: auto; border: 1px solid var(--rule); border-radius: var(--radius-md); }
#tbl-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
#tbl-wrap th, #tbl-wrap td { padding: 0 var(--space-4); text-align: left; border-bottom: 1px solid var(--rule); height: var(--target-min); }
#tbl-wrap td.num, #tbl-wrap th.num { text-align: right; }
#tbl-wrap thead th { position: sticky; top: 0; background: var(--surface-sunk); z-index: 1; padding: 0; }
#tbl-wrap th button { width: 100%; min-height: var(--target-min); padding: 0 var(--space-4); font-size: 13px; font-weight: 700; color: var(--ink); background: transparent; border: 0; text-align: inherit; }
#tbl-wrap button.rowbtn { min-height: var(--target-min); padding: 0; font-size: 13px; font-weight: 600; color: var(--accent); background: none; border: 0; text-align: left; text-decoration: underline; }
#tbl-wrap tr.sel td, #tbl-wrap tr.sel th { background: var(--highlight); }
#tbl-wrap tr:hover td { background: var(--lens-blue-tint); }
#tbl-wrap tr.sel:hover td { background: var(--highlight); }
#tbl-wrap .tbl-empty, #tbl-wrap .tbl-more { padding: var(--space-4); font-size: 13px; line-height: 18px; }
@media (max-width: 600px) { #tbl-wrap .opt { display: none; } #tbl-wrap th, #tbl-wrap td { padding: 0 8px; } #tbl-wrap th button { padding: 0 8px; } #tbl-wrap td { white-space: nowrap; } #tbl-wrap th button, #tbl-wrap td button.rowbtn { white-space: normal; overflow-wrap: anywhere; } }
#tbl-wrap td.num, #tbl-wrap th.num { white-space: nowrap; } #tbl-wrap td button.rowbtn, #tbl-wrap th button { overflow-wrap: anywhere; } #tbl-wrap td { overflow-wrap: anywhere; }
@media (max-width: 400px) { #tbl-wrap table, #tbl-wrap th button, #tbl-wrap td button.rowbtn { font-size: 11px; } #tbl-wrap th, #tbl-wrap td, #tbl-wrap th button { padding: 0 4px; } #tblview { padding: 10px; } }

/* ---------- desktop layout: app bar, rail, map, docked detail panel ---------- */
@media (min-width: 821px) {
  #app { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); background: var(--paper); }
  #sidebar { display: contents; }
  #scrim { display: none; }
  #topbar { grid-column: 1 / -1; grid-row: 1; position: relative; z-index: 12; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: var(--space-2) var(--space-3); min-height: var(--header-height); padding: var(--space-2) var(--space-4) var(--space-2) var(--space-5); background: var(--surface); border-bottom: 1px solid var(--rule); }
  .brand { flex: none; }
  #city-switch { flex: 0 1 auto; min-width: 0; }
  #city-btn { width: auto; max-width: 100%; }
  #city-btn .cs-name { flex: none; white-space: nowrap; }
  #city-btn .cs-model { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
  #city-btn .cs-beta { flex: none; }
  #city-list { right: auto; min-width: 320px; }
  #search-wrap { flex: 1 1 140px; min-width: 96px; max-width: 420px; }
  #places { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; }
  #geo-seg { display: inline-flex; flex: 0 0 auto; }
  #geo-seg button { flex: 0 0 auto; padding: 0 10px; }
  .tb-actions .btn { padding: 0 var(--space-3); }
  .tb-actions { margin-left: auto; flex: none; }
  #rail { grid-column: 1; grid-row: 2; overflow-y: auto; padding: var(--space-5) var(--space-4); background: var(--surface); border-right: 1px solid var(--rule); }
  #mapwrap { grid-column: 2; grid-row: 2; }
  #detail { top: 0; right: 0; bottom: 0; width: var(--panel-width); max-width: 100%; padding: var(--space-5); border-width: 0 0 0 1px; border-radius: 0; box-shadow: none; }
  #mapwrap:has(#detail:not([hidden])) .maplibregl-ctrl-bottom-right { right: var(--panel-width); }
  #tblview { top: var(--space-4); left: var(--space-4); bottom: var(--space-4); width: min(640px, calc(100% - var(--panel-width) - 3 * var(--space-4))); }
  .info-panel { right: 52px; bottom: 0; }
  #tbl-wrap th, #tbl-wrap td { padding: 0 var(--space-3); }
  #tbl-wrap th:first-child, #tbl-wrap td:first-child { padding-left: var(--space-4); }
  #tbl-wrap th:last-child, #tbl-wrap td:last-child { padding-right: var(--space-4); }
  #tbl-wrap thead th { padding: 0; }
  #tbl-wrap button.rowbtn { display: inline-flex; align-items: center; min-width: var(--target-min); }
  #tbl-wrap th button { padding: 0 var(--space-3); }
  #tbl-wrap thead th:first-child button { padding-left: var(--space-4); }
  #tbl-wrap thead th:last-child button { padding-right: var(--space-4); }
}

/* narrow desktop (821-1250px): keep the app bar on one row. Tour/Table go icon-only, geography labels wrap, city and search shrink. */
@media (min-width: 821px) and (max-width: 1250px) {
  #topbar { gap: var(--space-2); padding-left: var(--space-4); }
  .tb-actions .lbl { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tb-actions .btn { min-width: var(--target-min); padding: 0; }
  #geo-seg { flex: 0 1 auto; min-width: 0; }
  #geo-seg button { flex: 1 1 auto; min-width: var(--target-min); padding: 0 6px; font-size: 12px; line-height: 14px; }
  #city-btn { padding-left: var(--space-3); }
}
@media (min-width: 821px) and (max-width: 1060px) {
  .wordmark { display: none; }
  #city-btn .cs-model { display: none; }
}

/* ---------- small screens (Phase 3): top bar (search + layers), controls drawer, bottom sheet, full-screen table ---------- */
#mtop, #sheet, #drawer-close { display: none; }
#scrim { display: none; }
@media (max-width: 820px) {
  #mapwrap { --sheet-peek: 204px; }
  /* top bar over the map: layers button + search */
  #mtop { display: flex; position: absolute; z-index: 8; left: 14px; right: 14px; top: var(--space-4); gap: var(--space-2); align-items: flex-start; }
  #menu { position: static; display: flex; align-items: center; justify-content: center; flex: none; width: var(--target-min); height: var(--target-min); min-height: var(--target-min); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); }
  #menu[aria-expanded="true"] { color: var(--lens-blue); border-color: var(--lens-blue); }
  #mtop #search-wrap { flex: 1; min-width: 0; }
  #mtop #search { background: var(--surface); box-shadow: var(--shadow-pop); }
  #places { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; }
  /* controls drawer: slides over the map, dimmed backdrop */
  #sidebar { position: absolute; z-index: 10; left: 0; top: 0; bottom: 0; width: min(332px, 88vw); height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-4) var(--space-4) var(--space-6); background: var(--surface); border-right: 1px solid var(--rule); border-radius: 0 var(--radius-xl) var(--radius-xl) 0; transform: translateX(-102%); visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s; box-shadow: var(--shadow-float); }
  #sidebar.open { transform: none; visibility: visible; transition: transform 0.25s ease, visibility 0s; }
  #scrim { display: block; position: fixed; inset: 0; z-index: 9; background: color-mix(in srgb, var(--ink) 45%, transparent); opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0s linear 0.25s; }
  #scrim.on { opacity: 1; visibility: visible; transition: opacity 0.25s ease, visibility 0s; }
  #drawer-close { display: flex; align-items: center; justify-content: center; flex: none; width: var(--target-min); height: var(--target-min); margin-left: auto; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
  .brand { width: 100%; }
  #colour-block { display: none; }
  .seg4 { display: grid; grid-template-columns: 1fr 1fr; }
  .tb-actions .btn { flex: 1; }
  #zonechip { display: none; }
  /* bottom sheet: peek = legend + view chips, half = detail, full = lists */
  #sheet { display: flex; flex-direction: column; position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; height: var(--sheet-peek); background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-sheet); transition: height 0.25s ease; }
  #sheet[data-state="half"] { height: 52%; }
  #sheet[data-state="full"] { height: calc(100% - 128px); }
  #sheet.drag { transition: none; }
  #sheet-handle { display: flex; align-items: center; justify-content: center; flex: none; height: var(--target-min); touch-action: none; cursor: grab; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  #sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--rule); }
  #sheet-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
  #sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--space-3); overflow-y: auto; padding: 0 var(--space-4) var(--space-4); }
  #sheet[data-state="peek"] #sheet-body { overflow: hidden; }
  #sheet-body > * { flex: none; }
  #sheet.has-detail #detail { order: -1; }
  #sheet #view { display: flex; flex-direction: row; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
  #sheet #view::-webkit-scrollbar { display: none; }
  #sheet .view { width: auto; flex: none; white-space: nowrap; padding: 0 var(--space-4); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-pill); }
  #sheet .view[aria-pressed="true"] { background: var(--lens-blue-tint); border-color: var(--lens-blue); }
  #sheet .vramp { display: none; }
  #legend-card { position: static; display: block; width: auto; max-height: none; overflow: visible; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
  #sheet #detail { position: relative; z-index: auto; top: auto; left: auto; right: auto; bottom: auto; width: auto; max-height: none; overflow: visible; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
  #sheet #detail.skel { padding: var(--space-4); overflow: hidden; }
  #detail h2 { font-size: 28px; line-height: 34px; }
  #detail .close { top: 0; right: 0; }
  #mapwrap .maplibregl-ctrl-bottom-right { bottom: var(--sheet-peek); }
  #mapwrap:has(#sheet[data-state="half"]) .maplibregl-ctrl-bottom-right { bottom: 52%; }
  /* at full height the controls sit in a row just above the sheet (below the search bar) instead of vanishing */
  #mapwrap:has(#sheet[data-state="full"]) .maplibregl-ctrl-bottom-right { bottom: auto; top: calc(var(--space-4) + var(--target-min) + var(--space-2)); flex-direction: row-reverse; align-items: center; }
  #mapwrap:has(#sheet[data-state="full"]) .maplibregl-ctrl-bottom-right .maplibregl-ctrl { margin: 0 var(--space-2) 0 0; }
  #mapwrap:has(#sheet[data-state="full"]) .maplibregl-ctrl-group { display: flex; }
  #mapwrap:has(#sheet[data-state="full"]) .maplibregl-ctrl-group button + button { border-top: 0; border-left: 1px solid var(--rule); }
  #mapwrap:has(#sheet[data-state="full"]) .cm-info { margin-bottom: 0 !important; }
  /* peek: legend shows only the heading and the compact gradient strip */
  #sheet[data-state="peek"] #legend, #sheet[data-state="peek"] #legend-all, #sheet[data-state="peek"] #legend-none, #sheet[data-state="peek"] #legend-toggle { display: none; }
  #legend-card .block-head { min-height: 40px; }
  #legend-card #legend { overflow: visible; }
  #loading { top: 76px; left: var(--space-4); transform: none; max-width: calc(100% - 2 * var(--space-4)); }
  /* under the search bar, full width: the foot of the map belongs to the Census notice */
  #empty { top: 76px; bottom: auto; left: var(--space-4); right: var(--space-4); transform: none; max-width: none; }
  /* table: full screen, 16px gutters, numbers right-aligned */
  #tblview { z-index: 8; inset: 0; width: auto; padding: var(--space-4) 0 0; border: 0; border-radius: 0; box-shadow: none; }
  #tblview .tbl-head, #tblview .tbl-tools { padding: 0 var(--space-4); }
  #tbl-wrap { border: 0; border-top: 1px solid var(--rule); border-radius: 0; }
  #tbl-wrap th, #tbl-wrap td { padding: 0 var(--space-2); }
  #tbl-wrap thead th { padding: 0; }
  #tbl-wrap th button { padding: 0 var(--space-2); }
  #tbl-wrap th:first-child, #tbl-wrap td:first-child, #tbl-wrap thead th:first-child button { padding-left: var(--space-4); }
  #tbl-wrap th:last-child, #tbl-wrap td:last-child, #tbl-wrap thead th:last-child button { padding-right: var(--space-4); }
  #tbl-wrap thead th:first-child, #tbl-wrap thead th:last-child { padding: 0; }
  #tbl-wrap button.rowbtn { display: inline-flex; align-items: center; }
}
@media (prefers-reduced-motion: reduce) { #sidebar, #sidebar.open, #scrim, #scrim.on, #sheet { transition: none; } }
#sidebar:focus { outline: none; }

/* ---------- Night theme: MapLibre control chrome that ships with light colours ---------- */
#mapwrap .maplibregl-ctrl-scale { color: var(--ink); background: var(--surface); border-color: var(--ink-2); }
:root[data-theme="night"] { color-scheme: dark; }
:root[data-theme="night"] #mapwrap .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; }
  :root:not([data-theme]) #mapwrap .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(180deg); }
}

/* small screens: landmark card and explainer become bottom sheets (compact; Read more expands) */
@media (max-width: 820px) {
  #bubble { position: fixed; left: 0; right: 0; bottom: 0; top: auto; translate: none !important; width: auto; max-width: none; max-height: 72%; overflow-y: auto; border-width: 1px 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-sheet); z-index: 11; padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
  #bubble .tail { display: none; }
  #mapwrap:has(#bubble:not([hidden])) .maplibregl-ctrl-bottom-right { display: none; }
  #bubble:not(.exp) .more { display: none; }
  #explain { position: fixed; left: 0; right: 0; bottom: 0; top: auto !important; width: auto; max-width: none; border-width: 1px 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-sheet); z-index: 14; }
  #explain .exbody { max-height: 72vh; padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
  #explain .tail { display: none; }
}

/* ---------- Settings page (5c): SettingsRow, Switch, SegmentedControl, ThemeCard, colour-ramp list ---------- */
#settings { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; color: var(--ink); background: var(--paper); }
.set-bar { flex: none; display: flex; align-items: center; gap: var(--space-3); min-height: var(--header-height); padding: var(--space-2) var(--space-4) var(--space-2) var(--space-5); background: var(--surface); border-bottom: 1px solid var(--rule); }
.set-bar .saved { margin-left: auto; }
.iconbtn-lg { min-width: var(--target-min); padding: 0; }
.iconbtn-lg.active { color: var(--lens-blue); border-color: var(--lens-blue); background: var(--lens-blue-tint); }
.spill { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 28px; padding: 0 var(--space-3); font: 600 12px/16px var(--font-sans); color: var(--ink-2); border: 1px dashed var(--ink-2); border-radius: var(--radius-pill); white-space: nowrap; }
.spill.saved { color: var(--lens-blue); background: var(--lens-blue-tint); border: 0; }
.set-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.set-nav { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 4px; padding: var(--space-4); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--rule); }
.set-nav a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--target-min); padding: 0 var(--space-3); font: 600 15px/20px var(--font-sans); color: var(--ink); text-decoration: none; border-radius: var(--radius-md); }
.set-nav a:hover { background: var(--lens-blue-tint); color: var(--lens-blue); }
.set-reset { grid-column: 1; grid-row: 2; padding: var(--space-4); background: var(--surface); border-right: 1px solid var(--rule); }
.set-main { grid-column: 2; grid-row: 1 / span 2; overflow-y: auto; padding: var(--space-6) var(--space-7) var(--space-8); outline: none; }
.set-main h1 { margin: 0 0 var(--space-5); font: 600 44px/52px var(--font-display); letter-spacing: -0.02em; }
.set-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; max-width: 1200px; }
.set-col { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.scard { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); overflow: hidden; }
.scard > .skick { padding: var(--space-5) var(--space-5) var(--space-2); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); width: 100%; min-height: 60px; padding: var(--space-3) var(--space-5); text-align: left; color: var(--ink); background: transparent; border: 0; border-top: 1px solid var(--rule); border-radius: 0; font: inherit; }
.scard > .skick + .srow { border-top: 0; }
.stx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stx b { font: 600 15px/20px var(--font-sans); }
.stx small { font: 400 14px/19px var(--font-sans); color: var(--ink-2); }
button.sswitch { cursor: pointer; }
button.sswitch:hover { background: var(--surface-sunk); }
.strack { position: relative; flex: none; width: var(--switch-width, 52px); height: 32px; border: 2px solid var(--ink-2); border-radius: var(--radius-pill); background: var(--surface-sunk); }
.sthumb { position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--ink-2); color: transparent; transition: transform 0.15s ease; }
.sswitch[aria-checked="true"] .strack { background: var(--lens-blue); border-color: var(--lens-blue); }
.sswitch[aria-checked="true"] .sthumb { transform: translateX(20px); background: var(--surface); color: var(--lens-blue); }
.sseg { display: flex; flex: none; gap: 2px; padding: 3px; background: var(--surface-sunk); border-radius: var(--radius-md); }
.sseg button { min-height: var(--target-min); min-width: var(--target-min); padding: 0 var(--space-3); font: 600 14px/18px var(--font-sans); color: var(--ink-2); background: transparent; border: 0; border-radius: calc(var(--radius-md) - 2px); }
.sseg button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop); }
.stheme-row, .sramp-row { flex-direction: column; align-items: stretch; }
.tcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.tcard { display: flex; flex-direction: column; gap: 6px; min-height: var(--target-min); padding: 6px; background: var(--surface); border: 2px solid var(--rule); border-radius: var(--radius-lg); color: var(--ink); }
.tcard svg { display: block; border-radius: var(--radius-md); }
.tcard .tname { display: flex; align-items: center; justify-content: space-between; min-height: 28px; padding: 0 4px; font: 600 14px/18px var(--font-sans); }
.tcard[aria-pressed="true"], .rcard[aria-pressed="true"] { border-color: var(--lens-blue); background: var(--lens-blue-tint); color: var(--lens-blue); }
.rlist { display: flex; flex-direction: column; gap: var(--space-2); }
.rcard { display: flex; align-items: center; gap: var(--space-4); min-height: var(--target-min); padding: 0 var(--space-4); background: var(--surface); border: 2px solid var(--rule); border-radius: var(--radius-md); color: var(--ink); text-align: left; font: 600 14px/18px var(--font-sans); }
.rcard .rname { flex: none; width: 140px; }
.rcard .rbar { display: flex; flex: 1; height: 12px; border-radius: 6px; overflow: hidden; }
.rcard .rbar i { flex: 1; }
.rcard .rsp, .rcard svg { flex: none; width: 16px; height: 16px; }
.slocked .spill { white-space: normal; text-align: center; }
.slocked .stx small { max-width: 38ch; }
#set-back { white-space: nowrap; flex: none; }
@media (max-width: 820px) {
  .mlong { display: none; }
  .set-bar { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
  .set-bar .wordmark { display: none; }
  .set-bar .saved { font-size: 11px; padding: 0 var(--space-2); white-space: normal; text-align: center; }
  .set-body { display: flex; flex-direction: column; overflow-y: auto; }
  .set-nav { flex: none; flex-direction: row; gap: 6px; padding: var(--space-2) var(--space-3); overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--rule); }
  .set-nav a { flex: none; padding: 0 var(--space-3); font-size: 14px; border: 1px solid var(--rule); border-radius: var(--radius-pill); }
  .set-main { overflow: visible; padding: var(--space-4); }
  .set-main h1 { font-size: 34px; line-height: 40px; }
  .set-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .set-col { gap: var(--space-4); margin-bottom: var(--space-4); }
  .set-reset { padding: var(--space-4); background: transparent; border: 0; }
  .sseg-row { flex-direction: column; align-items: stretch; }
  .sseg-row .sseg button { flex: 1; }
  .rcard .rname { width: 104px; }
  .slocked { flex-wrap: wrap; }
}

/* ---------- settings that change the whole page ---------- */
html[data-text="large"] { --ts: 1.15; }
html[data-text="largest"] { --ts: 1.3; }
html[data-text] #rail, html[data-text] #legend-card, html[data-text] #tblview, html[data-text] #explain, html[data-text] #sheet-body, html[data-text] #settings .set-main, html[data-text] #detail { zoom: var(--ts); }
@media (min-width: 821px) { html[data-text] #detail { width: calc(var(--panel-width) / var(--ts)); } }
:root:root[data-targets="large"] { --target-min: 48px; }
:root:root[data-outlines="strong"] { --rule: var(--ink-2); }
:root:root[data-outlines="strong"] button:focus-visible, :root:root[data-outlines="strong"] input:focus-visible { outline-width: 3px; }
:root:root[data-outlines="strong"] .scard, :root:root[data-outlines="strong"] .btn, :root:root[data-outlines="strong"] .seg { border-width: 2px; }
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }

/* High-uncertainty flag (muted red caution icon; the note is body-coloured text) */
.unc { display: inline-flex; align-items: center; justify-content: center; color: var(--survey-red-deep); vertical-align: middle; }
button.unc { min-width: 44px; min-height: 44px; margin: -12px -8px -12px -4px; padding: 0; background: none; border: 0; border-radius: var(--radius-md); cursor: pointer; opacity: .85; }
button.unc:hover { opacity: 1; background: var(--survey-red-tint); }
button.unc:focus-visible { outline: 2px solid var(--survey-red-deep); outline-offset: -2px; opacity: 1; }
.unc-tip { margin-left: 4px; margin-top: -2px; }
.hero .val .unc { margin-left: 2px; }
.stats .v button.unc { margin-right: 0; }
.unc-note { grid-column: 1 / -1; margin: 6px 0 0; padding: 8px 10px; font: 400 13px/20px var(--font-sans); color: var(--ink-2); background: var(--paper); border-left: 3px solid var(--survey-red-deep); border-radius: var(--radius-sm); }
.unc-note[hidden] { display: none; }
.hero .moewrap { white-space: nowrap; }

/* map container background before JS paints: Night uses the sunk surface (same as P.outside in app.js) so it never flashes light */
:root[data-theme="night"] { --map-outside: var(--surface-sunk); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --map-outside: var(--surface-sunk); } }

/* Elastic edges: glow along the side pulled past the pannable area (opacity and size set inline by app.js; colour from the lens-blue token, which Night remaps) */
.edge-glow { position: absolute; z-index: 2; pointer-events: none; opacity: 0; }
.edge-glow[data-side="left"] { left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(to right, var(--lens-blue), transparent); }
.edge-glow[data-side="right"] { right: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(to left, var(--lens-blue), transparent); }
.edge-glow[data-side="top"] { top: 0; left: 0; right: 0; height: 0; background: linear-gradient(to bottom, var(--lens-blue), transparent); }
.edge-glow[data-side="bottom"] { bottom: 0; left: 0; right: 0; height: 0; background: linear-gradient(to top, var(--lens-blue), transparent); }

/* ---- Districts (registry kind "state"): panel, reliability chips, compare, brief. No red (models only) and no gold. */
.dist-status { overflow-wrap: anywhere; margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3); font: 500 13px/18px var(--font-sans); color: var(--ink-2); background: var(--surface-sunk); border-radius: var(--radius-md); }
.dist-basis { margin: var(--space-2) 0 0; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.dist-panel h3 { margin: var(--space-5) 0 var(--space-2); font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.dist-panel h4 { margin: var(--space-3) 0 2px; font: 600 14px/20px var(--font-sans); color: var(--ink); }
.dist-panel ul { margin: 0; padding: 0; list-style: none; }
.dist-figs li { grid-template-columns: 1fr auto; padding-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }
.dist-figs li.cur .k { color: var(--lens-blue); font-weight: 700; }
.dist-figs .sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font: 400 13px/18px var(--font-sans); color: var(--ink-2); }
.dist-figs .rank, .dist-figs .stv { font-variant-numeric: tabular-nums; }
.rel { display: inline-flex; align-items: center; min-height: 22px; padding: 0 10px; border-radius: var(--radius-pill); font: 600 12px/16px var(--font-sans); white-space: nowrap; border: 1px solid transparent; }
.rel-h { background: var(--lens-blue-tint); color: var(--lens-blue); }
.rel-m { background: var(--surface); color: var(--ink); border-color: var(--ink-2); }
.rel-l { background: var(--surface-sunk); color: var(--ink); border: 1px dashed var(--ink); }
.dist-figs .vin { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; flex-basis: 100%; font-size: 12px; }
#dover.seg4 { display: grid; grid-template-columns: 1fr 1fr; }
.sseg-row[data-row^="ms"] { flex-wrap: wrap; } .sseg-row[data-row^="ms"] .sseg { flex-wrap: wrap; }
.dist-src { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.tier.tfb { background: var(--surface-sunk); color: var(--ink); border: 1px solid var(--rule); }
.tier.test { background: var(--surface); color: var(--ink-2); border: 1px dashed var(--ink-2); }
.tier.tthird { background: var(--surface); color: var(--ink); border: 1px solid var(--ink-2); }
.dist-src .tier { white-space: normal; max-width: 100%; }
.statefig { overflow-wrap: anywhere; }
.statefig .vin { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.tierkey { margin-top: var(--space-2); border-top: 1px solid var(--rule); font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.tierkey summary { display: flex; align-items: center; min-height: var(--target-min); font-weight: 600; color: var(--lens-blue); cursor: pointer; }
.calc { font-style: italic; }
.tierkey dl { margin: 0; } .tierkey dt { margin-top: var(--space-2); } .tierkey dd { margin: var(--space-1) 0 0; } .tierkey p { margin: var(--space-2) 0 0; }
.dist-overlap .zlink, .dist-cover .zlink { min-height: var(--target-min); }
.dist-cmp-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-5); }
.dist-cmp-ctl label { font: 600 14px/20px var(--font-sans); }
.dist-cmp-ctl select, .dist-cmp-clear, .dist-brief-btn { min-height: var(--target-min); padding: 0 var(--space-3); font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); }
.dist-cmp-ctl select { flex: 1 1 160px; min-width: 0; }
.dist-compare table { width: 100%; border-collapse: collapse; margin-top: var(--space-2); font: 500 13px/18px var(--font-sans); }
.dist-compare th, .dist-compare td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; vertical-align: top; }
.dist-compare thead th { color: var(--ink-2); font-weight: 600; }
.dist-compare .sig { display: inline-block; margin-top: 2px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--lens-blue-tint); color: var(--lens-blue); font: 600 12px/18px var(--font-sans); }
.dist-panel .actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Topic tabs (statewide entry), inside the colour-by list. */
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; margin-bottom: var(--space-2); background: var(--surface-sunk); border-radius: var(--radius-md); }
.topic { min-width: var(--target-min); min-height: var(--target-min); padding: 0 var(--space-2); font: 600 13px/16px var(--font-sans); color: var(--ink-2); background: transparent; border: 0; border-radius: calc(var(--radius-md) - 2px); }
.topic:hover { color: var(--ink); }
.topic[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop); }
.view[hidden] { display: none; }
.vlist { display: contents; }
@media (max-width: 820px) {
  #mapwrap.has-topics { --sheet-peek: 262px; }
  #sheet #view.has-topics { flex-wrap: wrap; overflow-x: visible; }
  #sheet #view .topics { display: flex; flex-basis: 100%; min-width: 0; margin: 0; overflow-x: auto; scrollbar-width: none; }
  #sheet .topic { flex: 1 0 auto; padding: 0 var(--space-3); }
  #sheet #view .vlist { display: flex; flex-basis: 100%; min-width: 0; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; }
}
/* Panel: topic groups, figure sources, rank strip, 2010-2020 slope line. */
.dist-panel h3.topic-h { margin-bottom: 0; }
.dist-panel h3.topic-h + .dist-figs { margin-top: var(--space-2); }
.vin .srcb { color: var(--ink-2); }
.hero-src { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--space-2); font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.dist-facts .vin { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: var(--space-1); font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.strip, .slope, .spark { grid-column: 1 / -1; display: block; min-width: 0; margin-top: var(--space-2); }
.spark svg { height: 48px; }
.strip svg, .slope svg, .spark svg { display: block; width: 100%; overflow: visible; }
.strip svg { height: 16px; } .slope svg { height: 64px; }
.spark path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.spark .stl { stroke: var(--ink-2); stroke-width: 1.5px; stroke-dasharray: 4 3; stroke-linecap: butt; }
.spark .me { stroke: var(--lens-blue); stroke-width: 2.5px; }
.strip path, .slope path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.strip .all { stroke: var(--ink-2); stroke-width: 5px; stroke-opacity: 0.35; }
.strip .stl { stroke: var(--ink); stroke-width: 1.5px; stroke-dasharray: 3 2; stroke-linecap: butt; }
.strip .me-halo { stroke: var(--surface); stroke-width: 13px; }
.strip .me { stroke: var(--lens-blue); stroke-width: 9px; }
.slope .base { stroke: var(--rule); stroke-width: 1px; }
.slope .stl { stroke: var(--ink-2); stroke-width: 1.5px; stroke-dasharray: 4 3; stroke-linecap: butt; }
.slope .me { stroke: var(--lens-blue); stroke-width: 2.5px; }
.slope .dot { stroke: var(--lens-blue); stroke-width: 7px; }
.strip-lab, .slope-lab { display: flex; justify-content: space-between; gap: var(--space-2); font: 400 12px/16px var(--font-sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.slope-key { display: block; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
/* Compare, up to three areas. */
.dist-cmp-rm { min-height: var(--target-min); min-width: var(--target-min); padding: 0 var(--space-3); font: 600 14px/20px var(--font-sans); color: var(--lens-blue); background: var(--lens-blue-tint); border: 0; border-radius: var(--radius-pill); }
.dist-compare table { table-layout: fixed; }
.dist-compare th, .dist-compare td { overflow-wrap: anywhere; }
.dist-compare thead th:first-child { width: 32%; }
.dist-compare td small, .dist-compare .cmp-src { display: block; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.dist-compare .cmp-topic th { padding-top: var(--space-3); font: 700 12px/16px var(--font-sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.dist-compare.n3 table { font-size: 12px; line-height: 16px; }
.dist-compare.n3 .sig { padding: 0 4px; }
/* Table (statewide entry): source line in headers, row choice and CSV button. */
.tbl-src { display: block; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
/* Source links: a badge or source line that opens the dataset's landing page; the whole badge is the 44 px target. */
a.srclink { display: inline-flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 4px 6px; min-height: var(--target-min); min-width: var(--target-min); color: inherit; text-decoration: underline; text-underline-offset: 2px; }
a.tier.srclink { white-space: normal; }
a.srclink.tbl-src { display: flex; color: var(--ink-2); }
a.srcin { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
a.srclink:hover, a.srcin:hover { color: var(--lens-blue); }
.tbl-extra { display: flex; gap: var(--space-2); }
.tbl-extra select, .tbl-extra button { min-height: var(--target-min); padding: 0 var(--space-3); font: 600 14px/20px var(--font-sans); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-md); white-space: nowrap; }
#tblview.dist .tbl-tools { flex-wrap: wrap; }
#tblview.dist #tbl-search { flex: 1 1 160px; min-width: 0; min-height: var(--target-min); }
#tblview.dist #tbl-count { flex-basis: 100%; order: 3; white-space: normal; }
#tblview.dist #tbl-wrap td.num, #tblview.dist #tbl-wrap th.num { white-space: normal; }
/* many measure columns: break only between words (never inside a number or a heading) and let the table scroll sideways */
#tblview.dist #tbl-wrap td, #tblview.dist #tbl-wrap th button { overflow-wrap: normal; }
#tip .tip-src { display: block; font-size: 12px; color: var(--ink-2); }
/* Settings > Figures: data catalogue. */
.scat { flex-direction: column; align-items: stretch; }
.topics .topic[hidden] { display: none; }
/* county dataset tables in the panel */
.dtl { margin-top: var(--space-2); border-top: 1px solid var(--rule); }
.dtl summary { min-height: var(--target-min); padding: var(--space-3) 0; cursor: pointer; font: 600 14px/20px var(--font-sans); }
.dtl table { width: 100%; border-collapse: collapse; table-layout: auto; font: 400 12px/16px var(--font-sans); font-variant-numeric: tabular-nums; }
.dtl th, .dtl td { padding: 4px 4px 4px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.dtl thead th { color: var(--ink-2); font-weight: 600; overflow-wrap: normal; }
.dtl tbody th { font-weight: 400; }
.dtl td { white-space: nowrap; overflow-wrap: normal; } /* numbers never break; the name column wraps */
.dtl[data-ds="fema"] td, .dtl[data-ds="usaspending"] td { white-space: normal; }
.dtl[data-ds="fema"] tbody th { white-space: nowrap; }
.dtl-note { margin: var(--space-2) 0; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.dtl .vin { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 var(--space-3); font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.catlist details { border-top: 1px solid var(--rule); }
.catlist summary { min-height: var(--target-min); padding: var(--space-2) 0; cursor: pointer; font: 600 14px/20px var(--font-sans); }
.catlist summary small { display: block; margin-left: 1.1em; font: 400 12px/16px var(--font-sans); color: var(--ink-2); }
.catlist dl { margin: 0 0 var(--space-3); font: 400 13px/18px var(--font-sans); }
.catlist dt { margin-top: var(--space-2); font-weight: 600; color: var(--ink-2); }
.catlist dd { margin: 0; overflow-wrap: anywhere; }
.catlist a { display: inline-flex; align-items: center; min-height: var(--target-min); color: var(--lens-blue); }

/* Printable brief: built on demand into #brief; hidden on screen, the only thing printed. One Letter page. */
#brief { display: none; }
/* No page margin, so the browser has no room for its own date, title and address lines; the half inch is the brief's own padding. */
@page { size: letter; margin: 0; }
@media print {
  body > *:not(#brief) { display: none !important; }
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; height: auto !important; overflow: visible !important; }
  #brief { display: block !important; box-sizing: border-box; padding: 0.5in; color: #16222F; font: 400 10pt/1.35 "Public Sans", system-ui, sans-serif; }
  #brief .brief-head { display: flex; justify-content: space-between; border-bottom: 1px solid #D9D3C6; padding-bottom: 4pt; font: 700 8pt/1.2 sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: #4A5663; }
  #brief .brief-kick { margin-top: 8pt; font: 700 8pt/1.2 sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: #4A5663; }
  #brief h1 { margin: 2pt 0 4pt; font: 600 22pt/1.1 Fraunces, Georgia, serif; }
  #brief .dist-status { overflow-wrap: anywhere; margin: 3pt 0 4pt; padding: 2pt 8pt; font-size: 8pt; line-height: 1.2; background: #EFEBE1; border-radius: 4pt; color: #16222F; }
  #brief .dist-basis { margin: 0 0 3pt; font-size: 7.5pt; line-height: 1.15; color: #4A5663; }
  #brief .brief-top { display: flex; gap: 14pt; align-items: flex-start; }
  #brief .brief-title { flex: 1; min-width: 0; }
  #brief .brief-map { flex: 0 0 1.5in; width: 1.5in; max-height: 1.25in; margin-top: 8pt; }
  #brief h1.long { font-size: 15pt; }
  #brief .brief-fig th:first-child { width: 25%; } #brief .brief-fig thead th:nth-child(2) { width: 24%; } #brief .brief-fig thead th:nth-child(5) { width: 27%; }
  #brief .brief-fig .brief-topic th { width: auto; padding-top: 2pt; font: 700 7.5pt/1.2 sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: #4A5663; }
  #brief small.brief-calc { display: block; font-size: 6.5pt; font-weight: 400; line-height: 1; }
  #brief .brief-src { font-size: 7pt; line-height: 1.15; color: #4A5663; } #brief .brief-src span { display: block; }
  #brief .brief-ov .brief-ovsrc { margin: 0 0 2pt; font-size: 7.5pt; color: #4A5663; }
  #brief table { width: 100%; border-collapse: collapse; font-size: 8.5pt; line-height: 1.25; }
  #brief th, #brief td { text-align: left; padding: 0.5pt 4pt; border-bottom: 0.5pt solid #D9D3C6; vertical-align: top; }
  #brief thead th { color: #4A5663; font-size: 8pt; }
  #brief small { font-size: 8pt; color: #4A5663; }
  #brief .brief-pop { margin: 3pt 0 0; font-size: 8.5pt; color: #4A5663; }
  #brief .brief-ov h2 { margin: 3pt 0 1pt; font: 700 9pt/1.2 sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: #4A5663; }
  #brief .brief-ov h3 { margin: 2pt 0 1pt; font: 700 9pt/1.2 sans-serif; }
  #brief .brief-top-n { margin: 1pt 0 0; font-size: 7pt; line-height: 1.15; color: #4A5663; }
  #brief .brief-cols { display: flex; gap: 16pt; } #brief .brief-cols > div { flex: 1; }
  #brief ul { margin: 0; padding: 0; list-style: none; font-size: 8pt; line-height: 1.18; } #brief li { padding: 0.5pt 0; }
  #brief .brief-foot { margin-top: 2pt; padding-top: 2pt; border-top: 0.5pt solid #D9D3C6; font-size: 7pt; line-height: 1.12; color: #4A5663; }
  #brief .brief-foot p { margin: 0 0 1pt; }
  #brief .brief-foot .brief-also { font-size: 6.75pt; line-height: 1.12; }
  #brief a { display: inline; min-height: 0; min-width: 0; color: inherit; text-decoration: none; }
  #brief .brief-urls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10pt; margin: 0; font-size: 6pt; line-height: 1.1; } #brief .brief-urls li { padding: 0; min-width: 0; }
  #brief .brief-urls span { display: block; overflow-wrap: anywhere; } #brief .brief-ds { font-weight: 700; }
}
.dist-figs { margin-top: var(--space-5); }

/* Preview-build notice (class set by app.js only when window.CM_BUILD.banner): a strip under the app; full-screen panels stop above it. */
html.cm-banner { --cm-banner-h: 22px; }
#cm-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; height: var(--cm-banner-h); margin: 0; display: flex; align-items: center; justify-content: center; padding: 0 var(--space-2); overflow: hidden; text-align: center; font: 600 11px/14px var(--font-sans); color: var(--ink); background: var(--surface-sunk); border-top: 1px solid var(--rule); }
html.cm-banner #app { position: relative; height: calc(100% - var(--cm-banner-h)); }
html.cm-banner #settings, html.cm-banner #scrim { bottom: var(--cm-banner-h); }
@media (max-width: 820px) { html.cm-banner #bubble, html.cm-banner #explain { bottom: var(--cm-banner-h); } }
@media (max-width: 520px) { html.cm-banner { --cm-banner-h: 34px; } }
@media print { #cm-banner { display: none; } html.cm-banner #app { height: auto; } }
