/* Densha Densha — visual language shared with the Apple app (DenshaCore/Rosen):
   a soft "journey canvas" backdrop (pastel wash + faint 48px grid) with
   translucent rounded surfaces, iOS-style capsule chips and a cyan→magenta
   brand gradient. Colours are the ones sampled in Apps/Shared/Formatting.swift. */

:root {
  /* Brand */
  --accent: #1a8cd9;          /* denshaAccent */
  --accent-strong: #0f6fb2;
  --sky: #6dccf0;             /* softSky */
  --pink: #f7a1cc;            /* softPink */
  --pink-strong: #ed579e;
  --peach: #ffb86b;           /* softPeach */
  --leaf: #4fae62;            /* text-safe softGreen */
  --leaf-soft: #a6d9ad;
  --orange: #fabf8c;          /* softOrange */
  --red: #f59e9e;             /* softRed */
  --red-text: #e04747;        /* softRedText */
  --indigo: #5c7db8;          /* softIndigo */

  /* Canvas + surfaces */
  --canvas: #f6fafe;
  --surface: rgba(255, 255, 255, 0.68);
  --surface-emph: rgba(255, 255, 255, 0.88);
  --surface-line: rgba(255, 255, 255, 0.65);
  --surface-line-emph: rgba(255, 255, 255, 0.9);
  --grid-line: rgba(60, 60, 67, 0.035);
  --chrome: rgba(255, 255, 255, 0.72);

  /* Text + fills (iOS label/fill scale) */
  --ink: #101724;
  --muted: rgba(60, 60, 67, 0.62);
  --faint: rgba(60, 60, 67, 0.32);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --hairline: rgba(60, 60, 67, 0.14);
  --accent-wash: rgba(26, 140, 217, 0.1);
  --accent-wash-strong: rgba(26, 140, 217, 0.18);

  --radius-lg: 20px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 10px 30px rgba(16, 23, 36, 0.07);
  --shadow-float: 0 18px 44px rgba(16, 23, 36, 0.16);
  --mobile-tabs-height: 62px;
  --topbar-height: 56px;

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
    "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4aa8ec;
    --accent-strong: #6dccf0;
    --canvas: #0a0d14;
    --surface: #171c2b;
    --surface-emph: #212936;
    --surface-line: rgba(255, 255, 255, 0.07);
    --surface-line-emph: rgba(255, 255, 255, 0.11);
    --grid-line: rgba(235, 235, 245, 0.045);
    --chrome: rgba(16, 20, 32, 0.72);

    --ink: #f2f4f8;
    --muted: rgba(235, 235, 245, 0.62);
    --faint: rgba(235, 235, 245, 0.3);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-strong: rgba(120, 120, 128, 0.36);
    --hairline: rgba(235, 235, 245, 0.16);
    --accent-wash: rgba(74, 168, 236, 0.16);
    --accent-wash-strong: rgba(74, 168, 236, 0.26);
    --red-text: #ff8080;
    --leaf: #6cc47f;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-float: 0 18px 44px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  position: relative;
  color: var(--ink);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--peach) 14%, transparent),
      color-mix(in srgb, var(--pink) 12%, transparent) 42%,
      color-mix(in srgb, var(--sky) 13%, transparent) 68%,
      transparent 92%),
    var(--canvas);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* Faint 48px grid, the Canvas layer of JourneyCanvasBackground. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(to right, var(--grid-line) 0 0.5px, transparent 0.5px 48px),
    repeating-linear-gradient(to bottom, var(--grid-line) 0 0.5px, transparent 0.5px 48px);
}

