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

body {
  display: flex;
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: #0a0a0a;
  color: #f0f0f0;
}

/* ── Sidebar ── */
#sidebar {
  width: 340px;
  min-width: 340px;
  background: linear-gradient(160deg, #161616 0%, #111111 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 13px 16px;
  overflow-y: auto;
  overflow-x: visible;
  position: relative;
  z-index: 1001;
  border-right: 1px solid rgba(255,255,255,0.05);
  box-shadow: 4px 0 32px rgba(0,0,0,0.6);
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }
#sidebar::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ── Loading bar ── */
#loading-bar {
  height: 2px;
  width: 100%;
  border-radius: 1px;
  overflow: hidden;
  flex-shrink: 0;
  margin-bottom: -8px;
  background: transparent;
}

#loading-bar.active {
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 15%,
    #4ade80 40%,
    #86efac 50%,
    #4ade80 60%,
    transparent 85%,
    transparent 100%
  );
  background-size: 250% 100%;
  animation: shimmerSlide 1.1s linear infinite;
}

@keyframes shimmerSlide {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Header ── */
#header {
  padding: 2px 2px 4px;
}

#header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, #4ade80 0%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glowPulse 4s ease-in-out infinite;
  display: inline-block;
}

@keyframes glowPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(74,222,128,0.2)); }
  50%       { filter: drop-shadow(0 0 14px rgba(74,222,128,0.55)) drop-shadow(0 0 28px rgba(34,211,238,0.2)); }
}

#tagline {
  font-size: 11px;
  color: #444;
  margin-top: 3px;
  letter-spacing: 0.3px;
}

/* ── Route card ── */
#route-card {
  background: rgba(255,255,255,0.04);
  border-radius: 22px;
  padding: 4px 10px 4px 13px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: border-color 0.25s, box-shadow 0.25s;
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 50;
}

#route-card:focus-within {
  border-color: rgba(74,222,128,0.25);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.08), 0 4px 20px rgba(0,0,0,0.3);
}

/* Left icon column */
#route-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 15px;
  flex-shrink: 0;
}

.r-origin {
  width: 10px;
  height: 10px;
  border: 2.5px solid #22d3ee;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(34,211,238,0.4);
}

.r-line {
  width: 2px;
  flex: 1;
  min-height: 16px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.2) 0px, rgba(255,255,255,0.2) 3px,
    transparent 3px, transparent 7px
  );
  margin: 5px 0;
}

.r-dest {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(239,68,68,0.5);
}

/* Inputs */
#route-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#route-fields .search-wrapper { position: relative; }

#route-fields input {
  width: 100%;
  padding: 14px 0;
  background: transparent;
  border: none;
  color: #eee;
  font-size: 13.5px;
  outline: none;
  letter-spacing: 0.1px;
}

#route-fields input::placeholder { color: #3d3d3d; }

.field-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 0 2px;
}

/* Swap button */
#swap-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

#swap-btn:hover {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.3);
  color: #4ade80;
}

#swap-btn.swapping { animation: swapSpin 0.35s cubic-bezier(0.34,1.56,0.64,1); }

@keyframes swapSpin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(90deg) scale(0.85); }
  100% { transform: rotate(180deg) scale(1); }
}

/* ── Travel mode selector ── */
#mode-selector {
  display: flex;
  gap: 6px;
  padding: 0 1px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  color: #555;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.1px;
}

.mode-btn span {
  font-size: 12px;
}

.mode-btn:hover {
  background: rgba(74,222,128,0.07);
  border-color: rgba(74,222,128,0.2);
  color: #bbb;
}

.mode-btn.active {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.35);
  color: #4ade80;
  box-shadow: 0 0 12px rgba(74,222,128,0.12);
}

/* ── Route delay toggles ── */
#route-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 1px;
}

.rtoggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  user-select: none;
}

.rtoggle:hover {
  background: rgba(255,255,255,0.05);
}

.rtoggle-icon  { font-size: 14px; flex-shrink: 0; }

.rtoggle-label {
  flex: 1;
  font-size: 12.5px;
  font-weight: 500;
  color: #888;
  transition: color 0.18s;
}

