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

:root {
  --earth: #2C3A2E;
  --earth-light: #3D4F40;
  --sage: #7A9B76;
  --sage-muted: #A8C4A4;
  --sand: #E8DFD0;
  --sand-light: #F5F0E8;
  --cream: #FDFBF7;
  --accent: #D4856A;
  --accent-hover: #C07050;
  --text: #1E2A20;
  --text-muted: #5F6F61;
  --shadow: rgba(44, 58, 46, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
}

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Header ── */
header {
  background: var(--earth);
  color: var(--sand-light);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1000;
  box-shadow: 0 4px 20px var(--shadow);
}

.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--sand);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo svg { width: 28px; height: 28px; }

.logo-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sage-muted);
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--earth-light);
}

.header-contact {
  margin-left: auto;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sage-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--earth-light);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}

.header-contact:hover {
  color: var(--sand);
  border-color: var(--sage-muted);
}

/* ── Sheet contact link (mobile, bottom of sidebar) ── */
.sheet-contact {
  display: none;
}

/* ── Layout ── */
.app-layout {
  display: grid;
  grid-template-columns: 400px 1fr 180px;
  grid-template-rows: 1fr;
  height: calc(100dvh - 62px);
}

/* Main content (sidebar + map) casts a rightward shadow over the ad column,
   giving it visual priority and gently receding the ad space behind it. */
.sidebar {
  position: relative;
  z-index: 2;
}

.map-container {
  position: relative;
  z-index: 2;
  box-shadow: 6px 0 28px rgba(44, 58, 46, 0.13);
}

/* ── Ad column ── */
.ad-column {
  grid-column: 3;
  grid-row: 1;
  background: #EDE7D9;
  border-left: 1px solid #D8D0C4;
  padding: 0.75rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  position: relative;
}

/* Inset shadow on left edge reinforces the "behind the main content" depth */
.ad-column::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 14px;
  background: linear-gradient(to right, rgba(44, 58, 46, 0.06), transparent);
  pointer-events: none;
}

.ad-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.55;
  align-self: flex-start;
  padding-left: 0.1rem;
}

.ad-slot {
  width: 160px;
  height: 600px;
  max-height: 600px;
  border: none;
  background: none;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.ad-slot:hover {
  border-color: #8A9E87;
  background: rgba(255, 255, 255, 0.48);
}

.ad-slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-align: center;
}

.ad-slot-bunny {
  width: 38px;
  height: 38px;
  opacity: 0.6;
}

.ad-slot-heading {
  font-family: 'DM Serif Display', serif;
  font-size: 0.78rem;
  color: #5A6E5C;
  line-height: 1.2;
}

.ad-slot-body {
  font-size: 0.62rem;
  color: #7A8E78;
  font-weight: 300;
  line-height: 1.4;
}

.ad-slot-cta {
  display: block;
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-align: center;
  text-decoration: none;
  color: white;
  background: var(--sage);
  border-radius: 6px;
  border-top: none;
  transition: background 0.2s;
}

.ad-slot-cta:hover { background: var(--earth-light); }

/* ── Mobile bottom sheet handle & preview (hidden on desktop) ── */
.sidebar-handle {
  display: none;
}

.sheet-preview {
  display: none;
}

/* ── Floating plan button (hidden on desktop) ── */
.btn-plan-fab {
  display: none;
}

/* Mobile styles at end of file — after all desktop rules so the cascade is correct */

/* ── Sidebar ── */
.sidebar {
  background: var(--cream);
  border-right: 1px solid var(--sand);
  overflow-y: auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sage-muted); border-radius: 4px; }

/* ── Panels ── */
.panel {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 12px var(--shadow);
  border: 1px solid var(--sand);
}

.panel-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  color: var(--earth);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title .step-badge {
  background: var(--sage);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  text-transform: uppercase;
}

/* ── Form elements ── */
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

input[type="number"], select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--sand);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--sand-light);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -moz-appearance: textfield;
}

