:root {
  --bg: #f3efe6;
  --fg: #1a1916;
  --surface: #fffdf8;
  --muted: #6b6560;
  --faint: #9a948c;
  --primary: #245a5c;
  --primary-fg: #f4f1ea;
  --border: #d9d1c3;
  --you: #1f6feb;
  --ink: #1a1916;
  --shadow:
    0 0 0 1px rgba(26, 25, 22, 0.08),
    0 1px 2px -1px rgba(26, 25, 22, 0.06),
    0 8px 24px -12px rgba(26, 25, 22, 0.18);
  --font-display: "Crimson Pro", ui-serif, Georgia, serif;
  --font: "Figtree", ui-sans-serif, system-ui, sans-serif;
  --safe-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
a { color: inherit; text-decoration: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

#app {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.leaflet-container {
  font-family: var(--font);
  background: #a9c9dc; /* the NatGeo tiles' ocean, so unloaded tiles do not flash */
  height: 100%;
  width: 100%;
}
.leaflet-control-attribution {
  font-size: 10px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--muted);
  max-width: 55vw;
}
.leaflet-control-attribution a { color: var(--primary); }
.leaflet-bottom.leaflet-right { bottom: 10.5rem; }

.chrome-top, .chrome-bottom {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  pointer-events: none;
}
.chrome-top { top: 0; padding: 12px; }
.chrome-bottom {
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 64px var(--safe-bottom) 12px;
}

.brand, .progress, .banner, .stop-card, .btn, .you-line {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.brand-copy { min-width: 0; flex: 1; }
.back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-top: 2px;
  border-radius: 8px;
  font-size: 20px;
  color: var(--muted);
}
.back:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); color: var(--fg); }
h1 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.sub {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  margin-top: 8px;
  height: 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  box-shadow: var(--shadow);
  overflow: hidden;
  pointer-events: none;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--you);
}

.banner {
  margin: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--primary-fg);
  padding: 8px 12px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.stop-card {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stop-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stop-card h2 {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.stop-card .blurb {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: color-mix(in srgb, var(--fg) 80%, transparent);
}
.stop-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  font: 500 16px/1 var(--font);
  padding: 0 20px;
  height: 48px;
  box-shadow: var(--shadow);
}
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.outline { background: var(--surface); color: var(--fg); }
.btn.surface {
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(8px);
  color: var(--fg);
  font-size: 14px;
}
.btn.xl {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  height: 56px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}
.icon-btn:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); color: var(--fg); }

.you-line {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: color-mix(in srgb, var(--ink) 70%, transparent);
}

.places {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.places.desktop { display: none; }
.places-head {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.places-head h2 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.places-head .muted { margin: 4px 0 0; font-size: 14px; }
.places-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.search input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 12px;
  font: 400 15px/1 var(--font);
  color: var(--fg);
  outline: none;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.kinds {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.kind {
  flex: 0 0 auto;
  height: 36px;
  border: 0;
  border-radius: 99px;
  padding: 0 12px;
  font: 500 14px/1 var(--font);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  color: var(--muted);
}
.kind.on { background: var(--ink); color: var(--primary-fg); }
.preview-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.preview-label .tabular { color: var(--fg); }
.preview input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 8px;
  accent-color: var(--primary);
  cursor: pointer;
}
.preview-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12px;
  color: var(--faint);
}
.places-list-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.places-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; }

/* The trail: a rail down the left, every stop a node on it, gaps sized by
   road miles, and a blue dot for where the car is. */
.trail {
  --rail-x: 26px;
  --row-x: 38px;
  position: relative;
  padding: 14px 0 10px;
}
.trail-line, .trail-done {
  position: absolute;
  left: calc(var(--rail-x) - 1.5px);
  top: 26px;
  width: 3px;
  border-radius: 99px;
}
.trail-line { bottom: 26px; background: var(--border); }
.trail-done { height: 0; background: var(--you); }
.node {
  position: absolute;
  left: calc(var(--rail-x) - var(--row-x) - 5px);
  top: 15px;
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--bg);
  border: 2px solid var(--faint);
  box-sizing: border-box;
}

