:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(56, 189, 248, 0.5);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #38bdf8;
  --accent-rose: #f43f5e;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #a855f7;

  --flight-color: #38bdf8;
  --train-color: #f59e0b;
  --road-color: #10b981;
  --transit-color: #f43f5e;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
#app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

#map-view {
  flex: 1;
  height: 100%;
  width: 100%;
  background: #090d16;
  z-index: 1;
}

/* Glassmorphic Overlays */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  border-radius: 16px;
}

/* Top Navigation / Header */
.top-nav {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  pointer-events: none;
}

.top-nav > * {
  pointer-events: auto;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  background: rgba(30, 41, 59, 0.6);
  color: var(--text-main);
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* Live production environment (Firebase): hide developer/editor actions */
body.env-production #btn-open-editor,
body.env-production #btn-build-deploy {
  display: none !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.5);
}

/* Era Filter Bar */
.era-pills {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  gap: 4px;
}

.era-pill {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: all 0.2s ease;
}

.era-pill:hover {
  color: var(--text-main);
}

.era-pill.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Top Playback HUD */
.playback-hud {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  min-width: 280px;
  max-width: 480px;
  pointer-events: auto;
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
  transition: all 0.25s ease;
}

.playback-hud.is-trip-active {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 28px rgba(56, 189, 248, 0.3);
}

.hud-eyebrow {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
}

.hud-date-main {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
  line-height: 1.2;
}

.hud-trip-details {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 100%;
}

.hud-trip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-passengers-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}

/* Companion Dock (Left-docked, non-intrusive) */
.companion-dock {
  position: absolute;
  top: 172px;
  left: 20px;
  z-index: 1000;
  width: 270px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  transition: all 0.25s ease;
}

.companion-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.companion-dock-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.companion-dock-title svg {
  color: var(--accent-cyan);
}

.companion-dock-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.companion-dock-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.companion-dock-arrow {
  font-size: 0.8rem;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.companion-dock.is-expanded .companion-dock-arrow {
  transform: rotate(180deg);
}

.companion-dock-stack {
  display: flex;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  min-height: 32px;
}

.stack-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #0f172a;
  margin-left: -8px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, z-index 0.15s ease;
  position: relative;
}

.stack-avatar:first-child {
  margin-left: 0;
}

.stack-avatar:hover {
  transform: translateY(-3px) scale(1.15);
  z-index: 10;
  border-color: var(--accent-cyan);
}

.stack-avatar.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan);
}

.stack-more-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #0f172a;
  margin-left: -8px;
  background: rgba(30, 41, 59, 0.9);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.companion-dock-expanded {
  margin-top: 4px;
  border-top: 1px solid var(--border-glass);
  padding-top: 8px;
}

.companion-chips-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 230px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 4px;
}

.dock-comp-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: all 0.18s ease;
}

.dock-comp-chip:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateX(2px);
}

.dock-comp-chip.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.dock-comp-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comp-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.comp-name {
  font-size: 0.78rem;
  font-weight: 500;
}

.comp-count {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 8px;
}

/* Stats HUD */
.stats-hud {
  position: absolute;
  top: 76px;
  left: 20px;
  z-index: 1000;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  min-width: 320px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
}

.stat-val.cyan { color: var(--accent-cyan); }
.stat-val.rose { color: var(--accent-rose); }
.stat-val.emerald { color: var(--accent-emerald); }
.stat-val.amber { color: var(--accent-amber); }

.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Mode Legend */
.mode-legend {
  position: absolute;
  top: 80px;
  right: 20px;
  z-index: 1000;
  padding: 8px 14px;
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.line-flight { background: var(--flight-color); box-shadow: 0 0 6px var(--flight-color); }
.line-train { background: var(--train-color); border: 1px dashed #fff; box-shadow: 0 0 6px var(--train-color); }
.line-road { background: var(--road-color); box-shadow: 0 0 6px var(--road-color); }
.line-transit { background: var(--transit-color); box-shadow: 0 0 6px var(--transit-color); }

/* Timeline Playback Float */
.timeline-float {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(800px, 92vw);
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-cyan);
  color: #090d16;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.8);
}

.timeline-slider-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.timeline-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  transition: transform 0.1s ease;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.active-trip-bubble {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-cyan);
  white-space: nowrap;
}

/* Side Drawer: Trip List & Detail */
.side-drawer {
  position: absolute;
  top: 140px;
  right: 20px;
  bottom: 90px;
  width: 380px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.side-drawer.closed {
  transform: translateX(420px);
  opacity: 0;
  pointer-events: none;
}

.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
}

