/* Map screen (M-032). The 1440 × 900 stage is scaled to fit the window and
   everything on it is positioned in percent of that box. Zoom (M-040, D3):
   --map-zoom (1, 2, 4) widens the stage and --map-pan-x/y move it (zoom
   controller); markers and popups keep their size in pixels. Layer colours
   from the card; theme colours from tokens.css. */

:root {
  --layer-neptun: #e23d3d;
  --layer-ua-alarms: #f2a3a3;
  --layer-rcb: #e23d3d;
  --layer-media: #6b6b6b;
  --layer-zone-r: #c43c3c;
  --layer-zone-tsa: #8a5ad8;
  --layer-nato: #3f6fd8;
  --layer-hostile: #e23d3d;
  --layer-colata: #ebbd00;
  --layer-vessels: #0e7c8a;
  --layer-fires: #f46d5b; /* token org (M-075) */
}

.map {
  position: fixed;
  inset: 0;
  /* clip, not hidden: a zoomed stage is larger than the window, and focusing a
     marker must not scroll the map (with the logo and buttons) out of place. */
  overflow: clip;
  background: var(--bg);
  /* Zoom and panning are the map's own (M-040): no browser pinch-zoom or touch scrolling. */
  touch-action: none;
  overscroll-behavior: none;
}

/* The stage is the 1440 × 900 map view; everything on it is positioned in
   percent of it. It is scaled so that the view plus 170 units of the Baltic Sea
   above it (a 1440 × 1070 box) always fits the window, and centred on that box.
   The basemap reaches far beyond the stage (Basemap::EXTENT: 560 left/right,
   400 top, 220 bottom), so the rest of any window shows map, not empty bands.
   On extremely wide windows (beyond ~2.4:1) the stage grows until the basemap
   still covers the full width, trimming a little sea and south instead. */
.map__stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(max(min(100vw, calc(100vh * 1440 / 1070)), calc(100vw * 1440 / 2560)) * var(--map-zoom, 1));
  aspect-ratio: 1440 / 900;
  /* (1070 / 2 − 170) / 900 of the stage height, plus the pan of a zoomed map */
  transform: translate(calc(-50% + var(--map-pan-x, 0px)), calc(-40.5556% + var(--map-pan-y, 0px)));
}

.map[data-zoom="2"] .map__stage,
.map[data-zoom="4"] .map__stage { cursor: grab; }
.map.map--dragging .map__stage { cursor: grabbing; user-select: none; }

/* Zoom buttons (M-040): a vertical "+ / 1:4 / −" bar as wide as the settings
   gear (44 px, same radius and shadow), in the bottom-right corner stacked above
   the sources caption in .map-attribution, so a wrapped caption never covers it. */
.map-zoom {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  padding: 2px 0;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.map-zoom__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
}

.map-zoom__button:disabled { opacity: .35; }
.map-zoom__button:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }

.map-zoom__scale { font-size: 11px; line-height: 14px; text-align: center; }

.map__layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Basemap viewBox −560 −400 2560 1520 placed on the 1440 × 900 stage. */
.map__basemap {
  position: absolute;
  left: -38.8889%;
  top: -44.4444%;
  width: 177.7778%;
  height: 168.8889%;
  max-width: none;
  display: block;
}

.map__layer { pointer-events: none; overflow: visible; }

.map__markers { position: absolute; inset: 0; }

/* Areas */
.map-area { vector-effect: non-scaling-stroke; }

