/* ═══════════════════════════════════════════════════════════════════════════
   LiveRoad · v2 map UI
   Design tokens + component styles for the redesigned /app experience.
   Mobile-first; left-rail layout kicks in at ≥900px.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:            #F7F7F5;
  --surface:       #FFFFFF;
  --surface-2:     #FAFAF7;
  --surface-3:     #F1EFEA;
  --border:        #E8E6E0;
  --border-strong: #D4D1C7;
  --text:          #18181B;
  --text-soft:     #3F3F46;
  --muted:         #71717A;
  --muted-2:       #A1A1AA;
  --brand:         #FFD200;
  --brand-ink:     #1A1A1A;
  --blue:          #2563EB;
  --red:           #E11D48;
  --amber:         #F59E0B;
  --green:         #10B981;
  --sev-major:     #E11D48;
  --sev-moderate:  #F59E0B;
  --sev-minor:     #10B981;
  --shadow-sm: 0 1px 2px rgba(24,24,27,.04), 0 1px 3px rgba(24,24,27,.06);
  --shadow-md: 0 2px 4px rgba(24,24,27,.04), 0 6px 16px rgba(24,24,27,.08);
  --shadow-lg: 0 4px 8px rgba(24,24,27,.04), 0 16px 32px rgba(24,24,27,.12);
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --pill:      999px;
  --rail-w:    380px;
  --top-h:     56px;
  --safe-top:  env(safe-area-inset-top, 0);
  --safe-bot:  env(safe-area-inset-bottom, 0);
}

body.dark {
  --bg:            #0A0A0B;
  --surface:       #18181B;
  --surface-2:     #1F1F23;
  --surface-3:     #27272A;
  --border:        #27272A;
  --border-strong: #3F3F46;
  --text:          #FAFAF9;
  --text-soft:     #E4E4E7;
  --muted:         #A1A1AA;
  --muted-2:       #71717A;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 4px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.5);
  --shadow-lg: 0 4px 8px rgba(0,0,0,.5), 0 16px 32px rgba(0,0,0,.6);
}

/* ── Base / reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.003em;
}

button  { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; padding: 0; }
input, select, textarea { font-family: inherit; color: inherit; }
a       { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

#app   { position: fixed; inset: 0; }
#map   { position: absolute; inset: 0; z-index: 1; background: var(--bg); }
body.dark #map { background: #0A0A0B; }

/* ── Top bar (floating pill) ──────────────────────────────────────────────── */
#top-bar {
  position: absolute;
  top:   calc(var(--safe-top) + 12px);
  left:  12px;
  right: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  height: var(--top-h);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: var(--pill);
  box-shadow: var(--shadow-md);
}

#top-bar .logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
  flex: 0 0 auto;
  color: var(--text);
}
#top-bar .logo:hover { text-decoration: none; }
#top-bar .logo-mark {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: #2a2f3a;
}
#top-bar .logo-mark svg {
  width: 24px;
  height: 24px;
  display: block;
}
body.dark #top-bar .logo-mark { color: #F7F7F5; }
#top-bar .logo-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  display: inline-block;
}
@media (max-width: 480px) {
  #top-bar .logo-text { display: none; }
}

.top-search {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  min-width: 0;
}
.top-search-icon  { flex: 0 0 auto; color: var(--muted); }
.top-search-input {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  min-width: 0;
}
.top-search-input::placeholder { color: var(--muted); }

.top-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--pill);
  display: grid;
  place-items: center;
  color: var(--text-soft);
  flex: 0 0 auto;
  transition: background 150ms ease, color 150ms ease;
}
.top-icon:hover { background: var(--surface-2); color: var(--text); }

.top-avatar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  transition: all 150ms ease;
  white-space: nowrap;
}
.top-avatar:hover { background: var(--surface-3); color: var(--text); }
.top-avatar svg  { flex: 0 0 auto; }

@media (min-width: 540px) {
  #top-bar .logo-text { display: inline; }
}

/* ── Filter rail (horizontal floating, Nearby-only) ───────────────────────── */
#filter-rail {
  position: absolute;
  top: calc(var(--safe-top) + var(--top-h) + 22px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 6px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
  transition: opacity 200ms ease, transform 200ms ease;
}
#filter-rail::-webkit-scrollbar { display: none; }
#filter-rail.rail-hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.pill {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: all 150ms ease;
  white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.on {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
body.dark .pill.on { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--pill);
  background: var(--muted);
}
.pill.sev-major   .pill-dot { background: var(--sev-major);    }
.pill.sev-moderate .pill-dot { background: var(--sev-moderate); }
.pill.sev-minor   .pill-dot { background: var(--sev-minor);    }

