/* =========================================================================
   Global Vibe Coding Density Index — cyber-dashboard theme
   ========================================================================= */

:root {
  --bg: #05070d;
  --panel: rgba(14, 20, 34, 0.72);
  --panel-solid: #0b1120;
  /* Glassmorphism: translucent frosted fills so the map shows through, plus a
     bright top edge that reads as a glass rim. */
  /* Alphas tuned with the brightness(0.65) backdrop-filter so every text color
     holds WCAG AA even over bright desert terrain (worst case ~#d8c9a3). */
  --glass: linear-gradient(160deg, rgba(16, 24, 42, 0.70), rgba(9, 14, 26, 0.58));
  --glass-strong: linear-gradient(160deg, rgba(16, 24, 42, 0.82), rgba(9, 14, 26, 0.70));
  --glass-edge: rgba(200, 228, 255, 0.14);
  --text: #e8f0fa;
  --muted: #a9b9d2; /* lifted from #93a4bd — AA over the darkened glass on any terrain */
  --accent: #00e5ff;   /* cyan — echoes cool end of the ramp */
  --accent2: #ff2d55;  /* neon red/magenta — echoes the hot peak */
  --line: rgba(0, 229, 255, 0.18);
  --line-strong: rgba(0, 229, 255, 0.4);
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; height: 100%; width: 100%; }

/* ----- Map fills the viewport ----- */
#map {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
}

/* MapLibre canvas / ctrls tuned to the dark theme */
.maplibregl-ctrl-group {
  background: var(--panel-solid) !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6) !important;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1) hue-rotate(150deg); }
.maplibregl-ctrl-attrib {
  background: rgba(5, 7, 13, 0.7) !important;
  color: var(--muted) !important;
}
.maplibregl-ctrl-attrib a { color: var(--accent) !important; }

/* ----- Decorative FX overlays ----- */
.fx-scanlines {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
  z-index: 5;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 229, 255, 0.035) 0px,
    rgba(0, 229, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.5;
}
.fx-vignette {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ----- Popups ----- */
.maplibregl-popup-content {
  background: var(--glass-strong) !important;
  backdrop-filter: blur(22px) saturate(150%) brightness(0.65);
  -webkit-backdrop-filter: blur(22px) saturate(150%) brightness(0.65);
  color: var(--text) !important;
  border: 1px solid var(--glass-edge) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  padding: 11px 13px !important;
  font-family: var(--font);
}
.maplibregl-popup-tip {
  border-top-color: rgba(13, 19, 33, 0.72) !important;
  border-bottom-color: rgba(13, 19, 33, 0.72) !important;
}
.hub-popup .maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 8px 12px; /* finger-sized dismiss target */
  background: transparent;
}
.hub-popup .maplibregl-popup-close-button:hover { color: var(--text); background: transparent; }
.hub-popup-name { font-weight: 700; color: var(--accent); font-size: 14px; padding-right: 14px; }
.hub-popup-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.hub-popup-vibe { margin-top: 6px; font-family: var(--mono); font-size: 12px; }
/* near-white glyphs with the red as GLOW — pure --accent2 text was ~1.9:1 over
   bright terrain behind the glass popup */
.hub-popup-vibe b { color: #ffdfe6; text-shadow: 0 0 8px var(--accent2); }
.hub-popup-count { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* =========================================================================
   Control panel (glassmorphism)
   ========================================================================= */
#panel {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 10;
  width: 340px;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px); /* iOS dynamic toolbar */
  display: flex;
  flex-direction: column;
  background: var(--glass);
  /* brightness(.65) darkens what's BEHIND the glass so text stays AA-readable
     even over bright desert terrain — the frosted look itself is unchanged. */
  backdrop-filter: blur(26px) saturate(155%) brightness(0.65);
  -webkit-backdrop-filter: blur(26px) saturate(155%) brightness(0.65);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow:
    0 16px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 0 40px rgba(0, 229, 255, 0.04);
  overflow: hidden;
}