button, input, select { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
input, select, textarea { user-select: text; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.glyph {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }

/* --- Chrome --------------------------------------------------------------- */

.topbar {
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) calc(18px + env(safe-area-inset-right, 0px)) 0 calc(18px + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--surface-line);
  background: var(--chrome);
  backdrop-filter: blur(24px) saturate(1.7);
  -webkit-backdrop-filter: blur(24px) saturate(1.7);
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand strong {
  display: block;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; font-weight: 500; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--surface-line-emph);
  border-radius: 11px;
  background: linear-gradient(140deg, #fff7ee, color-mix(in srgb, var(--sky) 55%, transparent));
  box-shadow: 0 4px 12px rgba(16, 23, 36, 0.12);
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-mark circle { fill: #fff; stroke: rgba(26, 140, 217, 0.28); stroke-width: 1.3; }
@media (prefers-color-scheme: dark) {
  .brand-mark { background: linear-gradient(140deg, #1c243a, #0d1120); }
  .brand-mark circle { fill: #e6ecf8; stroke: rgba(255, 255, 255, 0.35); }
}

.top-actions { display: flex; align-items: center; gap: 6px; }
.nav-action {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s, transform 0.15s;
}
.nav-action:hover { background: var(--fill); color: var(--ink); }
.nav-action b { font-size: 12px; font-weight: 600; }
.nav-action i {
  position: absolute; right: 4px; top: 3px;
  width: 8px; height: 8px;
  border: 2px solid var(--chrome);
  border-radius: 50%;
  background: var(--red-text);
}
.network-status { display: flex; align-items: center; gap: 6px; margin: 0 6px; color: var(--muted); font-size: 12px; }
.network-status > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); }
.network-status.offline > span:first-child { background: var(--red-text); }
.language-control { display: flex; align-items: center; }
.language-control select {
  min-height: 30px;
  padding: 3px 24px 3px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 380px minmax(380px, 1fr) 420px;
}
.planner-panel, .itinerary-panel { min-width: 0; position: relative; z-index: 500; }
.planner-panel { padding: 18px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
/* In a scrolling flex column the cards would otherwise shrink below their
   content and overlap each other. */
.planner-panel > * { flex: none; }
.itinerary-panel { border-left: 1px solid var(--hairline); background: color-mix(in srgb, var(--canvas) 55%, transparent); }
.panel-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* --- Building blocks ------------------------------------------------------ */

.card {
  padding: 13px 14px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
}
.card.emph { border-color: var(--surface-line-emph); background: var(--surface-emph); }

.eyebrow, .section-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.planner-heading { padding: 2px 4px 0; }
.planner-heading h1 {
  margin: 4px 0 0;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Endpoints ---------------------------------------------------------------- */

.endpoints-card {
  position: relative;
  /* `backdrop-filter` makes every card its own stacking context, so the
     autocomplete dropdown can only escape if this card sits above the ones
     that follow it. */
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 12px;
  border-color: var(--surface-line-emph);
  background: var(--surface-emph);
}
.endpoint-rail {
  flex: none;
  width: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 6px;
}
.endpoint-rail .rail-origin {
  width: 11px; height: 11px;
  border: 2.5px solid var(--leaf);
  border-radius: 50%;
  background: color-mix(in srgb, var(--leaf) 15%, transparent);
}
.endpoint-rail b {
  flex: 1;
  width: 2px;
  margin: 5px 0;
  background: repeating-linear-gradient(to bottom, var(--faint) 0 2px, transparent 2px 6px);
}
.endpoint-rail .rail-pin { width: 16px; height: 16px; color: var(--red-text); stroke-width: 2.1; }

.endpoint-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-right: 30px; }
.endpoint-divider { height: 1px; margin: 8px 0; background: var(--hairline); }
.search-field { position: relative; }
.search-field label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input {
  width: 100%;
  height: 28px;
  padding: 0 58px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  outline: none;
}
.input-wrap input::placeholder { color: var(--faint); }
.clear-search, .current-location-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: background-color 0.18s, color 0.18s;
}
.clear-search { right: 0; font-size: 19px; line-height: 1; }
.clear-search:hover { background: var(--fill); color: var(--ink); }
.current-location-button { right: 28px; color: var(--accent); }
.current-location-button:hover:not(:disabled) { background: var(--accent-wash); }
.current-location-button:disabled { cursor: wait; opacity: 0.55; }
.current-location-button span { font-size: 15px; }

.swap-button {
  position: absolute;
  z-index: 4;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--surface-line-emph);
  border-radius: 50%;
  background: var(--canvas);
  color: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 23, 36, 0.14);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s;
}
.swap-button .glyph { width: 19px; height: 19px; }
.swap-button.flipped { transform: translateY(-50%) rotate(180deg); }

.search-results {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 8px);
  left: -6px;
  right: -6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--surface-line-emph);
  border-radius: var(--radius);
  background: var(--surface-emph);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: var(--shadow-float);
}
.result-row { display: flex; align-items: stretch; gap: 2px; }
.result-item {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 7px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.result-item:hover:not(:disabled) { background: var(--accent-wash); }
.result-item:disabled { opacity: 0.5; cursor: default; }
.result-symbol {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.result-item strong { display: block; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.result-item small { display: block; margin-top: 1px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.result-star {
  flex: none;
  width: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  font-size: 16px;
}
.result-star.active { color: var(--peach); }
.result-section { padding: 8px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.result-empty { padding: 16px; color: var(--muted); text-align: center; font-size: 13px; }

/* Chips and segmented controls --------------------------------------------- */

.time-card { display: flex; flex-direction: column; gap: 10px; }
.chip-group, .segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--fill);
}
.chip-group button, .segmented button {
  flex: 1 1 auto;
  min-width: 62px;
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.18s, color 0.18s;
}
.chip-group button.active, .segmented button.active {
  background: var(--surface-emph);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 23, 36, 0.16);
}
@media (prefers-color-scheme: dark) {
  .chip-group button.active, .segmented button.active { background: var(--accent-wash-strong); color: var(--accent-strong); }
}

.time-row { display: flex; flex-direction: column; gap: 6px; }
.date-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--fill);
  color: var(--ink);
  font-size: 14px;
}
.time-hint { display: flex; align-items: center; gap: 5px; padding-left: 2px; color: var(--muted); font-size: 11px; }

.mode-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.15s;
}
.mode-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-chip.active {
  border-color: transparent;
  background: var(--accent-wash-strong);
  color: var(--accent);
}
.mode-chip .glyph { width: 17px; height: 17px; }

