/* === Color Register ===
   Single source of truth for all colors.
   JS mirror: const C = {...} in index.html.
   Keep both in sync when changing colors.
*/
:root {
  /* Greens */
  --c-green: #27ae60;           /* hut marker dots, + add buttons, route-add-btn */
  --c-green-dark: #1e8449;      /* hover: add buttons, route-add-btn */
  --c-green-bright: #22c55e;    /* avail "many beds", timeline legend swatch */
  /* Blues */
  --c-blue: #2980b9;            /* book links, stay button, popup meta links */
  --c-blue-dark: #1a6da0;       /* hover: book links, stay button */
  --c-blue-active: #1d4ed8;     /* active toggle: "Show routes", "Drive time" */
  --c-blue-marker: #3498db;     /* "unknown" hut marker dots */
  --c-blue-light: #60a5fa;      /* diff-1 route dots/lines, unknown +add button */
  --c-blue-mid: #3b82f6;        /* hover: unknown +add button */
  --c-blue-drive: #1e40af;      /* drive time label text */
  --c-blue-drive-border: #93c5fd; /* drive time label border */
  --c-blue-tint: #f0f9ff;       /* hut search result hover bg */
  /* Purple */
  --c-purple: #8e44ad;          /* huetten-holiday book button */
  --c-purple-dark: #6c3483;     /* hover: hh book button */
  /* Reds */
  --c-red: #c0392b;             /* share-trip button, remove-stay hover */
  --c-red-dark: #a93226;        /* share-trip button border */
  --c-red-bright: #e74c3c;      /* share-trip hover, remove-stay badge */
  --c-red-full: #ef4444;        /* avail "full/no beds", timeline legend swatch */
  --c-red-route: #dc2626;       /* diff-2 route dots/lines */
  /* Warm */
  --c-orange: #f97316;          /* avail "few beds" (< persons+5) */
  --c-yellow: #eab308;          /* avail "some beds" (< persons+15), legend swatch */
  --c-yellow-marker: #fbbf24;   /* draggable start-date circle on timeline */
  /* Dark (topbar) */
  --c-dark: #2c3e50;            /* topbar background */
  --c-dark-mid: #3d5166;        /* topbar date input bg, copyDate bg */
  --c-dark-border: #5a6d7e;     /* topbar date input border */
  --c-dark-hover: #4a6a85;      /* topbar copyDate hover */
  --c-dark-muted: #5a7a95;      /* build version text */
  --c-dark-label: #cbd5e1;      /* topbar labels ("Start", "Persons") */
  /* Grays */
  --c-gray: #9ca3af;            /* week numbers, loading text, row buttons, legend "closed" */
  --c-gray-border: #e5e7eb;     /* controls/timeline border, week lines, section dividers */
  --c-gray-light: #f3f4f6;      /* search result dividers, nav button hover */
  --c-gray-input: #d1d5db;      /* input borders, drag handle, nav button border */
  --c-gray-label: #6b7280;      /* controls labels, route times, routes heading */
  --c-gray-hover: #f9fafb;      /* row hover bg, button default bg */
  --c-gray-icon: #999999;       /* "place" hut marker dots */
  --c-gray-route: #b0b0b0;      /* fallback route line color, route-diff dot default */
  --c-gray-noavail: #b0b5bd;    /* timeline tiles for non-bookable huts */
  /* Text */
  --c-text: #111;               /* month names, month border lines, diagonal lines */
  --c-text-primary: #1f2937;    /* hut row names, route dest names, search results */
  --c-text-secondary: #374151;  /* button text, row-btn hover */
  --c-text-body: #333;          /* hut name labels on map, route duration labels */
  --c-text-meta: #666;          /* popup meta text, timeline legend text */
  --c-text-detail: #444;        /* popup phone/warden detail text */
  /* Neutrals */
  --c-white: #fff;              /* backgrounds, marker borders, button text, text shadows */
  --c-black-route: #1a1a1a;     /* diff-3 route dots/lines */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

button, a, input, select, label {
  touch-action: manipulation;
}

button, .tl-nav, .tl-label, .tl-legend, #langPicker, #controls {
  user-select: none;
  -webkit-user-select: none;
}

button:active {
  transform: scale(0.96);
  opacity: 0.85;
}

:focus-visible {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
}

