/* ═══════════════════════════════════════════════════
   Meteorite Map — Cosmic Observatory Theme
   Fonts: Chakra Petch (display) · JetBrains Mono (data)
   ═══════════════════════════════════════════════════ */

/* ── Variables ── */
:root {
  --bg:           #0a0a0f;
  --bg-mid:       #0e0e1a;
  --bg-elevated:  #131323;
  --panel-bg:     rgba(8, 8, 20, 0.90);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-border-hover: rgba(255, 255, 255, 0.14);

  --accent:       #f59e0b;
  --accent-dim:   rgba(245, 158, 11, 0.55);
  --accent-glow:  rgba(245, 158, 11, 0.20);
  --accent-bg:    rgba(245, 158, 11, 0.10);

  --cyan:         #06b6d4;
  --cyan-dim:     rgba(6, 182, 212, 0.55);
  --cyan-glow:    rgba(6, 182, 212, 0.20);
  --cyan-bg:      rgba(6, 182, 212, 0.10);

  --text:         #e5e5e5;
  --text-muted:   #8a8a9a;
  --text-dim:     #4a4a5a;

  --sidebar-w:    292px;
  --stats-h:      50px;
  --radius:       8px;
  --radius-sm:    5px;
  --radius-pill:  100px;

  --font:         'Chakra Petch', sans-serif;
  --mono:         'JetBrains Mono', monospace;

  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:       0.15s;
  --t-med:        0.25s;
  --t-slow:       0.35s;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
ul { list-style: none; }
input { font-family: var(--font); }

/* ── Base ── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════
   MAP
   ═══════════════════════════════════════════════════ */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Zoom controls — above stats bar */
.leaflet-bottom { margin-bottom: var(--stats-h); }

.leaflet-control-zoom {
  border: 1px solid var(--panel-border) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--panel-border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover {
  background: var(--bg-elevated) !important;
  color: var(--accent) !important;
}
.leaflet-control-attribution {
  background: rgba(8, 8, 20, 0.75) !important;
  color: var(--text-dim) !important;
  font-size: 9px !important;
  font-family: var(--mono) !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* ═══════════════════════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════════════════════ */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  /* Starfield-like subtle texture */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(245,158,11,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(6,182,212,0.03) 0%, transparent 50%);
  transition: opacity 0.5s var(--ease);
}
#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.loader-visual {
  width: 100px;
  height: 100px;
  position: relative;
}

.meteor-svg {
  width: 100%;
  height: 100%;
  animation: meteor-float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(245,158,11,0.4));
}

@keyframes meteor-float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33%       { transform: translate(4px, -6px) rotate(1deg); }
  66%       { transform: translate(-3px, 4px) rotate(-1deg); }
}

.meteor-halo {
  animation: halo-pulse 2s ease-in-out infinite;
}
@keyframes halo-pulse {
  0%, 100% { opacity: 0.5; transform-origin: 78px 42px; transform: scale(1); }
  50%       { opacity: 1;   transform-origin: 78px 42px; transform: scale(1.3); }
}

.meteor-body {
  animation: body-pulse 2s ease-in-out infinite;
}
@keyframes body-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.8; }
}

.loader-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text);
}

.loading-text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.loading-bar-wrap {
  width: 220px;
  height: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 1px;
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--accent));
  background-size: 200% 100%;
  border-radius: 1px;
  animation: bar-slide 1.8s ease-in-out infinite;
}
@keyframes bar-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.btn-retry {
  padding: 9px 22px;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.btn-retry:hover {
  background: var(--accent-bg);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════
   SIDEBAR TOGGLE
   ═══════════════════════════════════════════════════ */
#sidebar-toggle {
  position: fixed;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  z-index: 400;
  width: 42px;
  height: 42px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), opacity var(--t-med) var(--ease);
}
#sidebar-toggle svg { width: 17px; height: 17px; }
#sidebar-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  box-shadow: 0 0 14px var(--accent-glow);
}
body.sidebar-open #sidebar-toggle {
  opacity: 0;
  pointer-events: none;
}

/* ── Surprise Me Button ── */
#surprise-btn {
  position: fixed;
  left: 16px;
  bottom: calc(var(--stats-h) + 60px);
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(10,10,20,0.85);
  border: 1px solid rgba(245,158,11,0.3);
  color: #f59e0b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
#surprise-btn:hover {
  background: rgba(245,158,11,0.15);
  border-color: #f59e0b;
}
#surprise-btn:active { transform: scale(0.93); }
#surprise-btn svg { width: 20px; height: 20px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--stats-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  background: rgba(10,10,20,0.9);
  border: 1px solid rgba(245,158,11,0.4);
  color: #e5e5e5;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s;
}
.toast.hidden { display: none; }
.toast.fading { opacity: 0; }