/* Collapse-to-map controls (mobile only; both hidden on desktop) */
.panel-collapse {
  display: none;             /* → flex on mobile */
  position: absolute;
  top: 7px; right: 7px;
  z-index: 3;
  width: 40px; height: 40px; /* ≥40px touch target (was 30px) */
  align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font: 700 12px/1 var(--font);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.panel-collapse:hover { color: var(--text); border-color: var(--line-strong); background: rgba(0, 229, 255, 0.08); }
.panel-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.map-fab {
  display: none;             /* → flex on mobile when the panel is collapsed */
  position: fixed;
  top: 12px; left: 12px;
  z-index: 12;
  width: 54px; height: 54px;
  align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(140%) brightness(0.65);
  -webkit-backdrop-filter: blur(16px) saturate(140%) brightness(0.65);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 18px rgba(0, 229, 255, 0.35), inset 0 0 20px rgba(0, 229, 255, 0.05);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.map-fab:hover { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 26px rgba(0, 229, 255, 0.6), inset 0 0 20px rgba(0, 229, 255, 0.08); }
.map-fab:active { transform: scale(0.94); }
.map-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Minimal footer — a small glass pill bottom-left; grows with more page links. */
.site-footer {
  position: fixed;
  left: 10px;
  bottom: 9px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 13px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%) brightness(0.65);
  -webkit-backdrop-filter: blur(16px) saturate(140%) brightness(0.65);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  font: 500 11px/1 var(--font);
  letter-spacing: 0.02em;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.footer-note { color: var(--muted); opacity: 0.8; }
@media (max-width: 640px) { .footer-note { display: none; } } /* keep the pill tiny on phones */

/* One-time "tap a dot" hint (touch only) — a floating glass pill, bottom-center. */
.tap-hint {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 9;
  max-width: calc(100vw - 32px);
  padding: 9px 16px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(150%) brightness(0.65);
  -webkit-backdrop-filter: blur(18px) saturate(150%) brightness(0.65);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  color: var(--text);
  font: 600 12.5px/1 var(--font);
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: hintIn 0.4s ease;
  pointer-events: none;
}
.tap-hint.hiding { opacity: 0; transition: opacity 0.4s ease; }
@keyframes hintIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.panel-body {
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Custom scrollbar */
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }

/* ----- Header ----- */
.panel-header { margin-bottom: 16px; }
.title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 19px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.title-glyph {
  font-size: 26px;
  filter: drop-shadow(0 0 8px var(--accent));
  animation: spin-slow 18s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }
.title-text {
  /* gradient's hot end is #ff5c7d (not --accent2): same neon heat, but the
     last word stays legible over bright terrain */
  background: linear-gradient(92deg, var(--accent) 0%, #beff46 45%, #ff5c7d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.25);
}
.caption {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.caption strong { color: var(--text); font-weight: 600; }
.hero-stat {
  margin: 8px 0 0;
  font: 700 13px/1.3 var(--font);
  color: var(--accent);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
}

/* ----- Live badge ----- */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 229, 255, 0.06);
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.live-badge.is-sample { color: var(--muted); background: rgba(255, 255, 255, 0.03); }
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #23f0a0;
  box-shadow: 0 0 8px #23f0a0;
  animation: live-pulse 2.2s ease-in-out infinite;
}
.live-badge.is-sample .live-dot { background: var(--muted); box-shadow: none; animation: none; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ----- City search (viral hook) ----- */
.citysearch { margin-top: 14px; position: relative; }

/* Mobile-only collapsed search button (hidden on desktop) */
.search-toggle {
  display: none;
  width: 100%;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font: 600 14px/1 var(--font);
  cursor: pointer;
}
.search-toggle:hover { border-color: var(--line-strong); color: var(--text); }

/* Autocomplete dropdown */
.city-suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 6px;
  z-index: 30;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 264px;
}
.city-suggest-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
}
.city-suggest-item:last-child { border-bottom: none; }
.city-suggest-item:hover,
.city-suggest-item.active { background: rgba(0, 229, 255, 0.10); }
.csi-name { font: 700 13px/1.15 var(--font); color: var(--text); }
.csi-sub { font: 500 11px/1.15 var(--font); color: var(--muted); }
.citysearch-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.citysearch-row { display: flex; gap: 6px; }
#cityInput {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  font: 500 13px/1 var(--font);
}
#cityInput::placeholder { color: var(--muted); }
#cityInput:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#cityGo {
  flex: none;
  background: linear-gradient(92deg, var(--accent), #beff46);
  color: #04121a;
  border: none;
  border-radius: 9px;
  padding: 0 16px;
  font: 800 12px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
}
#cityGo:hover { filter: brightness(1.08); }
#cityGo:active { transform: translateY(1px); }

