/* B7Tracker — map module styles.
 * Scope: everything inside #map (the Leaflet container) and the overlays Leaflet
 * parents into it. Consumes the design tokens from base.css, never redefines them.
 * Layout of #map itself belongs to base.css (shell agent).
 */

/* ------------------------------------------------------------------ *
 * Container
 * ------------------------------------------------------------------ */

#map {
  background: var(--bg-2);
  isolation: isolate;
}

#map.leaflet-container {
  font-family: var(--font-sans);
  font-size: var(--fs-2);
  color: var(--fg);
  background: var(--bg-2);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#map.leaflet-container a {
  color: var(--accent);
}

/* base.css resets `img, svg, canvas { max-width: 100% }`. Leaflet exempts only its own
 * .leaflet-overlay-pane, and every renderer here lives in a custom pane (b7-course,
 * b7-trail, b7-dots) whose div has no intrinsic width — so the reset clamps those
 * renderers to zero width and the course, trail and field dots paint nothing at all.
 * Re-assert the exemption. Direct children only, so marker/control icons are untouched. */
#map .leaflet-pane > svg,
#map .leaflet-pane > canvas {
  max-width: none !important;
  max-height: none !important;
}

/* Safe-area padding for the four Leaflet corner containers, so controls clear
   the notch / home indicator when the map is full-bleed. */
#map .leaflet-top { padding-top: env(safe-area-inset-top, 0px); }
#map .leaflet-bottom { padding-bottom: env(safe-area-inset-bottom, 0px); }
#map .leaflet-left { padding-left: env(safe-area-inset-left, 0px); }
#map .leaflet-right { padding-right: env(safe-area-inset-right, 0px); }

/* ------------------------------------------------------------------ *
 * Basemap tuning — one filter per layer container, cheap to composite
 * ------------------------------------------------------------------ */

#map .b7m-basemap-topo { filter: brightness(0.92) saturate(0.94) contrast(1.03); }
#map .b7m-basemap-osm { filter: brightness(0.8) saturate(0.82) contrast(1.06); }
#map .b7m-basemap-sat { filter: brightness(0.94); }

/* ------------------------------------------------------------------ *
 * Radar overlay
 *
 * Every frame of the loop is its own tile layer, parked at opacity 0; the
 * animation just moves opacity between them, so the transition below is the
 * cross-fade. RainViewer only renders tiles to a low native zoom, so past that
 * Leaflet upscales — data-radar-up says by how much and we soften the result
 * into a deliberate wash instead of a grid of fat pixels.
 * ------------------------------------------------------------------ */

#map .b7m-radar {
  filter: saturate(1.18) contrast(1.04);
  transition: opacity 240ms linear;
  will-change: opacity;
}

/* beat Leaflet's own -webkit-optimize-contrast so upscaled frames interpolate */
#map .b7m-radar .leaflet-tile,
#map .b7m-radar img.leaflet-tile {
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
}

#map[data-radar-up="1"] .b7m-radar { filter: saturate(1.26) contrast(1.02) blur(1.2px); }
#map[data-radar-up="2"] .b7m-radar { filter: saturate(1.34) contrast(0.98) blur(2.6px); }

/* ------------------------------------------------------------------ *
 * Leaflet controls: zoom + attribution
 * ------------------------------------------------------------------ */

#map .leaflet-bar,
#map .b7m-bar {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  background: var(--surface);
}

#map .leaflet-bar a,
#map .leaflet-bar a:hover,
#map .leaflet-bar a:focus {
  width: 44px;
  height: 44px;
  line-height: 44px;
  background: var(--surface);
  color: var(--fg);
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-4);
  font-weight: 600;
  text-decoration: none;
}

#map .leaflet-bar a:last-child { border-bottom: 0; }

#map .leaflet-bar a:hover,
#map .leaflet-bar a:focus-visible {
  background: var(--surface-2);
  color: var(--accent);
}

