:root {
  --bg: #f8f3e8;
  --panel: #fffaf0;
  --text: #21190f;
  --muted: #625645;
  --accent: #7b3f22;
  --start: #3ca324;
  --end: #d64a2f;
  --optional: #6c5f54;
  --border: rgba(33, 25, 15, 0.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
.map-shell { display: grid; grid-template-columns: 390px 1fr; width: 100%; height: 100vh; min-height: 620px; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 24px; }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; color: var(--accent); }
h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.05; }
p { color: var(--muted); line-height: 1.45; }
.stop-list { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.stop-button { width: 100%; text-align: left; cursor: pointer; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; color: var(--text); box-shadow: 0 1px 8px rgba(33,25,15,.04); }
.stop-button:hover, .stop-button:focus { outline: 2px solid rgba(123,63,34,.25); border-color: rgba(123,63,34,.45); }
.stop-number { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; margin-right: 8px; }
.stop-number.start { background: var(--start); }
.stop-number.end { background: var(--end); }
.stop-number.optional { background: var(--optional); }
.stop-name { font-weight: 750; }
.stop-subtitle { display: block; margin-top: 6px; margin-left: 34px; font-size: 13px; color: var(--muted); }
.map { width: 100%; height: 100%; }
.marker { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; border: 2px solid #fff; box-shadow: 0 2px 9px rgba(0,0,0,.28); cursor: pointer; }
.marker.start { background: var(--start); }
.marker.end { background: var(--end); }
.marker.optional { background: var(--optional); }
.mapboxgl-popup-content { border-radius: 14px; padding: 16px 18px; max-width: 340px; color: var(--text); }
.popup-title { margin: 0 0 4px; font-size: 17px; line-height: 1.2; }
.popup-subtitle { margin: 0 0 8px; color: var(--accent); font-size: 13px; font-weight: 800; line-height: 1.3; }
.popup-address { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.popup-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.mobile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% + 48px);
  margin: -24px -24px 22px;
  padding: 15px 18px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  font-size: 14px;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--border);
}

.mobile-toggle::before {
  content: '‹';
  font-size: 22px;
  line-height: 1;
  transform: translateY(-1px);
}

.map-shell.panel-collapsed {
  grid-template-columns: 64px 1fr;
}

.map-shell.panel-collapsed .sidebar {
  padding: 0;
  overflow: hidden;
}

.map-shell.panel-collapsed .intro,
.map-shell.panel-collapsed .stop-list {
  display: none;
}

.map-shell.panel-collapsed .mobile-toggle {
  width: 64px;
  height: 100vh;
  margin: 0;
  padding: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  border-radius: 0;
}

.map-shell.panel-collapsed .mobile-toggle::before {
  content: '›';
  writing-mode: horizontal-tb;
  transform: rotate(180deg);
}

@media (max-width: 760px) {
  html, body { height: 100%; overflow: hidden; }

  .map-shell,
  .map-shell.panel-collapsed {
    display: block;
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 0;
  }

  .map {
    width: 100%;
    height: 100vh;
  }

  .sidebar,
  .map-shell.panel-collapsed .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    max-height: 68vh;
    overflow-y: auto;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    padding: 0 18px 18px;
    box-shadow: 0 -8px 28px rgba(33,25,15,.16);
    transition: transform 0.28s ease;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.collapsed,
  .map-shell.panel-collapsed .sidebar {
    transform: translateY(calc(100% - 58px));
    overflow: hidden;
  }

  .map-shell.panel-collapsed .intro,
  .map-shell.panel-collapsed .stop-list {
    display: block;
  }

  .mobile-toggle,
  .map-shell.panel-collapsed .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
    width: calc(100% + 36px);
    height: auto;
    margin: 0 -18px 16px;
    padding: 16px 18px;
    border: 0;
    border-radius: 22px 22px 0 0;
    background: var(--panel);
    color: var(--accent);
    font-weight: 850;
    font-size: 15px;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 1px 0 var(--border);
    writing-mode: horizontal-tb;
    transform: none;
  }

  .mobile-toggle::before,
  .map-shell.panel-collapsed .mobile-toggle::before {
    content: '';
    position: absolute;
    top: 8px;
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(33,25,15,.25);
    transform: none;
  }

  .intro { padding-top: 0; }
  h1 { font-size: 23px; }

  .mapboxgl-ctrl-top-right {
    top: 14px;
  }
}

.route-controls { margin: 18px 0 6px; }
.route-toggle {
  width: 100%;
  border: 1px solid rgba(123,63,34,.35);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 1px 8px rgba(33,25,15,.06);
}
.route-toggle:hover, .route-toggle:focus { outline: 2px solid rgba(123,63,34,.25); }
.route-toggle[aria-pressed="true"] { background: #fff; color: var(--accent); }
.route-status { margin: 8px 3px 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.map-shell.panel-collapsed .route-controls { display: none; }
@media (max-width: 760px) {
  .map-shell.panel-collapsed .route-controls { display: block; }
  .route-controls { margin: 14px 0 8px; }
}