/* Disclosure with the API route options ------------------------------------ */

.options-card { padding: 0; overflow: hidden; }
.options-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.options-card summary::-webkit-details-marker { display: none; }
.options-summary-lead { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--accent); }
.options-summary-lead > span { min-width: 0; color: var(--ink); }
.options-summary-lead b { display: block; font-size: 13.5px; font-weight: 650; }
.filter-summary { display: block; overflow: hidden; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.options-chevron { color: var(--faint); transition: transform 0.22s ease; }
.options-card[open] .options-chevron { transform: rotate(90deg); }
.options-body { padding: 0 14px 12px; }
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 13px;
}
.option-row select {
  max-width: 62%;
  min-height: 32px;
  padding: 4px 24px 4px 10px;
  border: 0;
  border-radius: 9px;
  background: var(--fill);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.link-button {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}

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

.primary-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--accent), var(--pink));
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(26, 140, 217, 0.25);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), filter 0.18s, opacity 0.18s;
}
.primary-button .glyph { stroke-width: 2.1; }
.primary-button:hover:not(:disabled) { filter: brightness(1.05); }
.primary-button:active { transform: scale(0.985); }
.primary-button.incomplete { opacity: 0.6; box-shadow: none; }
.primary-button:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
.start-button { background: linear-gradient(100deg, var(--leaf), color-mix(in srgb, var(--leaf) 78%, #fff)); box-shadow: 0 6px 18px rgba(79, 174, 98, 0.22); }

.secondary-button {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--ink);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background-color 0.18s, transform 0.15s;
}
.secondary-button:hover { background: var(--fill-strong); }
.secondary-button:active { transform: scale(0.985); }
.secondary-button.danger { color: var(--red-text); }
.ghost-button {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.planner-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}

/* Shared-route banner ------------------------------------------------------ */

.shared-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-wash), color-mix(in srgb, var(--pink) 18%, transparent));
}
.shared-banner-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shared-banner-head .eyebrow { color: var(--accent); }
.shared-banner-text { margin: 0; font-size: 14px; font-weight: 600; }