input[type="number"]:focus, select:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(122, 155, 118, 0.15);
}

input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.input-group { margin-bottom: 0.85rem; }
.input-group:last-child { margin-bottom: 0; }

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-weight: 300;
}

/* ── Steps slider ── */
.steps-display {
  text-align: center;
  margin-bottom: 0.75rem;
}

.steps-number {
  font-family: 'DM Serif Display', serif;
  font-size: 2.8rem;
  color: var(--earth);
  line-height: 1;
}

.steps-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  font-weight: 500;
}

.steps-distance {
  font-size: 0.85rem;
  color: var(--sage);
  font-weight: 500;
  margin-top: 0.2rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, var(--sage), var(--accent));
  border-radius: 3px;
  outline: none;
  margin: 0.75rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: white;
  border: 3px solid var(--sage);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }

.steps-presets {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.4rem;
}

.preset-btn {
  background: var(--sand-light);
  border: 1.5px solid var(--sand);
  min-height: 38px;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
}

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(212, 133, 106, 0.3); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--sand-light);
  border: 1.5px solid var(--sand);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover { background: var(--sand); color: var(--text); }

/* ── Address search (desktop) ── */
.search-overlay {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 2rem));
  z-index: 999;
  pointer-events: none;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
  padding: 0.55rem 0.7rem;
  pointer-events: all;
  transition: box-shadow 0.2s;
}

.search-bar:focus-within {
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.2);
}

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

#search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
}

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

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.search-clear:hover { color: var(--text); }

.search-clear.visible { display: flex; }

.search-results {
  list-style: none;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.13);
  margin-top: 0.4rem;
  overflow: hidden;
  display: none;
  pointer-events: all;
}

.search-results.visible { display: block; }

.search-result-item {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--sand);
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--sand-light); }

.search-result-empty {
  cursor: default;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.search-result-empty:hover { background: transparent; }

.search-result-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Map ── */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-container { position: relative; }

.map-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 999;
  pointer-events: none;
}

.map-hint {
  background: white;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px var(--shadow);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  animation: fadeSlideIn 0.4s ease;
  border-left: 3px solid var(--sage);
}

.map-hint.hidden { display: none; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Experimental section (collapsible) ── */
.experimental-section {
  border: 1.5px solid #F0D080;
  border-radius: var(--radius-sm);
  background: #FFFBEE;
  overflow: hidden;
}

.panel + .experimental-section,
.experimental-section:not(.panel) { margin-top: 0.85rem; }

.experimental-summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: #7A6010;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.experimental-summary::-webkit-details-marker { display: none; }

.experimental-chevron {
  display: flex;
  align-items: center;
  color: #B8980A;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.experimental-section[open] .experimental-chevron {
  transform: rotate(180deg);
}

.experimental-badge {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #F5C400;
  color: #5A4800;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  flex-shrink: 0;
}

.experimental-body {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid #F0D080;
}

.experimental-note {
  font-size: 0.72rem;
  color: #7A6010;
  line-height: 1.45;
  padding: 0.55rem 0 0.5rem;
  font-weight: 300;
}

/* ── OSM contribution CTA ── */
.osm-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--sand-light);
  border: 1.5px solid var(--sage-muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.osm-cta:hover {
  background: white;
  border-color: var(--sage);
  box-shadow: 0 2px 10px rgba(122, 155, 118, 0.15);
}

.osm-cta:active {
  background: var(--sand);
}

.osm-cta-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.osm-cta:hover .osm-cta-icon {
  background: var(--earth);
}

.osm-cta-body {
  flex: 1;
  min-width: 0;
}

.osm-cta-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.osm-cta-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.4;
  margin-top: 0.15rem;
}

.osm-cta-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

.osm-cta:hover .osm-cta-arrow {
  color: var(--sage);
  transform: translate(2px, -2px);
}

/* ── Route summary ── */
.route-summary {
  display: none;
  animation: fadeSlideIn 0.4s ease;
}