/* --- Top bar --- */
#topbar {
  height: 64px;
  display: flex;
  align-items: flex-end;
  padding: 0 16px 8px 0;
  background: linear-gradient(to bottom, rgb(47.7%, 71.6%, 90.2%) 41%, rgb(21%, 31.6%, 43.2%) 41%);
  color: var(--c-white);
  gap: 6px;
  z-index: 1000;
  position: relative;
  overflow: visible;
}

#topbar-logo {
  height: 50px;
  width: auto;
  flex-shrink: 0;
  margin-bottom: -2px;
}

#topbar h1 {
  font-size: 35px;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1;
  margin-bottom: -4px;
}

.logo-dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  background: #f1c40f;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
  position: relative;
  top: -2px;
}



#langPicker {
  margin-left: auto;
  display: flex;
  gap: 2px;
  align-items: center;
}
.lang-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 1px;
  opacity: 0.7;
  display: none;
}
.lang-btn:hover {
  opacity: 1;
}
.lang-btn.active {
  display: inline-flex;
  opacity: 1;
}
#langPicker.expanded .lang-btn {
  display: inline-flex;
}

#build {
  font-size: 10px;
  color: var(--c-dark-muted);
  font-family: monospace;
}

#topbar input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--c-dark-border);
  border-radius: 4px;
  background: var(--c-dark-mid);
  color: var(--c-white);
  font-size: 14px;
}

#topbar input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

#copyDate {
  padding: 4px 10px;
  border: 1px solid var(--c-dark-border);
  border-radius: 4px;
  background: var(--c-dark-mid);
  color: var(--c-white);
  font-size: 13px;
  cursor: pointer;
}

#copyDate:hover {
  background: var(--c-dark-hover);
}

/* --- Controls bar (below topbar) --- */
#controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-gray-border);
  z-index: 950;
  position: relative;
}

#controls .topbar-label {
  color: var(--c-gray-label);
}

#controls input[type="number"] {
  padding: 3px 6px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-white);
  color: var(--c-text);
  font-size: 13px;
  width: 52px;
}

#controls input[type="date"] {
  padding: 3px 8px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-white);
  color: var(--c-text);
  font-size: 13px;
}

#controls #copyDate {
  padding: 3px 10px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-gray-hover);
  color: var(--c-text-secondary);
  font-size: 12px;
  cursor: pointer;
}

#controls #copyDate:hover {
  background: var(--c-gray-border);
}

#hutSearchWrap {
  position: relative;
  margin-left: auto;
}

#hutSearch {
  padding: 3px 8px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  font-size: 13px;
  width: 180px;
  color: var(--c-text);
}

#hutSearchResults {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--c-white);
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 2000;
  min-width: 220px;
  max-height: 300px;
  overflow-y: auto;
}

#hutSearchResults.hidden {
  display: none;
}

.hut-search-result {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--c-text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--c-gray-light);
}

.hut-search-result:last-child {
  border-bottom: none;
}

.hut-search-result:hover {
  background: var(--c-blue-tint);
}

#controls #showRoutes {
  padding: 3px 10px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-gray-hover);
  color: var(--c-text-secondary);
  font-size: 12px;
  cursor: pointer;
}

#controls #showRoutes:hover {
  background: var(--c-gray-border);
}

#controls #showRoutes.active {
  background: var(--c-blue-active);
  border-color: var(--c-blue-active);
  color: var(--c-white);
}

#controls #driveTimeToggle {
  padding: 3px 10px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-gray-hover);
  color: var(--c-text-secondary);
  font-size: 12px;
  cursor: pointer;
}
#controls #driveTimeToggle:hover { background: var(--c-gray-border); }
#controls #driveTimeToggle.active {
  background: var(--c-blue-active);
  border-color: var(--c-blue-active);
  color: var(--c-white);
}

#controls #driveHutsToggle {
  padding: 3px 10px;
  border: 1px solid var(--c-green);
  border-radius: 4px;
  background: var(--c-gray-hover);
  color: var(--c-text-secondary);
  font-size: 12px;
  cursor: pointer;
}
#controls #driveHutsToggle:hover { background: var(--c-gray-border); }
#controls #driveHutsToggle.active {
  background: var(--c-green);
  border-color: var(--c-green);
  color: var(--c-white);
}