/* ── Heatmap Toggle Button ── */
#heatmap-toggle {
  position: fixed;
  left: 16px;
  bottom: calc(var(--stats-h) + 108px);
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(10,10,20,0.85);
  border: 1px solid rgba(6,182,212,0.3);
  color: #06b6d4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
}
#heatmap-toggle:hover {
  background: rgba(6,182,212,0.15);
  border-color: #06b6d4;
}
#heatmap-toggle.active {
  background: rgba(6,182,212,0.25);
  border-color: #06b6d4;
  color: #fff;
}
#heatmap-toggle svg { width: 20px; height: 20px; }

/* ═══════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 500;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translateX(calc(-1 * var(--sidebar-w) - 2px));
  transition: transform var(--t-slow) var(--ease);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Dot-grid observatory pattern */
#sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
  z-index: 0;
}

/* Subtle amber gradient top accent */
#sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  z-index: 1;
}

body.sidebar-open #sidebar { transform: translateX(0); }

/* Header */
.sidebar-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 14px 13px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.title-icon { width: 14px; height: 14px; stroke: var(--accent); }

#sidebar-close {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
#sidebar-close svg { width: 15px; height: 15px; }
#sidebar-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* Content */
.sidebar-content {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}
.sidebar-content::-webkit-scrollbar { width: 3px; }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

/* Footer */
.sidebar-footer {
  position: relative;
  z-index: 2;
  padding: 12px 14px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
}

/* ── Filter Sections ── */
.filter-section { margin-bottom: 22px; }
.filter-section:last-child { margin-bottom: 0; }

.filter-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-label-sub {
  font-weight: 400;
  opacity: 0.6;
  text-transform: none;
  letter-spacing: 0;
}

/* Year range display */
.year-range-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* noUiSlider overrides */
.year-slider-el { margin: 6px 4px 2px; }

.noUi-target {
  background: rgba(255,255,255,0.06);
  border: none;
  box-shadow: none;
  border-radius: 2px;
  height: 3px;
}
.noUi-connect { background: linear-gradient(90deg, var(--accent), var(--cyan)); }
.noUi-handle {
  width: 15px !important;
  height: 15px !important;
  top: -6px !important;
  right: -7.5px !important;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow), 0 0 0 2px rgba(10,10,20,0.6);
  cursor: grab;
  transition: box-shadow var(--t-fast);
}
.noUi-handle:active { cursor: grabbing; box-shadow: 0 0 14px var(--accent-glow); }
.noUi-handle::before, .noUi-handle::after { display: none; }
.noUi-tooltip {
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  bottom: 20px;
}

/* Mass buttons */
.mass-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.mass-grid .mass-btn:first-child { grid-column: span 2; }

.mass-btn {
  padding: 7px 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
}
.mass-btn:hover {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border-color: var(--panel-border-hover);
}
.mass-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* Fall type toggle */
.fall-toggle { display: flex; gap: 4px; }
.fall-btn {
  flex: 1;
  padding: 8px 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all var(--t-fast) var(--ease);
}
.fall-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.fall-btn.active {
  background: var(--accent-bg);
  border-color: var(--accent-dim);
  color: var(--accent);
}

/* Dots — sidebar */
.dot-fell  { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-found { width: 7px; height: 7px; background: var(--cyan);   border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Dots — stats bar */
.dot-fell-sm  { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }
.dot-found-sm { width: 6px; height: 6px; background: var(--cyan);   border-radius: 50%; flex-shrink: 0; }

/* Classification list */
.class-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 210px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-dim) transparent;
}
.class-list::-webkit-scrollbar { width: 3px; }
.class-list::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

.class-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}
.class-item:hover { background: rgba(255,255,255,0.04); }

.class-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--text-dim);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.class-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.class-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px; left: 3px;
  width: 4px; height: 7px;
  border: 1.5px solid var(--bg);
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.class-item label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  flex: 1;
  transition: color var(--t-fast);
}
.class-item:hover label { color: var(--text); }

.class-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* Footer */
.filter-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
}

.filter-actions { display: flex; gap: 8px; }

.btn-apply {
  flex: 1;
  padding: 9px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity var(--t-fast), box-shadow var(--t-fast);
}
.btn-apply:hover {
  opacity: 0.88;
  box-shadow: 0 0 18px var(--accent-glow);
}

.btn-reset {
  padding: 9px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  letter-spacing: 0.04em;
  transition: all var(--t-fast);
}
.btn-reset:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* ═══════════════════════════════════════════════════
   SEARCH
   ═══════════════════════════════════════════════════ */
