* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
/* IBM Plex Mono, self-hosted (SIL OFL). Latin subset only, ~10 KB a weight, so
   there is no CDN dependency and it works offline - which matters for a site
   meant to be open-sourced and self-hosted. */
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/fonts/ibm-plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/fonts/ibm-plex-mono-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/fonts/ibm-plex-mono-700.woff2") format("woff2");
}
body {
  /* Typewriter character from a monospace face that can actually draw digits.
     American Typewriter looked the part but its figures are thin and stylised,
     and the percentages were unreadable at 11px. */
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo,
               Consolas, "DejaVu Sans Mono", "Courier New", monospace;
  font-size: 12.5px; color: #1c1e21;
  font-variant-numeric: tabular-nums;
}
#map { position: absolute; inset: 0; background: #e8ecef; }
/* index-finger cursor over the map (both engines set their own grab cursors) */
#map, #map * { cursor: pointer !important; }
#dots, #ui {
  /* mounted inside the map engine's moving pane so panning carries the dots
     natively, in the same compositor frame as the tiles */
  position: absolute; left: 0; top: 0;
  pointer-events: none;
  z-index: 500;
}

.card {
  position: absolute;
  background: rgba(255,255,255,.96);
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0,0,0,.22);
  padding: 12px 14px;
  z-index: 900;
}