.map-area--ua-alarm {
  fill: var(--redBg);
  fill-opacity: .8;
  stroke: var(--layer-neptun);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* Lithuanian air alarms (M-073): red filled, yellow filled with a dashed edge
   like UA alarms. The notice names a county or municipality only, so it is
   drawn the same at every zoom. */
.map-area--lt-red {
  fill: var(--redBg);
  fill-opacity: .8;
  stroke: var(--red);
  stroke-width: 1.2;
}

.map-area--lt-yel {
  fill: var(--yelBg);
  fill-opacity: .8;
  stroke: var(--yel);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* Powiaty named by an RCB alert (M-048), drawn at 1:2 and 1:1 only. */
.map-area--powiaty {
  fill: var(--layer-rcb);
  fill-opacity: .14;
  stroke: var(--layer-rcb);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

/* UA alarms (M-044): the whole oblast at 1:4, only its alarmed raions at 1:2 and 1:1;
   RCB powiaty (M-048) at 1:2 and 1:1 only (data-zoom from the zoom controller).
   Only hides, so the layer switch still wins. */
.map:not([data-zoom="2"]):not([data-zoom="4"]) .map-area--zoomed-in,
.map:is([data-zoom="2"], [data-zoom="4"]) .map-area--zoomed-out { display: none; }

/* PAŻP zones (M-049): grouped zones share one group marker and popup at 1:4 and
   1:2, each zone has its own at 1:1 (where they no longer overlap). Only hides. */
.map:not([data-zoom="4"]) .map-closest-only,
.map[data-zoom="4"] .map-not-closest { display: none; }

/* Satellite fires (M-075): fires within 15 km share one count marker at 1:4,
   each has its own at 1:2 and 1:1. Only hides. */
.map:not([data-zoom="2"]):not([data-zoom="4"]) .map-zoomed-in-only,
.map:is([data-zoom="2"], [data-zoom="4"]) .map-zoomed-out-only { display: none; }

.map-area--zone-r { fill: url(#map-hatch-r); stroke: var(--layer-zone-r); stroke-width: 1.2; }
.map-area--zone-tsa { fill: rgba(140, 90, 220, .10); stroke: var(--layer-zone-tsa); stroke-width: 1.5; stroke-dasharray: 4 3; }
/* Temporary areas from NOTAMs (M-071): like a PAŻP R zone, with a dashed outline. */
.map-area--notam-area { fill: rgba(196, 60, 60, .08); stroke: var(--layer-zone-r); stroke-width: 1.5; stroke-dasharray: 6 4; }
/* GPS interference (M-072): hexagons without outline, under the other areas */
.map-area--gnss-interference { stroke: none; fill-opacity: .25; }
.map-area--gnss-medium { fill: var(--yel); }
.map-area--gnss-high { fill: var(--red); }
:root[data-theme="dark"] .map-area--gnss-interference { fill-opacity: .3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .map-area--gnss-interference { fill-opacity: .3; } }
.map-hatch__ground { fill: rgba(226, 61, 61, .08); }
.map-hatch__line { stroke: rgba(196, 60, 60, .45); stroke-width: 1.6; }

/* Seabed cables and pipelines (M-062) */
.map-infrastructure {
  fill: none;
  stroke: #5b7f99;
  stroke-width: 1;
  stroke-dasharray: 2 3;
  stroke-opacity: .7;
  vector-effect: non-scaling-stroke;
}

:root[data-theme="dark"] .map-infrastructure { stroke: #7aa3c2; stroke-opacity: .55; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .map-infrastructure { stroke: #7aa3c2; stroke-opacity: .55; } }

/* Tracks and course lines */
.map-track { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.map-track--dashed { stroke-dasharray: 4 4; }
.map-track--neptun { stroke: var(--layer-neptun); }
.map-track--hostile_aircraft { stroke: var(--layer-hostile); }
.map-track--nato { stroke: var(--layer-nato); }
.map-track--colata { stroke: var(--layer-colata); }
.map-track--vessels { stroke: var(--layer-vessels); }

/* Halos: colata drone range, uncertain position, NATO orbit */
.map-halo {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.map-halo--range { width: 52px; height: 52px; border: 2px solid var(--layer-colata); opacity: .6; }
.map-halo--uncertain { width: var(--size, 52px); height: var(--size, 52px); border: 2px dashed var(--layer-neptun); }
.map-halo--orbit { width: 80px; height: 34px; border: 1.5px dashed var(--layer-nato); }

/* Markers: 30 px circle with the layer icon and a 4 px glow in the layer colour */
.map-marker {
  --tone: var(--layer-media);
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid var(--tone);
  border-radius: 50%;
  background: var(--panel);
  color: var(--tone);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 18%, transparent);
}

.map-marker__icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.map-marker__icon--filled { fill: currentColor; }

.map-marker--neptun { --tone: var(--layer-neptun); }
.map-marker--rcb { --tone: var(--layer-rcb); }
.map-marker--media { --tone: var(--layer-media); }
/* Unconfirmed reports from Belarus (M-074): grey like media, orange ring. */
.map-marker--unconfirmed { --tone: var(--layer-media); border-color: var(--org); }
.map-marker--nato { --tone: var(--layer-nato); }
.map-marker--hostile_aircraft { --tone: var(--layer-hostile); }
.map-marker--colata { --tone: var(--layer-colata); }
.map-marker--vessels { --tone: var(--layer-vessels); }
.map-marker--fires { --tone: var(--layer-fires); }

/* Ships under the Russian flag (M-063): small tricolour on the marker's corner */
.map-marker__flag {
  position: absolute;
  right: -7px;
  top: -5px;
  width: 14px;
  height: 9px;
  border-radius: 2px;
  background: linear-gradient(#fff 0 33.3%, #0039a6 33.3% 66.6%, #d52b1e 66.6%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.map-marker--alarm { --tone: var(--layer-neptun); }
.map-marker--zone-r { --tone: var(--layer-zone-r); }
.map-marker--zone-tsa { --tone: var(--layer-zone-tsa); }
.map-marker--notam-area { --tone: var(--layer-zone-r); border-style: dashed; }

/* colata clusters: square with the number of detections, coloured by priority */
.map-marker--count { border-radius: 6px; }
.map-marker--grn { --tone: var(--grn); background: var(--grnBg); color: var(--grnFg); }
.map-marker--yel { --tone: var(--yel); background: var(--yelBg); color: var(--yelFg); }
.map-marker--red { --tone: var(--red); background: var(--redBg); color: var(--redFg); }
.map-marker__count { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }

/* Corner cards */
.map-logo {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.map-logo__mark { display: block; fill: currentColor; }

/* Empty or stale map (M-037): a card like the logo card, centred at the top. */
.map-status {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  height: 44px;
  margin: 0;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.map-status:empty { display: none; }

/* Banners (M-070): yellow cards under the status card, same column. */
.map-banners {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 160px);
  pointer-events: none;
}
.map-status:not(:empty) + .map-banners { top: 68px; }
.map-banners:empty { display: none; }
.map-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--yelBg);
  box-shadow: var(--shadow);
  color: var(--yelFg);
  font-size: 13px;
  pointer-events: auto;
}
.map-banner--ended { background: var(--panel); color: var(--ink); }
.map-banner__icon { flex: none; fill: currentColor; }
.map-banner__link { display: inline-flex; align-items: center; min-height: 24px; color: inherit; font-weight: 600; white-space: nowrap; }

/* Below 1024 px the middle of the top row is too narrow (logo left, settings
   right): the status message (one line, fits 343 px) and the DORSZ banner go
   under the row, between the 16 px margins. */
@media (max-width: 1023.98px) {
  .map-status, .map-banners { top: 72px; left: 16px; right: 16px; transform: none; max-width: none; }
  .map-status { justify-content: center; }
  .map-status:not(:empty) + .map-banners { top: 124px; }
  .map-banners { align-items: stretch; }
  /* Icon and text on one row, the DORSZ link under the text. */
  .map-banner { flex-wrap: wrap; row-gap: 4px; }
  .map-banner > span { flex: 1 1 calc(100% - 24px); }
  .map-banner__link { margin-left: 24px; }
}
.map-status--stale::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--org);
}
.map-logo__suffix { padding-top: 4px; font-size: 11px; letter-spacing: .12em; color: var(--mute); }

/* Hidden layers (M-034): the layers controller sets data-hide-<layer> on .map. */
.map[data-hide-neptun] [data-layer="neptun"],
.map[data-hide-ua-alarms] [data-layer="ua_alarms"],
.map[data-hide-rcb] [data-layer="rcb"],
.map[data-hide-media] [data-layer="media"],
.map[data-hide-airspace-zones] [data-layer="airspace_zones"],
.map[data-hide-notam] [data-layer="notam"],
.map[data-hide-nato] [data-layer="nato"],
.map[data-hide-hostile-aircraft] [data-layer="hostile_aircraft"],
.map[data-hide-vessels] [data-layer="vessels"],
.map[data-hide-gnss] [data-layer="gnss"],
.map[data-hide-fires] [data-layer="fires"],
.map[data-hide-dorsz] [data-layer="dorsz"] { display: none; }

/* "Warstwy i motyw" card */
.map-settings { position: absolute; right: 16px; top: 16px; z-index: 5; }

.map-settings__gear {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.map-settings__dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--panel);
}

.map-settings__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map-settings__card[hidden], .map-settings__gear[hidden], .map-settings__dot[hidden] { display: none; }

.map-settings__header { display: flex; align-items: center; gap: 8px; }
.map-settings__header .theme-switch { margin-right: auto; }

.map-settings__collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
}

.map-settings__groups { display: grid; grid-template-columns: repeat(3, max-content); gap: 16px 24px; }
.map-settings__group { display: flex; flex-direction: column; gap: 8px; }

.map-settings__group-name {
  margin: 0;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--mute);
}

.map-filter { display: flex; align-items: center; gap: 8px; }
.map-filter__swatch { flex: none; }
.map-filter__name { min-width: 0; overflow: hidden; font-size: 13px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; }
.map-filter__flags { display: inline-flex; gap: 4px; margin-right: auto; }
.map-filter__name:not(:has(+ .map-filter__flags)) { margin-right: auto; }
.map-filter__flag { flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }

.map-filter__switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin-left: 8px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #8a939f;
}

:root[data-theme="dark"] .map-filter__switch { background: #6a6b72; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .map-filter__switch { background: #6a6b72; } }

.map-filter__switch[aria-checked="true"] { background: var(--ink); }

.map-filter__knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: left .15s;
}

.map-filter__switch[aria-checked="true"] .map-filter__knob { left: 20px; }

/* Sources caption and the card it opens above itself (M-092) */
.map-attribution {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  /* Leaves the bottom-left corner to the history icon on narrow screens (M-096). */
  max-width: calc(100vw - 92px);
  text-align: right;
  /* The column is as wide as the caption and as tall as caption + zoom bar
     (M-040); only its parts take clicks, so markers next to them stay clickable. */
  pointer-events: none;
}

.map-attribution > * { pointer-events: auto; }

/* Stays right of the history card (546 px + margins): a long caption wraps
   onto a second line on 1280 px windows instead of covering the card. */
.map-attribution__line { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 6px; max-width: max(320px, calc(100vw - 610px)); }

/* Visible source link next to the caption (NEPTUN terms, M-054). */
.map-attribution__link {
  display: inline-block;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--mute);
  font-size: 11px;
  line-height: 1.4;
  text-decoration: underline;
}

.map-attribution__link:hover { color: var(--ink); }

.map-attribution__toggle {
  min-height: 24px;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--panel);
  color: var(--mute);
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  text-align: right;
  cursor: pointer;
}