.route-summary.visible { display: block; }

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  text-align: center;
  padding: 0.65rem 0.3rem;
  background: var(--sand-light);
  border-radius: var(--radius-sm);
}

.stat-value {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--earth);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── POI list ── */
.poi-list { list-style: none; }

.poi-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--sand);
  animation: fadeSlideIn 0.3s ease;
}

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

.poi-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.poi-icon.park { background: #E8F5E9; }
.poi-icon.viewpoint { background: #E3F2FD; }
.poi-icon.historic { background: #FFF3E0; }
.poi-icon.water { background: #E0F7FA; }
.poi-icon.art { background: #F3E5F5; }
.poi-icon.food { background: #FBE9E7; }
.poi-icon.default { background: var(--sand-light); }

.poi-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.poi-type {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Progress bar ── */
.progress-bar {
  display: none;
  flex-direction: column;
  gap: 0;
  padding: 0.5rem 0;
  animation: fadeSlideIn 0.3s ease;
}

.progress-bar.visible { display: flex; }

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  opacity: 0.35;
  transition: opacity 0.3s;
  position: relative;
}

.progress-step::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 28px;
  bottom: -2px;
  width: 2px;
  background: var(--sand);
}

.progress-step:last-child::before { display: none; }

.progress-step.active {
  opacity: 1;
}

.progress-step.active .progress-dot {
  background: var(--sage);
  box-shadow: 0 0 0 5px rgba(122, 155, 118, 0.25);
}

.progress-step.active .progress-dot::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.progress-step.done { opacity: 0.7; }

.progress-step.done .progress-dot {
  background: var(--sage);
}

.progress-step.done .progress-dot::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 3px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: none;
}

.progress-step.done::before {
  background: var(--sage-muted);
}

.progress-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sand);
  flex-shrink: 0;
  position: relative;
  transition: background 0.3s, box-shadow 0.3s;
}

.progress-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.progress-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 300;
}

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

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.toggle-label {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 400;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--sand);
  border-radius: 11px;
  transition: background 0.25s;
}

.toggle input:checked + .toggle-track { background: var(--sage); }

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 4px var(--shadow);
  transition: transform 0.25s;
}

.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); }

