html,body,#map { 
  height: 100vh;
  margin: 0; 
  padding: 0;
  overflow: hidden;
}
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; }

/* Theme CSS Variables */
:root {
  /* Light mode colors */
  --bg-primary: rgba(255,255,255,0.98);
  --bg-secondary: #f8f8f8;
  --bg-tertiary: #f5f5f5;
  --bg-input: #fff;
  --bg-button: linear-gradient(to bottom, #fff, #f8f8f8);
  --bg-button-hover: linear-gradient(to bottom, #f8f8f8, #f0f0f0);
  --bg-button-active: #e8e8e8;
  --bg-accent: linear-gradient(to bottom, #0077cc, #0066b3);
  --bg-accent-hover: linear-gradient(to bottom, #0066b3, #005599);
  
  --border-primary: #e0e0e0;
  --border-secondary: #d0d0d0;
  --border-input: #ddd;
  --border-accent: #0055aa;
  
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-tertiary: #666;
  --text-quaternary: #777;
  --text-muted: #888;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --shadow-xl: 0 -2px 12px rgba(0,0,0,0.1);
  
  --overlay-bg: rgba(0, 119, 204, 0.95);
  --debug-bg: rgba(30, 30, 30, 0.98);
  --debug-text: #e0e0e0;
  
  --accent-blue: #0077cc;
  --accent-blue-light: #4db8ff;
}

/* Dark mode colors */
body.dark-mode {
  --bg-primary: rgba(30,30,30,0.98);
  --bg-secondary: #252525;
  --bg-tertiary: #2a2a2a;
  --bg-input: #333;
  --bg-button: linear-gradient(to bottom, #3a3a3a, #333);
  --bg-button-hover: linear-gradient(to bottom, #454545, #3a3a3a);
  --bg-button-active: #4a4a4a;
  --bg-accent: linear-gradient(to bottom, #0088dd, #0077cc);
  --bg-accent-hover: linear-gradient(to bottom, #0077cc, #0066aa);
  
  --border-primary: #404040;
  --border-secondary: #4a4a4a;
  --border-input: #4a4a4a;
  --border-accent: #0088dd;
  
  --text-primary: #e8e8e8;
  --text-secondary: #b8b8b8;
  --text-tertiary: #a0a0a0;
  --text-quaternary: #888;
  --text-muted: #777;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-xl: 0 -2px 12px rgba(0,0,0,0.3);
  
  --overlay-bg: rgba(0, 136, 221, 0.95);
  --debug-bg: rgba(20, 20, 20, 0.98);
  --debug-text: #d0d0d0;
  
  --accent-blue: #4db8ff;
  --accent-blue-light: #66c2ff;
}

/* UI header with inline settings button */
.ui-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ui-header h1 {
  margin: 0;
  flex: 1;
}

/* Inline settings button (desktop only) */
.settings-btn-inline {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 20px;
  flex-shrink: 0;
}

.settings-btn-inline:hover {
  background: var(--bg-button-hover);
  border-color: var(--border-input);
  transform: scale(1.05);
}

.settings-btn-inline:active {
  transform: scale(0.95);
}

.settings-btn-inline.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
}

body.dark-mode .settings-btn-inline.active .settings-icon {
  filter: brightness(0) invert(1);
}

/* Desktop settings panel */
.settings-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1003;
  background: var(--bg-primary);
  padding: 0;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  width: 380px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.settings-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

.settings-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  border-radius: 12px 12px 0 0;
}

.settings-panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-panel-close {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.settings-panel-close:hover {
  background: rgba(0,0,0,0.05);
}

body.dark-mode .settings-panel-close:hover {
  background: rgba(255,255,255,0.1);
}

.settings-panel-close:active {
  background: rgba(0,0,0,0.1);
}

body.dark-mode .settings-panel-close:active {
  background: rgba(255,255,255,0.15);
}

.settings-panel-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Settings categories */
.settings-category {
  margin-bottom: 20px;
}

.settings-category:last-child {
  margin-bottom: 0;
}

.settings-category-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-primary);
}

.settings-category-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Settings toggle buttons */
.settings-toggle-btn {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.settings-toggle-btn:hover {
  background: var(--bg-button-hover);
  border-color: var(--border-secondary);
}

.settings-toggle-btn:active {
  transform: scale(0.98);
}

.settings-toggle-btn.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
  color: #fff;
}

.settings-toggle-icon {
  font-size: 20px;
  margin-right: 10px;
  line-height: 1;
}

.settings-toggle-label {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}

/* Grid layout for layer toggles */
.layer-toggles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-control-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-secondary);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.2s ease;
}

.settings-control-btn:hover {
  background: var(--bg-secondary);
  border-color: #b8b8b8;
}

.settings-control-btn:active {
  background: #f0f0f0;
  transform: scale(0.98);
}

.slideshow-interval-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slideshow-interval-wrapper label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.slideshow-interval-wrapper input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

.slideshow-interval-wrapper .slideshow-interval-label {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 0;
}

/* Vehicle display mode buttons */
.vehicle-display-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.vehicle-display-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px;
}

.vehicle-display-btn:hover {
  background: #ececec;
  border-color: #d0d0d0;
  transform: translateY(-2px);
}

.vehicle-display-btn:active {
  transform: scale(0.98);
}

.vehicle-display-btn.active {
  background: linear-gradient(to bottom, #0077cc, #0066b3);
  border-color: #0055aa;
  color: #fff;
}

.vehicle-display-icon {
  font-size: 24px;
  margin-bottom: 6px;
  line-height: 1;
}

.vehicle-display-label {
  font-size: 13px;
  font-weight: 500;
}

/* Direction filter buttons */
.direction-filter-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.direction-filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px;
}

.direction-filter-btn:hover {
  background: var(--bg-button-hover);
  border-color: var(--border-secondary);
  transform: translateY(-2px);
}

.direction-filter-btn:active {
  transform: scale(0.98);
}

.direction-filter-btn.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
  color: #fff;
}

.direction-filter-icon {
  font-size: 24px;
  margin-bottom: 6px;
  line-height: 1;
}

.direction-filter-label {
  font-size: 13px;
  font-weight: 500;
}

/* Vehicle Type Filter buttons */
.vehicle-type-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.vehicle-type-filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px;
}

