/* Alberta Gravel — shared design tokens and map-page components */

:root {
  --forest-900: #14261b;
  --forest-800: #1c3526;
  --forest-700: #264a33;
  --forest-600: #2f5d3f;
  --forest-500: #3d7350;
  --forest-100: #e2ebe3;
  --forest-50: #f1f5f1;
  --sand-50: #fbf8f1;
  --sand-100: #f4eddd;
  --sand-200: #e9dcc0;
  --sand-300: #d9c49b;
  --sand-500: #b99a62;
  --ochre-500: #d08a2c;
  --ochre-600: #8f5a12;
  --ink: #1a231d;
  --ink-soft: #3b463f;
  --muted: #66736b;
  --line: rgba(26, 35, 29, 0.12);
  --surface: #ffffff;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(20, 38, 27, 0.08);
  --shadow: 0 4px 14px rgba(20, 38, 27, 0.12), 0 1px 3px rgba(20, 38, 27, 0.08);
  --shadow-lg: 0 18px 40px rgba(20, 38, 27, 0.2), 0 3px 8px rgba(20, 38, 27, 0.1);
  --topbar-h: 60px;
  --drawer-w: 400px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body.map-page {
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand-50);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--ochre-500);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: 1200;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--forest-800);
  color: var(--sand-100);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sand-300);
}

.topnav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topnav a {
  color: var(--sand-100);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.topnav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.topnav a.nav-facebook {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(233, 220, 192, 0.35);
}

.topnav a.nav-facebook:hover {
  border-color: rgba(233, 220, 192, 0.6);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-ext {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.75;
}

.route-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--forest-900);
  background: var(--sand-300);
  padding: 5px 10px;
  border-radius: 999px;
  margin-right: 6px;
  white-space: nowrap;
}

/* ---------- App shell ---------- */

.app {
  position: relative;
  height: calc(100% - var(--topbar-h));
}

#map {
  position: absolute;
  inset: 0;
  background: var(--forest-50);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--forest-700);
  color: #fff;
}

.btn-primary:hover {
  background: var(--forest-600);
}

.btn-secondary {
  background: var(--surface);
  color: var(--forest-800);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--forest-50);
  border-color: rgba(26, 35, 29, 0.2);
}

.btn-block {
  width: 100%;
}

/* ---------- Explore panel (desktop) ---------- */

.panel {
  position: absolute;
  z-index: 1000;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.panel-head {
  padding: 18px 18px 10px;
  flex-shrink: 0;
}

.panel-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head .panel-title {
  margin: 0;
}

.panel-close {
  display: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--forest-50);
  color: var(--forest-800);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.panel-close svg {
  width: 18px;
  height: 18px;
}

/* Search */

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--sand-50);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  border-color: var(--forest-500);
  box-shadow: 0 0 0 3px rgba(61, 115, 80, 0.15);
  background: #fff;
}

.search svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
}

.search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  outline: none;
}

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

/* Filter chips */

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.filter-label {
  flex: 0 0 58px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--sand-200);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--sand-300);
  background: var(--sand-50);
}

.chip.is-active {
  background: var(--forest-700);
  border-color: var(--forest-700);
  color: #fff;
}

/* Results */

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px 8px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.clear-filters {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ochre-600);
  padding: 4px 6px;
  margin-left: -4px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.clear-filters:hover {
  background: var(--sand-100);
}

.clear-filters[hidden] {
  display: none;
}

.near-me {
  margin-left: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--forest-700);
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.near-me:hover {
  background: var(--forest-50);
}

.near-me svg {
  width: 15px;
  height: 15px;
}

.results-count {
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.sort select {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--forest-800);
  padding: 5px 26px 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23264a33' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 12px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.route-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0 8px 8px;
  list-style: none;
}

.route-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: 10px 10px 10px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
}

.route-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 2px;
  background: var(--swatch, var(--sand-300));
}

.route-item:hover,
.route-item.is-current {
  background: var(--forest-50);
}

.route-item-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--forest-900);
  line-height: 1.3;
}

.route-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--muted);
}