/* The actual checkbox is hidden; we use the track span */
.rtoggle-switch { position: relative; flex-shrink: 0; }

.rtoggle-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.rtoggle-track {
  display: block;
  width: 38px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 11px;
  position: relative;
  transition: background 0.22s, box-shadow 0.22s;
}

.rtoggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #555;
  border-radius: 50%;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), background 0.22s;
}

/* Checked state */
.rtoggle-switch input:checked + .rtoggle-track {
  background: rgba(74,222,128,0.25);
  box-shadow: 0 0 10px rgba(74,222,128,0.2);
}

.rtoggle-switch input:checked + .rtoggle-track::after {
  transform: translateX(16px);
  background: #4ade80;
}

/* Highlight label when enabled */
.rtoggle:has(input:checked) .rtoggle-label { color: #ccc; }

/* ── Add-stop row ── */
#add-stop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 1px;
}

.stop-icon-col {
  width: 22px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.stop-dot {
  width: 8px;
  height: 8px;
  border: 2px dashed rgba(74,222,128,0.35);
  border-radius: 50%;
}

#stop-wrapper { flex: 1; position: relative; }

#stop-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  color: #aaa;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

#stop-input:focus {
  border-color: rgba(74,222,128,0.4);
  color: #f0f0f0;
  box-shadow: 0 0 0 3px rgba(74,222,128,0.08);
}

#stop-input::placeholder { color: #333; }

/* ── Autocomplete dropdown ── */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: -14px;
  right: -44px;
  background: #1c1c1c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  overflow: hidden;
  z-index: 9999;
  box-shadow: 0 16px 48px rgba(0,0,0,0.85), 0 0 0 1px rgba(74,222,128,0.06);
}