.vehicle-type-filter-btn:hover {
  background: var(--bg-button-hover);
  border-color: var(--border-secondary);
  transform: translateY(-2px);
}

.vehicle-type-filter-btn:active {
  transform: scale(0.98);
}

.vehicle-type-filter-btn.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
  color: #fff;
}

.vehicle-type-filter-icon {
  font-size: 24px;
  margin-bottom: 6px;
  line-height: 1;
}

.vehicle-type-filter-label {
  font-size: 13px;
  font-weight: 500;
}

/* Theme mode buttons */
.theme-mode-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px;
}

.theme-mode-btn:hover {
  background: var(--bg-button-hover);
  border-color: var(--border-secondary);
  transform: translateY(-2px);
}

.theme-mode-btn:active {
  transform: scale(0.98);
}

.theme-mode-btn.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
  color: #fff;
}

.theme-mode-icon {
  font-size: 24px;
  margin-bottom: 6px;
  line-height: 1;
}

.theme-mode-label {
  font-size: 13px;
  font-weight: 500;
}

.ui { 
  position: absolute; 
  left: 12px; 
  top: 12px;
  z-index: 2; 
  background: var(--bg-primary); 
  padding: 14px 16px; 
  border-radius: 12px; 
  box-shadow: var(--shadow-lg); 
  max-width: 420px;
}

.ui h1 { 
  margin: 0 0 12px 0; 
  font-size: 18px; 
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.controls { 
  display: flex; 
  gap: 8px; 
  align-items: stretch; 
  flex-wrap: wrap; 
}

/* Mobile navigation (hidden on desktop) */
.mobile-nav {
  display: none;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  padding: 0;
  margin-top: 0;
}

.mobile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active {
  background: rgba(0,0,0,0.05);
  transform: scale(0.95);
}

body.dark-mode .mobile-btn:active {
  background: rgba(255,255,255,0.1);
}

.mobile-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}

.mobile-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.controls-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-wrapper {
  position: relative;
  flex: 1;
  min-width: 120px;
}

