/* ──────────────────────────────────────────────
   Route Builder v2 — CSS
   Visual style matched to incident-map.html/css
   ────────────────────────────────────────────── */

/* ─── Design Tokens ─── */
:root {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-warning: #f97316;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-bg: #ffffff;
  --color-bg-muted: #f9fafb;
  --color-bg-card: #f9fafb;
  --color-bg-hover: #f3f4f6;
  --sidebar-width: 410px;
  /* Global shrink for the floating UI chrome (sidebar, toolbar, bars, popups).
     1 = full size; 0.90 = 10% smaller. */
  --ui-scale: 0.90;
  --navbar-height: 56px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --shadow-panel: -4px 0 16px rgba(0,0,0,0.12);
  --popover-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.28), 0 6px 16px -8px rgba(15, 23, 42, 0.16);
  --z-sidebar: 100;
  --z-map-controls: 150;
  --z-panel: 200;
  --z-modal: 500;
  --z-toast: 9999;
  --z-navbar: 9999;
}

/* ─── User Location Puck ─── */
.user-location-puck,
.user-location-puck * {
  /* Puck is purely informational — must never intercept pointer events
   * from the route line or draggable waypoint markers it can overlap.
   * !important because .mapboxgl-marker forces cursor:pointer and we
   * need to defeat any inherited pointer-events too. */
  pointer-events: none !important;
}
.user-location-puck {
  position: relative;
  width: 22px;
  height: 22px;
}
.user-puck-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #3b82f6;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  z-index: 2;
}
.user-puck-pulse {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 22px; height: 22px;
  background: rgba(59, 130, 246, 0.25);
  border-radius: 50%;
  z-index: 1;
  animation: puck-pulse 2s ease-out infinite;
}
@keyframes puck-pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