.route-item-meta .dot::before {
  content: '·';
  margin-right: 8px;
}

.route-item-rating {
  color: var(--ochre-600);
  font-weight: 600;
}

.list-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.list-empty .btn {
  margin-top: 10px;
}

.panel-foot {
  flex-shrink: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
}

.panel-foot .panel-section {
  margin: 0;
  padding: 0;
  border: none;
}

.panel-foot .panel-links {
  margin-top: 12px;
}

.panel-foot .btn {
  padding: 9px 14px;
}

.browse-btn {
  display: none;
}

.panel-eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ochre-600);
}

.panel-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--forest-900);
}

.panel-lead {
  margin: 0 0 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.panel-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.82rem;
}

.panel-links a {
  color: var(--forest-600);
  font-weight: 500;
  text-decoration: none;
}

.panel-links a:hover {
  text-decoration: underline;
}

.panel-links .contact {
  color: var(--muted);
}

/* Switch row (colour by rating) */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.switch-row strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.switch-row small {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--muted);
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--sand-200);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.switch:checked {
  background: var(--forest-600);
}

.switch:checked::after {
  transform: translateX(18px);
}

.switch:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Rating legend */

.legend {
  margin-top: 12px;
}

.legend[hidden] {
  display: none;
}

.legend-bar {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e74c3c 0%, #f39c12 50%, #27ae60 100%);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend-none {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend-none::before {
  content: '';
  width: 22px;
  height: 4px;
  border-radius: 2px;
  background: #807b7a;
}

/* Floating legend on small screens */
.legend-floating {
  position: absolute;
  z-index: 1000;
  left: 12px;
  bottom: 88px;
  width: 190px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0;
}

/* ---------- Mobile floating controls ---------- */

.map-hint {
  display: none;
}

.fab-stack {
  display: none;
}

.fab {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--forest-800);
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fab svg {
  width: 22px;
  height: 22px;
}

.fab[aria-pressed='true'] {
  background: var(--forest-700);
  color: #fff;
}

/* ---------- Leaflet polish ---------- */

.leaflet-container {
  font-family: var(--font);
}

.leaflet-bar {
  border: none !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}

.leaflet-bar a {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  color: var(--forest-800) !important;
  border-bottom-color: var(--line) !important;
}

.leaflet-bar a:hover {
  background: var(--forest-50) !important;
}

.leaflet-control-layers {
  border: none !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-layers-expanded {
  padding: 10px 14px !important;
  font-size: 0.85rem;
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.8) !important;
  border-top-left-radius: 6px;
}

.leaflet-right {
  transition: right 0.3s ease;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  font-weight: 600;
  color: var(--forest-800);
}

/* ---------- Overlapping-route chooser ---------- */

.route-picker-popup .leaflet-popup-content {
  margin: 10px;
  font-weight: 400;
}

.route-picker-title {
  margin: 2px 6px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.route-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 7px 8px 7px 16px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  position: relative;
}

.route-picker-item::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 9px;
  bottom: 9px;
  width: 4px;
  border-radius: 2px;
  background: var(--swatch, var(--sand-300));
}

.route-picker-item:hover,
.route-picker-item:focus-visible {
  background: var(--forest-50);
}

.route-picker-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--forest-900);
  line-height: 1.3;
}

.route-picker-meta {
  display: block;
  margin-top: 1px;
  font-size: 0.76rem;
  color: var(--muted);
}

.route-picker-more {
  margin: 6px 8px 2px;
  font-size: 0.76rem;
  color: var(--muted);
}

/* ---------- Route drawer ---------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1290;
  background: rgba(20, 38, 27, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.route-drawer {
  position: absolute;
  z-index: 1300;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.route-drawer.open {
  transform: translateX(0);
}

.drawer-handle {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.drawer-eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ochre-600);
}

.drawer-eyebrow:empty {
  display: none;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--forest-900);
}

.drawer-close-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--forest-50);
  color: var(--forest-800);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.drawer-close-btn:hover {
  background: var(--forest-100);
}

.drawer-close-btn svg {
  width: 18px;
  height: 18px;
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--sand-50);
  border: 1px solid var(--sand-200);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--forest-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value small {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 2px;
}

.meta-line {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-line strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.drawer-section {
  margin-top: 18px;
}

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label span + span {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.78rem;
}

.section-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
  word-break: break-word;
}

/* Elevation profile */

