/* swelter dashboard — framework-free, mobile-first, WCAG 2.2 AA.
   Severity is carried by text and pattern, not color alone; focus is always visible;
   motion respects prefers-reduced-motion. Colors are AA-contrast on their surfaces, but are
   never the only signal. Provisional (uncalibrated) locations are rendered neutrally so an
   unconfirmed reading never "wears" a confirmed air-quality category. */

:root {
  --bg: #fbf7f2;
  --fg: #1c1714;
  --muted: #5a4f48;
  --surface: #ffffff;
  --border: #c9bcb0;
  --accent: #7b2d26;
  --accent-fg: #ffffff;
  --focus: #11489c;
  --provisional: #6b5b4d;
  --map-land: #ece3d6;
  --map-line: #b3a294;
  --max-width: 70rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --fg: #f2ece6;
    --muted: #c2b6ac;
    --surface: #221d19;
    --border: #4a4039;
    --accent: #e2786b;
    --accent-fg: #14110f;
    --focus: #9ec1ff;
    --provisional: #b8a695;
    --map-land: #241d18;
    --map-line: #5c4f44;
  }
}

/* High-contrast theme (R6), opt-in via the Display control. Pushes text/UI to maximum contrast on a
   pure background and darkens borders/focus; it works in both light and dark schemes. Severity is
   carried by text and pattern (not these tokens), so the map's category cues stay legible. */
:root[data-contrast="high"] {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #1c1c1c;
  --surface: #ffffff;
  --border: #000000;
  --accent: #6a1410;
  --accent-fg: #ffffff;
  --focus: #0a33cc;
  --provisional: #1c1c1c;
  --map-land: #f2f2f2;
  --map-line: #000000;
}

@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"] {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #ededed;
    --surface: #000000;
    --border: #ffffff;
    --accent: #ffc4ba;
    --accent-fg: #000000;
    --focus: #a9c4ff;
    --provisional: #ededed;
    --map-land: #0a0a0a;
    --map-line: #ffffff;
  }
}

* {
  box-sizing: border-box;
}

/* In-page text-size control (R6). The whole UI is rem-based, so scaling the root font scales every
   view proportionally. Default is 1; the control steps it up for readers who need larger type. */