.drawer-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 10px;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

.drawer-close-btn:hover {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.4);
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Trip Card */
.trip-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trip-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateX(-2px);
}

.trip-card.active {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.trip-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.trip-destination {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trip-dates {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.trip-route {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.trip-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.trip-avatars {
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.trip-avatars .comp-avatar {
  margin-left: -6px;
  border: 2px solid var(--bg-secondary);
}

.tag-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.mode-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
  text-transform: uppercase;
}

.mode-badge.flight { background: rgba(56, 189, 248, 0.2); color: var(--accent-cyan); }
.mode-badge.train { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); }
.mode-badge.roadtrip { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }

/* Trip Modal / Detail View */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(540px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 20px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

/* Map Elements Styling */
.leaflet-container {
  background: #090d16 !important;
}

.leaflet-tile {
  /* Carto Dark Matter is already dark; keep subtle contrast */
  filter: brightness(0.95) contrast(1.05);
}

/* Custom Marker Pulsing */
.pulse-node {
  border-radius: 50%;
  animation: pulseNode 2s infinite ease-out;
}

@keyframes pulseNode {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 12px rgba(56, 189, 248, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.home-node {
  animation: pulseHome 2.5s infinite ease-out;
}

@keyframes pulseHome {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.8); }
  70% { box-shadow: 0 0 0 16px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Follow Camera Mode Button */
.follow-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
  background: rgba(30, 41, 59, 0.7);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  flex-shrink: 0;
}

.follow-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  color: var(--text-main);
  border-color: rgba(56, 189, 248, 0.5);
}

.follow-btn.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}

.btn-play-single-trip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #fff;
  transition: all 0.2s ease;
}

.btn-play-single-trip:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

/* Speed Settings Button & Panel */
.settings-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: rgba(30, 41, 59, 0.7);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.settings-btn:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(51, 65, 85, 0.9);
  transform: rotate(45deg);
}

.speed-settings-panel {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: min(440px, 94vw);
  padding: 18px 20px;
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), 0 0 25px rgba(56, 189, 248, 0.2);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.settings-title svg {
  color: var(--accent-cyan);
}

.settings-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 4px;
}

.settings-close-btn:hover {
  color: #fff;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
}

.setting-badge {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 700;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 7px;
  border-radius: 6px;
}

.setting-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

.setting-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.presets-section {
  margin: 12px 0 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-glass);
}

.presets-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.presets-row {
  display: flex;
  gap: 8px;
}

.preset-btn {
  flex: 1;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.preset-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.settings-footer-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.settings-toast {
  display: none;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--accent-emerald);
  text-align: center;
  font-weight: 500;
}

/* Animated Traveler Vehicle Pod on Map */
.traveler-vehicle-marker {
  pointer-events: none;
  z-index: 1500 !important;
}

.traveler-vehicle-pod {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(56, 189, 248, 0.8);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8), 0 0 16px rgba(56, 189, 248, 0.6);
  transform: translate(-50%, -50%);
  white-space: nowrap;
  animation: floatPod 2s ease-in-out infinite;
}

@keyframes floatPod {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-2px); }
}