.pill-divider {
  flex: 0 0 auto;
  width: 1px;
  align-self: center;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

/* ── Layer rail (colored layer toggles under filter rail) ─────────────────── */
#layer-rail {
  position: absolute;
  top: calc(var(--safe-top) + var(--top-h) + 22px + 44px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 6px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent);
  transition: opacity 200ms ease, transform 200ms ease;
}
#layer-rail::-webkit-scrollbar { display: none; }
#layer-rail.rail-hidden {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.layer-chip {
  /* Per-chip accent vars set from data-accent below */
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-wash: color-mix(in srgb, var(--accent) 14%, var(--surface));
  flex: 0 0 auto;
  height: 34px;
  padding: 0 12px 0 6px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: all 150ms ease;
  cursor: pointer;
}
.layer-chip:hover { border-color: var(--border-strong); color: var(--text); }
.layer-chip:hover .layer-chip-icon { transform: scale(1.05); }

.layer-chip-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--pill);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent);
  flex: 0 0 auto;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

/* Active state: accent-tinted chip + solid accent icon */
.layer-chip.active {
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent-ink);
}
.layer-chip.active .layer-chip-icon {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
body.dark .layer-chip.active {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  color: color-mix(in srgb, var(--accent) 80%, #fff);
}

/* Per-layer accent palette */
.layer-chip[data-accent="blue"]   { --accent: #2563eb; --accent-ink: #1d4ed8; }
.layer-chip[data-accent="green"]  { --accent: #16a34a; --accent-ink: #15803d; }
.layer-chip[data-accent="amber"]  { --accent: #f59e0b; --accent-ink: #b45309; }
.layer-chip[data-accent="purple"] { --accent: #7c3aed; --accent-ink: #6d28d9; }
.layer-chip[data-accent="red"]    { --accent: #ef4444; --accent-ink: #b91c1c; }

body.dark .layer-chip[data-accent="blue"]   { --accent-ink: #60a5fa; }
body.dark .layer-chip[data-accent="green"]  { --accent-ink: #4ade80; }
body.dark .layer-chip[data-accent="amber"]  { --accent-ink: #fbbf24; }
body.dark .layer-chip[data-accent="purple"] { --accent-ink: #a78bfa; }
body.dark .layer-chip[data-accent="red"]    { --accent-ink: #f87171; }

/* Also support plain `.chip` / `.sev-dot` legacy classes used in work-card list items */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chip.on.sev-major    { border-color: color-mix(in srgb, var(--sev-major) 50%, var(--border)); background: color-mix(in srgb, var(--sev-major) 10%, var(--surface)); color: var(--sev-major); }
.chip.on.sev-moderate { border-color: color-mix(in srgb, var(--sev-moderate) 50%, var(--border)); background: color-mix(in srgb, var(--sev-moderate) 12%, var(--surface)); color: #B45309; }
.chip.on.sev-minor    { border-color: color-mix(in srgb, var(--sev-minor) 50%, var(--border)); background: color-mix(in srgb, var(--sev-minor) 10%, var(--surface)); color: #047857; }
body.dark .chip.on.sev-moderate { color: var(--sev-moderate); }
body.dark .chip.on.sev-minor    { color: var(--sev-minor); }

/* ── FAB stack (locate + layers + report) ─────────────────────────────────── */
#fab-stack {
  position: absolute;
  right: 14px;
  bottom: calc(96px + var(--safe-bot) + 16px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: bottom 280ms cubic-bezier(.22,1,.36,1);
}
#sidebar.sheet-half ~ #fab-stack,
#sidebar.sheet-half + div #fab-stack { bottom: calc(52vh + 16px); }

.fab {
  width: 44px;
  height: 44px;
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, color 150ms ease;
}
.fab:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); color: var(--text); }
.fab.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
body.dark .fab.primary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.fab.active {
  background: color-mix(in srgb, var(--brand) 18%, var(--surface));
  color: var(--brand-ink);
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
}
body.dark .fab.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }

/* ── Popovers (layers, more menu) ─────────────────────────────────────────── */
.popover {
  position: fixed;
  z-index: 55;
  width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: popFade 120ms ease-out;
}
@keyframes popFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.popover-title {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.popover-divider { height: 1px; background: var(--border); margin: 6px 0; }

.layer-row, .menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}
.layer-row svg, .menu-row svg { flex: 0 0 auto; color: var(--muted); }
.layer-row:hover, .menu-row:hover { background: var(--surface-2); color: var(--text); }
.layer-row.active {
  background: color-mix(in srgb, var(--brand) 14%, var(--surface));
  color: var(--brand-ink);
}
.layer-row.active svg { color: var(--brand-ink); }
body.dark .layer-row.active { color: var(--brand); }

/* ── Map legend (desktop only) ────────────────────────────────────────────── */
#map-legend {
  position: absolute;
  left: 16px;
  bottom: calc(96px + var(--safe-bot) + 16px);
  z-index: 20;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  color: var(--muted);
  display: none;
}
.legend-row   { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.legend-row:last-child { margin-bottom: 0; }
.legend-divider { height: 1px; background: var(--border); margin: 6px 0; }
.legend-cone  { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.legend-cone.major    { background: var(--sev-major); }
.legend-cone.moderate { background: var(--sev-moderate); }
.legend-cone.minor    { background: var(--sev-minor); }
.legend-dot   { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.legend-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sev-major);
  box-shadow: 0 0 0 0 rgba(225,29,72,.6);
  animation: pulse 1.8s infinite;
  flex: 0 0 auto;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(225,29,72,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(225,29,72,0); }
  100% { box-shadow: 0 0 0 0 rgba(225,29,72,0); }
}

/* ── Sidebar / bottom sheet ───────────────────────────────────────────────── */
#sidebar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  box-shadow: 0 -6px 24px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(calc(100vh - 96px - env(safe-area-inset-bottom, 0)));
  transition: transform 300ms cubic-bezier(.22,1,.36,1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body.dark #sidebar { box-shadow: 0 -6px 24px rgba(0,0,0,.5); }

#sidebar.sheet-half { transform: translateY(48vh); }
#sidebar.sheet-full { transform: translateY(8vh); border-top-left-radius: 0; border-top-right-radius: 0; }

#sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: var(--pill);
  background: var(--border-strong);
  margin: 10px auto 6px;
  flex: 0 0 auto;
  cursor: ns-resize;
  touch-action: none;
}

#sheet-head {
  padding: 4px 16px 10px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
}
#sheet-summary {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  min-width: 0;
  overflow: hidden;
}
#sheet-count-num {
  font-weight: 700;
  color: var(--sev-major);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
}
#sheet-count-unit {
  color: var(--text-soft);
  font-weight: 500;
}
#source-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  margin-left: 2px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#source-badge:empty { display: none; }

/* Icon button used across sheet head, detail, modal close */
.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--pill);
  color: var(--muted);
  background: transparent;
  border: 0;
  transition: background 120ms ease, color 120ms ease;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Tabs (segmented control) ─────────────────────────────────────────────── */
#tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 0 14px 10px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.tab {
  flex: 1;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: all 150ms ease;
  white-space: nowrap;
}
.tab:hover { color: var(--text-soft); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
body.dark .tab.active { background: var(--surface-3); }

/* ── Panels (scroll area) ─────────────────────────────────────────────────── */
.panel {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 12px 20px;
}
.panel::-webkit-scrollbar        { width: 6px; }
.panel::-webkit-scrollbar-thumb  { background: var(--border-strong); border-radius: 3px; }

/* ── Nearby panel ─────────────────────────────────────────────────────────── */
#impact-score {
  margin: 4px 4px 8px;
  font-size: 12px;
  color: var(--muted);
}
#impact-score:empty { display: none; }

#ai-summary {
  margin: 0 4px 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border));
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-soft);
}

/* Legacy #works-count – kept in DOM for app.js text-writes, hidden from user */
#works-count { display: none !important; }

#works-list, #route-works-list, #timeline-list { display: flex; flex-direction: column; gap: 0; }

.list-empty {
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  margin: 0;
}

/* ── Work cards ───────────────────────────────────────────────────────────── */
.work-card {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 6px 4px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.work-card::before {
  content: "";
  flex: 0 0 4px;
  background: var(--muted);
}
.work-card[data-sev="major"]::before,
.work-card.sev-major::before    { background: var(--sev-major); }
.work-card[data-sev="moderate"]::before,
.work-card.sev-moderate::before { background: var(--sev-moderate); }
.work-card[data-sev="minor"]::before,
.work-card.sev-minor::before    { background: var(--sev-minor); }

.work-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.work-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 18%, transparent), var(--shadow-sm);
}
.work-card.on-route { border-color: color-mix(in srgb, var(--blue) 50%, var(--border)); }
.work-card.on-route::before { background: var(--blue); }