#map .leaflet-bar a.leaflet-disabled {
  background: var(--surface);
  color: var(--fg-3);
  opacity: 0.5;
}

#map .leaflet-control-attribution {
  max-width: 66%;
  padding: 2px var(--s-2);
  background: var(--surface);
  color: var(--fg-3);
  font-size: 10px;
  line-height: 1.45;
  border-top-left-radius: var(--r-1);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  opacity: 0.9;
}

#map .leaflet-control-attribution a {
  color: var(--fg-2);
  text-decoration: none;
}

#map .leaflet-control-attribution a:hover { color: var(--accent); }

/* ------------------------------------------------------------------ *
 * Toolbar (follow / fit course / fit trail / layers)
 * ------------------------------------------------------------------ */

#map .b7m-tools {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  margin: var(--s-3);
}

#map .b7m-bar {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}

#map .b7m-btn {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease;
}

#map .b7m-bar .b7m-btn:last-child { border-bottom: 0; }

#map .b7m-btn:hover { background: var(--surface-2); color: var(--fg); }

#map .b7m-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
  color: var(--fg);
}

#map .b7m-btn.is-on {
  background: var(--accent);
  color: var(--bg);
}

#map .b7m-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

#map .b7m-btn svg .o { opacity: 0.55; }

#map .b7m-btn-follow.is-on svg .o { opacity: 0.85; }

/* ------------------------------------------------------------------ *
 * Layers panel
 * ------------------------------------------------------------------ */

#map .b7m-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 244px;
  max-width: calc(100vw - 104px);
  max-height: 62vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  color: var(--fg);
}

#map .b7m-panel[hidden] { display: none; }

#map .b7m-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

#map .b7m-panel-title {
  margin: 0;
  font-size: var(--fs-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg-2);
}

#map .b7m-panel .b7m-btn-close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  background: var(--surface-2);
}

#map .b7m-panel .b7m-btn-close svg { width: 16px; height: 16px; }

#map .b7m-panel-label {
  font-size: var(--fs-1);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: var(--s-1);
}

/* segmented basemap picker */
#map .b7m-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
}

#map .b7m-seg-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 0;
  min-height: 40px;
  padding: var(--s-2) var(--s-1);
  border: 0;
  border-radius: var(--r-1);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: var(--fs-1);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease;
}

#map .b7m-seg-btn:hover { color: var(--fg); background: var(--surface-2); }

#map .b7m-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

#map .b7m-seg-btn.is-active {
  background: var(--accent);
  color: var(--bg);
}

/* switch rows */
#map .b7m-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  min-height: 44px;
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-3);
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur) ease, background var(--dur) ease;
}

#map .b7m-toggle:hover { background: var(--surface-2); }

#map .b7m-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

#map .b7m-toggle.is-on { border-color: var(--accent-dim); }

#map .b7m-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

#map .b7m-toggle-label {
  font-size: var(--fs-2);
  font-weight: 600;
  line-height: 1.2;
}

#map .b7m-toggle-note {
  font-size: var(--fs-1);
  line-height: 1.2;
  color: var(--fg-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

#map .b7m-toggle-note.is-bad { color: var(--bad); }

#map .b7m-switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  transition: background var(--dur) ease, border-color var(--dur) ease;
}

#map .b7m-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--fg-3);
  transition: transform var(--dur) ease, background var(--dur) ease;
}

#map .b7m-toggle.is-on .b7m-switch {
  background: var(--accent-dim);
  border-color: var(--accent);
}

#map .b7m-toggle.is-on .b7m-switch::after {
  background: var(--accent);
  transform: translateX(16px);
}

/* ------------------------------------------------------------------ *
 * Radar chip: frame time + the position of that frame in the loop
 * ------------------------------------------------------------------ */

#map .b7m-chip {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-3);
  padding: 4px var(--s-3) 4px var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-1);
  color: var(--fg-2);
  font-size: var(--fs-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#map .b7m-chip[hidden] { display: none; }

#map .b7m-chip-k { color: var(--fg-3); }

#map .b7m-chip-v {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--fg);
}