/* Results ------------------------------------------------------------------ */

.route-results { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.results-heading { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.results-title {
  display: block;
  overflow: hidden;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.results-title .arrow { margin: 0 6px; color: var(--faint); }
.results-context { color: var(--muted); font-size: 12px; font-weight: 600; }

.shift-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.shift-button:hover { background: var(--fill-strong); }
.shift-up { transform: rotate(-90deg); }
.shift-down { transform: rotate(90deg); }

.route-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--surface-line-emph);
  border-radius: 18px;
  background: var(--surface-emph);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, border-color 0.2s;
  animation: card-in 0.36s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.route-card + .route-card { margin-top: 10px; }
.route-card:hover { box-shadow: var(--shadow-card); }
.route-card:active { transform: scale(0.99); }
.route-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 22px rgba(26, 140, 217, 0.14);
  background: linear-gradient(0deg, var(--accent-wash), var(--accent-wash)), var(--surface-emph);
}

.route-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge .glyph { width: 12px; height: 12px; stroke-width: 2.6; }
.badge.fastest { background: var(--accent); }
.badge.cheapest { background: var(--leaf); }
.badge.fewest { background: var(--indigo); }
.badge.icon-only { padding: 3px 6px; }

.route-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.route-card-time {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.route-card-time sup { font-size: 11px; color: var(--muted); }
.route-card-fare {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.info-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
}
.info-chip .glyph { width: 13px; height: 13px; stroke-width: 2.1; }
.route-delta { color: var(--faint); font-size: 11.5px; font-weight: 650; }
.countdown { align-self: flex-start; background: var(--accent-wash); color: var(--accent); }

.path-bar { display: flex; align-items: center; gap: 5px; padding-top: 2px; overflow: hidden; }
.path-node { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--leaf); }
.path-end { flex: none; width: 14px; height: 14px; color: var(--red-text); stroke-width: 2.2; margin-left: auto; }
.path-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 118px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.path-chip span { overflow: hidden; text-overflow: ellipsis; }
.path-chip .glyph { width: 12px; height: 12px; stroke-width: 2.3; }
.path-chip.walk { background: var(--fill); color: var(--muted); }
.path-sep { flex: none; color: var(--faint); font-size: 11px; }
.path-more { padding: 3px 7px; border-radius: 999px; background: var(--fill); color: var(--muted); font-size: 11px; font-weight: 700; }

/* Map ---------------------------------------------------------------------- */

.map-panel { min-width: 0; position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; z-index: 1; }
.map-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  pointer-events: none;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: blur(4px);
}
.map-placeholder-mark {
  width: 54px; height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(140deg, var(--sky), var(--accent) 55%, var(--pink));
  color: #fff;
  box-shadow: 0 10px 26px rgba(26, 140, 217, 0.26);
}
.map-placeholder-mark .glyph { width: 28px; height: 28px; stroke-width: 1.8; }
.map-placeholder strong {
  margin-top: 8px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
}
.map-placeholder span { max-width: 260px; color: var(--muted); font-size: 13px; }
.map-legend {
  position: absolute;
  z-index: 450;
  left: 14px; bottom: 14px;
  display: flex;
  gap: 12px;
  padding: 7px 11px;
  border: 1px solid var(--surface-line);
  border-radius: 12px;
  background: var(--chrome);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
}
.map-legend span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.map-legend i { display: block; width: 20px; height: 4px; border-radius: 4px; }
.legend-selected { background: var(--accent); }
.legend-alternative { background: var(--faint); }
.leaflet-control-zoom { border: 0 !important; border-radius: 10px !important; overflow: hidden; box-shadow: var(--shadow-card) !important; }
.leaflet-control-zoom a { color: var(--accent) !important; }
.station-marker {
  width: 12px; height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.station-marker.terminal { width: 16px; height: 16px; background: var(--red-text); }
.user-location-pulse {
  position: relative;
  width: 16px; height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(26, 140, 217, 0.6);
}
.user-location-pulse::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: rgba(26, 140, 217, 0.24);
  animation: userLocationPulse 2s infinite ease-out;
}
@keyframes userLocationPulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Itinerary ---------------------------------------------------------------- */