.search-dropdown:not(.hidden) {
  animation: dropdownIn 0.16s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes dropdownIn {
  0%   { opacity: 0; transform: translateY(-8px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#stop-dropdown { left: 0; right: 0; }

.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 15px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-left: 2.5px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.dropdown-item:last-child { border-bottom: none; }

.dropdown-item:hover,
.dropdown-item.active {
  background: rgba(74,222,128,0.06);
  border-left-color: #4ade80;
}

.dropdown-icon {
  font-size: 14px;
  margin-top: 1px;
  flex-shrink: 0;
  opacity: 0.75;
}

.dropdown-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dropdown-name {
  font-size: 13px;
  font-weight: 600;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-address {
  font-size: 11px;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Instructions ── */
#instructions p {
  font-size: 12.5px;
  color: #555;
  line-height: 1.6;
  padding: 11px 14px;
  background: rgba(74,222,128,0.04);
  border-radius: 14px;
  border: 1px solid rgba(74,222,128,0.1);
}

/* ── Route Info ── */
#route-info:not(.hidden) {
  animation: fadeInUp 0.28s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes fadeInUp {
  0%   { opacity: 0; transform: translateY(8px) scale(0.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

#route-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 9px;
}

/* Register the custom property so CSS can animate it */
@property --stat-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes rotateStat { to { --stat-angle: 360deg; } }

.stat {
  flex: 1;
  background: linear-gradient(145deg, rgba(74,222,128,0.08) 0%, rgba(10,10,10,0.6) 100%);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
  border: 1px solid rgba(74,222,128,0.15);
  transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
  cursor: default;
  position: relative;
  isolation: isolate;
}

/* Top edge shimmer (always visible) */
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(74,222,128,0.4), transparent);
  pointer-events: none;
}

/* Rotating glow border on hover — conic gradient masked to border-only strip */
.stat::before {
  content: '';
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: 19px;
  background: conic-gradient(
    from var(--stat-angle),
    transparent 0%,
    transparent 30%,
    #4ade80 48%,
    #22d3ee 58%,
    #4ade80 70%,
    transparent 88%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box,
                linear-gradient(#fff 0 0);
  mask:         linear-gradient(#fff 0 0) content-box,
                linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.stat:hover::before {
  opacity: 1;
  animation: rotateStat 2.2s linear infinite;
}

.stat:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 8px 28px rgba(74,222,128,0.18), 0 0 0 0 transparent;
  border-color: transparent;
}

.stat-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #4a4a4a;
  margin-bottom: 5px;
}

.stat-value {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: #4ade80;
  letter-spacing: -0.3px;
}

/* ── Traffic note ── */
#traffic-note {
  font-size: 10.5px;
  color: #3a3a3a;
  margin-bottom: 9px;
  padding: 0 2px;
  letter-spacing: 0.1px;
}

/* ── Waypoint list ── */
#waypoint-list label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #3a3a3a;
  margin-bottom: 7px;
  padding: 0 2px;
}

#waypoints-ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

#waypoints-ul li {
  font-size: 12px;
  color: #999;
  padding: 9px 12px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,0.06);
  animation: fadeSlideIn 0.22s cubic-bezier(0.34,1.56,0.64,1) both;
  transition: background 0.15s;
}

#waypoints-ul li:hover { background: rgba(255,255,255,0.05); }

#waypoints-ul li:nth-child(1)  { animation-delay: 0ms;   }
#waypoints-ul li:nth-child(2)  { animation-delay: 40ms;  }
#waypoints-ul li:nth-child(3)  { animation-delay: 80ms;  }
#waypoints-ul li:nth-child(4)  { animation-delay: 120ms; }
#waypoints-ul li:nth-child(5)  { animation-delay: 160ms; }
#waypoints-ul li:nth-child(n+6){ animation-delay: 200ms; }

@keyframes fadeSlideIn {
  0%   { opacity: 0; transform: translateY(-5px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.wp-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ccc;
  font-size: 12.5px;
}

.wp-time {
  font-size: 11px;
  font-weight: 700;
  color: #4ade80;
  flex-shrink: 0;
  background: rgba(74,222,128,0.1);
  padding: 2px 7px;
  border-radius: 20px;
}

.wp-remove {
  background: none;
  border: none;
  color: #333;
  font-size: 15px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.wp-remove:hover { color: #ef4444; }

#waypoints-ul li .wp-num {
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  color: #0a0a0a;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(74,222,128,0.3);
}

#waypoints-ul li.destination .wp-num {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 8px rgba(245,158,11,0.3);
}

/* ── Action buttons ── */
#action-buttons { display: flex; gap: 8px; }

.secondary-btn {
  flex: 1;
  padding: 11px;
  background: rgba(255,255,255,0.04);
  color: #555;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.1px;
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  color: #ddd;
  border-color: rgba(255,255,255,0.12);
}

.secondary-btn:active:not(:disabled) { transform: scale(0.96); }

.secondary-btn:disabled { opacity: 0.25; cursor: not-allowed; }

#clear-btn:hover:not(:disabled) {
  background: rgba(239,68,68,0.08);
  color: #ef4444;
  border-color: rgba(239,68,68,0.25);
}

/* ── Status bar ── */
#status-bar {
  margin-top: auto;
  padding: 9px 14px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  transition: border-color 0.3s, background 0.3s;
}

#status-bar.success {
  border-color: rgba(74,222,128,0.25);
  background: rgba(74,222,128,0.04);
}

#status-bar.error {
  border-color: rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.04);
}

#status-text {
  font-size: 11.5px;
  color: #444;
  transition: color 0.3s;
}

#status-bar.success #status-text { color: #4ade80; }
#status-bar.error   #status-text { color: #ef4444; }

/* ── Map ── */
#map { flex: 1; height: 100vh; position: relative; z-index: 0; overflow: hidden; }

/* ── Map controls ── */
/* ── Map top-right controls (view toggles) ── */
#map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 999;
  display: flex;
  flex-direction: row;
  gap: 7px;
}

#map-controls button {
  background: rgba(10,10,10,0.88);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 22px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: all 0.2s;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  color: #bbb;
  letter-spacing: 0.1px;
}

#map-controls button:hover {
  background: rgba(30,30,30,0.95);
  border-color: rgba(255,255,255,0.18);
  color: #fff;
}

#layer-btn.active {
  background: rgba(74,222,128,0.18);
  color: #4ade80;
  border-color: rgba(74,222,128,0.4);
  box-shadow: 0 4px 16px rgba(74,222,128,0.15);
}