.map-attribution__toggle:hover, .map-attribution__toggle[aria-expanded="true"] { color: var(--ink); }

.map-sources {
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  width: 360px;
  max-width: calc(100vw - 32px);
  /* Window minus the caption, the zoom bar (98 px + 8 px gap, M-040) and margins. */
  max-height: calc(100vh - 202px);
  overflow: auto;
  padding: 16px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.map-sources[hidden] { display: none; }
.map-sources__header { display: flex; align-items: center; gap: 8px; }
.map-sources__title { margin: 0 auto 0 0; font-size: 14px; font-weight: 600; }

.map-sources__collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
}

.map-sources__list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.map-sources__item { display: flex; flex-direction: column; }
.map-sources__name { font-weight: 500; }
.map-sources__name a { display: inline-block; min-height: 24px; line-height: 24px; } /* WCAG 2.2 target size */
.map-sources__what, .map-sources__note { color: var(--mute); }
.map-sources__note { margin: 0; }
.map-sources__disclaimer { padding-top: 10px; border-top: 1px solid var(--soft); color: var(--ink); }
.map-sources a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.map-sources a:hover, .map-sources a:focus-visible { color: var(--ink); }

/* Detection history card (M-035) */
:root {
  --heat-0: #eceef1; --heat-1: #d6efc8; --heat-2: #c4e8a6; --heat-3: #d2dc6e; --heat-4: #ecc94e;
  --heat-5: #f2b43f; --heat-6: #ec8f37; --heat-7: #e06636; --heat-8: #cc4232; --heat-9: #a32329;
}

