:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #141414;
  --muted: #4a4a4a;
  --light: #6b6b6b;
  --border: #e6e3dc;
  --border-light: #efece6;
  --hover: #f1eee8;
  --blue: #002FA7;
  --blue-hover: #00227a;
  --red: #c2401f;
  --radius: 12px;
  --map-h: 44svh;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
a { color: var(--blue); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Map on top, the panel slides up over it like a sheet. */
#map {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--map-h);
  background: #efece6;
  z-index: 0;
}
.panel {
  position: relative;
  z-index: 1;
  margin-top: calc(var(--map-h) - 16px);
  min-height: calc(100svh - var(--map-h) + 16px);
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(20, 20, 20, 0.07);
  padding: 8px 18px calc(28px + env(safe-area-inset-bottom));
}
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 10px; }

@media (min-width: 900px) {
  #map { inset: 0 0 0 420px; height: 100vh; }
  .panel {
    position: fixed;
    inset: 0 auto 0 0;
    width: 420px;
    margin: 0;
    min-height: 0;
    overflow-y: auto;
    border-radius: 0;
    box-shadow: none;
    border-right: 1px solid var(--border);
    padding: 28px 26px 32px;
  }
  .grab { display: none; }
}

.brand h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 4px;
}
.brand p { margin: 0 0 16px; color: var(--muted); font-size: 15px; }

/* Inputs */
.fields {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.field { position: relative; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; }
.field + .field { border-top: 1px solid var(--border-light); }
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 13px 0;
  font-size: 16px; /* no iOS zoom on focus */
  outline: none;
}
.field input::placeholder { color: #8a877f; }
.field:focus-within { background: #fdfcfa; }
.pin { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.pin-from { border: 2.5px solid var(--blue); background: #fff; }
.pin-to { background: var(--blue); }
.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--light);
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.suggest {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 20, 20, 0.1);
}
.suggest li { padding: 9px 10px; border-radius: 8px; cursor: pointer; line-height: 1.3; }
.suggest li small { display: block; color: var(--light); font-size: 13px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--hover); }

.primary {
  width: 100%;
  margin-top: 12px;
  height: 50px;
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}
.primary:hover { background: var(--blue-hover); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.hint { margin: 8px 2px 0; color: var(--light); font-size: 13px; }

.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0 6px; font-size: 13px; color: var(--light); }
.examples button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
}
.examples button:hover { border-color: #cfcabf; background: var(--hover); }

/* Status */
.status {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 16px 0 4px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 15px;
}
.status .spinner {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2.5px solid #d9dff0;
  border-top-color: var(--blue);
  animation: spin 0.9s linear infinite;
}
.status small { display: block; color: var(--light); font-size: 13px; margin-top: 2px; }
.status.error { border-color: #ecc9bd; background: #fdf6f3; }
.status.error b { color: var(--red); font-weight: 600; }
.status button { margin-top: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 5px 12px; cursor: pointer; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status .spinner { animation-duration: 3s; } }

/* Route cards */
.routes { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.routes:empty { display: none; }
.routes-head { font-size: 13px; color: var(--light); margin: 4px 2px -2px; }
.route {
  --c: var(--blue);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.route.selected { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }
.route-main { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 14px 14px 10px; cursor: pointer; }
.route-top { display: flex; align-items: baseline; gap: 10px; }
.swatch { flex: none; width: 14px; height: 4px; border-radius: 2px; background: var(--c); transform: translateY(-3px); }
.route.fastest .swatch { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.route-title { flex: 1; font-family: var(--serif); font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; }
.route-time { flex: none; font-weight: 600; font-size: 17px; white-space: nowrap; }
.route-sub { margin: 4px 0 0 24px; color: var(--light); font-size: 14px; }
.route-sub .extra { color: var(--c); font-weight: 600; }
.route.fastest .route-sub .extra { color: var(--light); }

.dims { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0 0 24px; }
.dim span { display: block; font-size: 11px; color: var(--light); letter-spacing: 0.02em; }
.dim i { display: block; height: 4px; margin-top: 3px; border-radius: 2px; background: var(--border-light); overflow: hidden; }
.dim i b { display: block; height: 100%; background: var(--c); border-radius: 2px; }

.why { margin: 10px 0 0 24px; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.why li { position: relative; padding-left: 14px; margin-top: 4px; }
.why li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.route-actions { display: flex; justify-content: flex-end; padding: 0 14px 12px; }
.route-actions a { font-size: 13px; text-decoration: none; color: var(--light); }
.route-actions a:hover { color: var(--blue); text-decoration: underline; }
.note { font-size: 13px; color: var(--light); margin: 6px 2px 0; }

.foot { margin-top: 28px; font-size: 12px; color: var(--light); line-height: 1.5; }
.foot a { color: inherit; }

/* Leaflet tweaks */
.leaflet-container { font-family: var(--sans); background: #efece6; }
.leaflet-control-attribution { font-size: 10px; background: rgba(251, 250, 247, 0.85) !important; }
.leaflet-bar a { color: var(--text); }
@media (max-width: 899px) { .leaflet-bottom { bottom: 16px; } }