.trail-end {
  position: relative;
  margin: 0 12px 0 var(--row-x);
  padding: 4px 8px 6px;
}
.trail-end .node.end {
  top: 8px;
  width: 12px;
  height: 12px;
  left: calc(var(--rail-x) - var(--row-x) - 6px);
  background: var(--ink);
  border-color: var(--ink);
}
.trail-end.finish .node.end { background: var(--primary); border-color: var(--primary); }
.end-name {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.end-sub { display: block; margin-top: 1px; font-size: 12px; color: var(--muted); }

.region {
  margin: 0 12px 0 var(--row-x);
  padding: 10px 8px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.region span { margin-left: 8px; color: var(--faint); font-variant-numeric: tabular-nums; }

.gap {
  position: relative;
  margin-left: var(--row-x);
  height: 0;
}
.gap span {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--faint);
  white-space: nowrap;
}
.gap.wide::before {
  content: "";
  position: absolute;
  left: calc(var(--rail-x) - var(--row-x) - 1.5px);
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: repeating-linear-gradient(to bottom, var(--bg) 0 4px, transparent 4px 9px);
}

.poi {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 12px 0 var(--row-x);
  padding: 9px 8px;
  border-radius: 8px;
  color: inherit;
}
.poi:hover { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.poi.selected { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.poi.selected .node {
  background: var(--primary);
  border-color: var(--primary);
  width: 14px;
  height: 14px;
  left: calc(var(--rail-x) - var(--row-x) - 7px);
  top: 13px;
}
.poi.passed .poi-main, .poi.passed .poi-side { opacity: 0.5; }
.poi.passed .node { background: color-mix(in srgb, var(--you) 40%, var(--bg)); border-color: transparent; }
.poi-main { min-width: 0; }
.poi .name {
  display: block;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poi .where { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.poi-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding-top: 1px;
  flex: 0 0 auto;
}
.poi-side .miles { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.you-row {
  position: relative;
  margin: 2px 12px 2px var(--row-x);
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--you) 9%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--you) 28%, transparent);
}
.you-row .node.you-node {
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  left: calc(var(--rail-x) - var(--row-x) - 8px - 1px);
  background: var(--you);
  border: 0;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px color-mix(in srgb, var(--you) 40%, transparent);
}
.you-row .node.you-node::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 99px;
  border: 2px solid color-mix(in srgb, var(--you) 45%, transparent);
  animation: you-pulse 2.2s ease-out infinite;
}
.you-text { display: block; min-width: 0; }
.you-text b { display: block; font-size: 14px; font-weight: 600; color: var(--you); line-height: 1.3; }
.you-text span { display: block; margin-top: 1px; font-size: 12px; line-height: 1.4; color: var(--muted); }

.jump {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 99px;
  background: var(--you);
  color: #fff;
  font: 600 13px/1 var(--font);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.places-foot {
  margin: 0;
  padding: 20px 20px 24px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--faint);
}
.empty { margin: 0; padding: 40px 20px; font-size: 14px; color: var(--muted); }

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--ink) 25%, transparent); }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 90dvh;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  outline: none;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  margin: 12px auto 0;
}
.sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.map-pin { display: flex; align-items: center; justify-content: center; }
.map-pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--surface), 0 4px 12px rgba(26, 25, 22, 0.28);
}
.map-pin-you {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 99px;
  background: var(--you);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--you);
}
.map-pin-you::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 99px;
  border: 2px solid color-mix(in srgb, var(--you) 45%, transparent);
  animation: you-pulse 2.2s ease-out infinite;
}
.map-label {
  position: absolute;
  left: 6px;
  top: 0;
  background: var(--ink);
  color: var(--primary-fg);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
@keyframes you-pulse {
  0% { transform: scale(0.6); opacity: 0.55; }
  100% { transform: scale(1.7); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .map-pin-you::after, .you-row .node.you-node::after { animation: none; }
}

@media (min-width: 640px) {
  .stop-actions { flex-direction: row; }
  .stop-actions .btn.primary { flex: 1; }
  .stop-actions .btn.outline { width: 9rem; }
}

@media (min-width: 1024px) {
  #app { flex-direction: row; }
  #map { right: 24rem; }
  .chrome-top, .chrome-bottom { right: 24rem; }
  .chrome-bottom { padding: 16px 80px 16px 16px; }
  .leaflet-bottom.leaflet-right { bottom: 7.5rem; }
  .lg-hidden { display: none !important; }
  .places.desktop {
    display: flex;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24rem;
    border-left: 1px solid var(--border);
    z-index: 5;
  }
}

@media (max-width: 1023px) {
  .places.desktop { display: none; }
}