:root[data-theme="dark"] {
  --heat-0: #2a2b2f; --heat-1: #1e3b27; --heat-2: #2c5a2f; --heat-3: #57681f; --heat-4: #80701a;
  --heat-5: #a8781c; --heat-6: #c47c1e; --heat-7: #ec7a34; --heat-8: #f6745a; --heat-9: #ff8a7a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --heat-0: #2a2b2f; --heat-1: #1e3b27; --heat-2: #2c5a2f; --heat-3: #57681f; --heat-4: #80701a;
    --heat-5: #a8781c; --heat-6: #c47c1e; --heat-7: #ec7a34; --heat-8: #f6745a; --heat-9: #ff8a7a;
  }
}

.heat-0 { --heat: var(--heat-0); } .heat-1 { --heat: var(--heat-1); } .heat-2 { --heat: var(--heat-2); }
.heat-3 { --heat: var(--heat-3); } .heat-4 { --heat: var(--heat-4); } .heat-5 { --heat: var(--heat-5); }
.heat-6 { --heat: var(--heat-6); } .heat-7 { --heat: var(--heat-7); } .heat-8 { --heat: var(--heat-8); }
.heat-9 { --heat: var(--heat-9); }

.history-card, .history-opener { position: absolute; left: 16px; bottom: 16px; z-index: 5; }
.history-card[hidden], .history-opener[hidden], .history__now[hidden], .map__day-frame[hidden] { display: none; }