#map .b7m-chip.is-dry .b7m-chip-v {
  font-family: inherit;
  font-weight: 600;
  color: var(--fg-2);
}

#map .b7m-chip-dots {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 2px;
}

#map .b7m-chip-dots:empty { display: none; }

/* nothing to scrub through when it is not raining — say it plainly, no ticker */
#map .b7m-chip.is-dry .b7m-chip-dots { display: none; }

#map .b7m-chip-dots i {
  width: 3px;
  height: 9px;
  border-radius: 1.5px;
  background: var(--line-strong);
  transition: background var(--dur) ease, height var(--dur) ease;
}

#map .b7m-chip-dots i.is-on {
  height: 13px;
  background: var(--accent);
}

/* ------------------------------------------------------------------ *
 * Course + trail paths
 * ------------------------------------------------------------------ */

#map .b7m-path { pointer-events: none; }

#map .b7m-trail-line { filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.55)); }

/* ------------------------------------------------------------------ *
 * Checkpoint markers
 * ------------------------------------------------------------------ */

#map .b7m-cp-icon {
  background: none;
  border: 0;
}

#map .b7m-cp {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--surface-2);
  color: var(--fg-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  transition: transform var(--dur) ease, background var(--dur) ease;
}

/* generous touch target without changing the visual size */
#map .b7m-cp::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

#map .b7m-cp-code {
  position: relative;
  top: 0.5px;
  pointer-events: none;
}

#map .b7m-cp[data-state="upcoming"] {
  background: var(--surface-2);
  color: var(--fg-2);
  border-color: var(--bg);
  box-shadow: 0 0 0 1px var(--line-strong), 0 1px 4px rgba(0, 0, 0, 0.6);
}

#map .b7m-cp[data-state="passed"] {
  background: var(--ok);
  color: var(--bg);
  border-color: var(--bg);
}

#map .b7m-cp[data-state="next"] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 1px 6px rgba(0, 0, 0, 0.7);
  transform: scale(1.12);
  z-index: 2;
}

#map .b7m-cp[data-kind="start"],
#map .b7m-cp[data-kind="finish"] {
  border-radius: var(--r-1);
  width: 28px;
  height: 28px;
  margin: -1px;
}

#map .b7m-cp-icon:hover .b7m-cp { transform: scale(1.15); }
#map .b7m-cp-icon:hover .b7m-cp[data-state="next"] { transform: scale(1.24); }

/* ------------------------------------------------------------------ *
 * Racer marker
 * ------------------------------------------------------------------ */

#map .b7m-racer-icon {
  width: 0;
  height: 0;
  background: none;
  border: 0;
  pointer-events: none;
}

#map .b7m-racer-dot,
#map .b7m-racer-pulse {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
}

#map .b7m-racer-dot {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 2px 8px rgba(0, 0, 0, 0.75);
}

#map .b7m-racer-pulse {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  background: var(--accent);
  opacity: 0.5;
  animation: b7m-pulse 2.4s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

@keyframes b7m-pulse {
  0% { transform: scale(0.7); opacity: 0.5; }
  70% { opacity: 0; }
  100% { transform: scale(3.2); opacity: 0; }
}

#map .b7m-racer-tag {
  position: absolute;
  left: 16px;
  top: 0;
  transform: translateY(-50%);
  display: flex;
  align-items: baseline;
  gap: var(--s-1);
  padding: 3px var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  line-height: 1.25;
}

#map .b7m-racer-bib {
  font-weight: 700;
  color: var(--fg);
}

#map .b7m-racer-bib:empty { display: none; }

#map .b7m-racer-km {
  font-style: normal;
  color: var(--accent-2);
}

#map .b7m-racer-km:empty { display: none; }