#search-container {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  width: min(380px, calc(100vw - 130px));
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-wrapper:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  pointer-events: none;
  flex-shrink: 0;
  transition: color var(--t-fast);
}
.search-wrapper:focus-within .search-icon { color: var(--accent-dim); }

#search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 11px 38px 11px 36px;
  color: var(--text);
  font-size: 13px;
  caret-color: var(--accent);
}
#search-input::placeholder { color: var(--text-dim); }

.search-clear {
  position: absolute;
  right: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.search-clear svg { width: 13px; height: 13px; }
.search-clear:hover { color: var(--text); background: rgba(255,255,255,0.07); }

.search-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(245,158,11,0.05);
}

.search-result-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background var(--t-fast);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.focused { background: rgba(255,255,255,0.055); }

.result-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.result-name mark { background: transparent; color: var(--accent); font-weight: 600; }
.result-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-no-results {
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════
   STATS BAR
   ═══════════════════════════════════════════════════ */
#stats-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--stats-h);
  z-index: 400;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  padding: 0 18px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  min-width: 0;
  flex-shrink: 0;
}
.stat-item:first-child { padding-left: 0; }
.stat-item.stat-expand { flex: 1; min-width: 0; }

.stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.stat-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value.mono { font-family: var(--mono); }

.stat-divider {
  width: 1px;
  height: 18px;
  background: var(--panel-border);
  flex-shrink: 0;
}
.stat-divider.stat-expand { flex: 0; }

/* ═══════════════════════════════════════════════════
   LEAFLET POPUP
   ═══════════════════════════════════════════════════ */
.leaflet-popup-content-wrapper {
  background: rgba(8, 8, 22, 0.96) !important;
  border: 1px solid rgba(255,255,255,0.09) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(245,158,11,0.06) !important;
  color: var(--text) !important;
  font-family: var(--font) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.leaflet-popup-tip-container { display: none; }
.leaflet-popup-content { margin: 0 !important; }
.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 6px 8px !important;
  top: 2px !important;
  right: 2px !important;
  transition: color var(--t-fast) !important;
}
.leaflet-popup-close-button:hover { color: var(--text) !important; }

/* Popup internals */
.meteorite-popup { padding: 14px 16px; min-width: 210px; }

.popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.popup-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  padding-right: 20px;
}
.popup-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.popup-badge.fell  { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-dim); }
.popup-badge.found { background: var(--cyan-bg);   color: var(--cyan);   border: 1px solid var(--cyan-dim);   }

.popup-class {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.popup-stat-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.popup-stat-value {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.popup-coords {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  padding-top: 9px;
  border-top: 1px solid rgba(255,255,255,0.055);
}

/* ═══════════════════════════════════════════════════
   CLUSTER ICONS
   ═══════════════════════════════════════════════════ */
/* Override Leaflet.markercluster defaults */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background-color: transparent !important; }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div { background-color: transparent !important; }

.cluster-icon {
  background: var(--panel-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: box-shadow var(--t-fast);
}
.cluster-icon:hover { box-shadow: 0 0 16px var(--accent-glow); }

.cluster-sm { width: 30px !important; height: 30px !important; font-size: 10px; }
.cluster-md {
  width: 40px !important; height: 40px !important; font-size: 11px;
  border-color: rgba(245, 158, 11, 0.5);
}
.cluster-lg {
  width: 52px !important; height: 52px !important; font-size: 12px;
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar becomes bottom sheet */
  #sidebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 78vh;
    border-radius: 14px 14px 0 0;
    border: 1px solid var(--panel-border);
    border-bottom: none;
    transform: translateY(100%);
  }
  body.sidebar-open #sidebar { transform: translateY(0); }

  /* Move toggle to above stats bar */
  #sidebar-toggle {
    top: auto;
    left: 12px;
    bottom: calc(var(--stats-h) + 10px);
    transform: none;
  }
  body.sidebar-open #sidebar-toggle { opacity: 0; pointer-events: none; }

  /* Search spans almost full width */
  #search-container {
    width: calc(100% - 32px);
    left: 16px;
    transform: none;
  }

  /* Stats bar — hide expanded items on very small screens */
  #stats-bar { padding: 0 12px; }
  .stat-item { padding: 0 8px; }
  .stat-item.stat-expand { display: none; }
  .stat-divider.stat-expand { display: none; }
}

/* ── Classification Tooltip ── */
.cls-tooltip {
  position: absolute;
  z-index: 2000;
  background: rgba(10,10,20,0.95);
  border: 1px solid rgba(245,158,11,0.4);
  color: #e5e5e5;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 280px;
  pointer-events: none;
  display: none;
  line-height: 1.4;
}

