/*
 * styles.css — Simba Bus Radar.
 *
 * Design constraints, all downstream of "this is read one-handed, outdoors,
 * with a dog on the other arm":
 *   - the verdict must be readable at arm's length in sunlight
 *   - dark by default (evening walks), high contrast throughout
 *   - nothing important below the fold on a phone
 *   - touch targets >= 44 px
 */

:root {
  --bg: #0d1117;
  --bg-raised: #161b22;
  --bg-sunk: #010409;
  --line: #2a323d;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7887;

  --clear: #2ea862;
  --clear-bg: #06281a;
  --caution: #e0a01a;
  --caution-bg: #2e2206;
  --danger: #f0553c;
  --danger-bg: #340f0a;
  --accent: #3b82f6;

  --radius: 14px;
  --pad: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --bg-raised: #ffffff;
    --bg-sunk: #e7ebf0;
    --line: #d3dae2;
    --text: #10161d;
    --text-dim: #4d5b6b;
    --text-faint: #78889a;
    --clear-bg: #dff3e6;
    --caution-bg: #fdf1d6;
    --danger-bg: #fde3de;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.boot {
  max-width: 460px;
  margin: 15vh auto;
  padding: 0 24px;
  text-align: center;
}
.boot-dog { font-size: 56px; }
.boot h1 { font-size: 22px; margin: 8px 0; }
.boot p { color: var(--text-dim); }
.boot-hint { font-size: 13px; color: var(--text-faint); line-height: 1.6; margin-top: 20px; }
.boot code {
  font-family: var(--mono);
  background: var(--bg-raised);
  padding: 2px 6px;
  border-radius: 5px;
}