.controls input[type=text] { 
  width: 100%;
  padding: 11px 36px 11px 12px; 
  border-radius: 8px; 
  border: 1.5px solid var(--border-input); 
  font-size: 15px;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.controls input[type=text]::placeholder {
  color: var(--text-tertiary);
  opacity: 0.7;
}

.controls input[type=text]:focus { 
  outline: none;
  border-color: #0077cc;
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
}

.controls input[type=number] {
  padding: 11px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--border-input);
  font-size: 15px;
  background: var(--bg-input);
  text-align: center;
  width: 60px;
  box-sizing: border-box;
}

.controls input[type=number]:focus {
  outline: none;
  border-color: #0077cc;
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
}

.slideshow-controls-hidden {
  display: none;
}

.slideshow-controls-visible {
  margin-top: 4px;
}

.slideshow-interval-label {
  padding: 11px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: none;
  box-shadow: none;
  transition: color 0.2s;
  line-height: 1;
}

.clear-btn:hover {
  color: #333;
  background: transparent;
  border: none;
  box-shadow: none;
  transform: translateY(-50%);
}

.clear-btn:active {
  transform: translateY(-50%);
}

.clear-btn.visible {
  display: block;
}

button { 
  padding: 11px 14px; 
  border-radius: 8px; 
  border: 1.5px solid var(--border-secondary); 
  background: var(--bg-button); 
  cursor: pointer; 
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  line-height: 1;
}

button:hover { 
  background: var(--bg-button-hover);
  border-color: var(--border-input);
  box-shadow: var(--shadow-md);
}

button:active { 
  background: var(--bg-button-active);
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

button:disabled,
input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.toggle-btn.active {
  background: var(--bg-accent);
  border-color: var(--border-accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-btn.active:hover {
  background: var(--bg-accent-hover);
  border-color: var(--border-accent);
}

/* Follow mode indicator */
.follow-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--overlay-bg);
  color: white;
  padding: 10px 20px;
  padding-right: 40px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10;
  display: none;
  animation: slideUp 0.3s ease-out;
}

.follow-indicator.visible {
  display: block;
}

.follow-indicator-close {
  position: absolute;
  right: 8px;
  top: 50%;
  margin-top: -13px;
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 18px;
  color: white;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.follow-indicator-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}




.meta { 
  margin-top: 12px; 
  padding-top: 12px;
  border-top: 1px solid var(--border-primary);
  font-size: 14px; 
  color: var(--text-secondary);
  line-height: 1.6;
}

.meta div {
  margin-bottom: 4px;
}

.meta span {
  font-weight: 500;
  color: var(--text-primary);
}

.legend { 
  margin-top: 10px; 
  padding-top: 10px;
  border-top: 1px solid var(--border-primary);
  font-size: 12px; 
  color: var(--text-quaternary); 
  line-height: 1.5; 
}

/* Auto-refresh button with progress fill */
#autoRefreshBtn {
  position: relative;
  overflow: hidden;
  --progress-width: 0%;
}

#autoRefreshBtn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--progress-width, 0%);
  background: linear-gradient(to right, rgba(0, 119, 204, 0.3), rgba(0, 170, 255, 0.3));
  transition: width 0.1s linear;
  z-index: 0;
  pointer-events: none;
}

#autoRefreshBtn:not(.active)::before {
  background: rgba(200, 200, 200, 0.3);
}

#autoRefreshBtn > * {
  position: relative;
  z-index: 1;
}

/* Custom popup styling */
.maplibregl-popup-content {
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  padding: 12px 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.maplibregl-popup-close-button {
  font-size: 20px;
  padding: 4px 8px;
  color: var(--text-muted);
}

.maplibregl-popup-close-button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Popup content classes */
.popup-container {
  font-family: inherit;
  min-width: 200px;
  max-width: 280px;
  padding: 4px;
}

.popup-heading {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-blue);
  word-wrap: break-word;
}

.popup-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.popup-detail {
  margin-bottom: 4px;
}

.popup-label {
  color: var(--text-tertiary);
}

.popup-value {
  font-weight: 600;
  word-wrap: break-word;
  word-break: break-all;
  color: var(--text-primary);
}

.popup-separator {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-primary);
}

.popup-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.popup-scrollable {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
  max-height: 200px;
  overflow-y: auto;
}