#legend-btn.active {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.22);
  color: #fff;
}

/* ── Map bottom-right actions (locate + track) ── */
#map-actions {
  position: absolute;
  bottom: 24px;
  right: 14px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#map-actions button {
  background: rgba(10,10,10,0.88);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  transition: all 0.2s;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#locate-btn { color: #4ade80; }
#locate-btn:hover {
  background: rgba(74,222,128,0.15);
  border-color: rgba(74,222,128,0.4);
  transform: scale(1.08);
  box-shadow: 0 0 14px rgba(74,222,128,0.25), 0 4px 16px rgba(0,0,0,0.5);
}

#track-btn { color: #f87171; }

/* ── Map legend panel ── */
#map-legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 1000;
  background: rgba(8,8,8,0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 14px 16px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.04);
  min-width: 180px;
  animation: hudSlideIn 0.25s cubic-bezier(0.34,1.3,0.64,1);
}

.legend-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #444;
  margin-bottom: 11px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.legend-item span:last-child {
  font-size: 12px;
  color: #999;
}

.legend-sym {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.7);
  display: block;
}

.legend-line {
  width: 24px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
  display: block;
}

.legend-dash {
  width: 28px;
  height: 0;
  flex-shrink: 0;
  border-top: 3px dashed #c4b5fd;
  filter: drop-shadow(0 0 4px rgba(196,181,253,0.6));
  margin: 1px 0;
}

/* Signal and stop legend icons */
.signal-sym, .stop-sym {
  font-size: 16px;
  width: 20px;
  height: 20px;
  border: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 !important;
  background: transparent !important;
}

/* ── Traffic signal map markers ── */
.signal-marker {
  width: 26px;
  height: 26px;
  background: rgba(251,191,36,0.95);
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 0 0 0 rgba(251,191,36,0.7);
  animation: signalPulse 2.5s ease-in-out infinite;
}

@keyframes signalPulse {
  0%   { box-shadow: 0 0 6px 0px  rgba(251,191,36,0.7), 0 2px 8px rgba(0,0,0,0.5); }
  50%  { box-shadow: 0 0 14px 4px rgba(251,191,36,0.9), 0 2px 8px rgba(0,0,0,0.5); }
  100% { box-shadow: 0 0 6px 0px  rgba(251,191,36,0.7), 0 2px 8px rgba(0,0,0,0.5); }
}

/* ── Stop sign map markers ── */
.stop-marker {
  width: 26px;
  height: 26px;
  background: rgba(239,68,68,0.95);
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  animation: stopGlow 1.6s ease-in-out infinite;
}

@keyframes stopGlow {
  0%   { box-shadow: 0 0 8px  2px rgba(239,68,68,0.8),  0 0 20px 0px rgba(239,68,68,0.3),  0 2px 8px rgba(0,0,0,0.5); }
  50%  { box-shadow: 0 0 18px 6px rgba(239,68,68,1),    0 0 40px 8px rgba(239,68,68,0.45), 0 2px 8px rgba(0,0,0,0.5); }
  100% { box-shadow: 0 0 8px  2px rgba(239,68,68,0.8),  0 0 20px 0px rgba(239,68,68,0.3),  0 2px 8px rgba(0,0,0,0.5); }
}

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

/* ── Track button states ── */
#track-btn:hover {
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.4);
  transform: scale(1.08);
  box-shadow: 0 0 14px rgba(239,68,68,0.25), 0 4px 16px rgba(0,0,0,0.5);
}

#track-btn.recording {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.55);
  color: #ef4444;
  animation: trackBtnPulse 1.4s ease-in-out infinite;
}

@keyframes trackBtnPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 8px rgba(239,68,68,0.3); }
  50%       { box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 22px rgba(239,68,68,0.65); }
}

/* ── Journey tracking HUD ── */
#track-hud {
  position: absolute;
  bottom: 170px;
  right: 14px;
  z-index: 1000;
  background: rgba(8,8,8,0.9);
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: 20px;
  padding: 14px 16px 12px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(239,68,68,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
  min-width: 210px;
  animation: hudSlideIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes hudSlideIn {
  0%   { opacity: 0; transform: translateX(12px) scale(0.95); }
  100% { opacity: 1; transform: translateX(0)   scale(1); }
}

#track-hud-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 13px;
}

