/* ========== Reset & Base ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-tertiary: #242836;
  --bg-hover: #2d3244;
  --text-primary: #f0f0f4;
  --text-secondary: #b0b8c8;
  --text-muted: #6b7590;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.15);
  --accent-hover: #16a34a;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  /* Safe area insets */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Map ========== */
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* Override Mapbox controls for dark theme */
.mapboxgl-ctrl-group {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
}

.mapboxgl-ctrl-group button {
  border-color: var(--border) !important;
}

.mapboxgl-ctrl-group button span {
  filter: invert(1);
}

.mapboxgl-ctrl-attrib {
  background: rgba(15, 17, 23, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.mapboxgl-ctrl-attrib a {
  color: var(--text-secondary) !important;
}

/* ========== Loading Overlay (initial map load) ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 0.4s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay.hidden {
  display: none;
}

.loading-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.loading-spinner-large {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin 0.8s linear infinite;
}

.loading-spinner-small {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin 0.8s linear infinite;
}

@keyframes spinner-spin {
  to { transform: rotate(360deg); }
}

/* Route calculating overlay */
.route-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 28px;
  box-shadow: var(--shadow);
}

.route-loading.hidden {
  display: none;
}

.route-loading-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========== Search Bar ========== */
.search-bar {
  position: fixed;
  top: calc(12px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 16px;
  box-shadow: var(--shadow);
  width: min(720px, calc(100% - 24px));
  backdrop-filter: blur(20px);
}

.search-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.search-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}

.logo-icon {
  font-size: 20px;
}

.logo-text {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.search-fields {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 0;
  min-width: 0;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  min-width: 0;
  padding: 6px 10px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  position: relative;
}

.search-input-wrapper:focus-within {
  background: var(--bg-tertiary);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input-wrapper input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px; /* prevents iOS zoom on focus */
  min-width: 0;
  line-height: 1.3;
}

.search-input-wrapper input::placeholder {
  color: var(--text-muted);
}

/* Clear/X button on inputs */
.input-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.input-clear-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
}

.input-clear-btn.hidden {
  display: none;
}

.input-clear-btn svg {
  width: 14px;
  height: 14px;
}

.search-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
}

.locate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.locate-btn:active {
  color: var(--accent);
  background: var(--accent-dim);
}

.locate-btn.active {
  color: var(--accent);
}

.locate-btn svg {
  width: 20px;
  height: 20px;
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.search-btn:active {
  background: var(--accent-hover);
  transform: scale(0.95);
}

.search-btn svg {
  width: 22px;
  height: 22px;
}

/* Fuel type chip buttons in search bar */
.search-fuel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  min-height: 44px;
}

.fuel-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 36px;
  min-width: 44px;
}

.fuel-chip:active {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.fuel-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ========== Autocomplete Dropdown ========== */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
  display: none;
}

.autocomplete-dropdown.visible {
  display: block;
}