.popup-stop-item {
  margin-bottom: 4px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.popup-stop-name {
  font-weight: 600;
  color: var(--text-primary);
}

.popup-stop-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.popup-distance-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  color: var(--text-secondary);
}

.popup-speed-value {
  color: var(--accent-blue);
  font-weight: 600;
}

/* Desktop popup follow button */
.maplibregl-popup-content #followBtn {
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(to bottom, #0077cc, #0066b3);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.maplibregl-popup-content #followBtn:hover {
  background: linear-gradient(to bottom, #0066b3, #00558a);
}

.maplibregl-popup-content #followBtn:active {
  background: #00558a;
}

/* MapLibre navigation controls (zoom buttons) - Dark mode support */
body.dark-mode .maplibregl-ctrl-group {
  background: transparent;
  box-shadow: none;
}

body.dark-mode .maplibregl-ctrl-group button {
  background-color: transparent;
  color: #e8e8e8;
}

body.dark-mode .maplibregl-ctrl-group button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .maplibregl-ctrl-group button + button {
  border-top-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .maplibregl-ctrl-icon {
  filter: brightness(0) invert(1);
}

/* Mobile bottom bar (hidden on desktop) */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-primary);
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  box-shadow: var(--shadow-xl);
  justify-content: space-around;
  align-items: center;
  gap: 4px;
}

.mobile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active {
  background: rgba(0,0,0,0.05);
  transform: scale(0.95);
}

body.dark-mode .mobile-btn:active {
  background: rgba(255,255,255,0.1);
}

.mobile-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}

.mobile-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Vehicle info card - hidden on desktop (popup used instead), shown on mobile */
.vehicle-card {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-input);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.12), 0 4px 40px rgba(0,0,0,0.08);
  z-index: 1000;
  max-height: min(65vh, calc(100vh - 140px));
  overflow: hidden;
  transform: translateY(calc(100% + 80px));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.vehicle-card.visible {
  transform: translateY(0);
}

.vehicle-card.minimized {
  max-height: 56px;
  overflow: hidden;
}

.vehicle-card.minimized .vehicle-card-content {
  display: none;
}

.vehicle-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-input);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.vehicle-card-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  color: var(--text-primary);
}

.vehicle-card-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

.vehicle-card-btn {
  background: var(--bg-tertiary);
  border: none;
  padding: 6px 12px;
  font-size: 16px;
  color: #007AFF;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.2s ease;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}

.vehicle-card-btn:active {
  background: #e0e0e0;
}

.vehicle-card-content {
  padding: 16px 20px 24px 20px;
  overflow-y: auto;
  max-height: calc(min(65vh, calc(100vh - 140px)) - 56px);
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 24px);
}

/* Style the content inside the card */
.vehicle-card-content > div {
  font-family: inherit;
  max-width: none !important;
  min-width: 0 !important;
  width: 100% !important;
  padding: 0 !important;
}

/* Hide the redundant heading in vehicle card */
.vehicle-card-content > div > div:first-child {
  display: none;
}

/* Style the vehicle details text */
.vehicle-card-content div[style*="font-size: 13px"] {
  font-size: 14px !important;
  line-height: 1.6 !important;
  color: #333 !important;
}

.vehicle-card-content div[style*="margin-bottom: 4px"] {
  margin-bottom: 8px !important;
  padding-bottom: 8px;
  border-bottom: 1px solid #f5f5f5;
}

.vehicle-card-content div[style*="margin-bottom: 4px"]:last-of-type {
  border-bottom: none;
}

.vehicle-card-content button {
  width: 100%;
  margin-top: 16px !important;
  margin-bottom: 8px !important;
  padding: 14px 16px;
  background: #007AFF;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.vehicle-card-content button:active {
  background: #0056b3;
}

/* Filter panel (hidden on desktop, shown on mobile) */
.filter-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-input);
  z-index: 1002;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.filter-panel.visible {
  transform: translateY(0);
}

.filter-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
}

.filter-panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.filter-panel-close {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.filter-panel-close:active {
  background: rgba(0,0,0,0.05);
}

body.dark-mode .filter-panel-close:active {
  background: rgba(255,255,255,0.1);
}

.filter-panel-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(70vh - 70px);
  padding-top: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Filter panel specific styles */
#filterPanel .input-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}

#filterPanel input[type=text] {
  width: 100%;
  padding: 14px 44px 14px 44px;
  border-radius: 12px;
  border: 2px solid var(--border-primary);
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#filterPanel input[type=text]::placeholder {
  color: var(--text-tertiary);
  opacity: 0.7;
}