.city-result {
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
}
.city-result-num {
  font: 900 30px/1 var(--mono);
  color: #ffffff;
  text-shadow: 0 0 20px rgba(255, 45, 85, 0.5);
  letter-spacing: -0.02em;
}
.city-result-sub { margin-top: 5px; font-size: 12px; color: var(--muted); }
.city-result-sub b { color: var(--accent); }
.city-result-tier {
  margin-top: 8px;
  font: 800 13px/1 var(--font);
  color: #beff46;
}
.city-share {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 16px;
  font: 700 12px/1 var(--font);
  cursor: pointer;
  transition: all 0.15s ease;
}
.city-share:hover { background: var(--accent); color: var(--bg); box-shadow: 0 0 14px rgba(0, 229, 255, 0.5); }
/* flex-it + platform share targets, one centered row */
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}
.share-alt {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  font: 700 11px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.share-alt:hover { color: var(--text); border-color: var(--line-strong); }
.city-result-rank {
  margin-top: 6px;
  font: 700 11px/1.3 var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}
/* idle result container collapses (it starts empty; JS fills it) */
.city-result:empty { display: none; }
.city-result-place { margin-top: 3px; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

/* Auto-location "near you" flourishes */
.city-result-you {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 9px;
  padding: 3px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(0, 229, 255, 0.09);
  font: 700 10px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}
.city-result-notyou { margin-top: 11px; font-size: 11px; color: var(--muted); }
.city-result-notyou .cr-notyou-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.city-result-notyou .cr-notyou-btn:hover { color: var(--text); }
.search-marker-you .search-marker-label {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.7);
}
.city-alts {
  margin-top: 11px;
  font-size: 11px;
  color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; justify-content: center;
}
.city-alt {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px; /* comfortable touch target */
  font: 600 11px/1 var(--font);
  cursor: pointer;
}
.city-alt:hover { border-color: var(--line-strong); color: var(--text); }
.city-result-notyou .cr-notyou-btn,
.city-result-notyou .cr-exact-btn { padding: 6px 2px; } /* bigger tap area, same look */

/* One visible focus ring for every interactive element that lacked one. */
#cityGo:focus-visible,
.city-share:focus-visible,
.share-alt:focus-visible,
.city-alt:focus-visible,
.city-suggest-item:focus-visible,
.cr-notyou-btn:focus-visible,
.cr-exact-btn:focus-visible,
.site-footer a:focus-visible,
.hub-popup .maplibregl-popup-close-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Map failed to boot (no WebGL / lib blocked) — small centered glass notice. */
.map-dead-notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  max-width: calc(100vw - 40px);
  padding: 12px 20px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(150%) brightness(0.65);
  -webkit-backdrop-filter: blur(18px) saturate(150%) brightness(0.65);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  color: var(--text);
  font: 600 13px/1.5 var(--font);
  text-align: center;
}

/* Marker dropped at the searched city (so any city shows on the map) */
.search-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.search-marker-label {
  background: var(--panel-solid);
  border: 1px solid var(--accent);
  color: var(--text);
  font: 700 11px/1 var(--font);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
}
.search-marker-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.25), 0 0 16px var(--accent2);
  animation: search-pulse 1.6s ease-in-out infinite;
}
@keyframes search-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .search-marker-dot { animation: none; } }

/* Sun / Moon markers for the day-night overlay */
.sky-marker { font-size: 26px; line-height: 1; pointer-events: none; user-select: none; }
.sun-marker-el { filter: drop-shadow(0 0 10px rgba(255, 210, 90, 0.95)); }
.moon-marker-el { filter: drop-shadow(0 0 9px rgba(190, 215, 255, 0.85)); }