.itinerary-empty {
  min-height: 100%;
  padding: 48px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.empty-icon {
  width: 60px; height: 60px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: var(--accent-wash);
  color: var(--accent);
}
.empty-icon .glyph { width: 28px; height: 28px; }
.itinerary-empty h2 {
  margin: 16px 0 6px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
}
.itinerary-empty p { max-width: 290px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.itinerary-header { padding: 20px 20px 18px; border-bottom: 1px solid var(--hairline); }
.itinerary-header h2 {
  margin: 5px 0 3px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.itinerary-header p { margin: 0; color: var(--muted); font-size: 12.5px; }
.itinerary-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.metric {
  padding: 9px 10px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.metric small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.metric strong { display: block; margin-top: 3px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.itinerary-actions { display: flex; gap: 8px; margin-top: 14px; }
.itinerary-actions .primary-button { flex: 2; min-height: 44px; }
.itinerary-actions .secondary-button { flex: 1; min-height: 44px; }

.trip-panel {
  margin: 14px 14px 0;
  padding: 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-wash);
}
.trip-panel h2 {
  margin: 5px 0 6px;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.trip-panel .eyebrow { color: var(--accent); }
.trip-status { margin: 0 0 12px; min-height: 1.2em; font-size: 13px; font-weight: 600; }
.trip-panel-actions { display: flex; gap: 8px; }

.timeline { padding: 18px 20px 40px; }
.timeline-point, .timeline-move { position: relative; margin-left: 14px; padding-left: 24px; }
.timeline-point { padding-bottom: 13px; }
.timeline-move { padding-bottom: 16px; border-left: 2px solid var(--hairline); }
.timeline-point::before {
  content: "";
  position: absolute;
  left: -6px; top: 3px;
  z-index: 2;
  width: 10px; height: 10px;
  border: 2px solid var(--canvas);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.timeline-point.terminal::before { background: var(--red-text); box-shadow: 0 0 0 2px var(--red-text); }
.point-time { color: var(--accent); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.point-name { margin-top: 2px; font-size: 14.5px; font-weight: 700; }
.point-meta { margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.timeline-point.direct-through::before { background: var(--canvas); box-shadow: 0 0 0 2px var(--sky); }
.direct-train-label { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.direct-train-instruction { margin-top: 3px; color: var(--accent); font-size: 12px; }
.direct-through .point-name { margin-top: 6px; }
.direct-train-popup { margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--hairline); color: var(--accent); }

.move-card {
  margin-left: 8px;
  padding: 11px 12px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, border-color 0.2s;
}
.move-card:hover, .move-card.focused { border-color: var(--accent); box-shadow: var(--shadow-card); }
.move-heading { display: flex; align-items: center; gap: 9px; }
.line-swatch { flex: none; width: 5px; height: 30px; border-radius: 3px; background: var(--accent); }
.move-heading-main { flex: 1; min-width: 0; }
.move-heading strong { display: block; overflow: hidden; font-size: 13.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.move-heading small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.move-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.move-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.stops-button {
  margin-top: 9px;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
}
.stops-list { margin-top: 9px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--fill); animation: fadeInUp 0.24s ease-out both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.stop-row { display: grid; grid-template-columns: 46px 8px minmax(0, 1fr); align-items: center; gap: 7px; padding: 3px 0; color: var(--muted); font-size: 11.5px; }
.stop-row i { width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.stop-row.active { color: var(--ink); font-weight: 700; }
.stop-row.active i { background: var(--accent); }

/* Live trip progress */
.timeline-point.completed, .timeline-move.completed { opacity: 0.5; transition: opacity 0.3s ease; }
.timeline-point.completed .point-name { color: var(--muted); text-decoration: line-through; }
.timeline-point.completed::before { background: var(--faint) !important; box-shadow: 0 0 0 2px var(--faint) !important; }
.timeline-point.current::before { background: var(--pink-strong) !important; box-shadow: 0 0 0 2px var(--pink-strong) !important; animation: pointPulse 1.8s infinite ease-in-out; }
@keyframes pointPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--pink-strong); }
  50% { box-shadow: 0 0 0 6px rgba(237, 87, 158, 0.35); }
}
.timeline-point.current .point-name { color: var(--pink-strong); }
.timeline-move.current { border-left-color: var(--pink-strong) !important; }
.timeline-move.current .move-card { border-color: var(--pink-strong); }
.timeline-move.completed { border-left-color: var(--faint) !important; }

/* Drawer, overlays --------------------------------------------------------- */

.drawer-backdrop { position: fixed; inset: 0; z-index: 3200; background: rgba(10, 13, 20, 0.28); backdrop-filter: blur(2px); }
.insights-drawer {
  position: fixed;
  z-index: 3300;
  top: 0; right: 0; bottom: 0;
  width: min(500px, 92vw);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-left: 1px solid var(--surface-line);
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(28px) saturate(1.6);
  -webkit-backdrop-filter: blur(28px) saturate(1.6);
  box-shadow: var(--shadow-float);
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.insights-drawer.open { transform: none; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 14px; }
.drawer-header h2 {
  margin: 4px 0 0;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  font-size: 23px;
  font-weight: 700;
}
.drawer-close {
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
}
.drawer-panel { min-height: 0; flex: 1; overflow-y: auto; padding: 4px 20px 34px; }
.drawer-intro { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.drawer-loading, .drawer-empty { padding: 38px 20px; color: var(--muted); text-align: center; font-size: 13px; }
.form-section { margin-top: 20px; }
.section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-label-row .link-button { margin: 0; }
.preset-row { display: flex; gap: 8px; margin-bottom: 10px; }
.preset-row button {
  min-height: 30px;
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.preset-row button:hover { background: var(--fill-strong); }
.transport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.transport-grid label { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 4px 6px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.transport-grid label:hover { background: var(--fill); }
.transport-grid label:has(input:not(:checked)) { color: var(--muted); }
.transport-grid input { width: 16px; height: 16px; accent-color: var(--accent); }

.alert-list { display: grid; gap: 10px; margin-top: 14px; }
.alert-location { border: 1px solid var(--surface-line); border-radius: var(--radius); background: var(--surface); }
.alert-location h3 { margin: 0; padding: 11px 13px; border-bottom: 1px solid var(--hairline); font-size: 13.5px; font-weight: 650; }
.alert-clear { display: flex; align-items: center; gap: 9px; padding: 14px 13px; color: var(--leaf); font-size: 12.5px; }
.alert-clear span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--leaf) 18%, transparent); font-weight: 800; }
.alert-item { margin: 9px; padding: 10px 12px; border-left: 3px solid var(--red-text); border-radius: 9px; background: color-mix(in srgb, var(--red) 22%, transparent); font-size: 12px; line-height: 1.5; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--canvas) 76%, transparent);
  backdrop-filter: blur(8px);
}
.loading-overlay p { margin-top: 14px; color: var(--muted); font-size: 13px; font-weight: 600; }
.train-loader {
  position: relative;
  width: 58px; height: 40px;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(140deg, var(--accent), var(--pink));
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12);
  animation: train-bob 0.7s ease-in-out infinite alternate;
}
.train-loader::before, .train-loader::after { content: ""; position: absolute; top: 9px; width: 16px; height: 11px; border-radius: 3px; background: rgba(255, 255, 255, 0.85); }
.train-loader::before { left: 8px; }
.train-loader::after { right: 8px; }
.train-loader span:nth-child(1), .train-loader span:nth-child(2) { position: absolute; bottom: -4px; width: 9px; height: 9px; border-radius: 50%; background: #1d2330; }
.train-loader span:nth-child(1) { left: 9px; }
.train-loader span:nth-child(2) { right: 9px; }
.train-loader span:nth-child(3) { position: absolute; left: -70px; right: -70px; bottom: -9px; border-bottom: 2px solid var(--faint); }
@keyframes train-bob { from { transform: translateY(-2px); } to { transform: translateY(2px); } }

.toast {
  position: fixed;
  z-index: 4000;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(460px, 92vw);
  padding: 11px 16px;
  border-radius: 14px;
  background: rgba(22, 27, 38, 0.92);
  backdrop-filter: blur(14px);
  color: #fff;
  box-shadow: var(--shadow-float);
  font-size: 13px;
}
.toast.error { background: rgba(160, 45, 45, 0.94); }

/* Mobile ------------------------------------------------------------------- */

.mobile-tabs { display: none; }
.trip-badge { position: absolute; top: 6px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.trip-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  opacity: 0.8;
  animation: tabPulse 1.6s infinite ease-in-out;
}
@keyframes tabPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 340px minmax(320px, 1fr) 360px; }
}

@media (max-width: 960px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100%; }
  .workspace { grid-template-columns: 340px 1fr; grid-template-rows: 56vh auto; }
  .planner-panel { grid-row: 1 / 3; }
  .map-panel { grid-column: 2; min-height: 56vh; }
  .itinerary-panel { grid-column: 2; min-height: 480px; }
  .panel-scroll { overflow: visible; }
}

@media (max-width: 720px) {
  .topbar { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
  .network-status, .nav-action b { display: none; }
  .app-shell {
    height: 100vh;
    height: 100dvh;
    padding-bottom: calc(var(--mobile-tabs-height) + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }
  .workspace { display: block; flex: 1 1 0; min-height: 0; overflow: hidden; }
  .workspace:not([data-active-tab="plan"]) .planner-panel,
  .workspace:not([data-active-tab="map"]) .map-panel,
  .workspace:not([data-active-tab="trip"]) .itinerary-panel { display: none !important; }
  .planner-panel, .map-panel, .itinerary-panel {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border: none !important;
    overflow-y: auto !important;
  }
  .planner-panel { padding: 14px 14px 30px !important; }
  .map-panel { display: flex; flex-direction: column; overflow: hidden !important; }
  .map-panel #map { flex: 1; }

  .mobile-tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    height: calc(var(--mobile-tabs-height) + env(safe-area-inset-bottom, 0px));
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    border-top: 1px solid var(--surface-line);
    background: var(--chrome);
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
  }
  .tab-item {
    position: relative;
    flex: 1;
    height: calc(var(--mobile-tabs-height) - 1px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: color 0.2s ease;
  }
  .tab-item svg { width: 20px; height: 20px; transition: transform 0.2s ease; }
  .tab-item.active { color: var(--accent); }
  .tab-item.active svg { transform: scale(1.08); }
  .drawer-backdrop, .insights-drawer { bottom: 0; }
  /* Keep messages clear of the tab bar. */
  .toast { bottom: calc(var(--mobile-tabs-height) + 16px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