.track-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  flex-shrink: 0;
  animation: trackDotPulse 1s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.6);
}

@keyframes trackDotPulse {
  0%   { box-shadow: 0 0 0 0   rgba(239,68,68,0.6); }
  50%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0   rgba(239,68,68,0); }
}

#track-hud-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.8px;
  color: #ef4444;
  text-transform: uppercase;
}

#track-hud-stats {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.track-stat {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 9px 6px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.05);
}

.track-stat-val {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: #f0f0f0;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.track-stat-label {
  display: block;
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #3a3a3a;
  margin-top: 3px;
}

#track-stop-btn {
  width: 100%;
  padding: 9px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.28);
  border-radius: 12px;
  color: #f87171;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 0.2px;
}

#track-stop-btn:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.5);
  color: #ef4444;
  box-shadow: 0 0 14px rgba(239,68,68,0.2);
}

/* ── Map markers ── */
.wp-marker {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  border: 2.5px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #0a0a0a;
  box-shadow: 0 3px 12px rgba(74,222,128,0.5), 0 1px 4px rgba(0,0,0,0.5);
  animation: markerDrop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

.dest-marker {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 2.5px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 3px 14px rgba(239,68,68,0.55), 0 1px 4px rgba(0,0,0,0.5);
  animation: markerDrop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes markerDrop {
  0%   { transform: translateY(-18px) scale(0.6); opacity: 0; }
  60%  { transform: translateY(4px) scale(1.08); opacity: 1; }
  80%  { transform: translateY(-2px) scale(0.97); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.start-marker {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px rgba(34,211,238,0.7)) drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  animation: markerDrop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}

.start-marker svg { width: 34px; height: 34px; }

/* GPS navigation arrow */
.gps-arrow-wrap {
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 0 8px rgba(59,130,246,0.8)) drop-shadow(0 0 16px rgba(59,130,246,0.4));
  animation: gpsPulse 2.2s ease-in-out infinite;
  transition: transform 0.3s ease;
}
.gps-dot { display: none; } /* kept for safety */

@keyframes gpsPulse {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.6); }
  50%  { box-shadow: 0 0 0 9px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}

/* ── Route line glow ── */
.route-line-crisp {
  animation: routeGlow 3s ease-in-out infinite;
}

@keyframes routeGlow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(74,222,128,0.7)) drop-shadow(0 0 10px rgba(74,222,128,0.3)); }
  50%       { filter: drop-shadow(0 0 10px rgba(74,222,128,1)) drop-shadow(0 0 24px rgba(74,222,128,0.55)) drop-shadow(0 0 48px rgba(74,222,128,0.2)); }
}

/* ── Header with menu button ── */
#header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

#menu-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  width: 36px;
  height: 36px;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#menu-btn:hover {
  background: rgba(74,222,128,0.1);
  color: #4ade80;
  border-color: rgba(74,222,128,0.3);
  box-shadow: 0 0 12px rgba(74,222,128,0.15);
}

/* ── Main Menu Panel ── */
#menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

#menu-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

#menu-panel {
  position: fixed;
  left: 0; top: 0;
  width: 340px;
  height: 100vh;
  background: linear-gradient(160deg, #0e0e0e 0%, #0a0a0a 100%);
  z-index: 2000;
  transform: translateX(-100%);
  transition: transform 0.38s cubic-bezier(0.34, 1.2, 0.64, 1);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(74,222,128,0.08);
  box-shadow: 6px 0 60px rgba(0,0,0,0.9), inset -1px 0 0 rgba(74,222,128,0.05);
}

#menu-panel.open {
  transform: translateX(0);
}

#menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  background: rgba(74,222,128,0.02);
}

#menu-brand h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.8px;
  background: linear-gradient(135deg, #4ade80 0%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(74,222,128,0.4));
}

#menu-brand p {
  font-size: 11px;
  color: #3a3a3a;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

#menu-close {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  width: 34px; height: 34px;
  color: #555;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