.work-card-top {
  padding: 11px 14px 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.work-card-top .work-title {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.sev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.sev-dot.major    { background: var(--sev-major); }
.sev-dot.moderate { background: var(--sev-moderate); }
.sev-dot.minor    { background: var(--sev-minor); }
.sev-dot.unknown  { background: var(--muted-2); }

.work-body {
  padding: 0 14px 12px;
  min-width: 0;
}
.work-road { font-size: 12px; color: var(--muted); margin: 0; }
.work-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.work-dates { font-size: 11px; color: var(--muted); }
.work-dist  { font-size: 11px; color: var(--muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-in_progress { background: color-mix(in srgb, var(--sev-major)   14%, var(--surface)); color: var(--sev-major); }
.status-planned     { background: color-mix(in srgb, var(--blue)        14%, var(--surface)); color: var(--blue); }
.status-unknown     { background: var(--surface-2); color: var(--muted); }

.traffic-impact {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ti-closed   { background: color-mix(in srgb, var(--sev-major)   14%, var(--surface)); color: var(--sev-major); }
.ti-high     { background: color-mix(in srgb, #EA580C            14%, var(--surface)); color: #C2410C; }
.ti-signals  { background: color-mix(in srgb, var(--sev-moderate) 14%, var(--surface)); color: #B45309; }
.ti-moderate { background: color-mix(in srgb, var(--blue)         14%, var(--surface)); color: var(--blue); }
.ti-low      { background: color-mix(in srgb, var(--sev-minor)   12%, var(--surface)); color: #047857; }
.ti-none     { background: var(--surface-2); color: var(--muted); }
body.dark .ti-signals { color: var(--sev-moderate); }
body.dark .ti-low     { color: var(--sev-minor); }
body.dark .ti-high    { color: #FB923C; }

/* ── Timeline view ────────────────────────────────────────────────────────── */
#timeline-wrap { flex: 1 1 auto; overflow: auto; padding: 4px 4px 12px; }
.tl-header {
  display: grid;
  grid-template-columns: 120px 1fr;
  padding: 6px 8px 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tl-month-row  { height: 20px; display: grid; grid-auto-flow: column; gap: 4px; padding: 0 8px 4px 128px; }
.tl-month      { font-size: 10px; color: var(--muted); text-align: center; }
.tl-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms ease;
  min-width: 0;
}
.tl-row:hover  { background: var(--surface-2); }
.tl-row.active { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); }
.tl-label-col {
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-bar-col {
  position: relative;
  height: 16px;
}
.tl-bar {
  position: absolute;
  top: 3px;
  height: 10px;
  background: var(--blue);
  border-radius: 3px;
  opacity: 0.75;
}
.tl-row[data-sev="major"] .tl-bar    { background: var(--sev-major); }
.tl-row[data-sev="moderate"] .tl-bar { background: var(--sev-moderate); }
.tl-row[data-sev="minor"] .tl-bar    { background: var(--sev-minor); }
.tl-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--sev-major);
  z-index: 1;
}

/* ── Route panel ──────────────────────────────────────────────────────────── */
#route-form { padding: 4px 4px 10px; }

.route-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  margin: 0 2px;
}
.route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.route-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }

.route-connector {
  position: relative;
  display: flex;
  align-items: center;
  padding-left: 5px;
  margin: 2px 0;
  height: 18px;
}
.route-connector-line {
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}
.route-connector-dots { display: none; }
#btn-swap-route {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: var(--pill);
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
}
#btn-swap-route:hover { color: var(--blue); border-color: var(--blue); }

.ac-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
.ac-wrap input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.ac-wrap input:focus { border-color: var(--blue); }

.ac-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
}
.ac-list:empty { display: none; }
.ac-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover      { background: var(--surface-2); }
.ac-item-icon { color: var(--muted); flex: 0 0 auto; margin-top: 2px; }
.ac-item-name { font-weight: 600; color: var(--text); }
.ac-item-addr { font-size: 11px; color: var(--muted); }

.btn-use-loc {
  width: 30px; height: 30px;
  border-radius: var(--pill);
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.btn-use-loc:hover { color: var(--blue); border-color: var(--blue); }

.route-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 2px;
}
#btn-find-route {
  flex: 1;
  height: 40px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  transition: opacity 150ms ease;
}
#btn-find-route:hover    { opacity: 0.9; }
#btn-find-route:disabled { opacity: 0.5; cursor: default; }
body.dark #btn-find-route { background: var(--brand); color: var(--brand-ink); }

#btn-save-route {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#btn-save-route:hover    { background: var(--surface-3); }
#btn-save-route:disabled { opacity: 0.45; cursor: default; }

#route-summary { margin: 10px 2px 0; }
#route-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
#route-stats:has(> .route-stat:nth-child(4):not(.hidden)) { grid-template-columns: repeat(4, 1fr); }
.route-stat {
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.route-stat:last-child { border-right: none; }
.stat-label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-val   { display: block; font-size: 14px; font-weight: 700; color: var(--text); margin-top: 2px; }
#route-delay-stat .stat-val { color: var(--sev-major); }

#route-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

#btn-share-route, #btn-clear-route {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#btn-share-route:hover, #btn-clear-route:hover { background: var(--surface-3); }

.btn-maps-link {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
}
.btn-maps-link:hover { text-decoration: none; background: var(--surface-3); color: var(--text); }

.route-risk-banner {
  margin: 10px 2px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.4;
}
.route-risk-banner.loading  { background: var(--surface-2); color: var(--muted); font-style: italic; }
.route-risk-banner.good     { background: color-mix(in srgb, var(--sev-minor) 12%, var(--surface));    color: #047857; border: 1px solid color-mix(in srgb, var(--sev-minor) 40%, var(--border)); }
.route-risk-banner.moderate { background: color-mix(in srgb, var(--sev-moderate) 12%, var(--surface)); color: #B45309; border: 1px solid color-mix(in srgb, var(--sev-moderate) 40%, var(--border)); }
.route-risk-banner.bad      { background: color-mix(in srgb, var(--sev-major) 12%, var(--surface));    color: var(--sev-major); border: 1px solid color-mix(in srgb, var(--sev-major) 40%, var(--border)); }
body.dark .route-risk-banner.good     { color: var(--sev-minor); }
body.dark .route-risk-banner.moderate { color: var(--sev-moderate); }

#alt-routes-wrap { margin-bottom: 8px; }

#route-works-wrap { margin: 10px 2px 0; }
#route-works-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}
.count-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--pill);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#saved-locs-section,
#saved-routes-section { margin: 12px 2px 0; }
#saved-locs-header,
#saved-routes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}
.mini-btn {
  height: 24px;
  padding: 0 8px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.mini-btn:hover { background: var(--surface-3); color: var(--text); }

#saved-locs-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
.loc-item { display: inline-flex; align-items: center; }
.loc-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.loc-chip:hover { border-color: var(--blue); color: var(--blue); }
.loc-del {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  margin-left: 4px;
}
.loc-del:hover { background: var(--surface-2); color: var(--sev-major); }

.saved-route-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 4px 2px;
}
.saved-route-item:hover { border-color: var(--border-strong); }
.sr-info   { flex: 1; min-width: 0; }
.sr-name   { font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-meta   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sr-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.sr-load, .sr-delete {
  height: 26px;
  padding: 0 10px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.sr-load:hover   { background: color-mix(in srgb, var(--blue) 10%, var(--surface)); color: var(--blue); border-color: var(--blue); }
.sr-delete:hover { background: color-mix(in srgb, var(--sev-major) 10%, var(--surface)); color: var(--sev-major); border-color: var(--sev-major); }

/* ── Tube panel ───────────────────────────────────────────────────────────── */
#tube-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  font-size: 11px;
  color: var(--muted);
}
#tube-list { display: flex; flex-direction: column; gap: 6px; padding: 0 2px; }
.tube-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.tube-row:hover    { border-color: var(--border-strong); }
.tube-row.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--surface)); }

/* ── Saved panel ──────────────────────────────────────────────────────────── */
#saved-login-prompt {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
#saved-login-prompt p { margin: 0 0 10px; }

#profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
#profile-avatar-wrap {
  flex: 0 0 auto;
}
#profile-initials {
  width: 40px;
  height: 40px;
  border-radius: var(--pill);
  background: linear-gradient(135deg, var(--blue), #7C3AED);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
#profile-info { flex: 1 1 auto; min-width: 0; }
#profile-name-row { display: flex; align-items: center; gap: 6px; }
#profile-name-display { font-weight: 600; font-size: 14px; color: var(--text); }
#btn-edit-name {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--muted);
}
#btn-edit-name:hover { color: var(--text); background: var(--surface-2); }
#profile-email { font-size: 11px; color: var(--muted); margin-top: 1px; }
#btn-signout-saved {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
}
#profile-edit-form {
  padding: 8px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
#profile-name-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#profile-name-input:focus { border-color: var(--blue); }
#profile-edit-actions { display: flex; gap: 6px; margin-top: 8px; }

.saved-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}