.vehicle-badge {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.vehicle-badge.mode-flight {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.vehicle-badge.mode-train {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
}

.vehicle-badge.mode-car {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.7);
}

.vehicle-rotator {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vehicle-rotator svg {
  width: 16px;
  height: 16px;
}

.passengers-cluster {
  display: flex;
  align-items: center;
}

.passenger-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #0f172a;
  margin-left: -5px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.passenger-circle:first-child {
  margin-left: 0;
}

.passenger-circle.me-user {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
}

/* Flash ripple on city arrival */
.city-arrival-wave {
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: rippleArrival 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleArrival {
  0% { width: 4px; height: 4px; opacity: 1; }
  100% { width: 36px; height: 36px; opacity: 0; border-color: rgba(56, 189, 248, 0); }
}

/* Active glowing route stroke */
.active-glow-path {
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.85));
}

/* ==========================================================================
   Active Flight City Highlights & Beacon Animation
   ========================================================================== */
.flight-city-marker {
  position: relative;
  pointer-events: none;
  z-index: 1000 !important;
}

.flight-city-beacon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.beacon-core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid #ffffff;
  box-shadow: 0 0 16px var(--accent-cyan), 0 0 28px rgba(56, 189, 248, 0.75);
  z-index: 3;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.beacon-ring {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 2;
  animation: radarRingPulse 2s cubic-bezier(0.1, 0.8, 0.3, 1) infinite;
}

.beacon-ring.ring-2 {
  animation-delay: 0.65s;
}

@keyframes radarRingPulse {
  0% {
    transform: scale(1);
    opacity: 0.95;
    border-width: 2.5px;
  }
  100% {
    transform: scale(4.2);
    opacity: 0;
    border-width: 1px;
  }
}

/* State: Departure */
.flight-city-beacon.is-departure .beacon-core {
  background: #38bdf8;
  border-color: #ffffff;
  box-shadow: 0 0 16px #38bdf8, 0 0 28px rgba(56, 189, 248, 0.8);
}
.flight-city-beacon.is-departure .beacon-ring {
  border-color: #38bdf8;
}

/* State: Target (Active pulsating destination / stop) */
.flight-city-beacon.is-target .beacon-core {
  background: #f43f5e;
  border-color: #ffffff;
  box-shadow: 0 0 22px #f43f5e, 0 0 36px rgba(244, 63, 94, 0.9);
  transform: scale(1.25);
  animation: targetCoreThrob 1.2s infinite alternate ease-in-out;
}
.flight-city-beacon.is-target .beacon-ring {
  border-color: #f43f5e;
  border-width: 2.5px;
  animation-duration: 1.5s;
}

@keyframes targetCoreThrob {
  0% { transform: scale(1.15); box-shadow: 0 0 14px #f43f5e; }
  100% { transform: scale(1.35); box-shadow: 0 0 28px #f43f5e, 0 0 45px rgba(244, 63, 94, 0.8); }
}

/* State: Arrived (Touchdown celebration) */
.flight-city-beacon.is-arrived .beacon-core {
  background: #10b981;
  border-color: #ffffff;
  box-shadow: 0 0 20px #10b981, 0 0 32px rgba(16, 185, 129, 0.85);
  transform: scale(1.15);
}
.flight-city-beacon.is-arrived .beacon-ring {
  border-color: #10b981;
}

/* Floating City Glass Badge */
.flight-city-badge {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.65), 0 0 12px rgba(56, 189, 248, 0.35);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  animation: badgePopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes badgePopIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(5px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.flight-city-badge .badge-icon {
  font-size: 0.78rem;
  line-height: 1;
}

.flight-city-badge .badge-name {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.flight-city-badge .badge-tag {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-cyan);
}

.flight-city-beacon.is-target .flight-city-badge {
  border-color: rgba(244, 63, 94, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 16px rgba(244, 63, 94, 0.45);
}
.flight-city-beacon.is-target .flight-city-badge .badge-tag {
  background: rgba(244, 63, 94, 0.22);
  color: #fb7185;
}

.flight-city-beacon.is-arrived .flight-city-badge {
  border-color: rgba(16, 185, 129, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 16px rgba(16, 185, 129, 0.45);
}
.flight-city-beacon.is-arrived .flight-city-badge .badge-tag {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

/* Follow Mode Toast Notification */
.follow-toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(56, 189, 248, 0.2);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2500;
}

.follow-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ====================================================
   Lock Screen / Password Protection Gate
   ==================================================== */
.app-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at 50% 30%, #0f172a 0%, #030712 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s;
}

.app-lock-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lock-card {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.15);
  border-radius: 24px;
  padding: 38px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: lockCardFloat 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.lock-card::before {
  content: '';
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 120px;
  background: radial-gradient(ellipse, rgba(56, 189, 248, 0.25), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

@keyframes lockCardFloat {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.lock-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(14, 165, 233, 0.05) 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: #38bdf8;
}

.lock-title {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.lock-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 24px;
}

.lock-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lock-input-group {
  position: relative;
  width: 100%;
}

.lock-input {
  width: 100%;
  height: 48px;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 0 46px 0 16px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
  font-family: inherit;
}

.lock-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
  background: rgba(2, 6, 23, 0.9);
}

.lock-toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.lock-toggle-visibility:hover {
  color: #fff;
}

.lock-btn-submit {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 14px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.35);
  font-family: inherit;
}

.lock-btn-submit:hover {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
  box-shadow: 0 10px 28px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.lock-btn-submit:active {
  transform: translateY(0);
}

.lock-error-msg {
  color: #fb7185;
  font-size: 0.82rem;
  min-height: 18px;
  display: none;
  animation: lockShake 0.4s ease-in-out;
}

.lock-error-msg.visible {
  display: block;
}

@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.lock-header-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 7px 11px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  transition: all 0.2s;
  text-decoration: none;
}

.lock-header-btn:hover {
  color: #f43f5e;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.1);
}

/* ====================================================
   Mobile Responsive Experience (Clean Map View)
   ==================================================== */
@media (max-width: 768px) {
  /* 1. HIDE ALL CLUTTERING OVERLAYS ON MOBILE */
  #stats-hud,
  .stats-hud,
  #mode-legend,
  .mode-legend,
  #companion-dock,
  .companion-dock,
  #btn-build-deploy,
  .brand-subtitle,
  .hud-eyebrow,
  #side-drawer:not(.open),
  .side-drawer:not(.open) {
    display: none !important;
  }

  .side-drawer.open {
    display: flex !important;
    position: fixed !important;
    top: 56px !important;
    bottom: 14px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    z-index: 2500 !important;
    border-radius: 20px !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    -webkit-backdrop-filter: blur(25px) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 30px rgba(56, 189, 248, 0.2) !important;
    animation: drawerMobilePop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes drawerMobilePop {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* 2. COMPACT TOP NAVIGATION */
  .top-nav {
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 6px 10px;
    gap: 8px;
    flex-wrap: nowrap;
    border-radius: 14px;
    max-width: calc(100vw - 16px);
  }

  .brand-section {
    gap: 8px;
    flex-shrink: 0;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .brand-logo svg {
    width: 16px;
    height: 16px;
  }

  .brand-title {
    font-size: 0.92rem;
  }

  /* Horizontally scrollable era pills */
  .era-pills {
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 4px;
    gap: 3px;
    border-radius: 10px;
    max-width: 50vw;
  }

  .era-pills::-webkit-scrollbar {
    display: none;
  }

  .era-pill {
    padding: 4px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
    border-radius: 6px;
  }

  .nav-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .nav-actions .btn {
    padding: 5px 8px;
    font-size: 0.72rem;
    gap: 4px;
    border-radius: 8px;
  }

  .lock-header-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
    gap: 4px;
    border-radius: 8px;
  }

  .lock-header-btn span,
  .nav-actions .btn span:not(.badge) {
    display: none; /* Icon-only on mobile */
  }

  /* 3. SLEEK SINGLE-BADGE PLAYBACK HUD */
  .playback-hud {
    top: 56px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    min-width: 0;
    max-width: calc(100vw - 16px);
    padding: 6px 12px;
    border-radius: 12px;
    gap: 1px;
    background: rgba(15, 23, 42, 0.88);
  }

  .hud-date-main {
    font-size: 1.05rem;
    letter-spacing: 0.02em;
  }

  .hud-trip-details {
    font-size: 0.78rem;
  }

  .hud-trip-name {
    font-size: 0.78rem;
    max-width: 88vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 4. ERGONOMIC MOBILE PLAYBACK TIMELINE (THUMB-FRIENDLY) */
  .timeline-float {
    bottom: 12px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    left: 8px;
    transform: none;
    padding: 8px 12px;
    gap: 8px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.92);
  }

  .play-btn {
    width: 36px;
    height: 36px;
  }

  .follow-btn {
    padding: 6px 8px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .settings-btn {
    width: 32px;
    height: 32px;
  }

  .timeline-slider-container {
    gap: 2px;
  }

  .timeline-labels {
    font-size: 0.65rem;
  }

  .active-trip-bubble {
    font-size: 0.68rem;
    padding: 1px 6px;
  }

  /* 5. MODALS & POPUPS ON MOBILE */
  .speed-settings-panel {
    top: auto;
    bottom: 74px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    max-width: calc(100vw - 16px);
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 18px;
    padding: 16px;
  }

  .modal-card {
    width: 95vw;
    max-width: 95vw;
    max-height: 85vh;
    padding: 18px 14px;
    border-radius: 20px;
  }

  .modal-overlay {
    padding: 10px;
  }

  /* 6. LEAFLET CONTROLS */
  .leaflet-bottom.leaflet-right {
    bottom: 80px !important;
    right: 8px !important;
  }

  /* 7. EDITOR ON MOBILE */
  .editor-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .editor-header > div:last-child {
    flex-wrap: wrap;
  }

  .trips-table-container,
  .trips-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .companions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand-title {
    display: none; /* Keep top bar clean on small devices */
  }

  .era-pills {
    max-width: 65vw;
  }

  .timeline-labels #timeline-start-label,
  .timeline-labels #timeline-end-label {
    display: none; /* Keep slider clean */
  }

  .timeline-labels {
    justify-content: center;
  }
}