/* ---------------------------------------------------------------- app shell */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 12px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px 12px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand .paw { font-size: 20px; }
.brand small {
  font-weight: 500;
  color: var(--text-faint);
  font-size: 12px;
}
.topbar-spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.chip.ok .dot { background: var(--clear); }
.chip.warn .dot { background: var(--caution); }
.chip.bad .dot { background: var(--danger); }
.chip.live .dot { animation: pulse 2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.icon-btn {
  appearance: none;
  min-width: 40px; min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------ verdict card */

.verdict {
  border-radius: var(--radius);
  padding: 18px var(--pad);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  position: relative;
  overflow: hidden;
}
.verdict.clear   { background: var(--clear-bg);   border-color: color-mix(in srgb, var(--clear) 45%, transparent); }
.verdict.caution { background: var(--caution-bg); border-color: color-mix(in srgb, var(--caution) 45%, transparent); }
.verdict.danger  { background: var(--danger-bg);  border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.verdict.danger  { animation: alarm 1.4s ease-in-out infinite; }

@keyframes alarm {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 85, 60, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(240, 85, 60, 0.22); }
}

.verdict-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.verdict-headline {
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 6px 0 2px;
}
.verdict.clear   .verdict-headline { color: var(--clear); }
.verdict.caution .verdict-headline { color: var(--caution); }
.verdict.danger  .verdict-headline { color: var(--danger); }
.verdict-detail { font-size: 15px; color: var(--text); opacity: 0.9; line-height: 1.45; }
.verdict-sub {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.countdown {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ------------------------------------------------------------------- layout */

.grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .grid { grid-template-columns: 360px 1fr; align-items: start; }
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px var(--pad);
  border-bottom: 1px solid var(--line);
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.card-note { font-size: 11px; color: var(--text-faint); margin-left: auto; text-align: right; }
.card-body { padding: var(--pad); }

/* --------------------------------------------------------------- rose / map */

.rose-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rose { width: 100%; max-width: 330px; height: auto; touch-action: manipulation; }
.rose-sector { cursor: pointer; transition: opacity 120ms; }
.rose-sector:hover { opacity: 0.75; }

.rose-verdict {
  text-align: center;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.rose-verdict strong { color: var(--text); font-size: 15px; }

#map {
  height: 380px;
  width: 100%;
  background: var(--bg-sunk);
}
@media (min-width: 900px) { #map { height: 520px; } }
.leaflet-container { background: var(--bg-sunk); font-family: var(--font); }
.map-missing {
  height: 200px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* Leaflet marker contents */
.bus-marker { position: relative; width: 34px; height: 34px; }
.bus-arrow {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 19px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.65));
}
.bus-tag {
  position: absolute;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(3, 7, 12, 0.86);
  color: #fff;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.22);
}
.me-marker {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.5), 0 2px 6px rgba(0,0,0,0.5);
}

/* ------------------------------------------------------------- threat list */

.threats { display: flex; flex-direction: column; }
.threat {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px var(--pad);
  border-bottom: 1px solid var(--line);
}
.threat:last-child { border-bottom: none; }
.threat.danger { background: color-mix(in srgb, var(--danger) 11%, transparent); }
.threat.caution { background: color-mix(in srgb, var(--caution) 8%, transparent); }

.route-badge {
  min-width: 46px;
  padding: 6px 7px;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  background: #444c56;
  line-height: 1.15;
  border: 1px solid rgba(255,255,255,0.14);
}
.threat-main { min-width: 0; }
.threat-line1 {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.threat-line2 { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.threat-eta {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
}
.threat.danger .threat-eta { color: var(--danger); }
.threat.caution .threat-eta { color: var(--caution); }
.threat.clear .threat-eta { color: var(--text-faint); font-weight: 600; }
.threat-eta small { display: block; font-size: 10px; font-weight: 600; color: var(--text-faint); font-family: var(--font); }

.tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--text-faint);
  margin-left: 6px;
  vertical-align: 1px;
}
.tag.est { color: var(--caution); border-color: color-mix(in srgb, var(--caution) 40%, transparent); }

.empty {
  padding: 26px var(--pad);
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- settings */

.settings { display: flex; flex-direction: column; gap: 16px; }
.setting { display: flex; flex-direction: column; gap: 6px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}
.setting-label { font-size: 13px; font-weight: 600; }
.setting-help { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }
.setting-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
}

input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
input[type="text"], input[type="password"], select {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-family: var(--font);
  width: 100%;
}

.switch {
  position: relative;
  width: 46px; height: 27px;
  flex: none;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 140ms;
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms;
}
.switch.on::after { transform: translateX(19px); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  appearance: none;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  color: var(--text-dim);
  cursor: pointer;
}
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.banner {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 10px;
  border: 1px solid;
}
.banner.warn { background: var(--caution-bg); border-color: color-mix(in srgb, var(--caution) 45%, transparent); }
.banner.bad  { background: var(--danger-bg);  border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.banner.info { background: var(--bg-sunk); border-color: var(--line); color: var(--text-dim); }
.banner button {
  appearance: none;
  margin-top: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.footnote {
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.65;
  text-align: center;
}
.footnote a { color: var(--text-dim); }

.rose-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ==================================================================== radar
   Fullscreen map view (radar.html). The map owns the viewport; everything
   else floats above it, so the body must not scroll. */

.radar-body { height: 100%; overflow: hidden; }
html:has(.radar-body), .radar-body { height: 100%; }

.radar-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.radar-map { flex: 1; min-height: 0; background: var(--bg-sunk); }

/* The trail canvas sits above the tiles and the radius circle, below popups. */
.trail-canvas {
  position: absolute;
  top: 0; left: 0;
  z-index: 450;
  pointer-events: none;
}

.radar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: linear-gradient(var(--bg) 62%, transparent);
  position: relative;
  z-index: 1000;
}
.radar-back {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  padding-bottom: 3px;
}
.radar-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.radar-title small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-faint);
}
.radar-top-chips { margin-left: auto; display: flex; gap: 6px; }

/* Bottom strip: legend on the left, the arrivals prediction beside it.
   Right inset clears Leaflet's zoom control. */
.radar-bottom {
  position: absolute;
  left: 12px;
  right: 58px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.radar-bottom > * { pointer-events: auto; }

.radar-legend {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(6, 10, 16, 0.82);
  border: 1px solid var(--line);
  font-size: 11px;
  color: #e6edf3;
  backdrop-filter: blur(6px);
}
.radar-legend span { display: flex; align-items: center; gap: 7px; }
.radar-legend .sw { width: 22px; height: 4px; border-radius: 2px; flex: none; }
.radar-legend .sw.past   { background: linear-gradient(90deg, rgba(245,158,11,0), rgba(245,158,11,1)); }
.radar-legend .sw.future { background: linear-gradient(90deg, rgba(239,68,68,1), rgba(239,68,68,0)); }
.radar-legend .sw.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #ff2d2d;
  border: 2px solid #fff;
}

.radar-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  max-width: min(340px, 84vw);
  padding: 16px 18px;
  border-radius: 12px;
  background: rgba(6, 10, 16, 0.86);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
  pointer-events: none;
}
.radar-empty strong { color: var(--text); font-size: 15px; }
.radar-empty-note { color: var(--text-faint); font-size: 11.5px; }

/* Toasts sit under the header, not at the bottom: the bottom strip is now the
   legend plus the arrivals list, and a toast there covered the predictions.
   The width leaves room for the settings button at top right. */
.radar-toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 56px);
  z-index: 1001;
  max-width: min(420px, calc(100vw - 130px));
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(6, 10, 16, 0.9);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  backdrop-filter: blur(6px);
}
.radar-toast-btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--font);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Control panel: a floating button that opens into a card. */
.radar-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 56px);
  right: 12px;
  z-index: 1002;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-height: calc(100% - 130px);
}
.radar-panel-toggle {
  appearance: none;
  width: 42px; height: 42px;
  flex: none;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
.radar-panel.open .radar-panel-toggle { background: var(--accent); border-color: var(--accent); color: #fff; }
.radar-panel-body {
  width: min(310px, calc(100vw - 24px));
  overflow-y: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (prefers-color-scheme: light) {
  .radar-panel-body { background: rgba(255,255,255,0.96); }
  .radar-legend, .radar-empty, .radar-toast { background: rgba(255,255,255,0.92); color: var(--text-dim); }
  .radar-legend { color: var(--text); }
}
.radar-stats {
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  line-height: 1.5;
}

/* Link across to the radar from the walk view. */
.radar-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  padding: 0 11px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  white-space: nowrap;
}
.radar-link:hover { border-color: var(--accent); }

/* Arrivals prediction, sitting beside the legend. */
.radar-arrivals {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(6, 10, 16, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.radar-arrivals-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.radar-arrivals-empty,
.radar-arrivals-more {
  font-size: 11.5px;
  color: var(--text-faint);
}
.radar-arrivals-more { margin-top: 2px; }

.arrival {
  display: grid;
  grid-template-columns: auto 52px 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.arrival-route {
  min-width: 30px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #444c56;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.35;
  border: 1px solid rgba(255,255,255,0.15);
}
.arrival-when {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 700;
  color: #e6edf3;
  white-space: nowrap;
}
.arrival.now .arrival-when { color: #ff6b57; font-size: 11px; }
.arrival-where {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

@media (prefers-color-scheme: light) {
  .radar-arrivals { background: rgba(255,255,255,0.93); }
  .arrival-when { color: var(--text); }
}

/* Narrow phones: the headsign is the first thing to go, then rows four and
   five, so the legend and the next few times always both fit. */
@media (max-width: 560px) {
  .radar-arrivals { padding: 8px 9px; }
  /* No headsign column to absorb the slack, so pin both columns to their
     content or the route badge stretches across the card. */
  .arrival { grid-template-columns: max-content 48px; justify-content: start; }
  .arrival-where { display: none; }
  /* Row count is limited in JS (4 collapsed, the lot when expanded); a CSS cap
     here would also hide rows inside the scrolling expanded list, leaving quiet
     markers with no buses between them. */
}
@media (max-width: 380px) {
  .radar-bottom { gap: 6px; }
  .radar-legend { font-size: 10px; }
}

/* Amber edge = heading estimate, the same signal the map labels use. */
.arrival.est .arrival-route { border-color: rgba(224,160,26,0.85); }
.arrival.est .arrival-when::after {
  content: "~";
  color: var(--caution);
  margin-left: 2px;
}

/* ---- planning board (12/24 h) ------------------------------------------- */

.radar-arrivals-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tt-title {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tt-title:hover { color: var(--text-dim); }
.tt-caret { font-size: 9px; }
.tt-hours {
  appearance: none;
  margin-left: auto;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  color: var(--text-dim);
}
.tt-hours:hover { border-color: var(--accent); color: var(--text); }

.radar-arrivals.expanded { max-width: 460px; }
.tt-list { display: flex; flex-direction: column; gap: 3px; }
.radar-arrivals.expanded .tt-list {
  max-height: min(46vh, 340px);
  overflow-y: auto;
  padding-right: 4px;
}

/* Four columns once clock times are involved: route, time, countdown, where. */
.arrival {
  grid-template-columns: auto 74px 62px 1fr;
}
.arrival-in {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.arrival.live .arrival-when { color: #6ee7a0; }
.arrival.live .arrival-when::before {
  content: "● ";
  font-size: 8px;
  vertical-align: 1px;
}

.tt-quiet {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  margin: 2px 0 4px;
  border-radius: 8px;
  background: rgba(46, 168, 98, 0.14);
  border: 1px solid rgba(46, 168, 98, 0.42);
}
.tt-quiet strong { font-size: 13px; color: #6ee7a0; }
.tt-quiet span { font-size: 11px; color: var(--text-dim); }

.tt-gap {
  font-size: 10px;
  color: var(--caution);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 0 3px 2px;
  border-top: 1px dashed color-mix(in srgb, var(--caution) 45%, transparent);
  margin-top: 3px;
}

.tt-foot {
  font-size: 10px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 4px;
}

button.radar-arrivals-more {
  appearance: none;
  background: none;
  border: 0;
  padding: 2px 0 0;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  color: var(--accent);
  text-align: left;
}

@media (prefers-color-scheme: light) {
  .tt-quiet strong { color: #17703f; }
  .arrival.live .arrival-when { color: #17703f; }
}

/* Narrow phones: drop the headsign, then the countdown, keeping route + time. */
@media (max-width: 560px) {
  .arrival { grid-template-columns: max-content 74px 58px; justify-content: start; }
  .radar-arrivals.expanded { max-width: none; }
}
@media (max-width: 430px) {
  .arrival { grid-template-columns: max-content 70px; }
  .arrival-in { display: none; }
}

/* ---- data provenance ---------------------------------------------------- */

/* One unambiguous statement of where the dots come from. Demo data must never
   sit quietly looking like real traffic. */
.source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.source-badge.live    { color: #6ee7a0; border-color: rgba(46,168,98,0.55);  background: rgba(46,168,98,0.14); }
.source-badge.demo    { color: #c496ff; border-color: rgba(167,87,255,0.65); background: rgba(167,87,255,0.18); }
.source-badge.stale   { color: #e0a01a; border-color: rgba(224,160,26,0.55); background: rgba(224,160,26,0.14); }
.source-badge.bad     { color: #f0553c; border-color: rgba(240,85,60,0.55);  background: rgba(240,85,60,0.14); }
.source-badge.wait    { color: var(--text-faint); border-color: var(--line); background: var(--bg-sunk); }

@media (prefers-color-scheme: light) {
  .source-badge.live { color: #17703f; }
  .source-badge.demo { color: #6b21c8; }
}

/* Legend swatches for the three provenance colours. */
.radar-legend .sw.dot.live      { background: #ff2d2d; }
.radar-legend .sw.dot.scheduled { background: #e0a01a; }
.radar-legend .sw.dot.synthetic { background: #a757ff; }

@media (max-width: 560px) {
  .source-badge { font-size: 9px; padding: 3px 7px; }
}

/* ---- version label ------------------------------------------------------ */

/* Small, monospaced and muted: identifies the build without competing with
   anything that matters. Bumped on every code change (see js/version.js). */
.version {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-faint);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  white-space: nowrap;
}
.radar-title .version { margin-left: 6px; }

@media (max-width: 430px) {
  .brand .version { display: none; }   /* the footnote still carries it */
}

/* An empty planning board that is empty because requests failed, not because
   the street is quiet. */
.radar-arrivals-empty.bad {
  color: #ffb4a6;
  line-height: 1.5;
}
.radar-arrivals-empty code {
  font-family: var(--mono);
  background: var(--bg-sunk);
  padding: 0 3px;
  border-radius: 3px;
}
@media (prefers-color-scheme: light) {
  .radar-arrivals-empty.bad { color: #a03020; }
}

/* Direction-only marker: a bus we can locate but not route. */
.radar-legend .sw.tick {
  width: 22px; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(224,160,26,1), rgba(224,160,26,0));
}

/* ---- agency picker ------------------------------------------------------ */

/* Each agency is a separate region-wide request per refresh, so the cost sits
   on the control rather than in a footnote nobody reads. */
.agency-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.agency {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
  font: inherit;
  text-align: left;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  color: var(--text-dim);
}
.agency:hover { border-color: var(--accent); }
.agency.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.agency-name { font-size: 12.5px; font-weight: 600; flex: 1; }
.agency-kb {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
  white-space: nowrap;
}
.agency.on .agency-kb { opacity: 0.9; }

/* ---- dismissible notices ------------------------------------------------ */

/* Floating messages get a close button. The body is a flex child so long text
   wraps against the button rather than running underneath it. */
.dismissible {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.dismissible-body { flex: 1; min-width: 0; }

.dismiss-x {
  appearance: none;
  flex: none;
  width: 26px;
  height: 26px;
  margin: -3px -4px 0 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  /* Comfortably tappable without making the notice taller. */
  display: grid;
  place-items: center;
}
.dismiss-x:hover { opacity: 1; background: rgba(127, 127, 127, 0.18); }
.dismiss-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The radar toast centres its text; keep that, with the button on the end. */
.radar-toast.dismissible { text-align: left; }