/* staleness states */
#map .b7m-racer-icon[data-state="warn"] .b7m-racer-dot {
  background: var(--warn);
  box-shadow: 0 0 0 1px var(--warn), 0 2px 8px rgba(0, 0, 0, 0.75);
}

#map .b7m-racer-icon[data-state="warn"] .b7m-racer-pulse { background: var(--warn); animation-duration: 3.6s; }
#map .b7m-racer-icon[data-state="warn"] .b7m-racer-tag { border-left-color: var(--warn); }
#map .b7m-racer-icon[data-state="warn"] .b7m-racer-km { color: var(--warn); }

#map .b7m-racer-icon[data-state="bad"] .b7m-racer-dot {
  background: var(--bad);
  box-shadow: 0 0 0 1px var(--bad), 0 2px 8px rgba(0, 0, 0, 0.75);
}

#map .b7m-racer-icon[data-state="bad"] .b7m-racer-pulse { display: none; }
#map .b7m-racer-icon[data-state="bad"] .b7m-racer-tag { border-left-color: var(--bad); }
#map .b7m-racer-icon[data-state="bad"] .b7m-racer-km { color: var(--bad); }

#map .b7m-racer-icon[data-state="unknown"] .b7m-racer-dot { background: var(--fg-3); box-shadow: 0 0 0 1px var(--fg-3), 0 2px 8px rgba(0, 0, 0, 0.75); }
#map .b7m-racer-icon[data-state="unknown"] .b7m-racer-pulse { display: none; }

/* ------------------------------------------------------------------ *
 * Replay: ghost racer at the replayed moment, live view stepped back
 *
 * The live racer runs warm (--accent); the replay runs cool (--info) so the
 * two are never read as the same thing. While a replay is on screen the live
 * marker and the live trail drop back and the re-run stretch takes the fore.
 * ------------------------------------------------------------------ */

#map .b7m-racer-icon,
#map .b7m-trail-line,
#map .b7m-trail-recent,
#map .b7m-done-line {
  transition: opacity var(--dur) ease;
}

#map[data-replay="1"] .b7m-racer-icon { opacity: 0.32; }
#map[data-replay="1"] .b7m-racer-pulse { display: none; }
#map[data-replay="1"] .b7m-trail-line { opacity: 0.3; }
#map[data-replay="1"] .b7m-trail-recent { opacity: 0.22; }
#map[data-replay="1"] .b7m-done-line { opacity: 0.35; }

#map .b7m-replay-line {
  filter: drop-shadow(0 0 4px rgba(92, 180, 255, 0.55));
}

#map .b7m-ghost-icon {
  width: 0;
  height: 0;
  background: none;
  border: 0;
  pointer-events: none;
}

#map .b7m-ghost-dot,
#map .b7m-ghost-halo {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
}

#map .b7m-ghost-dot {
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  background: var(--info);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--info), 0 2px 10px rgba(0, 0, 0, 0.8);
}

#map .b7m-ghost-halo {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 1px solid var(--info);
  background: rgba(92, 180, 255, 0.12);
  opacity: 0.75;
}

#map .b7m-ghost-icon[data-playing="1"] .b7m-ghost-halo {
  animation: b7m-ghost-sweep 1.6s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

@keyframes b7m-ghost-sweep {
  0% { transform: scale(0.55); opacity: 0.8; }
  70% { opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

#map .b7m-ghost-tag {
  position: absolute;
  left: 15px;
  top: 0;
  transform: translateY(-50%);
  display: flex;
  align-items: baseline;
  gap: var(--s-1);
  padding: 3px var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  line-height: 1.25;
}

#map .b7m-ghost-time {
  font-weight: 700;
  color: var(--fg);
}

#map .b7m-ghost-km {
  font-style: normal;
  color: var(--info);
}

#map .b7m-ghost-time:empty,
#map .b7m-ghost-km:empty { display: none; }

/* ------------------------------------------------------------------ *
 * Elevation-scrub cursor
 * ------------------------------------------------------------------ */