/* ── Warning ── */
.warning-msg {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  color: #7B6B1A;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

.warning-msg.visible { display: block; }

/* ── Error ── */
.error-msg {
  background: #FFF0ED;
  border: 1px solid #FFCDC2;
  color: #9B3522;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

.error-msg.visible { display: block; }

/* ── Route actions ── */
.route-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.route-actions .btn-secondary { flex: 1; text-align: center; }

/* ── Leaflet overrides ── */
.leaflet-control-zoom a {
  background: white !important;
  color: var(--earth) !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'DM Sans', sans-serif !important;
}

.route-arrow { background: none !important; border: none !important; }

/* ═══════════════════════════════════════════════════════════════════
   Mobile — max-width: 900px

   Field Guide principles applied:
   · Full-viewport map — the walk IS the map
   · Thumb-zone FAB (bottom-right, natural reach)
   · 44 px minimum touch targets on every interactive element
   · Draggable bottom sheet: collapsed → half → full
   · Flat panel sections separated by hairline dividers
   · env(safe-area-inset-*) for notched/dynamic-island devices
   · Momentum-based transitions (cubic-bezier ease-out)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {

  /* ── Chrome: hide desktop header, kill ad column ── */
  header { display: none; }
  .ad-column { display: none; }

  /* ── Full-viewport map grid ── */
  .app-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    height: 100dvh;
    position: relative;
    overflow: hidden;
  }

  .map-container {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    box-shadow: none;
  }

  /* ── Bottom sheet ──
     Fixed overlay that slides up from bottom edge.
     Three states driven by class: collapsed | half | (no class = full open). */
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1001;
    max-height: 88dvh;
    background: var(--cream);
    border-right: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -3px 24px rgba(44, 58, 46, 0.18);
    padding: 0 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    will-change: transform;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  /* Collapsed: handle + preview peek (~76 px visible) */
  .sidebar.collapsed {
    transform: translateY(calc(100% - 76px));
    overflow: hidden;
  }

  /* Half: roughly 45 dvh visible */
  .sidebar.half {
    transform: translateY(calc(100% - 45dvh));
  }

  /* While user is dragging, kill the transition so movement is 1:1 */
  .sidebar.dragging { transition: none; }

  /* ── Drag handle ── */
  .sidebar-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 0 8px;
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    position: sticky;
    top: 0;
    background: var(--cream);
    z-index: 2;
    margin: 0 -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    min-height: 52px;
    flex-shrink: 0;
  }

  .sidebar-handle:active { cursor: grabbing; }

  .sidebar-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #C2CCBE;
    flex-shrink: 0;
    transition: background 0.15s;
  }

  .sidebar-handle:active .sidebar-handle-bar { background: var(--sage); }

  /* ── Sheet preview (visible inside collapsed handle area) ── */
  .sheet-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0 0 2px;
  }

  .sheet-preview-steps {
    font-family: 'DM Serif Display', serif;
    font-size: 1rem;
    color: var(--earth);
  }

  .sheet-preview-dist {
    font-size: 0.76rem;
    color: var(--sage);
    font-weight: 500;
  }

  /* ── Panels: flat, divided by hairlines ── */
  .panel {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 1rem 0;
    border-bottom: 1px solid var(--sand);
  }

  .panel:last-of-type { border-bottom: none; }

  /* Experimental panels keep their yellow border + background on mobile */
  .experimental-section.panel {
    border: 1.5px solid #F0D080;
    border-radius: var(--radius-sm);
    background: #FFFBEE;
    padding: 0;
    margin: 0.5rem 0;
  }

  .panel-title {
    font-size: 0.92rem;
    margin-bottom: 0.65rem;
  }

  .step-badge {
    width: 20px;
    height: 20px;
    font-size: 0.58rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Touch targets: 44 px minimum everywhere (field guide) ── */
  .preset-btn {
    min-height: 44px;
    padding: 0.45rem 0.85rem;
    font-size: 0.76rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
  }

  .btn-secondary {
    min-height: 44px;
    font-size: 0.82rem;
  }

  .btn-plan-inline { display: none; }

  .toggle {
    width: 48px;
    height: 28px;
    min-width: 48px;
  }

  .toggle-track { border-radius: 14px; }

  .toggle-thumb {
    width: 24px;
    height: 24px;
  }

  .toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }

  input[type="number"],
  select {
    min-height: 44px;
    font-size: 1rem;
    border-radius: 10px;
  }

  input[type="range"] {
    height: 8px;
    margin: 0.75rem 0;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 30px;
    height: 30px;
    border-width: 3px;
  }

  label { font-size: 0.72rem; }
  .input-hint { font-size: 0.66rem; }
  .toggle-label { font-size: 0.8rem; }
  .toggle-row { padding: 0.5rem 0; }

  /* ── Search overlay: compact bar, clear of Leaflet zoom (top-left) ── */
  .search-overlay {
    top: calc(0.6rem + env(safe-area-inset-top, 0px));
    left: calc(0.6rem + 44px);
    right: 0.75rem;
    width: auto;
    transform: none;
  }

  .search-bar {
    border-radius: 10px;
    padding: 0.35rem 0.55rem;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.1);
    min-height: 36px;
  }

  #search-input { font-size: 0.82rem; }

  /* ── Map hint: floating toast above FAB zone ── */
  .map-overlay {
    top: auto;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    left: 0.75rem;
    right: 0.75rem;
  }

  .map-hint {
    font-size: 0.78rem;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    border-left: none;
    text-align: center;
    justify-content: center;
    box-shadow: 0 2px 14px rgba(44, 58, 46, 0.14);
  }

  /* ── FAB: thumb-zone, bottom-right ── */
  .btn-plan-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    z-index: 1002;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 18px rgba(212, 133, 106, 0.35);
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s, transform 0.12s, box-shadow 0.2s;
  }

  .btn-plan-fab:active { transform: scale(0.92); }

  .btn-plan-fab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(212, 133, 106, 0.15);
  }

  .btn-plan-fab.hidden { display: none; }

  /* ── Leaflet zoom: top-left, clear of safe area ── */
  .leaflet-control-zoom {
    margin-top: calc(0.6rem + env(safe-area-inset-top, 0px)) !important;
    margin-left: 0.6rem !important;
  }

  .leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 16px !important;
  }

  /* ── Steps display ── */
  .steps-number { font-size: 2.1rem; }
  .steps-display { margin-bottom: 0.4rem; }
  .steps-label { font-size: 0.7rem; }
  .steps-distance { font-size: 0.8rem; }

  .steps-presets {
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  /* ── Route summary ── */
  .summary-stats { gap: 0.5rem; }

  .stat {
    padding: 0.6rem 0.25rem;
    border-radius: 10px;
  }

  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.6rem; }

  .route-summary .panel {
    border-bottom: none;
    padding-top: 0.5rem;
  }

  .route-actions {
    gap: 0.4rem;
    margin-top: 0.65rem;
  }

  /* ── Progress bar ── */
  .progress-step { padding: 0.35rem 0.2rem; }
  .progress-label { font-size: 0.78rem; }
  .progress-detail { font-size: 0.68rem; }

  .progress-dot {
    width: 18px;
    height: 18px;
  }

  /* ── Warning / error ── */
  .warning-msg,
  .error-msg {
    border-radius: 10px;
    font-size: 0.8rem;
  }

  /* ── Experimental section ── */
  .experimental-summary { font-size: 0.76rem; padding: 0.6rem 0.7rem; min-height: 44px; }
  .experimental-note { font-size: 0.68rem; }
  .experimental-badge { font-size: 0.55rem; }

  /* ── OSM CTA ── */
  .osm-cta {
    gap: 0.55rem;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    min-height: 44px;
  }

  .osm-cta-icon { width: 32px; height: 32px; }
  .osm-cta-title { font-size: 0.78rem; }
  .osm-cta-sub { font-size: 0.65rem; }

  /* ── POI list ── */
  .poi-item {
    padding: 0.55rem 0;
    gap: 0.55rem;
  }

  .poi-icon {
    width: 30px;
    height: 30px;
    font-size: 0.82rem;
  }

  .poi-name { font-size: 0.82rem; }
  .poi-type { font-size: 0.66rem; }

  /* ── Input row ── */
  .input-row { gap: 0.6rem; }
  .input-group { margin-bottom: 0.7rem; }

  /* ── Sheet contact link ── */
  .sheet-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 0;
    font-size: 0.74rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-top: 1px solid var(--sand);
    margin-top: 0.25rem;
    min-height: 44px;
    transition: color 0.15s;
  }

  .sheet-contact:hover { color: var(--sage); }
}

/* ── Small phones (≤ 400 px) ── */
@media (max-width: 400px) {

  .sidebar {
    padding: 0 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .sidebar.collapsed {
    transform: translateY(calc(100% - 68px));
  }

  .sidebar-handle {
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    min-height: 48px;
  }

  .sheet-preview-steps { font-size: 0.9rem; }
  .sheet-preview-dist { font-size: 0.7rem; }

  .steps-number { font-size: 1.9rem; }

  .steps-presets { gap: 0.3rem; }

  .preset-btn {
    min-height: 40px;
    padding: 0.4rem 0.7rem;
    font-size: 0.72rem;
  }

  .input-row {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .btn-plan-fab {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .search-overlay {
    left: calc(0.5rem + 40px);
    right: 0.5rem;
  }

  .panel { padding: 0.85rem 0; }
  .panel-title { font-size: 0.88rem; }
  .stat-value { font-size: 1.05rem; }
}