#saved-db-list { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }

/* ── Route comparison delta chips ───────────────────────────────────────── */
.alt-pill-fastest {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--pill);
  background: color-mix(in srgb, #4ade80 18%, transparent);
  color: #4ade80;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.alt-pill-delta {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

/* ── Commute alerts card (#80) ───────────────────────────────────────────── */
.commute-card {
  padding: 10px 4px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.commute-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--pill);
  background: color-mix(in srgb, #2a7f3a 22%, transparent);
  color: #4ade80;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.commute-pitch {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0 4px 10px;
}
.commute-field { padding: 0 4px; margin-bottom: 8px; position: relative; }
.commute-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.commute-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.commute-field input:focus {
  border-color: var(--text);
}
.commute-autocomplete {
  position: absolute;
  left: 4px;
  right: 4px;
  top: calc(100% + 2px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}
.commute-autocomplete-row {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.commute-autocomplete-row:last-child { border-bottom: 0; }
.commute-autocomplete-row:hover { background: var(--surface-3); }
.commute-save-btn {
  width: calc(100% - 8px);
  margin: 4px 4px 0;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}
.commute-save-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.commute-error {
  font-size: 12px;
  color: #f87171;
  margin: 8px 4px 0;
  line-height: 1.4;
}
.commute-row {
  display: flex;
  align-items: baseline;
  padding: 6px 4px;
  gap: 10px;
}
.commute-row-label {
  flex: 0 0 44px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.commute-row-value {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.commute-schedule {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 4px 12px;
  line-height: 1.5;
}
.commute-remove-btn {
  width: calc(100% - 8px);
  margin: 0 4px;
  font-size: 13px;
}

/* ── Detail panel ─────────────────────────────────────────────────────────── */
#detail-panel {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 90px;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  transition: transform 200ms ease, opacity 200ms ease;
}
#detail-panel.hidden { transform: translateY(10px); opacity: 0; pointer-events: none; }

#detail-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
#detail-header-btns { display: flex; gap: 6px; }
#detail-title {
  margin: 2px 0 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
}
#detail-share, #detail-export {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#detail-share:hover, #detail-export:hover { background: var(--surface-3); color: var(--text); }

#detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#detail-table td               { padding: 5px 0; vertical-align: top; color: var(--text); line-height: 1.4; }
#detail-table td:first-child   { color: var(--muted); width: 90px; font-size: 12px; }

/* Bus-route chips in the popup detail table — stop them from running into
   each other ("482h32") by giving them a pill chip visual. */
.bus-pill {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: 0.01em;
}

#detail-vote { margin-top: 10px; }

/* ── PWA install banner (#85) ───────────────────────────────────────────── */
.pwa-install-banner {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 1000;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg, 0 20px 60px rgba(0,0,0,.35));
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 560px;
  margin: 0 auto;
  animation: pwa-slide-in .25s ease-out;
}
@keyframes pwa-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pwa-install-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-install-text strong { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -0.2px; }
.pwa-install-text span { font-size: 11px; color: var(--muted); line-height: 1.4; }
.pwa-install-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.pwa-install-dismiss {
  padding: 8px 12px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.pwa-install-yes {
  padding: 8px 14px;
  background: #f5b800;
  color: #111827;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Watch this road (#81) ──────────────────────────────────────────────── */
#detail-watch-road { margin-top: 12px; }
.watch-row {
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.watch-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.watch-input-row {
  display: flex;
  gap: 6px;
}
.watch-email-input {
  flex: 1 1 auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.watch-email-input:focus { border-color: var(--text); }
.watch-btn {
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: #f5b800;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.watch-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.watch-error {
  font-size: 11px;
  color: #f87171;
  margin: 6px 0 0;
}
.watch-row-subscribed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #4ade80;
  font-weight: 500;
  padding: 8px 12px;
  background: color-mix(in srgb, #4ade80 10%, transparent);
  border: 1px solid color-mix(in srgb, #4ade80 30%, transparent);
}

#detail-buzz {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.buzz-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.buzz-source {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

#detail-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
#detail-streetview,
#detail-share-wa,
#detail-share-x { color: var(--blue); }

/* ── Modals (advanced, digest, embed, report) ─────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modalFade 160ms ease-out;
}
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-inner {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 16px 18px calc(22px + var(--safe-bot));
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,.25);
  animation: modalSlide 220ms cubic-bezier(.22,1,.36,1);
}
@keyframes modalSlide { from { transform: translateY(20px); } to { transform: translateY(0); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-header span {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.adv-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.adv-row label { font-size: 13px; color: var(--muted); }
.adv-row select,
.adv-row input,
.modal-inner > input,
.modal-inner > textarea,
.modal-inner > select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.adv-row select:focus,
.adv-row input:focus,
.modal-inner > input:focus,
.modal-inner > textarea:focus,
.modal-inner > select:focus { border-color: var(--blue); background: var(--surface); }

.adv-input-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.adv-input-row input { flex: 1 1 auto; min-width: 0; }
.adv-date-row .date-sep { font-size: 12px; color: var(--muted); }
.adv-date-row input[type="date"] { min-width: 0; flex: 1 1 auto; }

#btn-postcode-go { height: 36px; padding: 0 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }

.adv-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.adv-refresh:hover { background: var(--surface-3); color: var(--text); }

.report-sev-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

#digest-immediate-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
  font-size: 13px;
  color: var(--text-soft);
}
#digest-immediate-wrap input { width: 16px; height: 16px; }

.embed-code {
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  transition: opacity 150ms ease;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
body.dark .btn-primary { background: var(--brand); color: var(--brand-ink); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background 150ms ease;
}
.btn-ghost:hover { background: var(--surface-3); }

.btn-block { width: 100%; }
.btn-signin-prompt { display: inline-flex; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(120px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: opacity 200ms ease;
  pointer-events: none;
}
#toast.hidden { opacity: 0; }
body.dark #toast { background: var(--surface-3); color: var(--text); }

/* ── Leaflet overrides ────────────────────────────────────────────────────── */
.leaflet-container { font-family: inherit; background: var(--bg); }
.leaflet-control-zoom, .leaflet-control-attribution { display: none !important; }

.marker-cluster-small  { background: rgba(225,29,72,.15); }
.marker-cluster-medium { background: rgba(225,29,72,.18); }
.marker-cluster-large  { background: rgba(225,29,72,.22); }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: var(--sev-major);
  color: #fff;
  font-weight: 700;
}

/* Map markers (cones) */
.m-cone-wrap { position: relative; display: inline-flex; align-items: flex-end; }
.m-cone      { display: flex; align-items: flex-end; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); position: relative; z-index: 1; }
.cone-ring   {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--sev-major);
  opacity: 0;
  animation: coneRing 1.8s ease-out infinite;
  z-index: 0;
}
@keyframes coneRing {
  0%   { opacity: 0.55; transform: translate(-50%,-50%) scale(0.4); }
  100% { opacity: 0;    transform: translate(-50%,-50%) scale(1.4); }
}

/* Leaflet popups */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════════════
   Map point-layer icons — distinctive silhouettes so cameras, speed cams
   and EV chargers are instantly legible at a glance.
   ══════════════════════════════════════════════════════════════════════════ */

/* Traffic camera (TfL JamCams): round blue badge, white video-camera SVG */
.cam-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: #0EA5E9;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(14,165,233,.45), 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.cam-icon:hover { transform: scale(1.12); }
.cam-icon svg { display: block; }

/* Speed camera: portrait Gatso-style box in red, speed number inline */
.speed-cam-icon {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: #DC2626;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(220,38,38,.45), 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.speed-cam-icon:hover { transform: scale(1.12); }
.speed-cam-icon svg { display: block; }
.speed-cam-limit {
  position: absolute;
  right: -10px; bottom: -8px;
  background: #fff;
  color: #DC2626;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  border: 1.5px solid #DC2626;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  line-height: 1;
  min-width: 18px;
  text-align: center;
}
/* "Hot" enforcement zone — pulsing red ring around the Gatso icon */
.speed-cam-icon.hot::before {
  content: '';
  position: absolute;
  inset: -5px;
  border: 2px solid #E31837;
  border-radius: 10px;
  animation: speedCamPulse 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes speedCamPulse {
  0%   { opacity: .8; transform: scale(.75); }
  100% { opacity: 0;  transform: scale(1.25); }
}

/* EV charger: rounded square with lightning bolt, colour by speed class */
.ev-icon {
  position: relative;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border: 2.5px solid currentColor;  /* color set inline by JS per speed class */
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
.ev-icon:hover { transform: scale(1.12); }
.ev-icon svg { display: block; }
.ev-kw {
  position: absolute;
  bottom: -8px; left: 50%;
  transform: translateX(-50%);
  background: currentColor;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
/* Put the "fill:currentColor" on the SVG via JS-friendly hook */
.ev-icon svg path { fill: currentColor; }

/* Dark-mode tweaks so icons keep contrast on a dark basemap */
body.dark .cam-icon,
body.dark .speed-cam-icon { border-color: #0f172a; }
body.dark .ev-icon        { background: #0f172a; }
body.dark .speed-cam-limit { background: #0f172a; color: #f87171; border-color: #f87171; }

/* Rail panel disruption badge (#91) — single-line headline above the list. */
.rail-summary {
  padding: 0.55rem 0.85rem;
  margin: 0.4rem 0 0.6rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.rail-summary.good   { background: rgba(16,185,129,.1);  color: #10B981; border-color: rgba(16,185,129,.28); }
.rail-summary.severe { background: rgba(239,68,68,.12);  color: #EF4444; border-color: rgba(239,68,68,.32); }

/* Fuel pin (#90): compact amber pump + inline price chip. Cheapest-in-view
   gets a filled amber chip so it pops even when zoomed out. */
.fuel-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  color: #f59e0b;
  border: 2px solid #f59e0b;
  border-radius: 999px;
  padding: 2px 6px 2px 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2), 0 1px 3px rgba(0,0,0,.15);
  transition: transform .15s ease;
  white-space: nowrap;
}
.fuel-icon:hover { transform: scale(1.08); z-index: 500; }
.fuel-icon svg { display: block; flex: 0 0 auto; }
.fuel-price {
  font-size: 10.5px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}
.fuel-icon.cheapest {
  background: #f59e0b;
  color: #111827;
}
.fuel-icon.cheapest .fuel-price { color: #111827; }
body.dark .fuel-icon { background: #0f172a; }
body.dark .fuel-price { color: #F9FAFB; }
body.dark .fuel-icon.cheapest { background: #f59e0b; }
body.dark .fuel-icon.cheapest .fuel-price { color: #111827; }


/* ── Compat shim (hidden mirror buttons for legacy app.js IDs) ─────────────── */
.compat-mob-shim {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Desktop layout (≥900px) — sidebar becomes a fixed left rail
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  #sidebar {
    top: 16px;
    left: 16px;
    bottom: 16px;
    right: auto;
    width: var(--rail-w);
    transform: none !important;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
  }
  #sidebar.sheet-half,
  #sidebar.sheet-full { transform: none !important; }

  #sheet-handle { display: none; }
  #sheet-head   { padding: 14px 18px 10px; }
  #tabs         { margin: 0 14px 12px; }
  .panel        { padding: 4px 14px 18px; }

  #top-bar {
    left: calc(var(--rail-w) + 32px);
    right: 16px;
    top: 16px;
  }

  #filter-rail {
    top: calc(16px + var(--top-h) + 16px);
    left: calc(var(--rail-w) + 32px);
    right: 16px;
    padding-left: 0;
    padding-right: 0;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent);
  }

  #layer-rail {
    top: calc(16px + var(--top-h) + 16px + 44px);
    left: calc(var(--rail-w) + 32px);
    right: 16px;
    padding-left: 0;
    padding-right: 0;
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent);
  }

  #fab-stack {
    right: 20px;
    bottom: 20px !important;
  }

  #map-legend {
    display: block;
    left: calc(var(--rail-w) + 32px);
    bottom: 20px;
  }

  #detail-panel {
    left: calc(var(--rail-w) + 32px);
    right: auto;
    bottom: 20px;
    width: 380px;
    max-height: calc(100vh - 120px);
  }
}

/* Extra-wide: more generous detail panel */
@media (min-width: 1200px) {
  #detail-panel { width: 420px; }
}

/* ── Accessibility: focus rings ───────────────────────────────────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