#filterPanel input[type=text]:focus {
  outline: none;
  border-color: #0077cc;
  background: var(--bg-input);
  box-shadow: 0 0 0 4px rgba(0, 119, 204, 0.1);
}

#filterPanel .clear-btn {
  right: 8px;
}

/* Menu panel (mobile only) */
.menu-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-input);
  z-index: 1002;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.menu-panel.visible {
  transform: translateY(0);
}

.menu-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
}

.menu-panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.menu-panel-close {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.menu-panel-close:active {
  background: rgba(0,0,0,0.05);
}

body.dark-mode .menu-panel-close:active {
  background: rgba(255,255,255,0.1);
}

.menu-panel-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(70vh - 70px);
}

.menu-info-section {
  padding-top: 12px;
  border-top: 1px solid var(--border-primary);
}

.menu-info-section .meta {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 14px;
}

/* Mobile panels */
.mobile-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-input);
  z-index: 1002;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.mobile-panel.visible {
  transform: translateY(0);
}

.mobile-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  background: var(--bg-secondary);
  border-radius: 16px 16px 0 0;
}

.mobile-panel-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-panel-close {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 24px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.mobile-panel-close:active {
  background: rgba(0,0,0,0.05);
}

.mobile-panel-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(70vh - 70px);
}

/* Mobile filter panel specific styles */
#mobileFilterPanel .mobile-panel-content {
  padding-top: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  padding-inline: 20px;
}

#mobileFilterPanel .input-wrapper {
  position: relative;
}

#mobileFilterPanel .input-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  z-index: 1;
}

#mobileFilterPanel input[type=text] {
  width: 100%;
  padding: 14px 44px 14px 44px;
  border-radius: 12px;
  border: 2px solid var(--border-primary);
  font-size: 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#mobileFilterPanel input[type=text]::placeholder {
  color: var(--text-tertiary);
  opacity: 0.7;
}

#mobileFilterPanel input[type=text]:focus {
  outline: none;
  border-color: #0077cc;
  background: var(--bg-input);
  box-shadow: 0 0 0 4px rgba(0, 119, 204, 0.1);
}

#mobileFilterPanel .clear-btn {
  right: 8px;
}

.mobile-toggle-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.mobile-toggle-btn {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.mobile-toggle-btn:active {
  transform: scale(0.98);
}

.mobile-toggle-btn.active {
  background: linear-gradient(to bottom, #0077cc, #0066b3);
  border-color: #0055aa;
  color: #fff;
}

.mobile-toggle-icon {
  font-size: 22px;
  margin-right: 12px;
  line-height: 1;
}

.mobile-toggle-label {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
}

.mobile-slideshow-controls {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  margin-bottom: 20px;
}

.mobile-control-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-secondary);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.mobile-control-btn:active {
  background: #f0f0f0;
  transform: scale(0.98);
}

.mobile-slideshow-interval {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-slideshow-interval input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--border-secondary);
  border-radius: 8px;
  font-size: 15px;
  text-align: center;
}

.mobile-slideshow-interval .slideshow-interval-label {
  font-size: 14px;
  color: var(--text-tertiary);
  padding: 0;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  /* Transform main UI from sidebar to bottom bar */
  .ui {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: none;
    width: auto;
    border-radius: 0;
    background: var(--bg-primary);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-primary);
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 1001;
    box-shadow: var(--shadow-xl);
  }
  
  /* Hide header on mobile */
  .ui-header {
    display: none;
  }
  
  /* Hide desktop controls on mobile */
  .desktop-controls,
  .desktop-meta,
  .desktop-legend {
    display: none;
  }
  
  /* Show mobile navigation on mobile */
  .mobile-nav {
    display: flex;
  }
  
  /* Settings panel transforms to bottom sheet on mobile */
  .settings-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  
  .settings-panel.visible {
    transform: translateY(0);
  }
  
  /* Show panels when needed */
  .filter-panel,
  .menu-panel {
    display: block;
  }
  
  /* Show vehicle card on mobile */
  .vehicle-card {
    display: block;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
}