.dropdown-item {
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.1s;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dropdown-item:active {
  background: var(--bg-tertiary);
}

.dropdown-item + .dropdown-item {
  border-top: 1px solid var(--border);
}

.dropdown-item-main {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.dropdown-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== Map Pins ========== */
.map-pin {
  cursor: pointer;
}

.map-pin svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ========== Route Summary ========== */
.route-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.route-summary-dot {
  color: var(--text-muted);
}

/* ========== Station Card ========== */
.station-card {
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
}

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

.station-card .station-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.station-card .station-address {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.station-card .station-price {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.station-card .station-price .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.station-card .station-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.loading-shimmer {
  color: #888;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Skeleton loading cards */
.station-card-skeleton {
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.skeleton-line {
  height: 14px;
  background: var(--bg-hover);
  border-radius: 6px;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.long { width: 100%; }
.skeleton-line.price { height: 28px; width: 40%; margin: 10px 0; }
.skeleton-line + .skeleton-line { margin-top: 8px; }

/* Price tier colors on cards — traffic light: green/amber/red */
.station-card.price-cheap { border-color: #22c55e; }
.station-card.price-mid { border-color: #f59e0b; }
.station-card.price-expensive { border-color: #ef4444; }

.station-card.price-cheap .station-price { color: #22c55e; }
.station-card.price-mid .station-price { color: #f59e0b; }
.station-card.price-expensive .station-price { color: #ef4444; }

.station-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

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

.station-saving {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Saving badge matches price tier color */
.station-saving.price-cheap { color: #22c55e; background: rgba(34, 197, 94, 0.15); }
.station-saving.price-mid { color: #f59e0b; background: rgba(245, 158, 11, 0.15); }
.station-saving.price-expensive { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

/* ========== Station Map Markers ========== */
.station-marker {
  background: var(--bg-secondary);
  border: 2.5px solid var(--accent);
  border-radius: 10px 10px 10px 0;
  padding: 6px 10px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  min-height: 36px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Price tier colors — traffic light */
.station-marker.price-cheap { border-color: #22c55e; }
.station-marker.price-mid { border-color: #f59e0b; }
.station-marker.price-expensive { border-color: #ef4444; }

.station-marker.price-cheap .station-marker-price { color: #22c55e; }
.station-marker.price-mid .station-marker-price { color: #f59e0b; }
.station-marker.price-expensive .station-marker-price { color: #ef4444; }

.station-marker.selected {
  transform: scale(1.3);
}

.station-marker.selected.price-cheap { background: #22c55e; }
.station-marker.selected.price-mid { background: #f59e0b; }
.station-marker.selected.price-expensive { background: #ef4444; }

.station-marker-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.station-marker.selected .station-marker-price {
  color: white;
}

/* ========== Station Info Card (fixed top-right) ========== */
.station-info-card {
  position: fixed;
  top: calc(90px + var(--sat));
  right: 16px;
  z-index: 11;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: var(--text-primary);
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  min-width: 200px;
  max-width: 280px;
  backdrop-filter: blur(20px);
}

.station-info-card.hidden {
  display: none;
}

.station-info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-info-close svg {
  width: 14px;
  height: 14px;
}

.station-info-close:active {
  background: var(--bg-hover);
}

.station-info-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  padding-right: 28px;
}

.station-info-address {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.station-info-detour {
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-weight: 500;
}

.station-info-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.station-info-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.station-info-price small {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.station-info-go {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 48px;
  min-width: 72px;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
}

.station-info-go:active {
  background: var(--accent-hover);
  transform: scale(0.95);
}

/* ========== Results Panel ========== */
.results-panel {
  position: fixed;
  top: 88px;
  left: 16px;
  z-index: 10;
  width: 360px;
  max-height: calc(100vh - 104px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
}

.panel-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}

.panel-filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: 22px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 40px;
}

.filter-btn:active {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 200px;
  -webkit-overflow-scrolling: touch;
}

.panel-content::-webkit-scrollbar {
  width: 4px;
}

.panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 12px;
}

.empty-icon {
  font-size: 36px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.fuel-type-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.fuel-select {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.fuel-select:focus {
  border-color: var(--accent);
}

.fuel-select option {
  background: var(--bg-secondary);
}

/* ========== View Mode Toggle ========== */
.view-toggle {
  position: fixed;
  bottom: calc(20px + var(--sab));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.view-toggle.hidden {
  display: none;
}

.view-toggle-btn {
  padding: 10px 22px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  min-height: 44px;
}

.view-toggle-btn.active {
  background: var(--accent);
  color: white;
}

/* ========== Panel Pill (mobile bottom sheet handle) ========== */
.panel-pill {
  display: none;
  padding: 12px 0 6px;
  cursor: grab;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

.panel-pill-handle {
  width: 40px;
  height: 5px;
  background: rgba(255,255,255,0.35);
  border-radius: 3px;
  margin: 0 auto;
}

/* ========== Locate Me FAB (floating action button) ========== */
.locate-me-fab {
  display: none; /* shown on mobile */
  position: fixed;
  z-index: 9;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: color 0.15s, background 0.15s;
}

.locate-me-fab:active {
  color: var(--accent);
  background: var(--accent-dim);
}

.locate-me-fab svg {
  width: 22px;
  height: 22px;
}

/* ========== User Location Marker ========== */
.user-location-marker {
  width: 24px;
  height: 24px;
  position: relative;
}

.user-location-dot {
  width: 16px;
  height: 16px;
  background: #4285f4;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(66, 133, 244, 0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.user-location-pulse {
  width: 44px;
  height: 44px;
  background: rgba(66, 133, 244, 0.2);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* ========== Go Button on Station Cards ========== */
.station-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.station-card-top .station-card-info {
  flex: 1;
  min-width: 0;
}

.station-card-top .station-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.station-card-top .station-address {
  font-size: 13px;
  color: var(--text-secondary);
}

.station-go-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  min-height: 44px;
  min-width: 72px;
}

.station-go-btn:active {
  background: var(--accent-hover);
  transform: scale(0.95);
}

.station-go-btn svg {
  width: 16px;
  height: 16px;
}

/* ========== Navigation UI ========== */
.nav-ui {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

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

.nav-ui.hidden {
  display: none;
}

/* ---- Navigation Back Button ---- */
.nav-back-btn {
  position: absolute;
  top: calc(8px + var(--sat));
  left: 12px;
  z-index: 25;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(26, 29, 39, 0.85);
  border: 1px solid var(--border);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.nav-back-btn:active {
  background: rgba(26, 29, 39, 1);
}

.nav-back-btn svg {
  width: 20px;
  height: 20px;
}

/* ---- Fuel Reminder Banner ---- */
.nav-fuel-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  padding: calc(12px + var(--sat)) 16px 12px 60px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 22;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
  line-height: 1.3;
}

.nav-fuel-icon {
  font-size: 18px;
}

/* ---- Turn Instruction Banner ---- */
.nav-instruction {
  position: absolute;
  top: calc(56px + var(--sat));
  left: 16px;
  right: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  z-index: 21;
  backdrop-filter: blur(20px);
}

.nav-instruction.hidden {
  display: none;
}

.nav-maneuver {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-instruction-info {
  flex: 1;
  min-width: 0;
}

.nav-instruction-distance {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.nav-instruction-text {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-weight: 500;
}

/* ---- Lane Guidance ---- */
.nav-lanes {
  position: absolute;
  top: calc(170px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  z-index: 21;
}

.nav-lanes.hidden {
  display: none;
}

.nav-lane {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 29, 39, 0.85);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 18px;
  backdrop-filter: blur(10px);
}

.nav-lane:first-child {
  border-radius: 8px 0 0 8px;
}

.nav-lane:last-child {
  border-radius: 0 8px 8px 0;
}

.nav-lane.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---- Rerouting Indicator ---- */
.nav-rerouting {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  z-index: 25;
}

.nav-rerouting.hidden {
  display: none;
}

.nav-rerouting-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin 0.8s linear infinite;
}

/* ---- Bottom Bar ---- */
.nav-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 18px 20px calc(18px + var(--sab));
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 22;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.nav-stats {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-stat {
  text-align: center;
}

.nav-stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.nav-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
  font-weight: 600;
}

.nav-stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.nav-btn:active {
  transform: scale(0.93);
}

.nav-mute-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-mute-btn:active {
  background: var(--bg-hover);
}

.nav-mute-btn.muted {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.nav-mute-btn svg {
  width: 22px;
  height: 22px;
}

.nav-stop-btn {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  background: #ef4444;
  color: white;
  font-size: 16px;
  font-weight: 700;
  min-height: 48px;
}

.nav-stop-btn:active {
  background: #dc2626;
}

/* ---- Arrival Overlay ---- */
.nav-arrival {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  backdrop-filter: blur(8px);
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}

.nav-arrival.hidden {
  display: none;
}

.nav-arrival-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 36px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: var(--shadow);
}

.nav-arrival-check {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 20px;
}

.nav-arrival-card h3 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.nav-arrival-card p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.nav-arrival-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-continue-btn {
  padding: 14px 24px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 700;
  width: 100%;
  min-height: 48px;
}

.nav-continue-btn:active {
  background: var(--accent-hover);
}

.nav-continue-btn.hidden {
  display: none;
}

.nav-done-btn {
  padding: 14px 24px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  min-height: 48px;
}

.nav-done-btn:active {
  background: var(--bg-hover);
}

/* ========== Hidden Utility ========== */
.search-bar.hidden,
.results-panel.hidden,
.panel-toggle.hidden {
  display: none !important;
}

/* ========== Responsive: Mobile ========== */
@media (max-width: 768px) {
  /* Search bar: stacked layout */
  .search-bar {
    top: calc(8px + var(--sat));
    width: calc(100% - 16px);
    align-items: stretch;
    padding: 8px;
  }

  .search-bar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .search-logo {
    display: none;
  }

  .search-fields {
    flex-direction: column;
    align-items: stretch;
  }

  .search-divider {
    width: 100%;
    height: 1px;
    margin: 0;
  }

  .search-btn {
    align-self: center;
    margin-top: 2px;
  }

  /* Map markers: larger for touch */
  .station-marker {
    min-height: 38px;
    min-width: 56px;
    padding: 8px 12px;
  }

  .station-marker-price {
    font-size: 14px;
  }

  /* Results panel: bottom sheet with 3 snap points */
  .results-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100dvh - var(--sat) - 60px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 10;
    will-change: transform;
  }

  /* Snap point: collapsed — just handle visible */
  .results-panel {
    transform: translateY(calc(100% - 44px - var(--sab)));
  }

  /* Snap point: half-screen — see results + map */
  .results-panel.snap-half {
    transform: translateY(50%);
  }

  /* Snap point: full-screen — scrollable list */
  .results-panel.expanded {
    transform: translateY(0);
  }

  /* Panel pill */
  .panel-pill {
    display: block;
  }

  /* Autocomplete: position above keyboard */
  .autocomplete-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 8px;
    right: 8px;
    max-height: 50vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 200;
    -webkit-overflow-scrolling: touch;
  }

  /* Station info card on mobile: below search bar */
  .station-info-card {
    top: auto;
    bottom: calc(60px + var(--sab));
    right: 12px;
    left: 12px;
    max-width: none;
  }

  /* View toggle */
  .view-toggle {
    bottom: calc(52px + var(--sab));
    z-index: 9;
  }

  /* Locate me FAB: bottom-right in thumb reach */
  .locate-me-fab {
    display: flex;
    bottom: calc(52px + var(--sab));
    right: calc(16px + var(--sar));
  }

  /* Hide locate button inside search (use FAB instead) */
  .locate-btn {
    display: none;
  }

  /* Navigation responsive adjustments */
  .nav-fuel-banner {
    padding: calc(10px + var(--sat)) 14px 10px 60px;
    font-size: 13px;
  }

  .nav-instruction {
    top: calc(52px + var(--sat));
    left: 12px;
    right: 12px;
    padding: 14px 16px;
    gap: 14px;
  }

  .nav-maneuver {
    width: 48px;
    height: 48px;
  }

  .nav-instruction-distance {
    font-size: 28px;
  }

  .nav-instruction-text {
    font-size: 15px;
  }

  .nav-bottom {
    padding: 14px 16px calc(14px + var(--sab));
  }

  .nav-stat-value {
    font-size: 22px;
  }

  .nav-stop-btn {
    padding: 10px 22px;
    font-size: 15px;
    min-height: 44px;
  }

  .nav-back-btn {
    top: calc(6px + var(--sat));
  }

  .nav-lanes {
    top: calc(156px + var(--sat));
  }

  /* Station cards: slightly more padding for touch */
  .station-card {
    padding: 18px;
    margin-bottom: 12px;
  }

  .panel-content {
    padding: 14px 16px calc(14px + var(--sab));
  }
}

/* ========== iPhone SE / small phones ========== */
@media (max-width: 375px) {
  .search-input-wrapper {
    min-height: 44px;
    padding: 4px 8px;
  }

  .search-input-wrapper input {
    font-size: 15px;
  }

  .fuel-chip {
    padding: 6px 10px;
    font-size: 12px;
    min-width: 38px;
  }

  .station-card .station-price {
    font-size: 24px;
  }

  .nav-instruction-distance {
    font-size: 24px;
  }

  .nav-stat-value {
    font-size: 20px;
  }
}

/* ========== iPhone 15 Pro Max / large phones ========== */
@media (min-width: 414px) and (max-width: 768px) {
  .station-card .station-price {
    font-size: 30px;
  }

  .nav-instruction-distance {
    font-size: 34px;
  }

  .nav-stat-value {
    font-size: 26px;
  }
}

/* ========== Reduce motion preference ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