#controls #driveStartInput {
  width: 120px;
  padding: 3px 6px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  font-size: 12px;
}
#controls .drive-from-label {
  font-size: 12px;
  color: var(--c-text-secondary);
}
#controls .drive-thresh-wrap {
  display: inline-block;
  position: relative;
}
#controls .drive-thresh-wrap #driveThreshold {
  width: 56px;
  padding: 3px 16px 3px 6px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
}
#controls .drive-thresh-wrap #driveThreshold::-webkit-inner-spin-button {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
}
#controls .drive-thresh-wrap .drive-thresh-h {
  position: absolute;
  right: 17px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--c-text-secondary);
  pointer-events: none;
}

.drive-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-blue-drive);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--c-blue-drive-border);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

#controls #shareTrip {
  padding: 3px 10px;
  border: 1px solid var(--c-red-dark);
  border-radius: 4px;
  background: var(--c-red);
  color: var(--c-white);
  font-size: 12px;
  cursor: pointer;
}

#controls #shareTrip:hover {
  background: var(--c-red-bright);
}

/* --- Map --- */
#map {
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  width: 100%;
}

/* --- Timeline --- */
#timeline {
  background: var(--c-white);
  border-bottom: 1px solid var(--c-gray-border);
  position: relative;
  z-index: 900;
}

#timeline.hidden {
  display: none;
}

.tl-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 2px;
}

.tl-nav button {
  padding: 2px 10px;
  border: 1px solid var(--c-gray-input);
  border-radius: 4px;
  background: var(--c-white);
  cursor: pointer;
  font-size: 14px;
}

.tl-nav button:hover {
  background: var(--c-gray-light);
}

.tl-legend {
  font-size: 11px;
  color: var(--c-text-meta);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.tl-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 1px;
  margin-left: 6px;
}

.tl-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 24px;
}

.tl-inner {
  display: inline-block;
  min-width: 100%;
}

/* Header rows (months, weeks) */
.tl-header {
  display: flex;
  height: 14px;
}

.tl-header .tl-label {
  width: 240px;
  min-width: 240px;
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--c-white);
}

.tl-header .tl-tiles {
  display: flex;
  gap: 4px;
  padding-left: 4px;
  position: relative;
}

.tl-header .tl-tile-slot {
  width: 12px;
  min-width: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.tl-month-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  margin-left: 2px;
}

.tl-week-num {
  font-size: 9px;
  color: var(--c-gray);
  white-space: nowrap;
}

/* Month & week border lines */
.tl-month-border::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  width: 1px;
  height: 300px;
  background: var(--c-text);
  z-index: 1;
}

.tl-week-border::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  width: 1px;
  height: 300px;
  background: var(--c-gray-border);
  z-index: 1;
}

/* Hut rows */
.tl-row {
  display: flex;
  height: 18px;
  align-items: center;
  cursor: grab;
}

.tl-row.dragging {
  opacity: 0.4;
}

.tl-row:hover {
  background: var(--c-gray-hover);
}

.tl-row .tl-label {
  width: 240px;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--c-white);
  height: 18px;
}

.tl-row:hover .tl-label {
  background: var(--c-gray-hover);
}

.tl-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 0;
  min-width: 0;
  cursor: grab;
}

.tl-loading {
  font-size: 10px;
  color: var(--c-gray);
  font-style: italic;
}

.tl-row-btn {
  font-size: 11px;
  cursor: pointer;
  color: var(--c-gray);
  line-height: 1;
  flex-shrink: 0;
}

.tl-row-btn:hover {
  color: var(--c-text-secondary);
}