#right-col {
  position: absolute; top: 12px; right: 12px; z-index: 900;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  max-height: calc(100% - 24px);
}
#right-col .card { position: static; }
#right-col #summary-panel { position: relative; }
#panel-card { width: 272px; font-size: 10.5px; padding: 10px 12px; }
#panel-card h1 { font-size: 12.5px; font-weight: 700; letter-spacing: -.01em; }
#panel-card .sub { margin-top: 2px; color: #444; font-weight: 600; display: flex; align-items: center; gap: 6px; justify-content: space-between; }
#year-select {
  font: inherit; font-size: 11px; padding: 1px 3px;
  border: 1px solid #ccc; border-radius: 5px; background: #fff; color: #1c1e21;
}
#legend { margin: 7px 0 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
.leg-row { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.leg-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#notes {
  position: absolute; left: 12px; bottom: 24px; z-index: 900;
  display: flex; flex-direction: column; gap: 8px; max-width: 330px;
}
.note {
  position: relative;
  background: rgba(255, 250, 235, .97); border: 1px solid #e5d9b8;
  border-radius: 8px; padding: 8px 26px 8px 11px;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); font-size: 11.5px; line-height: 1.4;
}
.note-x {
  position: absolute; top: 4px; right: 6px;
  border: 0; background: none; font-size: 16px; line-height: 1;
  color: #9a8f70; cursor: pointer; padding: 2px 4px;
}
.note-x:hover { color: #333; }
#sat-row, #dark-row, #labels-row { display: flex; align-items: center; gap: 5px; margin: 5px 0 2px; color: #444; cursor: pointer; }
#sat-row input, #dark-row input, #labels-row input { accent-color: #3b6ada; }

/* Dark mode. Only the chrome changes - the dots keep their palette, which was
   picked to read on either ground, and the basemap swaps to CARTO's dark
   render of the same OpenStreetMap data. */
body.dark { color: #e8eaed; }
body.dark #map { background: #12151a; }
body.dark .card { background: rgba(24,27,33,.96); box-shadow: 0 2px 14px rgba(0,0,0,.5); }
body.dark #panel-card h1 { color: #f1f3f5; }
body.dark #panel-card .sub { color: #c8ccd2; }
body.dark #year-select { background: #23272e; color: #e8eaed; border-color: #3a3f47; }
body.dark #sat-row, body.dark #dark-row, body.dark #labels-row, body.dark .slider-row { color: #b9bec6; }
body.dark .hint { color: #9aa0a8; }
body.dark .src, body.dark .slider-note { color: #7c828a; }
body.dark #more-btn { color: #b9bec6; }
body.dark #more-btn:hover, body.dark #more-btn[aria-expanded="true"] {
  background: rgba(255,255,255,.1); color: #fff;
}
body.dark #more-menu { border-top-color: rgba(255,255,255,.12); }
body.dark #tooltip { background: rgba(24,27,33,.97); box-shadow: 0 2px 12px rgba(0,0,0,.6); }
body.dark #tooltip .tt-sub { color: #9aa0a8; }
body.dark #tooltip .tt-pop { border-top-color: #3a3f47; }
body.dark #tooltip .tt-pop span:first-child { color: #9aa0a8; }
body.dark #summary-sub { color: #9aa0a8; }
body.dark #summary-close { color: #9aa0a8; }
body.dark #summary-close:hover { color: #fff; }
body.dark #summary-stats .stat { background: #23272e; }
body.dark #summary-stats .stat span { color: #9aa0a8; }
body.dark #summary-history .gridline { stroke: #333840; }
body.dark #summary-history .axis-label { fill: #7c828a; }
body.dark .note { background: rgba(40,36,24,.97); border-color: #5a5030; color: #e8dfc4; }
body.dark .note-x { color: #b3a678; }
/* Everything past the key itself lives behind the "..." button, so the card
   stays small and the map stays visible. */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.title-btns { display: flex; align-items: center; gap: 2px; flex: none; }
#share-btn {
  font: inherit; font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border: 1px solid rgba(0,0,0,.14); border-radius: 6px;
  background: transparent; color: #555; cursor: pointer; white-space: nowrap;
}
#share-btn:hover { background: rgba(0,0,0,.06); color: #222; }
#share-btn.done { color: #2f9e44; border-color: #2f9e44; }
body.dark #share-btn { border-color: rgba(255,255,255,.18); color: #b9bec6; }
body.dark #share-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
body.dark #share-btn.done { color: #51cf66; border-color: #51cf66; }
#more-btn {
  font: inherit; font-size: 15px; line-height: 1; letter-spacing: 1px;
  padding: 0 5px 4px; margin: -2px -3px 0 0;
  border: 0; border-radius: 6px; background: transparent; color: #666; cursor: pointer;
}
#more-btn:hover { background: rgba(0,0,0,.07); color: #222; }
#more-btn[aria-expanded="true"] { background: rgba(0,0,0,.09); color: #222; }
#more-menu {
  margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(0,0,0,.09);
}
.slider-row {
  display: grid; grid-template-columns: 52px 1fr 30px;
  align-items: center; gap: 6px; margin: 5px 0 0; color: #555;
}
.slider-row input[type=range] { accent-color: #3b6ada; width: 100%; height: 14px; }
.slider-row span { text-align: right; color: #888; font-variant-numeric: tabular-nums; }
.slider-note { color: #999; font-size: 9.5px; margin-top: 4px; line-height: 1.3; }
.hint { color: #666; margin-top: 6px; line-height: 1.35; }
.src { color: #999; font-size: 9.5px; margin-top: 6px; line-height: 1.35; }
/* Byline sits under the data source inside the "..." menu, quieter than it: the
   Census attribution is required, this one is a signature. */
.src.credit { margin-top: 3px; }
.src.credit a { color: #777; text-decoration: none; border-bottom: 1px solid #ddd; }
.src.credit a:hover { color: #3b6ada; border-bottom-color: #3b6ada; }
body.dark .src.credit a { color: #8b9199; border-bottom-color: #3a3f47; }
body.dark .src.credit a:hover { color: #7d9bff; border-bottom-color: #7d9bff; }

#tooltip {
  position: fixed; z-index: 1000; display: none;
  background: rgba(255,255,255,.97);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,.28);
  padding: 9px 11px;
  pointer-events: none;
  min-width: 185px;
}
#tooltip .tt-title { font-weight: 700; font-size: 13px; }
#tooltip .tt-sub { color: #666; font-size: 11.5px; margin-bottom: 6px; }
#tooltip .tt-row { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
#tooltip .tt-row .leg-dot { width: 8px; height: 8px; }
#tooltip .tt-row .tt-name { flex: 1; }
#tooltip .tt-row .tt-pct { font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -.2px; }
#tooltip .tt-pop { border-top: 1px solid #e5e5e5; margin-top: 6px; padding-top: 5px;
  display: flex; justify-content: space-between; font-weight: 600; }
#tooltip .tt-pop span:first-child { color: #666; font-weight: 400; }

#summary-panel { width: 336px; min-height: 0; overflow-y: auto; }
#summary-panel.hidden { display: none; }
#summary-close {
  position: absolute; top: 8px; right: 10px;
  border: 0; background: none; font-size: 20px; line-height: 1;
  color: #888; cursor: pointer; padding: 2px 4px;
}
#summary-close:hover { color: #222; }
#summary-title { font-size: 15px; font-weight: 700; padding-right: 22px; }
#summary-sub { color: #666; font-size: 12px; margin-bottom: 8px; }
#summary-body { line-height: 1.5; font-size: 12.5px; }
#summary-body .loading { color: #888; }
#summary-body .err { color: #a33; }
#summary-history { margin-top: 10px; }
#summary-history .chart-title { font-weight: 600; font-size: 11.5px; margin-bottom: 2px; }
#summary-history .chart-note { color: #999; font-size: 10px; margin-top: 2px; line-height: 1.35; }
/* Coverage caveats: a series sitting at zero because a group was never counted
   looks identical to one at zero because nobody lived there. Set apart from the
   ordinary note so it reads as a warning about the DATA, not a description. */
#summary-history .chart-caveat { margin-top: 6px; padding-top: 5px; border-top: 1px solid #e6e6e6; }
#summary-history .chart-caveat ul { margin: 3px 0 0; padding-left: 14px; }
#summary-history .chart-caveat li { margin-bottom: 3px; }
#summary-history .chart-caveat b { color: #666; }
body.dark #summary-history .chart-caveat { border-top-color: #333840; }
body.dark #summary-history .chart-caveat b { color: #b9bec6; }
#summary-history .loading { color: #888; font-size: 11.5px; }
#summary-history svg { display: block; width: 100%; height: auto; }
#summary-history .gridline { stroke: #e6e6e6; stroke-width: 1; }
#summary-history .axis-label { fill: #999; font-size: 9px; }
#summary-stats { margin-top: 9px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
#summary-stats .stat { background: #f5f6f7; border-radius: 6px; padding: 5px 8px; }
#summary-stats .stat b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
#summary-stats .stat span { color: #666; font-size: 10.5px; }

.leaflet-control-attribution { font-size: 10px !important; }

/* Phones. Two things break here that don't on a desktop: the legend's second
   column overflows the card (monospace is wide, and "Black"/"Asian" were being
   cut off at 375px), and the detail panel is tall enough to bury the map. */
@media (max-width: 640px) {
  #right-col { top: 8px; right: 8px; left: 8px; align-items: stretch; gap: 8px; }
  #panel-card { width: auto; font-size: 11px; }
  /* The card is full-width here, so the zoom buttons would sit on top of it.
     Drop them - pinch works, and every touch map relies on that. */
  .leaflet-control-zoom { display: none; }
  #legend { grid-template-columns: 1fr 1fr; gap: 2px 10px; }
  #summary-panel { width: auto; }
}
/* Narrow phones: one legend column, so nothing can clip. */
@media (max-width: 430px) {
  #legend { grid-template-columns: 1fr; }
}
/* Keep the detail panel from swallowing the screen - it scrolls instead. */
@media (max-height: 900px) {
  #summary-panel { max-height: 52vh; }
}

/* Tap panel on phones: the percentages take the place of the trend chart.
   The row styles are scoped to #tooltip, so they have to be restated here or
   the colour dot and the right-aligned percentage are simply missing. */
.panel-shares { margin-top: 6px; }
.panel-shares .tt-row {
  display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 13px;
}
.panel-shares .tt-row .leg-dot { width: 9px; height: 9px; flex: none; }
.panel-shares .tt-name { flex: 1; }
.panel-shares .tt-pct { font-variant-numeric: tabular-nums; font-weight: 700; }