#menu-close:hover {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border-color: rgba(239,68,68,0.3);
}

#menu-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
  scrollbar-color: #1e1e1e transparent;
}

.menu-section {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  color: #2a2a2a;
  text-transform: uppercase;
  padding: 16px 4px 7px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 15px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  color: #bbb;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  margin-bottom: 3px;
  letter-spacing: 0.1px;
}

.menu-item:hover {
  background: rgba(74,222,128,0.07);
  border-color: rgba(74,222,128,0.2);
  color: #eee;
  transform: translateX(3px);
  box-shadow: 0 2px 12px rgba(74,222,128,0.08);
}

.menu-icon { font-size: 17px; flex-shrink: 0; }
.menu-label { flex: 1; }

.menu-arrow {
  font-size: 20px;
  color: #2e2e2e;
  transition: transform 0.18s, color 0.18s;
}

.menu-item:hover .menu-arrow {
  transform: translateX(4px);
  color: #4ade80;
}

/* Settings row */
.menu-setting {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  margin-bottom: 3px;
}

.menu-setting .menu-label {
  flex: 1;
  font-size: 13.5px;
  color: #bbb;
  font-weight: 500;
}

.toggle-group {
  display: flex;
  background: rgba(0,0,0,0.4);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.toggle-opt {
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #444;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-opt.active {
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  color: #0a0a0a;
  box-shadow: 0 0 10px rgba(74,222,128,0.4);
}

/* Saved route cards */
.saved-route-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.18s;
  margin-bottom: 3px;
}

.saved-route-card:hover {
  background: rgba(74,222,128,0.06);
  border-color: rgba(74,222,128,0.18);
  transform: translateX(3px);
}

.saved-route-info { flex: 1; min-width: 0; }

.saved-route-name {
  font-size: 13px;
  font-weight: 600;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-route-meta {
  font-size: 11px;
  color: #3a3a3a;
  margin-top: 2px;
}

.saved-route-delete {
  background: none;
  border: none;
  color: #2a2a2a;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 7px;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.saved-route-delete:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

.menu-empty {
  font-size: 12px;
  color: #2a2a2a;
  text-align: center;
  padding: 18px;
  font-style: italic;
  border: 1px dashed rgba(255,255,255,0.05);
  border-radius: 12px;
}

#menu-footer {
  margin-top: auto;
  padding: 20px 4px 4px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

#menu-footer p {
  font-size: 10.5px;
  color: #252525;
  line-height: 1.8;
}

/* ── Leaflet zoom button overrides ── */
.leaflet-bar {
  border: none !important;
  border-radius: 16px !important;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.05) !important;
}

.leaflet-bar a {
  background: rgba(10,10,10,0.88) !important;
  color: #aaa !important;
  border: none !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  font-size: 20px !important;
  font-weight: 300 !important;
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s !important;
  display: block !important;
  text-align: center !important;
}

.leaflet-bar a:last-child {
  border-bottom: none !important;
}

.leaflet-bar a:hover {
  background: rgba(74,222,128,0.14) !important;
  color: #4ade80 !important;
  box-shadow: inset 0 0 0 1px rgba(74,222,128,0.3) !important;
}

.leaflet-bar a.leaflet-disabled {
  opacity: 0.25 !important;
}

.leaflet-control-zoom {
  margin: 16px 0 0 16px !important;
}

/* Leaflet attribution */
.leaflet-control-attribution {
  background: rgba(0,0,0,0.6) !important;
  backdrop-filter: blur(8px) !important;
  border-radius: 8px 0 0 0 !important;
  color: #333 !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a { color: #3a3a3a !important; }

/* ── Menu Hero ── */
#menu-hero {
  padding: 36px 20px 24px;
  background: radial-gradient(ellipse at top left, rgba(74,222,128,0.08) 0%, transparent 60%);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  position: relative;
}

#menu-hero #menu-close {
  position: absolute;
  top: 20px;
  right: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  width: 34px; height: 34px;
  color: #555;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

#menu-hero #menu-close:hover {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border-color: rgba(239,68,68,0.3);
}