/* ----- KPI tiles ----- */
.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}
.kpi {
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}
.kpi-wide { grid-column: 1 / -1; }
.kpi-value {
  font: 800 22px/1 var(--mono);
  color: var(--accent);
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
}
.kpi-peak {
  font-size: 15px;
  color: #beff46;
  text-shadow: 0 0 14px rgba(190, 255, 70, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-label {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ----- Controls ----- */
.controls { display: flex; flex-direction: column; gap: 16px; }
.control { display: flex; flex-direction: column; gap: 6px; }
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.control label,
.control-legend-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.control output {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}
.control-hint { margin: 0; font-size: 11px; color: var(--muted); }

/* Range inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(0, 229, 255, 0.15),
    rgba(190, 255, 70, 0.25),
    rgba(255, 45, 85, 0.35));
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
input[type="range"]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 600 11px/1 var(--font);
  letter-spacing: 0.02em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mini-btn {
  font: 600 10px/1 var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--line-strong); }
.mini-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Select */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  pointer-events: none;
  font-size: 12px;
}
select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 30px 9px 12px;
  font: 500 13px/1 var(--font);
  cursor: pointer;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select option { background: var(--panel-solid); color: var(--text); }

/* Day/Night toggle switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}
.switch-sun { font-size: 12px; filter: drop-shadow(0 0 4px rgba(255, 210, 58, 0.7)); }
.switch { position: relative; display: inline-flex; width: 42px; height: 22px; flex: none; }
.switch input {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 2;
}
.switch-track {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch input:checked + .switch-track {
  background: rgba(0, 229, 255, 0.25);
  border-color: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(20px);
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- Legend (artistic, non-numeric) ----- */
.legend { margin-top: 20px; }
.legend-strip {
  height: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg,
    rgba(10, 20, 40, 0.2) 0%,
    rgba(20, 130, 200, 0.6) 14%,
    rgba(0, 200, 220, 0.8) 32%,
    rgba(30, 235, 160, 0.9) 50%,
    rgba(190, 255, 70, 0.95) 68%,
    rgba(255, 215, 30, 1) 84%,
    rgba(255, 120, 20, 1) 94%,
    rgba(255, 30, 45, 1) 100%);
  box-shadow: 0 0 18px rgba(255, 45, 85, 0.25);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ----- a11y helper ----- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 640px) {
  /* A compact floating glass card, not a full-width bar: leave room on the
     right so the map is visible beside it too. */
  #panel {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px); /* iOS dynamic toolbar */
    border-radius: 18px;
    animation: panelIn 0.28s ease;   /* entrance, and replays each time it re-opens */
  }

  /* Map mode: the whole panel folds away to a floating 🔎 so the map is full-screen. */
  #panel.collapsed { display: none; }
  #panel.collapsed ~ .map-fab { display: flex; animation: fabIn 0.28s ease; }
  .panel-collapse { display: flex; top: 6px; right: 6px; }

  .panel-body { padding: 12px 13px 13px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .panel-header { margin-bottom: 0; }

  .title { font-size: 14px; gap: 7px; margin-bottom: 5px; padding-right: 44px; }
  .title-glyph { font-size: 19px; }
  .title-text { line-height: 1.1; }
  .hero-stat { font-size: 11.5px; margin-top: 5px; }

  /* Search field is shown directly when the panel is open (no extra tap). */
  .citysearch { display: block; margin-top: 10px; }
  .citysearch-label { font-size: 11.5px; margin-bottom: 5px; }

  /* Tighten the result card so a few numbers don't need a whole screen. */
  .city-result { margin-top: 9px; padding: 10px 12px; }
  .city-result-num { font-size: 26px; }
  .city-result-you { margin-bottom: 7px; }
  .city-result-tier { margin-top: 6px; }
  .city-share { margin-top: 8px; }
  .city-result-notyou { margin-top: 8px; }
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes fabIn {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .title-glyph { animation: none; }
  #panel, .map-fab, .tap-hint { animation: none; }
  * { scroll-behavior: auto; }
}