.history-card { padding: 16px; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
/* Below 1024 px the open card sits above the sources caption, which wraps to up to 4 lines with the NEPTUN link (M-096). */
@media (max-width: 1023.98px) { .history-card { bottom: 108px; } }

.history-opener {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.history { display: flex; flex-direction: column; gap: 12px; }
.history__header { display: flex; align-items: center; gap: 8px; }
.history__spacer { flex: 1; }

.history__icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.history__icon-button:disabled { opacity: .35; cursor: default; }

.history__now {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.history__month { min-width: 128px; font-size: 13px; font-weight: 600; text-align: center; }

/* On narrow screens the day grid scrolls inside the card, not the page (M-096). */
.history__body { display: flex; gap: 8px; overflow-x: auto; }
.history__bands { display: flex; flex-direction: column; gap: 4px; }
.history__band { height: 12px; font-size: 10px; line-height: 12px; color: var(--mute); white-space: nowrap; }
.history__grid { display: flex; flex-direction: column; gap: 4px; }
.history__row, .history__days { display: flex; gap: 4px; }

.history__cell {
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--heat);
}

.history__cell--future { background: transparent; border: 1px dashed var(--line2); cursor: default; }
.history__cell--now { box-shadow: 0 0 0 1px var(--ink), 0 0 0 3px var(--brand); }
.history__cell--selected { border: 2px solid var(--ink); }
.history__cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

.history__day { width: 12px; font-size: 9px; line-height: 12px; text-align: center; color: var(--mute); }
.history__day--weekend { color: var(--redFg); }
.history__day--selected { color: var(--ink); font-weight: 700; }

.history__footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--mute); }
.history__legend-low { margin-left: 6px; }
.history__swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--heat); }

/* Selected day: yellow frame around the map, current layers dimmed (real past state: M-082, v2) */
.map__day-frame { position: absolute; inset: 0; z-index: 4; box-shadow: inset 0 0 0 3px var(--brand); pointer-events: none; }
.map--day-selected .map__layer,
.map--day-selected .map__markers { opacity: .45; }

/* Popups with leader lines (M-033) */
.map__popups { position: absolute; inset: 0; pointer-events: none; }
.map--day-selected .map__popups, .map--day-selected .map__leaders { opacity: .45; }

.map-popup {
  position: absolute;
  min-width: 220px;
  max-width: 300px;
  width: max-content;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  pointer-events: auto;
}

:root[data-theme="dark"] .map-popup { box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.map-popup--colata { border: 2px solid var(--layer-colata); }

.map-popup__header { display: flex; align-items: center; gap: 8px; }
.map-popup__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--mute)); }
.map-popup__kicker { flex: 1; font-family: var(--font-mono); font-size: 11px; color: var(--mute); }

.map-popup__close {
  flex: none;
  width: 24px;
  height: 24px;
  margin: -5px -7px -5px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--mute);
  font-size: 16px;
  line-height: 1;
}

.map-popup__title {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Label and value each stay on one line; the value may move below as a whole. */
.map-popup__line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 8px;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--mute);
}

.map-popup__label, .map-popup__value { white-space: nowrap; }

/* Source of the data (M-046); a link to the original
   message (RCB, media) is 24 px tall for WCAG 2.5.8. */
.map-popup__note {
  margin-top: 4px;
  font-size: 11px;
  line-height: 16px;
  color: var(--ink);
}
.map-popup__source {
  margin-top: 4px;
  font-size: 11px;
  line-height: 16px;
  color: var(--mute);
}
.map-popup__link {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.map-popup__value { margin-left: auto; font-family: var(--font-mono); color: var(--ink); }

.map-leader__halo { stroke: var(--halo); stroke-width: 3.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.map-leader__line { stroke: #5f5f5f; stroke-width: 1.25; vector-effect: non-scaling-stroke; }
:root[data-theme="dark"] .map-leader__line { stroke: #9a9a9a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .map-leader__line { stroke: #9a9a9a; } }