.tl-btn-remove {
  font-size: 10px;
  color: var(--c-white);
  background: var(--c-red-bright);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.tl-btn-remove:hover {
  background: var(--c-red);
}

.tl-btn-locate {
  font-size: 13px;
}

.tl-itin-date {
  font-size: 10px;
  color: var(--c-gray-label);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.tl-drag-handle {
  color: var(--c-gray-input);
  cursor: grab;
  font-size: 11px;
  letter-spacing: -2px;
  flex: 0 0 auto;
}

.tl-row .tl-tiles {
  display: flex;
  gap: 4px;
  padding-left: 4px;
}

.tl-row .tl-tile-slot {
  width: 12px;
  min-width: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tl-tile {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  cursor: pointer;
}

.tl-tile:hover {
  opacity: 0.75;
}

/* --- Popup --- */
.popup-topleft .leaflet-popup-tip-container {
  left: 16px;
  margin-left: 0;
  width: 20px;
}

.leaflet-popup-content {
  margin: 6px 8px;
  line-height: 1.25;
}

.hut-popup h3 {
  margin: 0 0 2px;
  font-size: 13px;
}

.hut-popup .meta {
  font-size: 11px;
  color: var(--c-text-meta);
  margin-bottom: 2px;
}

.hut-popup .meta a {
  color: var(--c-blue);
}

.hut-popup .altitude {
  font-weight: 600;
}

.hut-popup .detail {
  font-size: 11px;
  color: var(--c-text-detail);
  margin-bottom: 1px;
}

.hut-popup .detail a {
  color: var(--c-blue);
  text-decoration: none;
}

.hut-popup {
  min-width: 180px;
}

.hut-popup .actions {
  margin-top: 3px;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 4px;
}

.hut-popup .book-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hut-popup .book-link,
.hut-popup .add-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 20px;
  padding: 0 8px;
  background: var(--c-blue);
  color: var(--c-white);
  text-decoration: none;
  border-radius: 3px;
  font-size: 11px;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
}

.hut-popup .add-link {
  background: var(--c-green);
}

.hut-popup .hh-book {
  background: var(--c-purple);
}

.hut-popup .hh-book:hover {
  background: var(--c-purple-dark);
}

.hut-popup .book-link:hover {
  background: var(--c-blue-dark);
}

.hut-popup .add-link:hover {
  background: var(--c-green-dark);
}

.hut-popup .add-link-unknown {
  background: var(--c-gray);
}

.hut-popup .add-link-unknown:hover {
  background: var(--c-gray-dark, #666);
}

/* --- Routes in popup --- */
.routes-section {
  margin-top: 3px;
  border-top: 1px solid var(--c-gray-border);
  padding-top: 2px;
}

.routes-heading {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-gray-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1px;
}

.routes-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.route-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 1px 2px;
  line-height: 1.4;
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.route-item.route-unmatched {
  cursor: default;
}
.route-item:hover {
  background: var(--c-gray-hover);
}
.route-item[data-notes]:not([data-notes=""]):hover::after {
  position: absolute;
  left: 0;
  bottom: 100%;
  background: var(--c-text);
  color: var(--c-white);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

.route-diff {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--c-gray-route);
}

.diff-1 { background: var(--c-blue-light); }
.diff-2 { background: var(--c-red-route); }
.diff-3 { background: var(--c-black-route); }

.route-dest {
  flex: 1;
  color: var(--c-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-time {
  color: var(--c-gray-label);
  white-space: nowrap;
  flex-shrink: 0;
}

.route-locate-btn {
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-gray);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.route-locate-btn:hover {
  color: var(--c-text-secondary);
}

.route-add-btn {
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  background: var(--c-green);
  color: var(--c-white);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1.4;
}
.route-add-btn:hover {
  background: var(--c-green-dark);
}
.route-add-btn-grey {
  background: var(--c-gray);
}
.route-add-btn-grey:hover {
  background: #666;
}

.route-unmatched .route-dest {
  color: var(--c-gray);
}

/* --- Marker --- */
.hut-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.hut-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--c-green);
  color: var(--c-white);
  border-radius: 50%;
  border: 2px solid var(--c-white);
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.hut-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--c-text-body);
  white-space: nowrap;
  text-align: center;
  margin-top: 1px;
  text-shadow: 0 0 3px var(--c-white), 0 0 3px var(--c-white), 0 0 3px var(--c-white);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Topbar extras --- */
.topbar-label {
  font-size: 13px;
  color: var(--c-dark-label);
  white-space: nowrap;
}

#shareTrip {
  padding: 4px 10px;
  border: 1px solid var(--c-red-dark);
  border-radius: 4px;
  background: var(--c-red);
  color: var(--c-white);
  font-size: 13px;
  cursor: pointer;
}

#shareTrip:hover {
  background: var(--c-red-bright);
}

/* --- Weekend marker in week header --- */
.tl-header .tl-weekend-slot {
  border-bottom: 2px solid rgba(0,0,0,0.3);
}

/* --- Start date yellow circle marker --- */
.tl-start-marker {
  position: absolute;
  top: 0;
  width: 12px;
  height: 12px;
  background: var(--c-yellow-marker);
  border-radius: 50%;
  cursor: grab;
  z-index: 25;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tl-start-marker:hover {
  transform: scale(1.2);
}

.tl-start-dragging {
  cursor: grabbing;
  transform: scale(1.3);
  transition: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* --- Diagonal itinerary marker --- */
.tl-diag {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(
    to top right,
    transparent calc(50% - 1.3px),
    var(--c-text) calc(50% - 1.3px),
    var(--c-text) calc(50% + 1.3px),
    transparent calc(50% + 1.3px)
  );
}

/* --- Vertical line for 0-night pass-through --- */
.tl-vert {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(
    90deg,
    transparent calc(50% - 1.3px),
    var(--c-text) calc(50% - 1.3px),
    var(--c-text) calc(50% + 1.3px),
    transparent calc(50% + 1.3px)
  );
}

/* --- Stay line (horizontal itinerary extension) --- */
.tl-stay-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 12px;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(
    transparent calc(50% - 1.3px),
    var(--c-text) calc(50% - 1.3px),
    var(--c-text) calc(50% + 1.3px),
    transparent calc(50% + 1.3px)
  );
}



/* --- Route duration label --- */
.route-hover-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text-body);
  white-space: nowrap;
  text-shadow: 0 0 3px var(--c-white), 0 0 3px var(--c-white), 0 0 3px var(--c-white);
  pointer-events: none;
  text-align: center;
}