#map .b7m-hover-icon {
  width: 0;
  height: 0;
  background: none;
  border: 0;
  pointer-events: none;
}

#map .b7m-hover-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid var(--accent-2);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45);
}

#map .b7m-hover-tag {
  position: absolute;
  left: 0;
  top: -12px;
  transform: translate(-50%, -100%);
  padding: 2px var(--s-2);
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r-1);
  box-shadow: var(--shadow-1);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  line-height: 1.3;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * Popups
 * ------------------------------------------------------------------ */

#map .b7m-popup .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  padding: 0;
}

#map .b7m-popup .leaflet-popup-content {
  margin: 0;
  padding: var(--s-3);
  width: auto !important;
  font-size: var(--fs-2);
  line-height: 1.4;
}

#map .b7m-popup .leaflet-popup-tip {
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: none;
}

#map .b7m-popup .leaflet-popup-close-button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 32px;
  color: var(--fg-3);
}

#map .b7m-popup .leaflet-popup-close-button:hover {
  color: var(--fg);
  background: transparent;
}

#map .b7m-pop-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding-right: var(--s-5);
}

#map .b7m-pop-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: var(--r-1);
  background: var(--accent-dim);
  color: var(--accent-2);
  font-family: var(--font-mono);
  font-size: var(--fs-1);
  font-weight: 700;
}

#map .b7m-pop-title {
  font-size: var(--fs-3);
  font-weight: 700;
  line-height: 1.2;
  color: var(--fg);
}

#map .b7m-pop-meta {
  margin-top: var(--s-1);
  color: var(--fg-3);
  font-size: var(--fs-1);
  font-variant-numeric: tabular-nums;
}

#map .b7m-pop-meta:empty { display: none; }

#map .b7m-pop-body {
  margin-top: var(--s-3);
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#map .b7m-pop-body:empty { display: none; }

#map .b7m-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}

#map .b7m-row-k {
  color: var(--fg-3);
  font-size: var(--fs-1);
  white-space: nowrap;
}

#map .b7m-row-v {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

#map .b7m-pop-note {
  margin-top: var(--s-1);
  color: var(--accent-2);
  font-size: var(--fs-1);
}

/* ------------------------------------------------------------------ *
 * Failure state (map could not initialise)
 * ------------------------------------------------------------------ */

#map .b7m-fail {
  position: absolute;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-5);
  background: var(--bg-2);
  color: var(--fg-2);
  text-align: center;
  font-size: var(--fs-2);
}

#map .b7m-fail strong { color: var(--fg); font-size: var(--fs-3); }

/* ------------------------------------------------------------------ *
 * Compact layouts
 * ------------------------------------------------------------------ */

@media (max-width: 480px) {
  #map .b7m-tools { margin: var(--s-2); }
  #map .b7m-chip { margin: var(--s-2); }
  /* keep the open panel clear of the zoom control in the opposite corner */
  #map .b7m-panel { width: 216px; max-width: calc(100vw - 128px); max-height: 56vh; }
  #map .leaflet-control-attribution { max-width: 58%; }
}

/* Short map strips (map sharing the viewport with the panel): keep the panel usable. */
@media (max-height: 560px) {
  #map .b7m-panel { max-height: 74vh; }
}

/* ------------------------------------------------------------------ *
 * Reduced motion
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  #map .b7m-racer-pulse { animation: none; opacity: 0.28; transform: scale(1.9); }
  #map .b7m-ghost-icon[data-playing="1"] .b7m-ghost-halo { animation: none; opacity: 0.5; }
  #map .b7m-radar { transition: none; }
  #map .b7m-chip-dots i { transition: none; }
  #map .b7m-cp,
  #map .b7m-btn,
  #map .b7m-seg-btn,
  #map .b7m-toggle,
  #map .b7m-switch,
  #map .b7m-switch::after { transition: none; }
  #map .leaflet-fade-anim .leaflet-tile { transition: none; }
}