/* ── Clickable class trigger ── */
.cls-trigger {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted rgba(245,158,11,0.5);
}
.cls-trigger:hover { color: #f59e0b; text-decoration-color: #f59e0b; }

/* ── Classification Modal ── */
.class-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.class-modal.hidden { display: none; }

.class-modal-content {
  position: relative;
  background: #0f1017;
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow-y: auto;
}

.class-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 4px;
}
.class-modal-close:hover { color: #e5e5e5; }
.class-modal-close svg { width: 20px; height: 20px; display: block; }

.class-modal-title {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1.4rem;
  color: #f59e0b;
  margin: 0 0 16px 0;
}

.cls-detail {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 16px 0;
  font-size: 0.85rem;
}
.cls-detail dt { color: #888; font-weight: 500; }
.cls-detail dd { color: #e5e5e5; margin: 0; }

.cls-wiki-loading { color: #888; font-size: 0.82rem; font-style: italic; }
.cls-wiki-extract { color: #c8c8c8; font-size: 0.85rem; line-height: 1.6; margin: 0; }
.cls-wiki-none    { color: #666; font-size: 0.82rem; font-style: italic; }
.cls-unknown      { color: #888; font-size: 0.85rem; }

.class-modal-wiki-link {
  display: inline-block;
  margin-top: 16px;
  color: #06b6d4;
  font-size: 0.82rem;
  text-decoration: none;
}
.class-modal-wiki-link:hover { text-decoration: underline; }

/* ── Timeline Toggle Button ── */
#timeline-toggle {
  position: fixed;
  left: 16px;
  bottom: calc(var(--stats-h) + 156px);
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(10,10,20,0.85);
  border: 1px solid rgba(245,158,11,0.3);
  color: #f59e0b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s;
}
#timeline-toggle:hover { background: rgba(245,158,11,0.15); border-color: #f59e0b; }
#timeline-toggle.active { background: rgba(245,158,11,0.2); border-color: #f59e0b; color: #fff; }
#timeline-toggle svg { width: 20px; height: 20px; }

/* ── Home / Reset View Button ── */
#home-btn {
  position: fixed;
  left: 16px;
  bottom: calc(var(--stats-h) + 204px);
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(10,10,20,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
#home-btn:hover { background: rgba(245,158,11,0.15); border-color: #f59e0b; color: #f59e0b; }
#home-btn:active { transform: scale(0.93); }
#home-btn svg { width: 18px; height: 18px; }

/* ── Timeline Bar ── */
.timeline-bar {
  position: fixed;
  bottom: var(--stats-h, 48px);
  left: 0;
  right: 0;
  z-index: 700;
  background: rgba(10,10,20,0.9);
  border-top: 1px solid rgba(245,158,11,0.2);
  backdrop-filter: blur(12px);
  padding: 10px 16px;
  transition: transform 0.3s ease;
}
.timeline-bar.hidden { display: none; }

.timeline-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.tl-btn {
  background: none;
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 6px;
  color: #f59e0b;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.tl-btn:hover { background: rgba(245,158,11,0.15); border-color: #f59e0b; }
.tl-btn svg { width: 16px; height: 16px; }

.tl-play-btn { background: rgba(245,158,11,0.1); }

.tl-year-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: #f59e0b;
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
}

.tl-slider-el { flex: 1; }

.tl-speed-group {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tl-speed-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  color: #888;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  padding: 4px 8px;
  transition: background 0.15s, color 0.15s;
}
.tl-speed-btn.active {
  background: rgba(245,158,11,0.2);
  border-color: rgba(245,158,11,0.5);
  color: #f59e0b;
}
.tl-speed-btn:hover:not(.active) { background: rgba(255,255,255,0.1); color: #ccc; }

/* ── Falling meteor animation ── */
.marker-anim-wrap {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: bottom center;
  animation: meteor-fall 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes meteor-fall {
  0%   { transform: translateY(-80px) translateX(28px) rotate(-40deg); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 1; }
}

.marker-anim-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 10px #f59e0b, 0 0 24px rgba(245,158,11,0.6), 0 0 40px rgba(245,158,11,0.2);
  animation: impact-pulse 0.3s ease-out 0.55s both;
}

@keyframes impact-pulse {
  0%   { transform: scale(1);   box-shadow: 0 0 10px #f59e0b, 0 0 24px rgba(245,158,11,0.5); }
  50%  { transform: scale(3.5); box-shadow: 0 0 30px #f59e0b, 0 0 60px rgba(245,158,11,0.4); opacity: 0.6; }
  100% { transform: scale(1);   box-shadow: 0 0 10px #f59e0b; }
}

/* When timeline is active, push stats bar down */
body.timeline-open #stats-bar {
  bottom: 54px; /* approximate timeline bar height */
}