/* --- Intro overlay --- */
#introOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#introOverlay:not(.hidden) {
  display: flex;
}
#introBox {
  background: #fff;
  border-radius: 8px;
  padding: 24px 28px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
#introBox h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
#introBox ul {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.6;
}
#introBox li + li {
  margin-top: 6px;
}
.intro-icon {
  display: inline-block;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  min-width: 16px;
  text-align: center;
  padding: 0 3px;
  border-radius: 3px;
  vertical-align: middle;
}
.intro-icon-green { background: var(--c-green); }
.intro-icon-blue { background: var(--c-blue); }
.intro-screenshot {
  display: block;
  max-width: 100%;
  margin: 6px 0 2px;
  border-radius: 4px;
  border: 1px solid var(--c-gray-input);
}

#introHideLabel {
  display: block;
  font-size: 12px;
  color: var(--c-text-secondary);
  margin-bottom: 12px;
  cursor: pointer;
}
#introClose {
  padding: 5px 18px;
  background: var(--c-blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
#introClose:hover {
  background: var(--c-blue-dark);
}

/* --- Utility --- */
.hidden {
  display: none;
}

/* --- Hover-only styles (mouse devices) --- */
@media (hover: hover) and (pointer: fine) {
  .route-item[data-notes]:not([data-notes=""]):hover::after {
    content: attr(data-notes);
  }
}

/* --- Tile tooltip (mobile tap-to-see-info) --- */
.tl-tile-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: var(--c-white);
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* --- Collapse bar --- */
.collapse-bar {
  display: none;
  text-align: center;
  padding: 2px 0;
  background: var(--c-gray-light);
  border-bottom: 1px solid var(--c-gray-border);
  cursor: pointer;
  font-size: 10px;
  color: var(--c-gray-label);
  z-index: 901;
  line-height: 1;
}

/* --- Help button & dropdown --- */
.help-wrap {
  display: none;
  position: relative;
}

.tl-help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--c-gray-input);
  background: var(--c-white);
  color: var(--c-gray-label);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.tl-help-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--c-white);
  border: 1px solid var(--c-gray-input);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 8px 12px;
  z-index: 2000;
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--c-text-meta);
  white-space: nowrap;
}

.tl-help-dropdown.hidden {
  display: none;
}

/* --- Combined header (mobile only, hidden on desktop) --- */
.tl-combined-header {
  display: none;
}