#menu-logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1.5px;
  background: linear-gradient(135deg, #4ade80 0%, #22d3ee 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 18px rgba(74,222,128,0.5));
  display: inline-block;
}

/* ── Primary CTA Button ── */
.menu-primary-btn {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, #4ade80 0%, #22d3ee 100%);
  color: #0a0a0a;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(74,222,128,0.35), 0 4px 16px rgba(0,0,0,0.4);
  transition: all 0.2s;
  letter-spacing: 0.2px;
  margin-bottom: 4px;
}

.menu-primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(74,222,128,0.55), 0 8px 24px rgba(0,0,0,0.5);
}

.menu-primary-btn:active { transform: translateY(0); }

/* ── Quick-action grid ── */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}

.menu-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 16px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
  color: #bbb;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-grid-item:hover {
  transform: translateY(-2px);
  background: rgba(74,222,128,0.07);
  border-color: rgba(74,222,128,0.3);
  box-shadow: 0 4px 16px rgba(74,222,128,0.1);
}

.grid-icon { font-size: 26px; line-height: 1; }
.grid-label { font-size: 12px; color: #bbb; font-weight: 500; }

/* ── Lifetime stats ── */
#menu-lifetime-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.mstat {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
}

.mstat-val {
  font-size: 16px;
  font-weight: 700;
  color: #4ade80;
  margin-bottom: 3px;
}

.mstat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #3a3a3a;
}

/* ── Section headers ── */
.menu-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 7px;
}

.menu-section-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  color: #2a2a2a;
  text-transform: uppercase;
}

.menu-section-btn {
  font-size: 11px;
  font-weight: 600;
  color: #4ade80;
  background: rgba(74,222,128,0.08);
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.menu-section-btn:hover {
  background: rgba(74,222,128,0.18);
  border-color: rgba(74,222,128,0.4);
}

/* ── Help steps ── */
#menu-help-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 4px;
}

.help-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
}

.help-num {
  width: 22px;
  height: 22px;
  min-width: 22px;
  background: rgba(74,222,128,0.12);
  border: 1px solid rgba(74,222,128,0.25);
  color: #4ade80;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* ── Explore overlay ── */
#explore-overlay {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

#explore-overlay:not(.hidden) {
  pointer-events: all;
}

#explore-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(10,10,10,0.82);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.explore-cat {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  color: #bbb;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.explore-cat:hover {
  background: rgba(74,222,128,0.12);
  border-color: rgba(74,222,128,0.35);
  color: #4ade80;
}

.explore-cat.active {
  background: rgba(74,222,128,0.18);
  border-color: rgba(74,222,128,0.45);
  color: #4ade80;
}

#explore-close {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  color: #888;
  font-size: 13px;
  padding: 5px 11px;
  cursor: pointer;
  transition: all 0.18s;
  margin-left: 2px;
}

#explore-close:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
  color: #ef4444;
}

#explore-status {
  font-size: 12px;
  color: #888;
  background: rgba(10,10,10,0.7);
  padding: 4px 14px;
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: center;
  min-height: 0;
}

#explore-status:empty { display: none; }

.explore-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* ── Widget cards ── */
.widget-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
  padding: 13px 15px;
  margin-bottom: 6px;
  transition: border-color 0.2s;
}
.widget-card:hover { border-color: rgba(255,255,255,0.11); }