/* ─── Mobile Search Sheet ─── */
.mobile-search-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100001;
  background: #003360;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
  padding: 20px 20px 28px;
  min-height: 32vh;
  transition: transform 0.3s ease;
}
.mobile-search-sheet-content { position: relative; }
.mobile-search-close {
  position: absolute; top: -4px; right: 0;
  background: none; border: none; color: #94a3b8;
  font-size: 24px; cursor: pointer; padding: 4px 8px;
}
.mobile-search-close:hover { color: #e2e8f0; }
.mobile-search-title {
  margin: 0 0 16px; font-size: 17px; font-weight: 600; color: #f1f5f9;
}
.mobile-search-fields { display: flex; flex-direction: column; gap: 10px; }
.mobile-search-row { display: flex; align-items: center; gap: 10px; }
.mobile-search-letter {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.mobile-search-letter.start { background: #22c55e; color: #fff; }
.mobile-search-letter.end { background: #ef4444; color: #fff; }
.mobile-search-input-wrap { flex: 1; position: relative; }
.mobile-search-input {
  width: 100%; box-sizing: border-box;
  padding: 10px 52px 10px 12px !important; border: 1px solid #475569; border-radius: 8px;
  background: #fff; color: #003360; font-size: 14px;
}
.mobile-search-input::placeholder { color: #94a3b8; }
.mobile-search-input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.mobile-search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff !important; border: 1px solid #d1d5db !important; border-radius: 8px;
  margin-top: 4px; max-height: 220px; overflow-y: auto; z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.mobile-search-results .search-result-item {
  padding: 10px 12px; font-size: 13px;
  cursor: pointer; border-bottom: 1px solid #e5e7eb !important;
}
.mobile-search-results .search-result-item:last-child { border-bottom: none !important; }
.mobile-search-results .search-result-item:hover,
.mobile-search-results .search-result-item.highlighted { background: #f1f5f9 !important; }
.mobile-search-results .search-result-item div { color: #003360 !important; }
.mobile-search-results .search-result-item div + div { color: #64748b !important; }
.mobile-search-hint {
  margin: 14px 0 0; text-align: center; font-size: 13px; color: #64748b;
}

/* ─── Global ─── */
html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }

/* ─── Focus Indicators (accessibility) ─── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
.layer-toggle:focus-visible,
.accordion-toggle:focus-visible,
.header-accordion-toggle:focus-visible,
.dark-accordion-toggle:focus-visible,
.profile-btn:focus-visible,
.footer-btn:focus-visible,
.action-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ─── Navbar (dark, matches near miss map) ─── */
#vicbug-navbar { width: 100%; max-width: 100vw; overflow: hidden; }
.app-badge-apple { height: 18px; width: auto; }
.app-badge-google { height: 28px; width: auto; margin: -4px 0; }
@media (min-width: 640px) {
  .app-badge-apple { height: 22px; }
  .app-badge-google { height: 34px; margin: -5px 0; }
}

/* ─── Navbar Auth Indicator ─── */
.nav-user-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: default;
}
.nav-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-user-name {
  font-size: 11px;
  color: #cbd5e1;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-sign-in {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.nav-sign-in:hover {
  color: white;
  border-color: #64748b;
  background: rgba(255,255,255,0.05);
}
@media (max-width: 768px) {
  /* No global UI shrink on mobile — layout already adapts to small screens. */
  :root { --ui-scale: 1; }
  .nav-user-name { display: none; }
}

/* ─── App Layout ─── */
.app-container {
  display: flex;
  height: calc(100vh - var(--navbar-height));
  position: relative;
}

/* ─── Sidebar (light body / dark accent) ─── */
.sidebar {
  position: absolute;
  top: 12px; left: 12px;
  zoom: var(--ui-scale);
  width: var(--sidebar-width);
  max-height: calc(100% - 24px);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar.minimized { transform: translateX(calc(-100% - 16px)); }
.sidebar.minimized .sidebar-content,
.sidebar.minimized .sidebar-footer,
.sidebar.minimized .sidebar-header .sidebar-logo,
.sidebar.minimized .dark-accordion,
.sidebar.minimized .header-accordion { display: none; }

/* Accordion container wrapper */
.accordion-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar header (minimal) */
.sidebar-header-minimal {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 12px;
  background: #003360;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

/* Header-style Accordions (My Saved Routes & Route Builder) */
/* ─── Sidebar tabs (Builder / My Routes / Collections) ─── */
.sidebar-tabs {
  display: flex; gap: 4px; flex-shrink: 0;
  margin: 12px 12px 6px; padding: 5px; background: #f1f3f0; border-radius: 14px;
}
.sidebar-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 4px; border: none; background: none; border-radius: 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: #6b7280; cursor: pointer;
  white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.sidebar-tab svg { flex-shrink: 0; }
.sidebar-tab:hover { color: #1f2937; }
.sidebar-tab.active { background: #fff; color: #387C2B; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* Tabs replace the dark accordion headers */
.sidebar .header-accordion-toggle { display: none; }

.header-accordion {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-bottom: 1px solid #334155;
}
.sidebar .header-accordion { border-bottom: none; }
.header-accordion.open {
  flex: 1;
  min-height: 0;
}
.header-accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #003360;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.header-accordion-toggle:hover {
  background: #334155;
}
.header-accordion-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-accordion-left svg {
  color: #60a5fa;
  flex-shrink: 0;
}
.header-accordion-arrow {
  color: #64748b;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
.header-accordion.open .header-accordion-arrow {
  transform: rotate(180deg);
}
.header-accordion-content {
  display: none;
  flex-direction: column;
  background: #003360;
  overflow: hidden;
}
#route-builder .header-accordion-content {
  background: #ffffff;
}
.header-accordion.open .header-accordion-content {
  display: flex;
  flex: 1;
  min-height: 0;
}
.scrollable-accordion-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Route Library Folders ─── */
.library-folder {
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.library-folder-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.library-folder-toggle:hover {
  background: rgba(255,255,255,0.05);
}
.library-folder-arrow {
  margin-left: auto;
  transition: transform 0.2s;
}
.library-folder.open .library-folder-arrow {
  transform: rotate(180deg);
}
.library-folder-content {
  display: none;
  padding: 0 4px 8px 12px;
}
.library-folder.open .library-folder-content {
  display: block;
}
.library-route-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.library-route-item:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}

/* ─── Route Library Sub-folders ─── */
.library-subfolder {
  margin-bottom: 2px;
}
.library-subfolder-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
  transition: background 0.15s;
}
.library-subfolder-toggle:hover {
  background: rgba(255,255,255,0.05);
}
.library-subfolder-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.library-subfolder-name {
  flex: 1;
  text-align: left;
}
.library-subfolder-count {
  color: #64748b;
  font-size: 11px;
  font-weight: 400;
}
.library-subfolder-arrow {
  transition: transform 0.2s;
  flex-shrink: 0;
}
.library-subfolder.open .library-subfolder-arrow {
  transform: rotate(180deg);
}
/* ─── Distance Markers ─── */
.distance-marker {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  font-family: 'Manrope', 'Inter', sans-serif;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}

.library-coming-soon {
  display: block;
  padding: 12px 16px;
  font-size: 12px;
  color: #475569;
  font-style: italic;
}
.library-subfolder-content {
  display: none;
  padding: 0 0 4px 8px;
}
.library-subfolder.open .library-subfolder-content {
  display: block;
}
.header-accordion .loading-state,
.header-accordion .empty-state {
  padding: 24px 20px;
  text-align: center;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.header-accordion .empty-state .hint {
  font-size: 12px;
  color: #475569;
}
.header-accordion .loading-spinner {
  border-color: #334155;
  border-top-color: #60a5fa;
}

/* Old sidebar header (deprecated) */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #003360;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}
.sidebar-content {
  background: #ffffff;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}
.sidebar-logo svg { color: #3b82f6; }

.sidebar-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: none; background: none;
  border-radius: var(--radius-md);
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-toggle-btn:hover { background: #334155; color: #fff; }

/* Sidebar scrollable body */
.sidebar-content {
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Sidebar Sections ─── */
.sidebar-section {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

/* Section label */
.section-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

/* ─── Auth ─── */
.login-prompt {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 13px;
  color: #475569;
  transition: background 0.15s;
}
.login-prompt:hover { background: #e2e8f0; color: #3b82f6; }

.auth-status { display: flex; align-items: center; gap: 10px; padding: 6px 0; }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0; cursor: pointer;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 500; color: #003360;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.signout-link { font-size: 11px; color: #64748b; cursor: pointer; }
.signout-link:hover { color: var(--color-danger); }

/* ─── POI Toggles (light) ─── */
.poi-toggles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.poi-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 4px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-lg);
  font-size: 11px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  background: #f8fafc;
  white-space: nowrap;
  justify-content: center;
}
.poi-toggle i { font-size: 13px; width: 16px; text-align: center; }
.poi-toggle input[type="checkbox"] { display: none; }
.poi-toggle:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #003360;
}
.poi-toggle:has(input:checked) {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.poi-toggle:has(input:checked) i {
  filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.4));
}

/* Sign-in handled by the navbar — hide the sidebar auth row */
#auth-container { display: none !important; }

/* ─── Import GPX button (above Waypoints) ─── */
.import-row { padding: 14px 16px 0; }
.import-gpx-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%;
  padding: 11px 16px; border: 1.5px dashed #d7d7d2; border-radius: 14px; background: #fafafa;
  font-family: inherit; font-size: 14px; font-weight: 600; color: #57534e; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.import-gpx-btn:hover { background: #f3f4f0; border-color: #387C2B; color: #387C2B; }

/* ─── Waypoints section (Komoot-style) ─── */
.wp-section { padding: 16px; border-bottom: 1px solid #eceae6; }
.wp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.wp-header-left { display: flex; align-items: center; gap: 10px; }
.wp-title { font-size: 21px; font-weight: 700; color: #1f2937; }
.wp-sort {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center; color: #57534e; cursor: pointer;
  transition: background 0.15s;
}
.wp-sort:hover { background: #e6e8e3; color: #1f2937; }

.wp-add-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px;
  padding: 13px 18px; border: 1.5px solid #e2e2de; border-radius: 999px;
  background: #fff; cursor: pointer; font-family: inherit;
  font-size: 15px; font-weight: 500; color: #6b7280; transition: background 0.15s, border-color 0.15s;
}
.wp-add-btn:hover { background: #f8f8f7; color: #1f2937; }
.wp-add-btn svg { color: #6b7280; flex-shrink: 0; }

.wp-footer-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.wp-tool-btn {
  display: flex; align-items: center; gap: 9px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600; color: #1f2937; padding: 2px;
}
.wp-tool-btn:hover { color: #0a84ff; }
.wp-footer-divider { width: 1px; height: 22px; background: #e2e2de; flex-shrink: 0; }
.wp-roundtrip { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 15px; font-weight: 500; color: #1f2937; }
.wp-filters-btn {
  margin-left: auto; width: 36px; height: 36px; border-radius: 10px; border: none; background: none;
  display: flex; align-items: center; justify-content: center; color: #57534e; cursor: pointer; transition: background 0.15s;
}
.wp-filters-btn:hover { background: #f1f3f0; color: #1f2937; }

/* ─── Profile dropdown trigger (Komoot-style, compact in header) ─── */
.profile-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 8px; border: none; border-radius: 9px;
  background: none; cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.profile-trigger:hover { background: #f5f5f3; }
.profile-trigger-icon {
  display: inline-flex; align-items: center; justify-content: center;
  color: #1f2937; font-size: 18px; flex-shrink: 0;
}
.profile-trigger-label { font-size: 15px; font-weight: 600; color: #1f2937; white-space: nowrap; }
.profile-trigger-arrow { color: #1f2937; flex-shrink: 0; }

/* ─── Profile popover ─── */
.profile-popover {
  /* Above the elevation bar (z-index: 99999) so the Routing dropdown isn't covered by it */
  position: fixed; z-index: 100000; width: 380px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 120px); overflow-y: auto;
  background: #fff; border-radius: 22px; box-shadow: var(--popover-shadow);
  padding: 10px;
  transform-origin: top left;
  animation: popover-pop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.profile-popover.hidden { display: none; }
.profile-popover-footer { border-top: 1px solid #ececea; margin-top: 6px; padding: 10px 12px 4px; }

/* ─── Shared popover animations + close button ─── */
@keyframes popover-pop {
  from { opacity: 0; transform: scale(calc(var(--ui-scale) * 0.97)) translateY(-4px); }
  to { opacity: 1; transform: scale(var(--ui-scale)) translateY(0); }
}
@keyframes popover-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.popover-close {
  border: none; background: none; color: #9ca3af; cursor: pointer;
  padding: 4px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.popover-close:hover { background: #f1f3f4; color: #4b5563; }

/* ─── Filters popover (Gravel / Ferries) ─── */
.filters-popover {
  /* Above the elevation bar (z-index: 99999); paired with reparenting to <body> in
     app.js so it escapes the sidebar's zoom stacking context (same as .profile-popover) */
  position: fixed; z-index: 100000; width: 280px; max-width: calc(100vw - 24px);
  background: #fff; border-radius: 24px;
  box-shadow: var(--popover-shadow);
  padding: 18px 18px 12px;
  transform-origin: top left;
  animation: popover-pop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.filters-popover.hidden { display: none; }
.filters-popover-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.filters-popover-title { font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: #9ca3af; margin: 2px 6px 8px; }
.filters-popover .routing-toggles-row { display: flex; flex-direction: column; gap: 2px; }
.filters-popover .inline-toggle-label {
  display: flex; align-items: center; gap: 14px; padding: 10px 8px; border-radius: 14px;
  font-size: 16px; font-weight: 600; color: #1f2937; cursor: pointer;
}
.filters-popover .inline-toggle-label:hover { background: #f6f6f4; }
.filters-popover .inline-toggle-label i {
  width: 42px; height: 42px; border-radius: 12px; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center; color: #57534e; font-size: 17px; flex-shrink: 0;
}
.filters-popover .inline-toggle-label > span { flex: 1; }

/* ─── Profile rows ─── */
.profile-picker { display: flex; flex-direction: column; gap: 2px; }
.profile-btn {
  position: relative; display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 11px 12px; border: none; border-radius: 12px;
  background: transparent; cursor: pointer; text-align: left;
  font-family: inherit; transition: background 0.12s;
}
.profile-btn:hover { background: #f5f5f3; }
.profile-row-icon {
  width: 44px; height: 44px; border-radius: 11px; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center;
  color: #57534e; font-size: 17px; flex-shrink: 0;
}
.profile-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-row-title { font-size: 16px; font-weight: 600; color: #1f2937; }
.profile-row-desc { font-size: 13px; line-height: 1.35; color: #8a857c; }
.profile-row-check { color: #387C2B; flex-shrink: 0; opacity: 0; }
.profile-btn.active { background: #eaf3e4; }
.profile-btn.active .profile-row-check { opacity: 1; }
.profile-icon-combo { display: inline-flex; align-items: center; gap: 2px; }
.profile-icon-combo .fa-bolt { font-size: 10px; margin-left: -1px; }
.profile-time-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ─── Profile Description ─── */
.profile-description {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
}
.profile-desc-text {
  font-size: 11px;
  line-height: 1.5;
  color: #475569;
}

/* ─── Profile Mode Toggle ─── */
.profile-mode-row {
  margin-top: 10px;
}
.profile-mode-toggle {
  display: flex;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.profile-mode-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.profile-mode-btn + .profile-mode-btn {
  border-left: 1px solid #d1d5db;
}
.profile-mode-btn:hover:not(.active) {
  background: #e2e8f0;
  color: #003360;
}
.profile-mode-btn.active {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  font-weight: 600;
}
.profile-mode-desc {
  font-size: 10px;
  line-height: 1.4;
  color: #64748b;
  margin-top: 6px;
}

/* ─── Routing Toggles (Gravel + Ferry, inline) ─── */
.routing-toggles-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}
.routing-toggles-row:not(:has(.inline-toggle-label:not(.hidden))) {
  display: none;
}
.inline-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
}
.inline-toggle-label.hidden { display: none !important; }

/* ─── Gravel Toggle ─── */
.gravel-toggle-row {
  margin-top: 10px;
}
.gravel-toggle-row.hidden { display: none !important; }
.gravel-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
}
.toggle-switch {
  position: relative;
  width: 46px;
  height: 27px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d6d6d2;
  border-radius: 999px;
  transition: background 0.22s ease;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 21px;
  height: 21px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.22s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-switch input:checked + .toggle-slider {
  background: #387C2B;
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(19px);
}
.gravel-status {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  min-width: 20px;
}
.gravel-hint {
  display: block;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
}

/* ─── Waypoints ─── */
.waypoint-inputs {
  display: flex;
  flex-direction: column;
  position: relative;
}

.waypoint-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  position: relative;
}

.waypoint-letter {
  width: 27px; height: 27px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0; z-index: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.waypoint-letter.start { background: #387C2B; }
.waypoint-letter.end { background: #c2410c; }
.waypoint-letter.via { background: #3b82f6; }

.waypoint-connector {
  position: absolute;
  left: 13px; top: 34px; bottom: 6px;
  width: 2px;
  background: #d4d4d0;
  z-index: 0;
}

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

.waypoint-search {
  width: 100%;
  padding: 13px 44px 13px 18px !important;
  border: 1.5px solid #e2e2de !important;
  border-radius: 999px !important;
  font-size: 15px !important;
  background-color: #ffffff !important;
  color: #003360 !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.waypoint-search::placeholder { color: #9a958c !important; }
.waypoint-search:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
  outline: none !important;
}

/* Inline quick-fill icons (Home + Current location) on empty waypoint fields */
.wp-quick-actions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 1px;
  z-index: 1;
}
.wp-quick-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: #3b82f6;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.wp-quick-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

.use-location-btn {
  position: static;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: #3b82f6;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.use-location-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}
.use-location-btn:active {
  background: rgba(59, 130, 246, 0.2);
}
.use-location-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.use-location-btn .spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  z-index: 1000;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
}
.search-results.hidden { display: none; }

.search-result-item {
  padding: 10px 14px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.highlighted { background: #f1f5f9; color: #111827; }

/* ─── Route Action Buttons (light) ─── */
.route-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
/* ─── Elevation title bar toolbar buttons ─── */
.ele-toolbar-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #334155;
  color: #cbd5e1;
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ele-toolbar-btn:hover {
  background: #475569;
  border-color: #64748b;
  color: #f1f5f9;
}
.ele-toolbar-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.ele-toolbar-btn-danger:hover {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fca5a5;
}

.action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-lg);
  background: #f8fafc;
  font-size: 12px; font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.action-btn:hover:not(:disabled) {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #003360;
}
.action-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.action-btn.danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.08);
}
.action-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.18);
}

/* ─── Accordions (light) ─── */
.accordion {
  border-bottom: 1px solid #e5e7eb;
}
.accordion-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 12px 20px;
  border: none; background: none;
  font-size: 13px; font-weight: 600;
  color: #003360;
  cursor: pointer;
  transition: background 0.15s;
}
.accordion-toggle:hover { background: #f1f5f9; }
.accordion-arrow { color: #94a3b8; }
.accordion-arrow { transition: transform 0.3s ease; }
.accordion.open .accordion-arrow { transform: rotate(180deg); }
.accordion-content { overflow: hidden; max-height: 0; padding-top: 0; padding-bottom: 0; transition: max-height 0.3s ease, padding 0.3s ease; }
.accordion.open .accordion-content { max-height: 5000px; }
#route-waypoints-content, #route-description-content { padding-left: 20px; padding-right: 20px; }
.accordion.open #route-waypoints-content { padding-bottom: 16px; }
.accordion.open #route-description-content { padding-bottom: 8px; }
.accordion-content.collapsed { max-height: 0; }

/* ─── Sidebar Accordions (Route Builder & Saved Routes) ─── */
.sidebar-accordion {
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.sidebar-accordion-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: #f8fafc;
  font-size: 14px; font-weight: 700;
  color: #003360;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #e5e7eb;
}
.sidebar-accordion-toggle:hover { background: #f1f5f9; }
.sidebar-accordion .accordion-arrow {
  color: #94a3b8;
  transition: transform 0.3s ease;
}
.sidebar-accordion.open .accordion-arrow { transform: rotate(180deg); }
.sidebar-accordion-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease;
}
.sidebar-accordion.open .sidebar-accordion-content { max-height: 5000px; }
.sidebar-accordion-content.collapsed { max-height: 0; }

/* Dark accordion for Saved Routes */
.dark-accordion .sidebar-accordion-toggle {
  background: #003360;
  color: #e2e8f0;
  border-bottom: 1px solid #334155;
}
.dark-accordion .sidebar-accordion-toggle:hover { background: #334155; }
.dark-accordion .sidebar-accordion-content {
  background: #003360;
}
.dark-accordion .loading-state,
.dark-accordion .empty-state {
  color: #64748b;
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dark-accordion .empty-state .hint { color: #475569; font-size: 12px; }
.dark-accordion .loading-spinner {
  border-color: #334155;
  border-top-color: #60a5fa;
  margin: 0 auto 8px;
}

/* ─── Stats Card (light) ─── */
.stats-card {
  margin: 0 20px 12px;
  padding: 14px 16px;
  background: #f1f5f9;
  border-radius: var(--radius-lg);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stats-item { text-align: center; }
.stats-value { font-size: 20px; font-weight: 700; color: #003360; }
.stats-label { font-size: 10px; font-weight: 500; color: #64748b; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.stats-note { margin-top: 10px; font-size: 11px; color: #64748b; text-align: center; }

/* ─── Loading / Empty ─── */
.loading-state {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; font-size: 13px; color: #64748b;
}
.loading-spinner {
  width: 16px; height: 16px;
  border: 2px solid #d1d5db;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}


.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 24px 20px; font-size: 13px; color: #64748b;
}
.empty-state .hint { font-size: 11px; color: #64748b; }

/* ─── Minimized Controls (profile + POI icons, hidden by default) ─── */
.minimized-controls { display: none; }
/* Route Builder "go to" icon (visible only in view mode) */
.route-builder-go-icon { display: none; color: #64748b; flex-shrink: 0; }
.sidebar.view-mode:not(.minimized) #route-builder .header-accordion-arrow { display: none; }
.sidebar.view-mode:not(.minimized) #route-builder .route-builder-go-icon { display: block; }
.sidebar.view-mode #route-builder .header-accordion-content { display: none !important; }
.sidebar.view-mode #route-builder { order: -2; flex: 0 0 auto !important; }
.sidebar.view-mode #route-library { order: -1; }

.minimized-view-controls { display: none; }
.mini-view-btn {
  width: 100%; padding: 10px 0;
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.mini-view-btn:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.mini-section-divider {
  height: 1px; background: #334155; margin: 4px 8px;
}
.mini-profiles {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding-top: 6px;
}
.mini-pois {
  display: flex; flex-direction: column; align-items: center; gap: 0;
}
.mini-profile-btn, .mini-poi-btn {
  position: relative;
  width: 100%; padding: 14px 0;
  background: none; border: none; cursor: pointer;
  color: #94a3b8; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 1px;
  transition: color 0.15s, background 0.15s;
}
.mini-profile-btn:hover, .mini-poi-btn:hover { background: rgba(255,255,255,0.08); }
.mini-profile-btn.active { color: #3b82f6; }
.mini-poi-btn.active { color: #22c55e; }
.mini-bolt { font-size: 7px; margin-left: -2px; }
.mini-profile-badge {
  position: absolute; top: 1px; right: 4px;
  min-width: 16px; height: 14px; padding: 0 3px;
  border-radius: 7px; font-size: 8px; font-weight: 700;
  color: #fff; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ─── Sidebar Footer (dark to match header) ─── */
.sidebar-footer {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  padding: 10px 16px;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  background: #003360;
  margin-top: auto;
  overflow-x: auto;
}
.footer-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 10px;
  border: none; background: none;
  border-radius: var(--radius-md);
  font-size: 10px; font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.footer-btn:hover:not(:disabled) { background: #334155; color: #e2e8f0; }
#builder-footer-btn { display: none !important; }
.footer-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.footer-btn.primary {
  background: var(--color-primary); color: white;
  border-radius: var(--radius-lg);
}
.footer-btn.primary:hover:not(:disabled) { background: var(--color-primary-hover); color: white; }
.footer-btn.primary:disabled { opacity: 0.5; }

/* ─── Weather Slider Controls ─── */
.weather-slider-controls {
  display: none;
  padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.weather-slider-controls.visible { display: block; }
.weather-slider-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.weather-slider-title { font-size: 11px; font-weight: 600; color: #94a3b8; }
.weather-slider-value { font-size: 12px; font-weight: 700; color: #e2e8f0; }
.weather-slider-controls input[type="range"] {
  width: 100%; cursor: pointer; accent-color: #3b82f6;
}
.weather-slider-range {
  display: flex; justify-content: space-between; font-size: 9px; color: #64748b; margin-top: 2px;
}

/* ─── Map Container ─── */
.map-container { flex: 1; position: relative; min-width: 0; width: 100%; }
#map { width: 100%; height: 100%; }

/* Always-visible map credit (ODbL + Mapbox ToS). position:fixed against
 * the viewport — NOT the map container — so the mobile 100vh overflow
 * can't push it off-screen and the side panels can't cover it. Anchored
 * bottom-centre where both desktop side panels and the mobile control
 * strips leave the map clear. */
#map-attribution {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  font: 500 10px/1.2 'Manrope', 'Inter', system-ui, sans-serif;
  color: #3b4252;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 9px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  pointer-events: auto;
}
#map-attribution:hover { text-decoration: underline; }

/* Keep Mapbox's own logo + ⓘ visible for full ToS compliance, but
 * compact and unobtrusive — our #map-attribution carries the readable
 * credit, the ⓘ just satisfies Mapbox's control requirement. */
.mapboxgl-ctrl-attrib {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.6) !important;
  padding: 0 4px !important;
}
.mapboxgl-ctrl-logo { display: block !important; }

/* ─── Custom Map Controls ─── */
.map-controls {
  position: fixed;
  right: 16px;
  bottom: 32px;
  zoom: var(--ui-scale);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: none;
  box-shadow: none;
  transition: bottom 0.25s ease;
}
/* Circular floating buttons (Komoot style) */
.map-controls .mc-ctrl {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #1f2937; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16); transition: background 0.15s, color 0.15s;
}
.map-controls .mc-ctrl:hover { background: #f1f3f4; }
.map-controls .mc-ctrl.active { background: #003360; color: #fff; }
.map-controls .mc-3d { font-weight: 800; font-size: 13px; }
/* Grouped zoom +/- */
.map-controls .mc-zoom {
  display: flex; flex-direction: column; background: #fff; border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16); overflow: hidden;
}
.map-controls .mc-zoom button {
  width: 44px; height: 44px; border: none; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: #1f2937;
  transition: background 0.15s;
}
.map-controls .mc-zoom button:first-child { border-bottom: 1px solid #ececea; }
.map-controls .mc-zoom button:hover { background: #f1f3f4; }
/* Lift the controls above the bottom stats bar when a route is active */
.map-controls.above-bar { bottom: 324px; }

/* ─── View mode (desktop): move map controls back to left of right sidebar ─── */
@media (min-width: 769px) {
  .sidebar.view-mode ~ .map-controls {
    right: 16px;
    z-index: 101;
  }
}

/* ─── Map Search Box ─── */
/* ─── Search Place modal (Komoot-style) ─── */
.search-modal {
  position: fixed;
  left: 12px; top: 70px;
  z-index: 1400;
  width: var(--sidebar-width); max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 22px;
  box-shadow: var(--popover-shadow);
  padding: 18px;
  transform-origin: top left;
  animation: popover-pop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.search-modal.hidden { display: none; }
.search-modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-shrink: 0; }
.search-modal-back { border: none; background: none; color: #57534e; cursor: pointer; padding: 4px; border-radius: 8px; display: flex; }
.search-modal-back:hover { background: #f1f3f4; color: #1f2937; }
.search-modal-header h2 { font-size: 21px; font-weight: 700; color: #1f2937; margin: 0; }
.search-modal-input {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  border: 1.5px solid #e2e2de; border-radius: 999px; padding: 0 16px; height: 50px; color: #9a958c;
}
.search-modal-input:focus-within { border-color: var(--color-primary); }
.search-modal-input input {
  flex: 1; border: none; outline: none; background: none; font-family: inherit;
  font-size: 15px; color: #1f2937;
}
.search-modal-input input::placeholder { color: #9a958c; }

.search-suggestions { margin-top: 18px; overflow-y: auto; }
.search-sugg-label { font-size: 13px; font-weight: 700; color: #9ca3af; margin: 0 6px 8px; }
.search-sugg {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 6px;
  border: none; background: none; border-radius: 12px; cursor: pointer; text-align: left; font-family: inherit;
}
.search-sugg:hover { background: #f5f5f3; }
.search-sugg-icon {
  width: 44px; height: 44px; border-radius: 12px; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center; color: #57534e; flex-shrink: 0;
}
.search-sugg-icon.home { background: #e7efff; color: #2563eb; }
.search-sugg-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.search-sugg-text b { font-size: 16px; font-weight: 600; color: #1f2937; }
.search-sugg-text small { font-size: 13px; color: #9a958c; }

.map-search-results {
  margin-top: 12px; overflow-y: auto;
  background: #fff; border: 1px solid #eceae6; border-radius: 14px;
}
.map-search-results.hidden { display: none; }
.map-search-results .search-result-item {
  padding: 10px 14px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
}
.map-search-results .search-result-item:last-child { border-bottom: none; }
.map-search-results .search-result-item:hover,
.map-search-results .search-result-item.highlighted { background: #f1f5f9; color: #111827; }

@media (max-width: 768px) {
  /* Map controls: bottom-right edge (Komoot style) */
  .map-controls {
    right: 12px;
    bottom: 24px;
    top: auto;
  }
  .map-search-box {
    right: 12px;
    left: 12px;
    width: auto;
    top: 66px;
    transform: none;
  }
  /* View mode: hide right sidebar + chevron on mobile, reset map controls to right edge */
  .sidebar.view-mode ~ .right-sidebar,
  .app-container:has(.sidebar.view-mode) > .sidebar-chevron.right {
    display: none !important;
  }
  .sidebar.view-mode ~ .map-controls {
    right: 12px;
    bottom: 24px;
    top: auto;
  }
}

/* Sidebar chevron toggle buttons */
.app-container { position: relative; }
.sidebar-chevron {
  position: absolute;
  top: 8px;
  z-index: 1000;
  background: #003360;
  border: none;
  width: 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #94a3b8;
  transition: color 0.15s, left 0.3s ease, right 0.3s ease;
}
.sidebar-chevron:hover { color: #e2e8f0; }
.sidebar-chevron.left {
  left: 372px;
  top: 24px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.sidebar-chevron.right {
  right: 200px;
  border-radius: 6px 0 0 6px;
  box-shadow: -2px 0 8px rgba(0,0,0,0.15);
}

/* Old floating sidebar toggle buttons (deprecated) */
.map-chevron-toggle {
  position: absolute;
  top: 12px;
  z-index: var(--z-map-controls);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 58, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid #334155;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.map-chevron-toggle:hover { background: #003360; color: #fff; }
.map-chevron-toggle.left { left: 8px; }
.map-chevron-toggle.right { right: 8px; }
.map-chevron-toggle svg { transition: transform 0.3s ease; }
.map-chevron-toggle.flipped svg { transform: scaleX(-1); }

/* Legacy — keep for compat */
.map-sidebar-toggle {
  position: absolute;
  top: 12px;
  z-index: var(--z-map-controls);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 58, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.map-sidebar-toggle:hover { background: #003360; color: #fff; }
.map-sidebar-toggle.left { left: 12px; }
.map-sidebar-toggle.right { right: 12px; }
.map-sidebar-toggle.hidden { display: none; }

/* ─── Right Sidebar (Layers) ─── */
.right-sidebar {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 200px;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width 0.3s ease, min-width 0.3s ease;
  overflow: hidden;
}
.right-sidebar.minimized { transform: translateX(100%); }
.right-sidebar.minimized .right-sidebar-content,
.right-sidebar.minimized .right-sidebar-header span { display: none; }

.right-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #003360;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: #e2e8f0;
}

.right-sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  scrollbar-width: none;
}
.right-sidebar-content::-webkit-scrollbar { display: none; }

.layer-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.layer-group + .layer-group {
  border-top: 1px solid #e5e7eb;
  padding-top: 6px;
  margin-top: 4px;
}

.layer-group-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 4px 10px 4px;
}

.layer-toggle {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border: none; background: none;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.layer-toggle svg { color: #94a3b8; }
.layer-toggle:hover { background: #f1f5f9; color: #003360; }
.layer-toggle:hover svg { color: #94a3b8; }
.layer-toggle.active {
  background: none;
  color: #003360;
  font-weight: 600;
}
.layer-toggle.active svg { color: #3b82f6; stroke-width: 2.5; }
.layer-toggle.active i { color: #60a5fa; }
.layer-desc {
  display: none;
  width: 100%;
  font-size: 11px;
  line-height: 1.4;
  color: #94a3b8;
  white-space: normal;
  margin-top: 2px;
  font-weight: 400;
}
.layer-toggle.active .layer-desc { display: block; }
.layer-suboption {
  display: none;
  width: 100%;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  cursor: pointer;
}
.layer-suboption input[type="checkbox"] {
  width: 13px; height: 13px;
  margin: 0;
  accent-color: #60a5fa;
  cursor: pointer;
}
.layer-toggle.active .layer-suboption { display: flex; }

/* ─── POI Filter Accordion (collectible POIs in right sidebar) ─── */
.poi-filter-accordion {
  display: none;
  border-top: 1px solid #e5e7eb;
}
.poi-filter-accordion.open {
  display: block;
}
.poi-filter-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s;
}
.poi-filter-toggle-btn:hover { background: #f1f5f9; }
.poi-filter-accordion.open .poi-filter-toggle-btn .accordion-arrow { transform: rotate(180deg); }
.poi-filter-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  padding: 0 12px;
}
.poi-filter-accordion.expanded .poi-filter-content {
  max-height: 600px;
  padding: 0 12px 8px;
}
.poi-filter-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.poi-filter-btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}
.poi-filter-btn {
  flex: 1;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 500;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  color: #475569;
  transition: all 0.15s;
}
.poi-filter-btn:hover { background: #e2e8f0; }
.poi-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 11px;
  cursor: pointer;
}
.poi-filter-row input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: #3b82f6;
  cursor: pointer;
}
.poi-filter-row .poi-filter-label { flex: 1; color: #374151; }
.poi-filter-row .poi-filter-count { color: #9ca3af; font-size: 10px; }

/* ─── Weather Slider Controls ─── */
.weather-slider-controls {
  display: none;
  padding: 8px 12px;
  border-top: 1px solid #e5e7eb;
}
.weather-slider-controls.visible {
  display: block;
}
.weather-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.weather-slider-label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
}
.weather-slider-value {
  font-size: 11px;
  font-weight: 700;
  color: #1f2937;
}
.weather-slider {
  width: 100%;
  cursor: pointer;
  accent-color: #3b82f6;
}
.weather-slider-range {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ─── Legend (inside light panel) ─── */
.legend-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none; background: none;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s;
}
.legend-toggle svg { color: #94a3b8; }
.legend-toggle:hover { background: #f1f5f9; }

.legend-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
  padding: 0 12px;
}
#legend-accordion.open .legend-content {
  max-height: 1200px;
  padding: 4px 12px 12px;
}
#legend-accordion.open .accordion-arrow { transform: rotate(180deg); }

.legend-section { margin-bottom: 10px; }
.legend-section:last-child { margin-bottom: 0; }

.legend-title {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 6px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  color: #475569;
}
.legend-row {
  border-bottom: 1px solid #e5e7eb;
}
.legend-row:last-child { border-bottom: none; }
.legend-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.legend-row.expanded .legend-chevron {
  transform: rotate(180deg);
}
.legend-desc {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  padding: 0 8px 0 20px;
}
.legend-row.expanded .legend-desc {
  max-height: 120px;
  padding: 0 8px 6px 20px;
}
.legend-line-wrap {
  width: 36px; height: 12px;
  background: #e2e8f0;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0 3px;
}
.legend-line {
  width: 100%; height: 5px;
  border-radius: 2px; flex-shrink: 0;
}

/* Route Details moved to the floating bottom bar (Komoot-style stat strip) */
#stats { display: none !important; }

/* ─── Elevation Bar ─── */
.elevation-bar {
  position: fixed;
  bottom: 12px;
  /* clears the (now scaled) floating sidebar card: 12 + sidebar*scale + 12 gap */
  left: calc(12px + var(--sidebar-width) * var(--ui-scale) + 12px);
  right: auto;
  /* over-size the layout box so that after scale() it still reaches the right edge */
  width: calc((100vw - (12px + var(--sidebar-width) * var(--ui-scale) + 12px) - 12px) / var(--ui-scale));
  transform-origin: bottom left;
  transform: scale(var(--ui-scale));
  height: 300px;
  background: #ffffff;
  border: 1px solid #e8e8e6;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 99999;
  display: flex; flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.elevation-bar.hidden { display: none; }
.elevation-bar-header {
  padding: 12px 18px;
  background: #ffffff;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.elevation-bar-title-row {
  display: flex; align-items: center; gap: 18px;
  min-width: 0; flex: 1;
}
.elevation-bar-title {
  font-size: 14px; font-weight: 700; color: #1f2937;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}
/* Komoot-style stat strip */
.ele-stat-strip {
  display: flex; align-items: center; gap: 26px;
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.ele-stat-strip::-webkit-scrollbar { display: none; }
.ele-stat { display: flex; flex-direction: column; line-height: 1.15; flex-shrink: 0; }
.ele-stat-val { font-size: 23px; font-weight: 700; color: #1f2937; white-space: nowrap; letter-spacing: -0.01em; }
.ele-unit { font-size: 13px; font-weight: 600; color: #9ca3af; margin-left: 2px; }
.ele-stat-lbl { font-size: 12px; font-weight: 500; color: #9ca3af; margin-top: 2px; }
.ele-stat-divider { width: 1px; align-self: stretch; background: #ececea; margin: 4px 0; flex-shrink: 0; }
/* Difficulty pill (Komoot-style) */
.ele-diff-pill {
  display: inline-block; background: #2b2b2b; color: #fff;
  font-size: 13px; font-weight: 600; padding: 3px 11px; border-radius: 7px;
  align-self: flex-start;
}
.elevation-bar-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
/* Footer row in elevation bar — hidden on desktop, shown on mobile */
.elevation-bar-footer-row { display: none; }
.elevation-bar .header-action-btn {
  padding: 8px 15px; font-size: 13px; font-weight: 600; font-family: 'Manrope', sans-serif;
  color: #1f2937; background: #fff;
  border: 1px solid #e2e2de; border-radius: 999px;
  cursor: pointer; display: flex; align-items: center; gap: 7px;
  transition: background 0.15s, border-color 0.15s;
}
.elevation-bar .header-action-btn:hover { background: #f5f5f3; }
.elevation-bar .header-action-btn svg { color: #57534e; }
.elevation-bar .header-action-btn.danger {
  color: #dc2626; border-color: #f3c9c9; background: #fff;
}
.elevation-bar .header-action-btn.danger svg { color: #dc2626; }
.elevation-bar .header-action-btn.danger:hover { background: #fef2f2; }
.elevation-bar #elevation-minimize-btn { padding: 8px 10px; }
.elevation-bar-modes {
  padding: 8px 16px 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end;
}
/* Segmented Elevation / Grade toggle (Komoot-style) */
.ele-mode-toggle {
  display: inline-flex; gap: 2px; background: #f1f3f0; border-radius: 999px; padding: 3px;
}
.ele-mode-toggle .ele-mode-btn {
  padding: 6px 18px; font-size: 13px; font-weight: 600; font-family: 'Manrope', sans-serif;
  border: none; background: none; border-radius: 999px; color: #6b7280; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ele-mode-toggle .ele-mode-btn:hover { color: #1f2937; }
.ele-mode-toggle .ele-mode-btn.active {
  background: #fff; color: #387C2B; box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.elevation-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600; color: #334155;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.ele-sep { color: #94a3b8; }
.elevation-bar canvas { flex: 1; width: 100%; display: block; cursor: crosshair; }

/* ─── Toast (copied from incident-map.css) ─── */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  z-index: var(--z-toast);
  transform: translateX(-50%) translateY(100px);
  background: #111827; color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ─── Detail Panel (matches incident-panel exactly) ─── */
.detail-panel {
  position: fixed; top: var(--navbar-height); right: 0;
  width: 420px; height: calc(100vh - var(--navbar-height));
  background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  z-index: 100000;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.detail-panel.visible { transform: translateX(0); }

.detail-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.detail-panel-header h2 {
  font-size: 18px; font-weight: 700; color: var(--color-text); margin: 0;
}
.detail-panel-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.detail-panel-close:hover { background: var(--color-bg-hover); color: var(--color-text); }
.detail-panel-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ─── Trail Detail Accordions ─── */
.trail-accordion {
  border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 8px; overflow: hidden;
  background: white;
}
.trail-accordion-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 11px 14px;
  border: none; background: #f8fafc;
  font-size: 13px; font-weight: 600; color: #003360;
  cursor: pointer; transition: background 0.15s;
}
.trail-accordion-toggle:hover { background: #f1f5f9; }
.trail-accordion-label {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0;
}
.trail-accordion-label svg { flex-shrink: 0; }
.trail-accordion-arrow { transition: transform 0.25s ease; flex-shrink: 0; color: #94a3b8; }
.trail-accordion.open .trail-accordion-arrow { transform: rotate(180deg); }
.trail-accordion.open .trail-accordion-toggle { border-bottom: 1px solid #f1f5f9; }
.trail-accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.trail-accordion.open .trail-accordion-content { max-height: 2000px; }

/* ─── Mapbox Popup (copied from incident-map.css) ─── */
.mapboxgl-popup-content {
  padding: 16px; border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  font-family: 'Inter', -apple-system, sans-serif;
}
.mapboxgl-popup-close-button {
  width: 28px; height: 28px; top: 8px; right: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0;
  border-radius: 8px; color: #9ca3af;
  transition: background 0.15s, color 0.15s;
}
.mapboxgl-popup-close-button::after {
  content: '';
  display: block; width: 14px; height: 14px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round'%3e%3cline x1='18' y1='6' x2='6' y2='18'/%3e%3cline x1='6' y1='6' x2='18' y2='18'/%3e%3c/svg%3e");
  background-size: contain; background-repeat: no-repeat;
}
.mapboxgl-popup-close-button:hover { background: #f3f4f6; color: #374151; }
.mapboxgl-popup-close-button:hover::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2.5' stroke-linecap='round'%3e%3cline x1='18' y1='6' x2='6' y2='18'/%3e%3cline x1='6' y1='6' x2='18' y2='18'/%3e%3c/svg%3e");
}
.mapboxgl-popup-tip { border-top-color: white; }

/* ─── Google Places Autocomplete (copied from incident-map.css) ─── */
.pac-container {
  font-family: 'Inter', -apple-system, sans-serif !important;
  border-radius: 12px !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12) !important;
  margin-top: 4px !important;
  z-index: 10000 !important;
}
.pac-item {
  padding: 10px 14px !important;
  font-size: 13px !important;
  border-top: 1px solid #f3f4f6 !important;
  cursor: pointer !important;
}
.pac-item:first-child { border-top: none !important; }
.pac-item:hover, .pac-item-selected { background: #f3f4f6 !important; }
.pac-item-query { font-size: 13px !important; font-weight: 500 !important; }
.pac-icon { display: none !important; }

/* ─── Image Overlay ─── */
.image-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
.image-overlay.hidden { display: none; }
.image-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: var(--radius-md); }

.image-overlay-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px;
  border: none; background: rgba(255,255,255,0.15);
  color: white; font-size: 24px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.image-overlay-close:hover { background: rgba(255,255,255,0.3); }

.image-overlay-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  border: none; background: rgba(255,255,255,0.15);
  color: white; font-size: 28px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.image-overlay-nav:hover { background: rgba(255,255,255,0.3); }
.image-overlay-nav.prev { left: 16px; }
.image-overlay-nav.next { right: 16px; }
.image-overlay-counter {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7); font-size: 13px;
}

/* ─── Route Markers (map) ─── */
/* CRITICAL: do NOT set `position`, `transform`, or `transition: transform`
 * on the marker root. Mapbox gives the element class `mapboxgl-marker`
 * (which is `position: absolute`) and rewrites its inline
 * `transform: translate(x,y)` every frame during pan/zoom. Overriding
 * `position` drops the marker into normal flow so it no longer tracks
 * its coordinate (markers drift / cluster off-map on zoom). A CSS
 * transform competes with the translate; a transform transition makes
 * it lag. Hover cues here use box-shadow only — safe because box-shadow
 * doesn't affect Mapbox positioning. */
.route-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  /* !important defeats the global .mapboxgl-marker { cursor: pointer
   * !important } rule, so hovering a draggable waypoint clearly signals
   * "you can grab this" instead of the generic pointer hand. */
  cursor: grab !important;
  user-select: none;
  transition: box-shadow 0.12s ease;
}
.route-marker:hover {
  /* Non-transform hover cue: a coloured glow ring. Obvious that the
   * marker is interactive without touching the Mapbox transform. */
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35), 0 2px 6px rgba(0, 0, 0, 0.28);
}
.route-marker:active,
.route-marker.dragging {
  cursor: grabbing !important;
  box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.32);
}
.route-marker--via {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', -apple-system, sans-serif;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.route-marker--start,
.route-marker--finish,
.route-marker--start-finish {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
}
.route-marker--start {
  background: #22c55e;
}
.route-marker--finish {
  background-image:
    linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937),
    linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937);
  background-position: 0 0, 4px 4px;
  background-size: 8px 8px;
  background-color: #fff;
}
.route-marker--start-finish {
  background:
    linear-gradient(135deg, #22c55e 0 49%, transparent 49% 51%, transparent 100%),
    linear-gradient(135deg, transparent 0 49%, #ffffff 49% 51%, transparent 51% 100%),
    linear-gradient(135deg, transparent 0 50%, #ffffff 50% 100%),
    linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937),
    linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%, #1f2937);
  background-position: 0 0, 0 0, 0 0, 0 0, 4px 4px;
  background-size: 100% 100%, 100% 100%, 100% 100%, 8px 8px, 8px 8px;
  background-color: #fff;
}

/* ─── Route Option Cards ─── */
.route-option {
  padding: 12px 14px;
  margin: 0 0 6px;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.15s;
}
.route-option:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}
.route-option.selected {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}

/* ─── Waypoint Remove Button ─── */
.waypoint-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.waypoint-remove-btn:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ─── Waypoint reorder (up / down) ─── */
.waypoint-move {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}
.waypoint-move-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 17px;
  border: none;
  background: none;
  border-radius: 5px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
}
.waypoint-move-btn:hover:not(:disabled) {
  color: #1f2937;
  background: #eef2f6;
}
.waypoint-move-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ─── Search dropdown shortcuts (Current location / Home) ─── */
.search-result-item.search-shortcut {
  display: flex;
  align-items: center;
  gap: 11px;
}
.search-shortcut .shortcut-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #eef2f6;
  color: #475569;
}
.search-shortcut .shortcut-main {
  font-weight: 600;
  color: #1e293b;
}
.search-shortcut .shortcut-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

/* ─── Breakdown Expandable Items ─── */
.breakdown-item {
  border-bottom: 1px solid #e5e7eb;
}
.breakdown-item:last-child {
  border-bottom: none;
}
.breakdown-item:hover {
  background: #f8fafc;
}
.breakdown-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.breakdown-item.expanded .breakdown-chevron {
  transform: rotate(180deg);
}
.breakdown-desc {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.25s ease;
  font-size: 11px;
  color: #64748b;
  line-height: 1.5;
  padding: 0 20px 0 48px;
}
.breakdown-item.expanded .breakdown-desc {
  max-height: 80px;
  padding: 0 20px 8px 48px;
}

/* ─── Modals ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200000;
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #003360; border-radius: 12px; padding: 24px; min-width: 300px; max-width: min(90vw, 420px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
#profile-modal .modal-box {
  max-width: min(92vw, 720px);
  max-height: min(90vh, 820px);
  overflow-y: auto;
}
#profile-wahoo-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#profile-wahoo-list {
  max-height: min(42vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
#profile-wahoo-list::-webkit-scrollbar {
  width: 8px;
}
#profile-wahoo-list::-webkit-scrollbar-track {
  background: #003360;
  border-radius: 999px;
}
#profile-wahoo-list::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 999px;
}
#profile-wahoo-list::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}
@media (max-width: 640px) {
  #profile-modal .modal-box {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 28px);
    padding: 18px;
  }
  #profile-wahoo-list {
    max-height: 46vh;
  }
}
.modal-box h3 {
  margin: 0 0 16px; font-size: 16px; font-weight: 600; color: #e2e8f0;
}
.modal-box input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid #475569; border-radius: 8px;
  font-size: 14px; outline: none; box-sizing: border-box; background: #334155; color: #f1f5f9;
}
.modal-box input[type="text"]:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid #475569; background: #334155;
  font-size: 13px; font-weight: 500; color: #cbd5e1; cursor: pointer;
}
.modal-btn:hover { background: #475569; color: #f1f5f9; }
.modal-btn.primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.modal-btn.primary:hover { background: #2563eb; }
.modal-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.share-url-row { display: flex; gap: 6px; align-items: center; }
.share-url-row input { flex: 1; font-size: 12px; color: #cbd5e1; background: #334155; }
.share-action-btn {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid #475569;
  background: #334155; color: #cbd5e1; cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
  transition: all 0.15s;
}
.share-action-btn:hover { background: #475569; color: #f1f5f9; border-color: #64748b; }
.share-action-btn.copied { background: #16a34a; border-color: #16a34a; color: #fff; }
.share-privacy-row { padding: 12px 0 4px; }
.share-toggle-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: #94a3b8; cursor: pointer; gap: 12px;
}
.share-toggle-label input { display: none; }
.share-toggle-track {
  width: 36px; height: 20px; background: #475569; border-radius: 10px;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
.share-toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #94a3b8;
  transition: all 0.2s;
}
.share-toggle-label input:checked + .share-toggle-track { background: #22c55e; }
.share-toggle-label input:checked + .share-toggle-track::after { left: 18px; background: #fff; }
.share-badge {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #22c55e; display: flex; align-items: center; justify-content: center;
}
.footer-btn { position: relative; }

/* ─── Dark Accordion (Saved Routes / Route Builder) ─── */
.dark-accordion { margin: 0; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; }
.dark-accordion.open { flex: 1; flex-shrink: 1; }
.dark-accordion-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 16px; border: none; cursor: pointer;
  background: #003360; color: #e2e8f0; font-size: 14px; font-weight: 700;
  border-bottom: 1px solid #334155; flex-shrink: 0;
}
.sidebar.minimized .dark-accordion { display: none; }
.dark-accordion-toggle:hover { background: #334155; }
.dark-accordion-left { display: flex; align-items: center; gap: 8px; }
.dark-accordion-left svg { color: #60a5fa; }
.dark-accordion-arrow {
  color: #64748b; transition: transform 0.3s ease;
}
.dark-accordion.open .dark-accordion-arrow { transform: rotate(180deg); }
.dark-accordion-content {
  display: none; background: #003360;
}
.dark-accordion.open .dark-accordion-content {
  display: flex; flex-direction: column;
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
}
#route-builder-accordion .dark-accordion-content { background: #fff; }

/* ─── Saved Route Items ─── */
.saved-route-item {
  padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #003360;
  transition: background 0.15s;
}
.saved-route-item:hover { background: #003360; }
.saved-route-item:last-child { border-bottom: none; }
.saved-route-row {
  display: flex; gap: 10px; align-items: center;
}
.saved-route-thumb {
  width: 72px; height: 72px; min-width: 72px; border-radius: 6px; overflow: hidden;
  background: #003360;
}
.saved-route-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.saved-route-info { flex: 1; min-width: 0; }
.saved-route-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.saved-route-name {
  font-size: 13px; font-weight: 600; color: #e2e8f0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.saved-route-delete {
  background: none; border: none; color: #475569; cursor: pointer; padding: 4px;
  border-radius: 4px; display: flex; align-items: center;
}
.saved-route-delete:hover { color: #ef4444; background: rgba(239,68,68,0.15); }
.saved-route-meta {
  display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: #64748b; margin-top: 4px;
}
.unpaved-tag {
  background: rgba(217,119,6,0.2); color: #60a5fa; padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.shared-tag {
  background: rgba(34,197,94,0.15); color: #4ade80; padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.dark-accordion-content .loading-state,
.dark-accordion-content .empty-state { color: #64748b; padding: 16px; text-align: center; }
.dark-accordion-content .empty-state .hint { color: #475569; display: block; margin-top: 4px; }
.dark-accordion-content .loading-spinner { border-color: #334155; border-top-color: #60a5fa; }

/* ─── My Routes / Collections panels: light theme (was navy) ─── */
#my-routes .header-accordion-content,
#route-library .header-accordion-content { background: #ffffff; color: #1f2937; }
#my-routes .library-folder,
#route-library .library-folder { border-bottom: 1px solid #eceae6; }
#my-routes .library-folder-toggle,
#route-library .library-folder-toggle { color: #1f2937; font-size: 14px; font-weight: 600; }
#my-routes .library-folder-toggle:hover,
#route-library .library-folder-toggle:hover { background: #f5f5f3; }
#my-routes .library-route-item,
#route-library .library-route-item { color: #6b7280; }
#my-routes .library-route-item:hover,
#route-library .library-route-item:hover { background: #f5f5f3; color: #1f2937; }
#route-library .library-coming-soon { color: #9ca3af; }

#my-routes .saved-route-item, #route-library .saved-route-item { border-bottom: 1px solid #eceae6; }
#my-routes .saved-route-item:hover, #route-library .saved-route-item:hover { background: #f5f5f3; }
#my-routes .saved-route-thumb, #route-library .saved-route-thumb { background: #f1f3f0; }
#my-routes .saved-route-name, #route-library .saved-route-name { color: #1f2937; }
#my-routes .saved-route-meta, #route-library .saved-route-meta { color: #6b7280; }
#my-routes .saved-route-delete, #route-library .saved-route-delete { color: #c4c4c0; }

/* Collections org sub-folders (VicBUG, Bike Routes, …) — dark text on white */
#route-library .library-subfolder { border-bottom: none; }
#route-library .library-subfolder-toggle { color: #1f2937; }
#route-library .library-subfolder-toggle:hover { background: #f5f5f3; }
#route-library .library-subfolder-name { color: #1f2937; font-weight: 600; }
#route-library .library-subfolder-count { color: #9ca3af; }

#my-routes .unpaved-tag, #route-library .unpaved-tag { background: #f1ece4; color: #a17c4e; }
#my-routes .shared-tag, #route-library .shared-tag { background: #e7f3ea; color: #2f8a43; }

#my-routes .loading-state, #my-routes .empty-state,
#route-library .loading-state, #route-library .empty-state { color: #9ca3af; }
#my-routes .empty-state .hint, #route-library .empty-state .hint { color: #c4c4c0; }

/* ─── POI Context Menu ─── */
/* ── Komoot-style Street View hover preview (gravel / quiet roads) ── */
.road-img-preview {
  position: fixed;
  z-index: 200001;
  width: 260px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transform-origin: bottom left;
  transform: translateY(5px) scale(calc(var(--ui-scale) * 0.985));
  transition: opacity .13s ease, transform .13s ease;
  font-family: 'Manrope', sans-serif;
}
.road-img-preview.visible {
  opacity: 1;
  transform: translateY(0) scale(var(--ui-scale));
}
.road-img-preview .rip-img-wrap {
  width: 100%;
  height: 162px;
  background: #eceff1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24' fill='none' stroke='%23b0bac1' stroke-width='1.6'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E") center/40px no-repeat;
}
.road-img-preview .rip-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .15s ease;
}
.road-img-preview.loaded .rip-img { opacity: 1; }
.road-img-preview .rip-cap {
  padding: 9px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.road-img-preview .rip-name {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.25;
}
.road-img-preview .rip-date {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
}

.poi-context-menu {
  position: fixed;
  background: white;
  border-radius: 18px;
  box-shadow: var(--popover-shadow);
  z-index: 100002;
  min-width: 250px;
  max-width: 320px;
  padding: 18px;
  font-family: 'Manrope', sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: scale(calc(var(--ui-scale) * 0.97)) translateY(-6px);
  transform-origin: top left;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.poi-context-menu.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(var(--ui-scale)) translateY(0);
}
/* Header: green uppercase, no divider (matches the waypoint / trail card) */
.poi-context-menu-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 0 12px;
  background: none;
  border-bottom: none;
  font-size: 13px;
  font-weight: 700;
  color: #387C2B;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.poi-context-menu-close {
  border: none; background: none; color: #9ca3af; cursor: pointer; padding: 2px;
  margin: -2px -4px 0 0;
  display: flex; flex-shrink: 0;
}
.poi-context-menu-close:hover { color: #4b5563; }
/* Action rows as grey pill buttons (matches the waypoint popup) */
.poi-context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 8px;
  border: none;
  border-radius: 14px;
  background: #f5f5f3;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.poi-context-menu-item:last-child { margin-bottom: 0; }
.poi-context-menu-item:hover { background: #ececea; }
.poi-context-menu-item i { width: 22px; text-align: center; flex-shrink: 0; }
.poi-context-menu-item svg { width: 20px; height: 20px; color: #6b7280; flex-shrink: 0; }
.poi-context-menu-item.cancel { color: #6b7280; }
.poi-context-menu-item.cancel svg { color: #9ca3af; }

/* ─── POI Place Popup ─── */
#poi-place-popup-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#poi-place-popup-backdrop.visible { opacity: 1; }

.poi-loading-spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: poi-spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes poi-spin { to { transform: rotate(360deg); } }

/* Desktop: scrollable content — no max-height (right sheet handles overflow) */
#poi-place-popup .poi-sheet-content-scroll {
  overflow-y: auto;
}

@media (max-width: 768px) {
  #poi-place-popup {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }
  #poi-place-popup.poi-sheet-visible { transform: translateY(0); }
  #poi-place-popup > div {
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
  }
  .poi-sheet-grabber {
    display: block !important;
    width: 40px; height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 8px auto 4px;
  }
  #poi-place-popup .poi-sheet-content-scroll {
    overflow-y: auto;
    max-height: calc(85vh - 200px);
    -webkit-overflow-scrolling: touch;
  }
}
@media (min-width: 769px) {
  .poi-sheet-grabber { display: none !important; }
}

/* ─── Animations ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

/* ─── Mobile ─── */
@media (max-width: 768px) {
  /* Sidebar chevrons: fixed positioning on mobile */
  .sidebar-chevron.left {
    position: fixed;
    top: calc(var(--navbar-height) + 64px);
    z-index: 100001;
  }
  .sidebar-chevron.right {
    position: fixed;
    top: calc(var(--navbar-height) + 8px);
    z-index: 100001;
  }

  /* Left sidebar: fixed, icon strip when minimized */
  .sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0; bottom: 0;
    max-height: none;
    border-radius: 0;
    border: none;
    z-index: 100000;
    transition: width 0.3s ease, min-width 0.3s ease, box-shadow 0.3s ease;
  }
  .sidebar:not(.minimized) {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    box-shadow: 4px 0 16px rgba(0,0,0,0.3);
  }
  .sidebar.minimized {
    transform: none;
    width: 50px;
    min-width: 50px;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    overflow: hidden;
    background: #334155;
  }
  /* In minimized icon strip: show accordion toggles, hide everything else */
  .sidebar.minimized .header-accordion {
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0;
    flex: 0 0 auto !important;
    border-bottom: 1px solid #334155;
  }
  .sidebar.minimized .header-accordion-toggle {
    padding: 10px 0;
    justify-content: center;
  }
  .sidebar.minimized .header-accordion-toggle svg {
    width: 16px;
    height: 16px;
  }
  .sidebar.minimized .header-accordion-left {
    gap: 0;
    justify-content: center;
  }
  .sidebar.minimized .header-accordion-left span { display: none; }
  .sidebar.minimized .header-accordion-arrow { display: none; }
  .sidebar.minimized .header-accordion-content { display: none !important; }
  .sidebar.minimized .sidebar-header-minimal { display: none; }
  .sidebar.minimized .sidebar-content { display: none; }
  .sidebar.minimized .sidebar-footer {
    display: none !important;
  }
  /* Route Builder accordion: flex-grow for controls, placed first */
  .sidebar.minimized #route-builder {
    flex: 1 1 0 !important;
    min-height: 0;
    overflow: hidden;
    order: -1;
  }
  /* Route Collections and My Routes: top in builder, bottom in view mode */
  .sidebar.minimized:not(.view-mode) #route-library { order: -2; }
  .sidebar.minimized:not(.view-mode) #my-routes { order: -3; }
  .sidebar.minimized.view-mode #route-library { order: 10; }
  .sidebar.minimized.view-mode #my-routes { order: 11; }
  /* Route Builder toggle: pinned to bottom in view mode only */
  .sidebar.minimized.view-mode #route-builder > .header-accordion-toggle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
    border-top: 1px solid #334155;
  }
  /* Reserve space at bottom for the absolute toggle */
  .sidebar.minimized { padding-bottom: 37px; }
  .sidebar.minimized .minimized-controls {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .sidebar.minimized .mini-profiles {
    flex-shrink: 0;
  }
  .sidebar.minimized .mini-section-divider {
    flex-shrink: 0;
  }
  .sidebar.minimized .mini-pois {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
  }
  /* Hide profile + POI icons until a route is selected (builder only) */
  .sidebar.minimized:not(.view-mode):not(.has-route) .minimized-controls {
    display: none !important;
  }
  .sidebar.minimized .mini-pois::-webkit-scrollbar { display: none; }
  /* Smaller icons on minimized sidebar for mobile */
  .sidebar.minimized .mini-profile-btn,
  .sidebar.minimized .mini-poi-btn {
    padding: 6px 0;
    font-size: 12px;
  }
  .sidebar.minimized .mini-view-btn {
    padding: 8px 0;
    font-size: 13px;
  }
  /* In view mode: hide build controls, show view controls */
  .sidebar.minimized.view-mode .minimized-controls { display: none !important; }
  .sidebar.minimized.view-mode .minimized-view-controls {
    display: flex !important;
    flex-direction: column;
    padding-top: 6px;
  }
  .sidebar.minimized .dark-accordion { display: none; }
  .sidebar.minimized #route-info-panel { display: none !important; }

  /* Right sidebar: fixed, icon strip when minimized */
  .right-sidebar {
    position: fixed;
    top: var(--navbar-height);
    right: 0; bottom: 0;
    z-index: var(--z-sidebar);
    transition: width 0.3s ease, min-width 0.3s ease, box-shadow 0.3s ease;
  }
  .right-sidebar:not(.minimized) {
    width: 200px;
    min-width: 200px;
    box-shadow: -4px 0 16px rgba(0,0,0,0.3);
  }
  .right-sidebar.minimized {
    transform: none;
    width: 50px;
    min-width: 50px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    overflow: hidden;
    background: #334155;
  }
  /* In minimized icon strip: show layer toggle icons as vertical strip */
  .right-sidebar.minimized .right-sidebar-header { display: none; }
  .right-sidebar.minimized .right-sidebar-content {
    display: flex !important;
    flex-direction: column;
    padding: 10px 0 4px 0;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .right-sidebar.minimized .right-sidebar-content::-webkit-scrollbar { display: none; }
  .right-sidebar.minimized .layer-group-label { display: none; }
  .right-sidebar.minimized .layer-group { gap: 0; }
  .right-sidebar.minimized .layer-group + .layer-group {
    border-top: 1px solid #334155;
    padding-top: 2px;
    margin-top: 2px;
  }
  .right-sidebar.minimized .layer-toggle {
    padding: 5px 0;
    justify-content: center;
    width: 100%;
    border-radius: 0;
    color: #94a3b8;
    font-size: 11px;
  }
  .right-sidebar.minimized .layer-toggle i {
    font-size: 13px !important;
  }
  .right-sidebar.minimized .layer-toggle.active {
    color: #3b82f6;
  }
  .right-sidebar.minimized .layer-toggle:hover {
    background: rgba(255,255,255,0.08);
  }
  .right-sidebar.minimized .layer-toggle > span { display: none; }
  .right-sidebar.minimized .layer-toggle .layer-desc { display: none !important; }
  .right-sidebar.minimized .layer-toggle .layer-suboption { display: none !important; }
  .right-sidebar.minimized .weather-slider-controls { display: none; }
  .right-sidebar.minimized #legend-accordion { display: none; }

  .detail-panel {
    width: 100%; top: auto; bottom: 0; height: 75vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .detail-panel.visible { transform: translateY(0); }

  /* Elevation bar: full-width bottom sheet on mobile */
  .elevation-bar {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    transform: none !important;
    height: 280px;
    border: none;
    border-radius: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    background: #003360;
    color: #e2e8f0;
  }
  .elevation-bar .elevation-bar-header { background: #003360; }
  .elevation-bar .ele-stat-val { color: #e2e8f0; }
  .elevation-bar .ele-stat-val.gain { color: #4ade80; }
  .elevation-bar .ele-stat-val.loss { color: #f87171; }
  .elevation-bar .ele-stat-lbl { color: #94a3b8; }
  .elevation-bar .ele-stat-strip { gap: 14px; }
  .elevation-bar .ele-stat-val { font-size: 16px; }
  .elevation-bar-title { color: #e2e8f0 !important; max-width: none !important; }
  .elevation-bar-header {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 6px;
    border-radius: 0;
  }
  .elevation-bar-modes { background: transparent; }
  .elevation-bar .ele-mode-btn {
    background: transparent !important;
    color: #94a3b8 !important;
  }
  .elevation-bar .ele-mode-btn.active {
    background: #334155 !important;
    color: #e2e8f0 !important;
    box-shadow: none !important;
  }
  #elevation-mode-toggle {
    background: #003360 !important;
  }
  .elevation-bar-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }
  .elevation-bar-title { font-size: 13px; }
  .elevation-bar-stats { font-size: 10px; }
  .elevation-bar-actions { gap: 4px; }
  .elevation-bar .header-action-btn .action-label { display: none; }
  .elevation-bar .header-action-btn { padding: 6px 8px; }
  .elevation-bar-modes { padding: 4px 12px; }
  /* Mobile footer row in elevation bar */
  .elevation-bar-footer-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    width: 100%;
    padding-top: 6px;
    border-top: 1px solid #334155;
    margin-top: 2px;
  }
  .elev-footer-btn {
    display: flex; align-items: center; justify-content: center;
    padding: 10px 12px;
    background: transparent; border: 1px solid #475569;
    border-radius: 6px; cursor: pointer; color: #cbd5e1;
    transition: background 0.15s;
  }
  .elev-footer-btn:hover { background: rgba(255,255,255,0.08); }
  .elev-footer-btn:disabled { opacity: 0.35; cursor: not-allowed; }
  .elev-footer-save { background: var(--color-primary); border-color: var(--color-primary); color: white; }
  .elev-footer-save:hover { background: var(--color-primary-hover); }
  /* When elevation bar is active, hide sidebar footer — actions move to elevation bar */
  .sidebar.minimized:not(.view-mode) .sidebar-footer.elev-active { display: none !important; }
}

/* ─── Hazard Panel ─── */
.hazard-panel {
  position: fixed;
  background: white;
  z-index: 100000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}
.hazard-panel.visible { opacity: 1; visibility: visible; }
@media (min-width: 769px) {
  .hazard-panel {
    top: 64px; right: 0; width: 400px; height: calc(100vh - 64px);
    border-left: 1px solid #e5e7eb; box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transform: translateX(100%);
  }
  .hazard-panel.visible { transform: translateX(0); }
}
@media (max-width: 768px) {
  .hazard-panel {
    bottom: 0; left: 0; right: 0; max-height: 70vh;
    border-radius: 20px 20px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    transform: translateY(100%);
  }
  .hazard-panel.visible { transform: translateY(0); }
}
.hazard-panel-grabber { display: none; }
@media (max-width: 768px) {
  .hazard-panel-grabber {
    display: block; width: 40px; height: 4px; background: #d1d5db;
    border-radius: 2px; margin: 8px auto 0;
  }
}
.hazard-panel-header {
  padding: 16px 20px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.hazard-panel-title { font-size: 18px; font-weight: 600; color: #111827; }
.hazard-panel-location {
  font-size: 13px; color: #6b7280; margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}
.hazard-panel-location svg { width: 14px; height: 14px; flex-shrink: 0; }
.hazard-panel-close {
  background: #f3f4f6; border: none; border-radius: 50%;
  width: 32px; height: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b7280; flex-shrink: 0; transition: background 0.15s;
}
.hazard-panel-close:hover { background: #e5e7eb; }
.hazard-panel-close svg { width: 18px; height: 18px; }
.hazard-panel-content { flex: 1; overflow-y: auto; padding: 20px; }

/* Hazard Type Selector */
.hazard-type-section { margin-bottom: 20px; }
.hazard-type-label {
  font-size: 13px; font-weight: 600; color: #374151;
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px;
}
.hazard-type-scroll {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.hazard-type-scroll::-webkit-scrollbar { display: none; }
.hazard-type-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 16px; border: 2px solid transparent; border-radius: 12px;
  background: rgba(0,0,0,0.04); cursor: pointer; transition: all 0.2s;
  flex-shrink: 0; min-width: 80px;
}
.hazard-type-btn:hover { background: rgba(0,0,0,0.08); }
.hazard-type-btn.selected {
  background: color-mix(in srgb, var(--hazard-color) 15%, transparent);
  border-color: var(--hazard-color);
}
.hazard-type-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--hazard-color);
  display: flex; align-items: center; justify-content: center;
  color: white; transition: all 0.2s;
}
.hazard-type-btn[data-type="debris"] .hazard-type-icon,
.hazard-type-btn[data-type="construction"] .hazard-type-icon,
.hazard-type-btn[data-type="closure"] .hazard-type-icon { color: black; }
.hazard-type-icon svg { width: 22px; height: 22px; }
.hazard-type-btn span { font-size: 12px; font-weight: 500; color: #374151; }
.hazard-type-btn.selected span { color: var(--hazard-color); font-weight: 600; }

/* Hazard Description & Submit */
.hazard-description-section { margin-bottom: 16px; }
.hazard-textarea {
  width: 100%; padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px;
  font-size: 14px; font-family: inherit; resize: vertical; min-height: 80px;
  background: #f9fafb; transition: border-color 0.2s;
}
.hazard-textarea:focus { outline: none; border-color: #3b82f6; background: white; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.hazard-submit-section { padding-top: 4px; }
.hazard-submit-btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: #3b82f6; color: white; font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: background 0.2s;
}
.hazard-submit-btn:hover { background: #2563eb; }
.hazard-submit-btn:active { background: #1d4ed8; }
.hazard-submit-btn:disabled { background: #94a3b8; cursor: not-allowed; }
.hazard-submit-btn svg { width: 18px; height: 18px; }

/* Hazard Markers */
.hazard-marker { width: 32px; height: 40px; cursor: pointer; }
.hazard-marker svg { width: 100%; height: 100%; }
.emergency-warning-marker { width: 32px; height: 40px; cursor: pointer; }
.emergency-warning-marker svg { width: 100%; height: 100%; }

/* Hazard Placeholder (pulsing marker while reporting) */
.hazard-placeholder-marker { width: 40px; height: 40px; position: relative; }
.hazard-placeholder-inner {
  width: 40px; height: 40px; border-radius: 50%; background: #3b82f6;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4); position: relative; z-index: 2;
}
.hazard-placeholder-inner svg { width: 20px; height: 20px; }
.hazard-placeholder-pulse {
  position: absolute; top: 50%; left: 50%; width: 60px; height: 60px;
  margin-top: -30px; margin-left: -30px; border-radius: 50%;
  background: rgba(59,130,246,0.3); animation: hazard-pulse 1.5s ease-out infinite;
}
@keyframes hazard-pulse {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Hazard Tooltip (click popup) */
.hazard-tooltip {
  position: fixed; z-index: 10000; background: white;
  border-radius: 12px; padding: 16px; max-width: 320px; width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15); border: 1px solid #e5e7eb;
  display: none; font-family: 'Manrope', 'Inter', sans-serif;
}
.hazard-tooltip.visible { display: block; }
.hazard-tooltip-close {
  position: absolute; top: 8px; right: 8px; background: none;
  border: none; font-size: 18px; color: #9ca3af; cursor: pointer; padding: 4px 8px;
}
.hazard-tooltip-close:hover { color: #6b7280; }
.hazard-tooltip-title {
  font-size: 15px; font-weight: 600; color: #111827;
  text-transform: capitalize; margin-bottom: 6px;
}
.hazard-tooltip-desc { font-size: 13px; color: #4b5563; line-height: 1.5; margin-bottom: 4px; }
.hazard-tooltip-meta { font-size: 12px; color: #9ca3af; margin-top: 2px; }

/* Hazard Hover Tooltip */
.hazard-hover-tooltip {
  position: fixed; padding: 6px 10px; border-radius: 6px; font-size: 12px;
  font-weight: 500; color: white; pointer-events: none; z-index: 1000;
  display: none; box-shadow: 0 2px 8px rgba(0,0,0,0.3); max-width: 220px;
}

/* ─── Route View Mode ─── */

/* Panel container — standalone section in sidebar, scrollable */
#route-info-panel {
  flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}

/* Dark header matching sidebar accordion style */
.view-route-header {
  padding: 14px 16px 12px;
  background: #003360;
  border-bottom: 1px solid #334155;
}
.view-route-name-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.view-route-header h2 {
  font-size: 15px; font-weight: 700; color: #e2e8f0;
  margin: 0 0 6px; line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.view-bookmark-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: color 0.15s;
  display: flex;
  align-items: center;
}
.view-bookmark-btn:hover {
  color: #e2e8f0;
}
.view-bookmark-btn.bookmarked {
  color: #3b82f6;
}
.view-bookmark-btn.bookmarked svg {
  fill: #3b82f6;
}
.view-route-author {
  margin-bottom: 8px;
}
.view-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.view-author-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.view-author-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #475569;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
}
.view-author-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}
.view-author-name {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}
.view-author-org {
  font-size: 10px;
  color: #94a3b8;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
}
.view-author-website {
  font-size: 10px;
  color: #60a5fa;
  text-decoration: none;
}
.view-author-website:hover {
  text-decoration: underline;
}
#view-route-stats {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.view-stat-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: #cbd5e1;
  background: rgba(255,255,255,0.08); border: 1px solid #475569;
  padding: 4px 10px; border-radius: 99px;
}
.view-stat-badge i {
  font-size: 11px; opacity: 0.8;
}

/* White content area below header */
.view-route-content {
  background: #ffffff;
  padding: 10px 12px;
}

/* View mode accordions */
.view-accordion {
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  margin-bottom: 8px; overflow: hidden;
}
.view-accordion-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 9px 12px; background: var(--color-bg-card); border: none;
  font-size: 12px; font-weight: 600; color: var(--color-text);
  cursor: pointer; transition: background 0.15s;
}
.view-accordion-toggle:hover { background: var(--color-bg-hover); }
.view-accordion-toggle > span:first-of-type { flex: 1; text-align: left; }
.view-accordion-arrow {
  transition: transform 0.2s; flex-shrink: 0;
}
.view-accordion.open .view-accordion-arrow { transform: rotate(180deg); }
.view-accordion-body {
  display: none; padding: 10px 12px; font-size: 13px;
  border-top: 1px solid var(--color-border-light);
}
.view-accordion.open .view-accordion-body { display: block; }
.view-accordion-badge {
  font-size: 10px; font-weight: 600; color: var(--color-text-muted);
  background: var(--color-border-light); padding: 1px 7px; border-radius: 99px;
}

/* POI list items */
.view-poi-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; margin: 0 -8px; border-radius: 6px;
  font-size: 12.5px; color: var(--color-text);
  transition: background 0.15s;
}
.view-poi-item:hover { background: var(--color-bg-hover); }
.view-poi-icon {
  width: 20px; text-align: center; font-size: 12px; flex-shrink: 0;
}
.view-poi-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.view-poi-dist {
  font-size: 11px; color: var(--color-text-muted); flex-shrink: 0; white-space: nowrap;
}

/* ─── View Mode: Photo Grid ─── */
.view-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.view-photo-thumb {
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.view-photo-thumb:hover {
  border-color: #3b82f6;
}
.view-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ─── Community Photos & Ratings ─── */

.community-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #3b82f6;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.community-upload-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.community-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.community-photo-item {
  min-width: 0;
  overflow: hidden;
}
.community-photo-thumb {
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.community-photo-thumb:hover {
  border-color: #3b82f6;
}
.community-photo-thumb img {
  width: 100%;
  display: block;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.community-photo-caption {
  font-size: 11px;
  color: #374151;
  padding: 2px 2px 0;
  line-height: 1.3;
  word-break: break-word;
}
.community-add-caption {
  font-size: 10px;
  color: #9ca3af;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 2px 0;
}
.community-add-caption:hover {
  color: #3b82f6;
}
.community-photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
  font-size: 10px;
  color: #6b7280;
  gap: 4px;
  min-width: 0;
}
.community-photo-meta .community-photo-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.community-photo-author {
  display: flex;
  align-items: center;
  gap: 4px;
}
.community-org-badge {
  font-size: 10px;
  background: #eff6ff;
  color: #3b82f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
}

.community-love-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #9ca3af;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.community-love-btn:hover {
  color: #ef4444;
}
.community-love-btn.loved {
  color: #ef4444;
}
.community-love-btn span {
  font-size: 11px;
}

/* Community lightbox */
.community-lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 300000;
  align-items: center;
  justify-content: center;
}
.community-lightbox-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
}
.community-lightbox-img {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}
.community-lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(0,0,0,0.6);
  border: none;
  color: white;
  font-size: 28px;
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ratings */
.rating-item {
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.rating-item:last-child {
  border-bottom: none;
}
.rating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.rating-author {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
.rating-time {
  font-size: 11px;
  color: #9ca3af;
}
.rating-stars {
  margin-bottom: 4px;
}
.rating-stars i {
  font-size: 12px;
  color: #f59e0b;
}
.rating-comment {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.4;
  margin-bottom: 4px;
}

/* Review form */
.review-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-stars-input {
  display: flex;
  align-items: center;
}
.review-star-btn {
  font-size: 18px;
  color: #f59e0b;
  cursor: pointer;
  padding: 0 2px;
}
.review-textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.review-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.review-submit-btn {
  padding: 6px 14px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.review-submit-btn:hover {
  background: #2563eb;
}
.review-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.review-cancel-btn {
  padding: 6px 14px;
  background: #f1f5f9;
  color: #64748b;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.review-cancel-btn:hover {
  background: #e2e8f0;
}

/* ─── View Mode: Start / Finish Markers ─── */
.view-start-finish-marker {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.view-start-finish-marker.start { background: #22c55e; }
.view-start-finish-marker.finish { background: #ef4444; }

/* ─── View Mode: POI Hover Popup ─── */
.poi-hover-popup .mapboxgl-popup-content {
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.poi-hover-popup .mapboxgl-popup-tip {
  border-top-color: #fff;
}
.poi-hover-name {
  font-size: 13px; font-weight: 600; color: #003360;
  margin-bottom: 2px;
}
.poi-hover-address {
  font-size: 11px; color: #64748b;
  margin-bottom: 3px;
}
.poi-hover-desc {
  font-size: 11px; color: #475569;
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.poi-hover-rating {
  font-size: 11px; color: #60a5fa;
  margin-top: 3px;
}

/* ─── View Mode: Photo Hover Popup ─── */
.photo-hover-popup .mapboxgl-popup-content {
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.photo-hover-popup .mapboxgl-popup-tip {
  border-top-color: #fff;
}
.view-photo-hover-preview img {
  width: calc(100% - 8px); height: 130px;
  object-fit: cover; display: block;
  margin: 4px;
  border-radius: 3px;
}
.photo-preview-caption {
  padding: 6px 8px;
  font-size: 11px; color: #374151;
  line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Cluster hover grid */
.photo-cluster-hover {
  padding: 4px;
}
.photo-cluster-grid {
  display: flex;
  gap: 3px;
}
.photo-cluster-grid img {
  width: 80px; height: 60px;
  object-fit: cover; display: block;
  border-radius: 3px;
}
.photo-cluster-more {
  text-align: center;
  font-size: 11px; color: #64748b;
  padding: 4px 0 2px;
}

/* ─── View Mode: Lightbox ─── */
.view-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200001;
  align-items: center;
  justify-content: center;
}
.view-lightbox.open {
  display: flex;
}
.view-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}
.view-lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.view-lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.view-lightbox-caption {
  color: #fff;
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  max-width: 600px;
  line-height: 1.4;
}
.view-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 200002;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  line-height: 1;
}
.view-lightbox-close:hover { opacity: 1; }
.view-lightbox-prev,
.view-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200002;
  background: rgba(0,0,0,0.4);
  border: none;
  color: #fff;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
.view-lightbox-prev:hover,
.view-lightbox-next:hover { opacity: 1; background: rgba(0,0,0,0.6); }
.view-lightbox-prev { left: 16px; }
.view-lightbox-next { right: 16px; }

/* ─── Floating Map Toolbar (Komoot-style) ─── */
.map-toolbar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  zoom: var(--ui-scale);
  display: flex; align-items: center; gap: 10px; z-index: 160;
}
.map-toolbar-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.16);
  display: flex; align-items: center; justify-content: center;
  color: #1f2937; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.map-toolbar-btn:hover { background: #f3f4f6; }
.map-toolbar-btn.active { background: #1f2937; color: #fff; }
.map-toolbar-btn.disabled { opacity: 0.4; pointer-events: none; }
.map-toolbar-pill {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
  border: none; border-radius: 999px; background: #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.16);
  font-family: inherit; font-size: 15px; font-weight: 600; color: #1f2937; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.map-toolbar-pill:hover { background: #f8f8f7; }
.map-toolbar-pill.active { box-shadow: 0 0 0 2px #1f2937, 0 4px 16px rgba(0,0,0,0.16); }
.map-toolbar-pill .pill-arrow { color: #9ca3af; }

/* Top-right Export route */
.map-topright { position: absolute; top: 16px; right: 16px; zoom: var(--ui-scale); z-index: 160; }
.export-route-pill {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
  border: none; border-radius: 999px; background: #003360; box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  font-family: inherit; font-size: 15px; font-weight: 600; color: #fff; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.export-route-pill:hover { background: #00284d; }
.export-route-pill .pill-arrow { color: rgba(255,255,255,0.75); }
.export-route-pill.active { box-shadow: 0 0 0 3px rgba(0,51,96,0.35), 0 4px 16px rgba(0,0,0,0.18); }

/* Export options rows */
#export-popover { width: 320px; }
.export-options { display: flex; flex-direction: column; gap: 1px; }
.export-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 8px;
  border: none; background: transparent; border-radius: 12px; cursor: pointer; text-align: left; font-family: inherit;
}
.export-opt:hover:not(:disabled) { background: #f5f5f3; }
.export-opt:disabled { opacity: 0.4; cursor: not-allowed; }
.export-opt-icon { width: 42px; height: 42px; border-radius: 11px; background: #f1f3f0; display: flex; align-items: center; justify-content: center; color: #57534e; flex-shrink: 0; }
.export-opt-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.export-opt-text b { font-size: 15px; font-weight: 600; color: #1f2937; }
.export-opt-text small { font-size: 12.5px; color: #9a958c; }

/* No sidebar collapse — hide the chevron */
#left-sidebar-chevron { display: none !important; }

/* ─── Route Breakdown (Komoot Surfaces / Way types) ─── */
#breakdown-list { padding: 4px 16px 14px; }
.brk-title { font-size: 16px; font-weight: 700; color: #1f2937; margin-bottom: 10px; }
.brk-title-spaced { margin-top: 22px; }
.brk-bar { display: flex; width: 100%; height: 12px; border-radius: 6px; overflow: hidden; background: #eceae6; gap: 1px; }
.brk-bar span { display: block; height: 100%; min-width: 1px; }
.brk-keys { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.brk-key { display: flex; align-items: center; gap: 7px; font-size: 14px; color: #6b7280; }
.brk-key i { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.brk-key b { color: #1f2937; font-weight: 600; }
.brk-rows { display: flex; flex-direction: column; margin-top: 12px; }
.brk-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.brk-row i { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; }
.brk-row-label { flex: 1; min-width: 0; font-size: 15px; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brk-row-dist { font-size: 14px; color: #6b7280; }
.brk-row-pct { font-size: 13px; color: #9ca3af; min-width: 36px; text-align: right; }

/* ─── Map Content Popover ─── */
.map-content-popover {
  position: fixed;
  width: 460px; max-width: calc(100vw - 24px); max-height: calc(100vh - 110px);
  overflow-y: auto; background: #fff; border-radius: 24px;
  box-shadow: var(--popover-shadow); padding: 22px 22px 14px; z-index: 1200;
  transform-origin: top left;
  transform: scale(var(--ui-scale));
  animation: popover-pop 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
#map-content-popover { width: 380px; }
.map-content-popover.hidden { display: none; }
.mc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mc-header h2 { font-size: 22px; font-weight: 700; margin: 0; color: #1f2937; }
.mc-close { border: none; background: none; color: #9ca3af; cursor: pointer; padding: 4px; border-radius: 8px; }
.mc-close:hover { background: #f1f3f4; }
.mc-section-label { font-size: 13px; font-weight: 700; color: #9ca3af; margin-bottom: 6px; }

/* POI rows inside the popover (icon + label + checkbox), two abreast */
#pois-popover .poi-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
#pois-popover .poi-toggle {
  display: flex; align-items: center; gap: 12px; padding: 9px 6px;
  border: none; border-radius: 12px; background: transparent; cursor: pointer;
  margin: 0; white-space: normal; justify-content: flex-start; min-width: 0;
}
#pois-popover .poi-toggle:hover { background: #f5f5f3; }
#pois-popover .poi-toggle:has(input:checked) { background: transparent; }
#pois-popover .poi-toggle i {
  order: 1; width: 40px; height: 40px; border-radius: 10px; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center;
  color: #57534e; font-size: 16px; flex-shrink: 0; filter: none;
}
#pois-popover .poi-toggle span { order: 2; flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; color: #1f2937; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pois-popover .poi-toggle input[type="checkbox"] {
  order: 3; display: block; width: 22px; height: 22px; flex-shrink: 0; cursor: pointer;
}
/* Brand-green checked state (was default blue) */
#pois-popover .poi-toggle input[type="checkbox"]:checked {
  background-color: #387C2B; border-color: #387C2B;
}

/* ─── Map content collapsible groups (POIs / Layers / Legend) ─── */
.mc-groups { display: flex; flex-direction: column; }
.mc-group + .mc-group { border-top: 1px solid #eceae6; }
.mc-group-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 13px 4px; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #9ca3af;
}
.mc-group-header:hover { color: #6b7280; }
.mc-chevron { color: #c4c4c0; transition: transform 0.2s; flex-shrink: 0; }
.mc-group:not(.open) .mc-chevron { transform: rotate(-90deg); }
.mc-group:not(.open) .mc-group-body { display: none; }
.mc-group-body { padding-bottom: 6px; }

/* Relocated layer toggles → clean rows with a green check when active */
#map-content-popover .layer-group-label { display: none; }
#map-content-popover .layer-toggle {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px; width: 100%; padding: 10px 8px;
  border: none; background: transparent; border-radius: 12px; cursor: pointer; text-align: left;
  font-size: 15px; font-weight: 500; color: #1f2937;
}
#map-content-popover .layer-toggle:hover { background: #f6f6f4; }
#map-content-popover .layer-toggle > i {
  order: 1; width: 40px; height: 40px; border-radius: 10px; background: #f1f3f0;
  display: flex; align-items: center; justify-content: center; color: #57534e; flex-shrink: 0;
}
#map-content-popover .layer-toggle > span { order: 2; flex: 1; min-width: 0; white-space: nowrap; }
/* On/off toggle switch — a real element appended to each row via JS */
#map-content-popover .mc-switch {
  order: 3; flex-shrink: 0; margin-left: auto; position: relative;
  width: 46px; height: 27px; border-radius: 999px; background: #d6d6d2; transition: background 0.22s ease;
}
#map-content-popover .mc-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.22s ease;
}
#map-content-popover .layer-toggle.active .mc-switch { background: #387C2B; }
#map-content-popover .layer-toggle.active .mc-switch::after { transform: translateX(19px); }
#map-content-popover .layer-toggle.active i { color: #57534e; }
#map-content-popover .layer-toggle .layer-desc {
  order: 5; flex-basis: 100%; font-size: 12px; color: #9a958c; line-height: 1.35; margin: -2px 0 2px 54px;
}
#map-content-popover .layer-toggle .layer-suboption {
  order: 6; flex-basis: 100%; display: flex; align-items: center; gap: 8px; margin-left: 54px; font-size: 13px; color: #6b7280;
}
#map-content-popover .layer-toggle .layer-suboption input { width: 16px; height: 16px; }

/* Weather sliders on white */
#map-content-popover .weather-slider-controls { padding: 8px; border: none; }
#map-content-popover .weather-slider-title { color: #6b7280; }
#map-content-popover .weather-slider-value { color: #1f2937; }
#map-content-popover .weather-slider-range span { color: #9ca3af; }

/* Legend popover */
#legend-popover { width: 300px; }
#legend-popover .legend-content { max-height: none !important; padding: 0; overflow: visible; }
#legend-popover .legend-title { display: none; } /* heading already says "Legend" */

@media (max-width: 640px) {
  .map-toolbar { top: 10px; gap: 6px; }
  .map-toolbar-btn { width: 40px; height: 40px; }
  .map-toolbar-pill { height: 40px; padding: 0 14px; font-size: 14px; }
  .map-content-popover { width: 94vw; max-width: 94vw; }
  #map-content-popover { width: 94vw; }
}

/* ─── Trail context menu as an anchored popup (matches waypoint card) ─── */
/* Shrink the map-anchored popups (waypoint + trail menu) by --ui-scale.
   We scale the content toward the tail side (per Mapbox anchor class) so the
   card stays visually attached to its tip. */
:is(.wp-popup, .trailmenu-popup) .mapboxgl-popup-content {
  transform: scale(var(--ui-scale));
  transform-origin: center bottom;
}
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-top .mapboxgl-popup-content { transform-origin: center top; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-bottom .mapboxgl-popup-content { transform-origin: center bottom; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-left .mapboxgl-popup-content { transform-origin: left center; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-right .mapboxgl-popup-content { transform-origin: right center; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-top-left .mapboxgl-popup-content { transform-origin: left top; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-top-right .mapboxgl-popup-content { transform-origin: right top; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content { transform-origin: left bottom; }
:is(.wp-popup, .trailmenu-popup).mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content { transform-origin: right bottom; }

.trailmenu-popup .mapboxgl-popup-content {
  padding: 18px; border-radius: 18px; box-shadow: var(--popover-shadow);
  overflow: hidden; font-family: 'Manrope', sans-serif;
}
.trailmenu-popup .mapboxgl-popup-tip { border-top-color: #fff; }
.trailmenu-popup .mapboxgl-popup-close-button { display: none; }
/* Header: green uppercase, no divider (matches the waypoint card spacing) */
.trailmenu-popup .poi-context-menu-header {
  padding: 0 0 12px; border-bottom: none; background: none;
}
/* Action rows as grey pill buttons (like the waypoint popup) */
.trailmenu-popup .poi-context-menu-item {
  background: #f5f5f3; border-radius: 14px; padding: 13px 16px; margin-bottom: 8px;
  font-size: 16px; font-weight: 600; gap: 12px;
}
.trailmenu-popup .poi-context-menu-item:last-child { margin-bottom: 0; }
.trailmenu-popup .poi-context-menu-item:not(:last-child) { border-bottom: none; }
.trailmenu-popup .poi-context-menu-item:hover { background: #ececea; }

/* ─── Waypoint popup (Komoot-style, on map click) ─── */
.wp-popup .mapboxgl-popup-content {
  padding: 18px; border-radius: 18px; box-shadow: var(--popover-shadow);
  font-family: 'Manrope', sans-serif;
}
.wp-popup .mapboxgl-popup-tip { border-top-color: #fff; }
.wp-popup .mapboxgl-popup-close-button { display: none; }
.wp-pop-head { display: flex; align-items: flex-start; justify-content: space-between; }
.wp-pop-title { font-size: 22px; font-weight: 700; color: #1f2937; }
.wp-pop-close { border: none; background: none; color: #9ca3af; cursor: pointer; padding: 2px; margin: -2px -4px 0 0; }
.wp-pop-close:hover { color: #4b5563; }
.wp-pop-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.wp-pop-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 16px; border: none; border-radius: 14px; background: #f5f5f3;
  font-family: inherit; font-size: 16px; font-weight: 600; color: #1f2937; cursor: pointer;
  transition: background 0.15s;
}
.wp-pop-btn:hover { background: #ececea; }
.wp-pop-badge {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; color: #fff;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.wp-pop-badge.start { background: #387C2B; }
.wp-pop-badge.end { background: #c2410c; }
.wp-pop-badge.via { background: #3b82f6; }
.wp-pop-badge.finish { background-color: #fff; background-size: cover; background-position: center; color: transparent; }
/* Blank waypoint badge — plain pin dot, no letter */
.wp-pop-badge.blank { background: #3b82f6; box-shadow: inset 0 0 0 3px rgba(255,255,255,0.9); }
/* Badge inside the trail context menu rows */
.poi-context-menu-item .ctx-badge { display: flex; flex-shrink: 0; }
.poi-context-menu-item .ctx-badge .wp-pop-badge { width: 24px; height: 24px; font-size: 12px; }

/* ─── Elevation hover card (Komoot-style) ─── */
.ele-hover-card {
  position: fixed; z-index: 100050; display: none;
  background: #fff; border-radius: 14px; box-shadow: var(--popover-shadow);
  padding: 12px 14px; min-width: 210px; pointer-events: none;
  font-family: 'Manrope', sans-serif;
}
.ele-hover-card .ehc-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 0; }
.ele-hover-card .ehc-k { font-size: 14px; color: #6b7280; }
.ele-hover-card .ehc-v { font-size: 14px; font-weight: 700; color: #1f2937; display: inline-flex; align-items: center; gap: 7px; }
.ele-hover-card .ehc-sub { font-weight: 500; color: #6b7280; }
.ele-hover-card .ehc-chip { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex-shrink: 0; }

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