html {
  font-size: calc(100% * var(--text-scale, 1));
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.6rem 1rem;
  border-radius: 0 0 0.4rem 0.4rem;
  z-index: 10;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

/* A visible focus indicator on every interactive element. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible,
[role="tab"]:focus-visible,
[role="tabpanel"]:focus-visible,
.map:focus-visible,
.cell:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

header,
main,
footer {
  max-width: var(--max-width);
  margin-inline: auto;
  padding: 1rem 1.25rem;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.header-controls {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
}

.units {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.units button {
  font: inherit;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

.units button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
}

.lang {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
}

.display {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.display button {
  font: inherit;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

.display button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
}

.display button:disabled {
  opacity: 0.5;
  cursor: default;
}

.data-source {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.source-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0;
}
.source-switch a {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.source-switch a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.source-switch a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.headline {
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 0.4rem solid var(--accent);
  border-radius: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control.find {
  flex: 1 1 18rem;
}

.control.time {
  flex: 1 1 16rem;
}

.find-row {
  display: flex;
  gap: 0.4rem;
}

.find-row input {
  flex: 1 1 auto;
}

#locate {
  font: inherit;
  white-space: nowrap;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

select,
input[type="range"],
input[type="search"] {
  font: inherit;
  padding: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--fg);
  accent-color: var(--accent);
}

input[type="range"] {
  padding: 0;
  width: 100%;
}

input[type="range"][aria-disabled="true"] {
  opacity: 0.5;
}

#time-readout {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.views {
  display: flex;
  gap: 0.25rem;
  margin: 1.25rem 0 0;
}

[role="tab"] {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: pointer;
}

[role="tab"][aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-fg);
}

[role="tabpanel"] {
  border: 1px solid var(--border);
  border-radius: 0 0.6rem 0.6rem 0.6rem;
  padding: 1rem;
  background: var(--surface);
}

.status {
  min-height: 1.4rem;
  margin: 0.5rem 0;
  color: var(--muted);
}

.hint {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Interactive map: a clipping viewport holding a pannable/zoomable canvas. Not tiles — an honest
   plot of positioned markers over an optional geographic outline. */
.map-wrap {
  position: relative;
}
.map {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 2;
  min-height: 20rem;
  background:
    repeating-linear-gradient(0deg, transparent 0 2.4rem, var(--border) 2.4rem 2.45rem),
    repeating-linear-gradient(90deg, transparent 0 2.4rem, var(--border) 2.4rem 2.45rem),
    var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  cursor: grab;
  touch-action: none; /* we handle pan + pinch ourselves */
  user-select: none;
}
.map.dragging {
  cursor: grabbing;
}
.map-canvas {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}
/* Promote to a compositor layer only while actively dragging, not for the whole session. */
.map.dragging .map-canvas {
  will-change: transform;
}
.map-canvas.animate {
  transition: transform 0.22s ease;
}
@media (prefers-reduced-motion: reduce) {
  .map-canvas.animate {
    transition: none;
  }
}

/* Zoom / reset controls, overlaid top-right of the map. */
.map-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.map-controls button {
  min-width: 2.4rem;
  min-height: 2.4rem;
  padding: 0.2rem 0.5rem;
  font: 700 1.1rem/1 system-ui, sans-serif;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.map-controls button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
#map-reset {
  font-size: 0.8rem;
}

/* Optional geographic basemap (e.g. California counties): decorative land fill + border lines,
   drawn behind the markers. Non-scaling stroke keeps the lines crisp under the stretched viewBox. */
.map .basemap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.basemap-land {
  fill: var(--map-land);
  stroke: var(--map-line);
  stroke-width: 0.8;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.cell {
  position: absolute;
  z-index: 1;
  /* Counter-scale by the map zoom (--k) so markers keep a constant on-screen size while the
     geography under them grows; the dot still moves with its point. */
  transform: translate(-50%, 50%) scale(calc(1 / var(--k, 1)));
  min-width: 3.6rem;
  min-height: 2.6rem;
  padding: 0.3rem 0.45rem;
  font: 700 0.9rem/1.15 system-ui, sans-serif;
  text-align: center;
  color: #14110f;
  background: var(--surface);
  border: 2px solid var(--fg);
  border-radius: 0.35rem;
  cursor: pointer;
}

.cell .cell-cat {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
}

/* Provisional locations read NEUTRAL — never wearing a confirmed category color. */
.cell.provisional {
  border-style: dashed;
  background: repeating-linear-gradient(45deg, #e7ddd2 0 4px, #d9cdbf 4px 8px);
  color: #2a221c;
}

.cell.selected {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* On a dense network, shrink markers to small dots so the coverage reads as a map, not a pile. */
.map.dense .cell {
  min-width: 1.7rem;
  min-height: 1.3rem;
  padding: 0.1rem 0.15rem;
  font-size: 0.62rem;
}

.map.dense .cell .cell-cat {
  display: none;
}

/* AQI severity: color AND a distinct background pattern AND text — never color alone. */
.aqi-good { background-color: #d7f0d0; background-image: none; }
.aqi-moderate {
  background-color: #f2e9b8;
  background-image: radial-gradient(circle, rgba(0,0,0,0.35) 1px, transparent 1.2px);
  background-size: 6px 6px;
}
.aqi-usg {
  background-color: #f6cf9b;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.3) 0 2px, transparent 2px 6px);
}
.aqi-unhealthy {
  background-color: #ef9a9a;
  background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.35) 0 2px, transparent 2px 5px);
}
.aqi-veryunhealthy {
  background-color: #cf93c8;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.4) 0 2px, transparent 2px 5px);
}
.aqi-hazardous {
  background-color: #c79a9a;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.5) 0 2px, transparent 2px 4px);
}

/* Heat map scale (cool → hot). The marker's number is the primary signal; colour + pattern are a
   redundant cue so the heat island is legible without relying on colour alone. */
.heat-1 { background-color: #dbe9f2; background-image: none; }
.heat-2 {
  background-color: #e6edcb;
  background-image: radial-gradient(circle, rgba(0,0,0,0.3) 1px, transparent 1.2px);
  background-size: 6px 6px;
}
.heat-3 {
  background-color: #f4e3b0;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.28) 0 2px, transparent 2px 6px);
}
.heat-4 {
  background-color: #f2c197;
  background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.32) 0 2px, transparent 2px 5px);
}
.heat-5 {
  background-color: #e89887;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.4) 0 2px, transparent 2px 5px);
}

.swatch {
  display: inline-block;
  width: 1.4rem;
  height: 1.4rem;
  margin-right: 0.5rem;
  vertical-align: middle;
  border: 1px solid var(--fg);
  border-radius: 0.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th button {
  font: inherit;
  font-weight: 700;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}

tr.selected td {
  background: rgba(17, 72, 156, 0.08);
}

td .tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--fg);
  border-radius: 0.3rem;
  font-size: 0.8rem;
}

.tag.provisional {
  border-style: dashed;
  color: var(--provisional);
}

.readings {
  margin: 0;
  padding: 0;
  list-style: none;
}

.readings li {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.readings li.selected {
  background: rgba(17, 72, 156, 0.08);
}

.readings .place {
  font-weight: 700;
}

.readings .reading {
  font-variant-numeric: tabular-nums;
}

.detail {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.overview {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.overview h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.overview p {
  margin: 0.2rem 0;
}

.overview-fresh {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Offline notice — the accent border is decorative; the message itself states the situation. */
.offline {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.4rem;
  font-size: 0.9rem;
}

/* Per-node health detail — which sensors a host should go check. */
.health-detail {
  margin: 0.3rem 0;
  font-size: 0.9rem;
}

.health-detail summary {
  cursor: pointer;
}

.health-list {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.health-list li {
  margin: 0.15rem 0;
}

/* Personal alerts banner. The accent border is decorative only — every alert states its severity in
   words (the reading and the level the reader set), never by color (the map/legend rule applies). */
.alerts {
  margin: 0.5rem 0 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.6rem;
}

.alerts h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.alerts-list {
  margin: 0;
  padding-left: 1.2rem;
}

.alerts-list li {
  margin: 0.3rem 0;
}

.alert-text {
  font-weight: 600;
}

.alerts-note {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Neighborhood alerts: the generated, subscribable feed (distinct from the personal watch banner). */
.area-alerts {
  margin: 0.5rem 0 1rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.6rem;
}

.area-alerts h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.aa-intro,
.aa-note {
  margin: 0.3rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.aa-pick {
  margin: 0.5rem 0;
}

.aa-list {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.aa-item {
  margin: 0.4rem 0;
}

/* Status is text-first, never color-only: provisional alerts get a dashed marker AND say so. */
.aa-item.provisional {
  list-style-type: "▢ ";
}

.aa-text {
  font-weight: 600;
}

.aa-prov {
  color: var(--muted);
  font-style: italic;
}

.aa-go {
  margin-left: 0.4rem;
}

.aa-copy-status {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Cooling-center overlay: the accessible parity list and its provenance line. */
.cooling {
  margin: 0.75rem 0;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.cooling h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.cooling-intro {
  margin: 0.3rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.cooling-list {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.cool-item {
  margin: 0.45rem 0;
}

.cool-meta {
  color: var(--muted);
}

.cool-note {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.cooling-source {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* The map overlay glyph for a cooling center — a distinct shape (not color) layered over the dots. */
.cool-center {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, 50%) scale(calc(1 / var(--k, 1)));
  font-size: 1.1rem;
  line-height: 1;
  color: #0b5cad;
  text-shadow:
    0 0 2px #fff,
    0 0 2px #fff,
    0 0 3px #fff;
  pointer-events: none;
}

/* The per-location alert-threshold control in the detail panel. */
.watch {
  margin: 0.75rem 0;
}

.watch-heading {
  font-size: 1rem;
  margin: 0 0 0.3rem;
}

.watch-intro {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.watch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.watch-row label {
  font-weight: 600;
  font-size: 0.9rem;
}

.watch-threshold,
.watch-number {
  font: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--fg);
}

.watch-number {
  max-width: 8rem;
}

.watch-buttons {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.watch-buttons button {
  font: inherit;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: inherit;
  cursor: pointer;
}

.watch-buttons button[disabled] {
  opacity: 0.5;
  cursor: default;
}

.watch-status {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

button.linklike {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}

#time-play {
  font: inherit;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: inherit;
  cursor: pointer;
}

#time-play[disabled] {
  opacity: 0.5;
  cursor: default;
}

.detail h2 {
  margin-top: 0;
}

.spark {
  display: block;
  margin: 0.3rem 0;
  color: var(--accent, #11489c);
}

.spark-svg {
  display: block;
  width: 8.5rem;
  height: auto;
  overflow: visible;
}

.context {
  font-weight: 600;
  margin: 0.35rem 0;
}

.trend {
  margin: 0.35rem 0;
  font-variant-numeric: tabular-nums;
}

.guidance {
  font-size: 1rem;
}

.guidance-source {
  color: var(--muted);
  font-size: 0.85rem;
}

/* "What to do now" action card. The neutral accent border is decorative only — severity is carried
   by the action text, never by color (the map/legend rule applies here too). */
.action-card {
  margin: 0.7rem 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 0.4rem;
  background: var(--surface);
}

.action-heading {
  font-size: 1rem;
  margin: 0 0 0.35rem;
}

.action-list {
  margin: 0;
  padding-left: 1.2rem;
}

.action-list li {
  margin: 0.2rem 0;
}

.action-note {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.provenance {
  font-size: 0.9rem;
}

/* Multi-day history: a per-location daily summary (high/low or worst category) under the sparkline. */
.history {
  margin: 0.6rem 0;
}

.history-heading {
  font-size: 1rem;
  margin: 0 0 0.3rem;
}

.history-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.95rem;
}

.history-list li {
  margin: 0.15rem 0;
}

/* Equity compare: pick a second location and read the two side by side. */
.compare {
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.compare label {
  font-weight: 600;
  font-size: 0.9rem;
}

.compare select {
  font: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--fg);
  max-width: 22rem;
}

.compare-result {
  font-size: 0.95rem;
}

.compare-result div {
  margin: 0.2rem 0;
}

.compare-result div:last-child {
  font-weight: 600;
  margin-top: 0.4rem;
}

.detail-actions {
  margin: 0.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.download-cell {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.detail-actions button,
.overview-actions button {
  font: inherit;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: inherit;
  cursor: pointer;
}

.overview-actions {
  margin: 0.6rem 0 0;
}

.explain {
  margin: 0.75rem 0;
}

.explain summary {
  cursor: pointer;
  font-weight: 600;
}

.method-heading {
  margin: 0.6rem 0 0.2rem;
  font-weight: 600;
}

.method-list {
  margin: 0;
  padding-left: 1.2rem;
}

.method-list li {
  margin: 0.2rem 0;
}

.trust {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.legend {
  margin-top: 1.5rem;
}

.legend-items {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.3rem;
}

.legend-items li {
  display: flex;
  align-items: center;
}

.legend-note,
.provisional-note {
  color: var(--muted);
  font-size: 0.9rem;
}

footer {
  border-top: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

footer a {
  color: var(--accent);
}

footer code {
  background: var(--surface);
  padding: 0.05rem 0.3rem;
  border-radius: 0.2rem;
}

.settings {
  margin-top: 1rem;
}

.settings summary {
  cursor: pointer;
  font-weight: 600;
}

.settings-intro,
.settings-state {
  margin: 0.4rem 0;
}

.settings-actions {
  margin: 0.5rem 0 0;
}

.settings-actions button {
  font: inherit;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: inherit;
  cursor: pointer;
}

.settings-status {
  margin: 0.4rem 0 0;
}

.shortcuts {
  margin-top: 0.6rem;
}

.shortcuts summary {
  cursor: pointer;
  font-weight: 600;
}

.shortcuts-toggle-row {
  margin: 0.4rem 0;
}

.shortcuts-list {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.shortcuts-list li {
  margin: 0.15rem 0;
}

.shortcuts-list kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 0.05rem 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 40rem) {
  header,
  main,
  footer {
    padding: 0.75rem 0.9rem;
  }
  h1 {
    font-size: 1.5rem;
  }
  .cell {
    min-width: 3rem;
    font-size: 0.82rem;
  }
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print as a community handout: ABOUT-THE-NETWORK.md tells networks to "copy this onto a flyer", so
   printing drops the interactive chrome and keeps the title, the network overview, the readings
   table, the AQI legend, and the data license — a self-describing, honest paper snapshot. */
@media print {
  @page {
    margin: 1.5cm;
  }

  .skip-link,
  .header-controls,
  .source-switch,
  .controls,
  #viewtabs,
  #panel-list,
  #panel-map,
  .map-controls,
  .detail-actions,
  .overview-actions,
  .compare,
  #watch,
  #alerts,
  #download-cell,
  #time-play,
  #place-search,
  .provenance {
    display: none !important;
  }

  /* The data table prints even if its tab wasn't the active view (it is always populated). */
  #panel-table {
    display: block !important;
  }

  body {
    color: #000;
    background: #fff;
  }

  .overview,
  .detail,
  .legend {
    border: 1px solid #000;
    break-inside: avoid;
  }

  tr,
  .legend-items li {
    break-inside: avoid;
  }

  /* AQI swatch patterns still carry severity on a black-and-white printer. */
  .tag,
  .swatch {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