.widget-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
}
.widget-icon { font-size: 17px; flex-shrink: 0; }
.widget-title { font-size: 12.5px; font-weight: 700; color: #bbb; flex: 1; letter-spacing: 0.2px; }
.widget-refresh {
  background: rgba(255,255,255,0.05); border: none; border-radius: 8px;
  color: #555; font-size: 14px; cursor: pointer; padding: 3px 7px;
  transition: all 0.18s;
}
.widget-refresh:hover { color: #4ade80; background: rgba(74,222,128,0.1); }

.widget-loading { font-size: 11.5px; color: #444; font-style: italic; }

.widget-body { display: flex; flex-direction: column; gap: 5px; }

/* Weather */
.weather-main { display: flex; align-items: center; gap: 10px; }
.weather-emoji { font-size: 28px; }
.weather-temp { font-size: 22px; font-weight: 800; color: #f0f0f0; }
.weather-desc { font-size: 11.5px; color: #777; margin-top: 1px; }
.weather-detail { font-size: 11px; color: #444; margin-top: 3px; }

/* Compass */
.compass-body { align-items: center; gap: 8px; }
#compass-rose {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.1);
  background: radial-gradient(circle, rgba(74,222,128,0.05) 0%, rgba(0,0,0,0.3) 100%);
  position: relative;
  margin: 0 auto;
}
#compass-needle {
  position: absolute;
  top: 50%; left: 50%;
  width: 3px; height: 30px;
  margin-left: -1.5px;
  transform-origin: bottom center;
  background: linear-gradient(to bottom, #ef4444 0%, #ef4444 50%, #aaa 50%, #aaa 100%);
  border-radius: 2px 2px 0 0;
  transform: translate(-50%, -100%) rotate(0deg);
  transition: transform 0.4s ease;
  margin-top: -30px;
}
.cdir {
  position: absolute; font-size: 10px; font-weight: 700; color: #555;
  line-height: 1;
}
.cn { top: 4px;  left: 50%; transform: translateX(-50%); color: #ef4444; }
.cs { bottom: 4px; left: 50%; transform: translateX(-50%); }
.ce { right: 5px; top: 50%; transform: translateY(-50%); }
.cw { left: 5px;  top: 50%; transform: translateY(-50%); }
#compass-label { font-size: 11px; color: #555; text-align: center; }

/* Fuel cost */
.fuel-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.fuel-label { font-size: 11.5px; color: #666; flex: 1; }
.fuel-input-wrap { display: flex; align-items: center; gap: 4px; }
.fuel-input-wrap input {
  width: 56px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: #eee; font-size: 12px; padding: 5px 7px; outline: none;
  text-align: center;
}
.fuel-input-wrap input:focus { border-color: rgba(74,222,128,0.4); }
.fuel-unit { font-size: 11px; color: #444; white-space: nowrap; }
#fuel-result {
  margin-top: 6px; font-size: 12.5px; font-weight: 700; color: #4ade80;
  background: rgba(74,222,128,0.07); border-radius: 10px; padding: 7px 10px;
  text-align: center; border: 1px solid rgba(74,222,128,0.15);
}

/* ── Mobile layout (phone) ── */
@media (max-width: 640px) {

  /* Map fills the full screen */
  body { flex-direction: column; position: relative; overflow: hidden; }

  #map {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 0;
  }

  /* Sidebar becomes a bottom sheet */
  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-width: unset;
    height: auto;
    max-height: 85dvh;
    z-index: 500;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.7);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 13px 24px;
    transform: translateY(calc(100% - 76px));
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  }

  #sidebar.expanded {
    transform: translateY(0);
  }

  /* Drag handle at top of sidebar */
  #sidebar::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    margin: 4px auto 10px;
    flex-shrink: 0;
  }

  /* When collapsed, only show the header and route card */
  #sidebar:not(.expanded) #instructions,
  #sidebar:not(.expanded) #route-info,
  #sidebar:not(.expanded) #action-buttons,
  #sidebar:not(.expanded) #status-bar,
  #sidebar:not(.expanded) #route-toggles,
  #sidebar:not(.expanded) #add-stop-row,
  #sidebar:not(.expanded) #mode-selector {
    display: none;
  }

  #header { padding: 2px 2px 0; }
  #header h1 { font-size: 20px; }

  /* Map controls move to accommodate bottom sheet */
  #map-controls {
    top: 12px;
    right: 10px;
  }

  #map-controls button {
    padding: 7px 11px;
    font-size: 12px;
  }

  #map-actions {
    bottom: 100px;
    right: 10px;
  }

  /* Legend anchors above the bottom sheet */
  #map-legend {
    bottom: 100px;
    left: 10px;
  }

  /* Track HUD adapts */
  #track-hud {
    top: 12px;
    left: 10px;
    right: 10px;
    max-width: unset;
    border-radius: 16px;
  }

  /* Explore overlay */
  #explore-overlay {
    bottom: 88px;
  }

  /* Menu panel full width on mobile */
  #menu-panel {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
}