/* --- Mobile (≤768px) --- */
@media (max-width: 768px) {
  /* Topbar */
  #topbar {
    height: auto;
    flex-wrap: wrap;
    padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
    gap: 4px 8px;
    background: var(--c-dark);
  }
  #topbar-logo { height: 30px; }
  #topbar h1 { font-size: 19px; }
  .logo-dot { width: 9px; height: 9px; margin-right: 3px; }
  #build { font-size: 9px; }

  /* Controls bar — single row, compact */
  #controls {
    flex-wrap: nowrap;
    gap: 3px;
    padding: 3px 6px;
  }
  #controls .topbar-label { display: none; }
  #controls input[type="date"] {
    font-size: 16px;
    padding: 2px 3px;
    height: 28px;
  }
  #controls input[type="number"] {
    font-size: 16px;
    width: 44px;
    height: 28px;
    padding: 2px 3px;
  }
  #controls #showRoutes,
  #controls #shareTrip {
    min-height: 28px;
    height: 28px;
    font-size: 10px;
    padding: 2px 6px;
    white-space: nowrap;
  }
  .help-wrap { display: block; }
  .collapse-bar { display: block; }
  /* Hide on mobile */
  #hutSearchWrap,
  #controls #driveTimeToggle,
  #controls #driveFromLabel,
  #controls #driveStartInput,
  #controls #driveThreshWrap,
  #controls #driveHutsToggle {
    display: none !important;
  }

  /* Map */
  #map {
    height: calc(100vh - 70px);
    height: calc(100dvh - 70px);
  }

  /* Timeline — hide nav (arrows + legend moved to ? button) */
  .tl-nav { display: none; }
  #tlMonths, #tlWeeks { display: none; }
  .tl-combined-header { display: flex !important; }
  .tl-row .tl-label,
  .tl-header .tl-label {
    width: 132px;
    min-width: 132px;
  }
  .tl-row { height: 16px; }
  .tl-row .tl-label {
    height: 16px;
    cursor: grab;
    touch-action: none;
  }
  .tl-row-name {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  /* Hide +/- on mobile — hut name takes priority */
  .tl-btn-plus, .tl-btn-minus {
    display: none;
  }
  .tl-itin-date { display: none; }
  .tl-drag-handle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
  }
  .tl-btn-remove {
    font-size: 9px;
    flex-shrink: 0;
  }
  .tl-btn-locate {
    display: none;
  }
  .tl-scroll {
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tl-scroll::-webkit-scrollbar { display: none; }

  /* Hut labels on map */
  .hut-label {
    font-size: 8px;
    max-width: 60px;
  }

  /* Popup — compact on tablets */
  .leaflet-popup-content {
    margin: 4px 6px;
  }
  .hut-popup { min-width: auto; }
  .hut-popup h3 { font-size: 12px; }
  .hut-popup .book-link,
  .hut-popup .add-link {
    min-height: 20px;
    min-width: 28px;
    padding: 1px 6px;
    font-size: 10px;
  }
  .route-item {
    min-height: auto;
    padding: 1px 1px;
    gap: 2px;
  }
  .route-add-btn {
    min-width: 20px;
    min-height: 16px;
    font-size: 9px;
    padding: 0 4px;
  }

  /* Intro overlay → bottom sheet style */
  #introOverlay {
    align-items: flex-end;
  }
  #introBox {
    max-width: 100%;
    width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #introBox h2 { font-size: 16px; }
  #introBox ul { font-size: 13px; }
  #introClose {
    min-height: 36px;
    width: 100%;
    font-size: 14px;
  }
  #introHideLabel { font-size: 13px; }

  /* Language picker */
  .lang-btn {
    font-size: 18px;
    padding: 3px 2px;
    min-width: 28px;
    min-height: 28px;
  }

  /* Collapsed UI state — map only */
  body.ui-collapsed #topbar,
  body.ui-collapsed #controls,
  body.ui-collapsed #timeline {
    display: none !important;
  }
  body.ui-collapsed .collapse-bar {
    background: rgba(255,255,255,0.85);
  }
}

/* --- Small phones (≤480px) --- */
@media (max-width: 480px) {
  #topbar { padding: calc(4px + env(safe-area-inset-top)) 8px 4px; background: var(--c-dark); }
  #topbar-logo { height: 27px; }
  #topbar h1 { font-size: 18px; }
  .logo-dot { width: 8px; height: 8px; margin-right: 2px; }

  .tl-row .tl-label,
  .tl-header .tl-label {
    width: 120px;
    min-width: 120px;
  }
  .tl-row-name { font-size: 9px; }

  /* Popup — narrow on small phones, hide route duration */
  .leaflet-popup-content {
    max-width: 140px !important;
  }
  .route-time { display: none; }
}

/* --- Touch-only: show notes inline on tap instead of CSS tooltip --- */
@media (hover: none), (pointer: coarse) {
  .route-item[data-notes]:not([data-notes=""])::after {
    display: none !important;
  }
}

.route-note-inline {
  font-size: 10px;
  color: var(--c-text-meta);
  font-style: italic;
  padding: 1px 0 1px 11px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