.elev-chart {
  display: block;
  width: 100%;
  height: 96px;
  border-radius: 10px;
  background: var(--forest-50);
}

.elev-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Ratings */

.rating-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rating-score {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--forest-900);
  line-height: 1;
}

.rating-stars {
  --pct: 0%;
  position: relative;
  font-size: 1.05rem;
  letter-spacing: 2px;
  line-height: 1;
  color: var(--sand-200);
}

.rating-stars::before {
  content: '★★★★★';
}

.rating-stars::after {
  content: '★★★★★';
  position: absolute;
  inset: 0;
  width: var(--pct);
  overflow: hidden;
  color: var(--ochre-500);
}

.rating-count {
  font-size: 0.82rem;
  color: var(--muted);
}

.rating-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.rate-prompt {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.rating-buttons {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 4px;
}

.rating-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--sand-300);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.1s ease, transform 0.1s ease;
}

.rating-buttons:not(.is-disabled) .rating-btn:hover,
.rating-buttons:not(.is-disabled) .rating-btn:hover ~ .rating-btn,
.rating-btn.is-selected,
.rating-btn.is-selected ~ .rating-btn {
  color: var(--ochre-500);
}

.rating-buttons:not(.is-disabled) .rating-btn:hover {
  transform: scale(1.08);
}

.rating-btn:disabled {
  cursor: default;
}

.rating-msg {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.rating-msg:empty {
  min-height: 0;
}

#turnstile-widget {
  margin-bottom: 8px;
}

.drawer-cta {
  margin-top: 22px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  :root {
    --drawer-w: 360px;
  }

  .panel {
    width: 290px;
  }
}

@media (min-width: 768px) {
  .drawer-backdrop {
    display: none;
  }

  .app.drawer-open .leaflet-right {
    right: var(--drawer-w);
  }
}

@media (max-width: 767.98px) {
  :root {
    --topbar-h: 56px;
  }

  .topbar {
    padding: 0 12px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .brand-name {
    font-size: 0.98rem;
  }

  .topnav a {
    padding: 8px 9px;
    font-size: 0.85rem;
  }

  .route-count {
    display: none;
  }

  .nav-long {
    display: none;
  }

  .panel {
    position: fixed;
    z-index: 1300;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 88vh;
    height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(105%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    visibility: hidden;
  }

  .panel.is-open {
    transform: translateY(0);
    visibility: visible;
  }

  .panel-close {
    display: inline-flex;
  }

  .panel-foot {
    display: none;
  }

  .browse-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    z-index: 1000;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    background: var(--forest-700);
    color: #fff;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
  }

  .browse-btn svg {
    width: 18px;
    height: 18px;
  }

  .map-hint {
    display: block;
    position: absolute;
    z-index: 1000;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(28, 53, 38, 0.92);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
    transition: opacity 0.4s ease;
  }

  .map-hint.is-hidden {
    opacity: 0;
  }

  .fab-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    z-index: 1000;
    right: 12px;
    bottom: 28px;
  }

  .route-drawer {
    position: fixed;
    top: auto;
    left: 0;
    width: 100%;
    max-height: 78vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(105%);
  }

  .route-drawer.open {
    transform: translateY(0);
  }

  .drawer-handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--sand-300);
  }

  .drawer-header {
    padding: 12px 16px 12px;
  }

  .drawer-content {
    padding: 16px 16px 28px;
  }
}

@media (max-width: 480px) {
  .topbar {
    gap: 8px;
  }

  .brand-sub,
  .nav-ext,
  .topnav a.nav-map {
    display: none;
  }

  .topnav {
    gap: 2px;
  }

  .topnav a {
    padding: 7px 8px;
  }
}

@media (max-width: 380px) {

  .stat-value {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