/* Status bar */
#statusBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 119, 204, 0.96);
  color: white;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#statusBar.hidden {
  transform: translateY(100%);
  opacity: 0;
}

/* Debug toggle icon */
#debugToggle {
  position: fixed;
  bottom: 10px;
  left: 10px;
  width: 32px;
  height: 32px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-input);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
  user-select: none;
}

#debugToggle:hover {
  background: var(--bg-primary);
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  transform: scale(1.05);
}

#debugToggle.active {
  background: var(--overlay-bg);
  color: white;
  border-color: #0055aa;
}

#debugToggle.error-flash {
  animation: errorFlash 0.5s ease-in-out 10;
}

@keyframes errorFlash {
  0%, 100% {
    background: var(--bg-primary);
    border-color: var(--border-input);
  }
  50% {
    background: #ff0000;
    border-color: #ff0000;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  }
}

/* Stats toggle icon */
#statsToggle {
  position: fixed;
  bottom: 10px;
  left: 52px;
  width: 32px;
  height: 32px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-input);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
  user-select: none;
}

#statsToggle:hover {
  background: var(--bg-primary);
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  transform: scale(1.05);
}

#statsToggle.active {
  background: var(--overlay-bg);
  color: white;
  border-color: #0055aa;
}

/* Stats box */
#statsBox {
  position: fixed;
  top: 12px;
  right: 12px;
  background: var(--bg-primary);
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 998;
  max-width: 280px;
  font-size: 14px;
  color: var(--text-primary);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

#statsBox.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#statsBox .stats-header {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--border-primary);
  color: #0077cc;
}

body.dark-mode #statsBox .stats-header {
  color: #4db8ff;
}

#statsBox .stats-table {
  width: 100%;
  border-collapse: collapse;
}

#statsBox .stats-table tr {
  border-bottom: 1px solid var(--border-primary);
}

#statsBox .stats-table tr:last-child {
  border-bottom: none;
}

#statsBox .stat-label {
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 6px 8px 6px 0;
  text-align: left;
}

#statsBox .stat-value {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  padding: 6px 0;
  text-align: right;
}

/* Debug pane */
#debugPane {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40vh;
  background: var(--debug-bg);
  color: var(--debug-text);
  z-index: 998;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

#debugPane.visible {
  transform: translateY(0);
}

#debugPane .debug-header {
  padding: 10px 16px;
  background: rgba(0, 119, 204, 0.9);
  color: white;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#debugPane .debug-controls {
  display: flex;
  gap: 8px;
}

#debugPane .debug-controls button {
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

#debugPane .debug-controls button:hover {
  background: rgba(255,255,255,0.3);
}

#debugPane .debug-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
}

#debugPane .log-entry {
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  border-left: 3px solid #888;
}

#debugPane .log-entry.info {
  border-left-color: #4CAF50;
}

#debugPane .log-entry.error {
  border-left-color: #F44336;
  background: rgba(244, 67, 54, 0.1);
}

#debugPane .log-entry.warn {
  border-left-color: #FFC107;
}

#debugPane .log-entry .timestamp {
  color: var(--text-muted);
  font-size: 11px;
  margin-right: 8px;
}

#debugPane .log-entry .message {
  color: var(--debug-text);
}

#debugPane .log-entry.error .message {
  color: #ffcdd2;
}

@media (max-width: 768px) {
  #debugPane {
    height: 50vh;
    bottom: 0px;
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  
  #debugToggle {
    width: 28px;
    height: 28px;
    font-size: 14px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  
  #statsToggle {
    width: 28px;
    height: 28px;
    font-size: 14px;
    left: 46px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  
  #statsBox {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 8px;
    left: 8px;
    max-width: none;
    font-size: 13px;
  }
  
  #statsBox .stats-header {
    font-size: 15px;
  }
  
  #statusBar {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  
  #statusBar.hidden {
    bottom: 0;
  }
  
  .follow-indicator {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  
  .maplibregl-ctrl-top-right {
    top: env(safe-area-inset-top, 0px);
  }
  
  .maplibregl-ctrl-bottom-right {
      display: none;
  }
}
