:root {
  --ink: #102a32;
  --ink-soft: #3a5660;
  --paper: #f3f7f6;
  --wash: #d7ebe6;
  --sea: #0f6b63;
  --sea-deep: #0a4a46;
  --coral: #d45d3a;
  --line: rgba(16, 42, 50, 0.12);
  --ok: #1f7a4d;
  --warn: #9a6b12;
  --err: #a33b2d;
  --shadow: 0 18px 50px rgba(16, 42, 50, 0.12);
  --radius: 14px;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
}

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

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 10% -10%, #9fd4cb 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, #f0c9b8 0%, transparent 50%),
    linear-gradient(165deg, #e9f3f1 0%, #f3f7f6 42%, #eef2f0 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='%23102a32' stroke-opacity='0.04'/%3E%3C/svg%3E");
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(243, 247, 246, 0.72);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.35rem;
  background: linear-gradient(135deg, var(--sea) 0%, var(--coral) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.brand-tag {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.status {
  justify-self: end;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
}

.status[data-state="ready"] {
  color: var(--ok);
  border-color: rgba(31, 122, 77, 0.35);
}

.status[data-state="down"] {
  color: var(--err);
  border-color: rgba(163, 59, 45, 0.35);
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.planner {
  grid-column: 1;
  grid-row: 1 / span 2;
  padding: 1.25rem 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.66);
  animation: rise 0.55s ease both;
}

.planner-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.planner-sub {
  margin: 0.55rem 0 1.25rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.planner-form {
  display: grid;
  gap: 0.9rem;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field select {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 500 0.95rem/1.2 var(--font-body);
  text-transform: none;
  letter-spacing: 0;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(15, 107, 99, 0.35);
  border-color: var(--sea);
}

.place-fields {
  display: grid;
  gap: 0.85rem;
}

.place-field {
  position: relative;
}

.place-suggestions {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.25rem;
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  max-height: 14rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(16, 42, 50, 0.12);
}

.place-suggestions[hidden] {
  display: none;
}

.place-suggestion {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.place-suggestion:hover,
.place-suggestion:focus {
  background: rgba(215, 235, 230, 0.75);
  outline: none;
}

.place-suggestion-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.place-suggestion-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.place-selected {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--sea-deep);
}

.place-fallback {
  margin-top: 0.55rem;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(212, 93, 58, 0.28);
  background: rgba(212, 93, 58, 0.06);
}

.place-fallback-title {
  margin: 0;
  font-weight: 700;
  color: var(--coral);
  font-size: 0.9rem;
}

.place-fallback-copy {
  margin: 0.2rem 0 0.55rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.place-fallback-actions {
  display: grid;
  gap: 0.4rem;
}

.place-fallback-actions button {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem 0.65rem;
  font: 600 0.85rem/1.3 var(--font-body);
  color: var(--sea-deep);
  cursor: pointer;
}

.place-fallback-actions button:hover {
  border-color: var(--sea);
  background: rgba(215, 235, 230, 0.55);
}

.landmark-search {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(16, 42, 50, 0.15);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.15rem 0 0.35rem;
}

.preset-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font: 500 0.78rem/1 var(--font-body);
  cursor: pointer;
}

.preset-chip:hover {
  border-color: var(--sea);
  color: var(--sea-deep);
}

.coords-details {
  border-top: 1px solid var(--line);
  padding-top: 0.55rem;
}

.coords-details summary {
  cursor: pointer;
  color: var(--sea-deep);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.55rem;
}

.prefs {
  margin: 0;
  padding: 0.75rem 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
}

.prefs legend {
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.85rem 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--sea);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.cta:hover {
  background: var(--sea-deep);
  transform: translateY(-1px);
}

.cta:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}

.cta-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}

.cta[data-loading="true"] .cta-spinner {
  display: inline-block;
}

.form-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.walk-budget {
  margin: 0.75rem 0 0.25rem;
}

.field-note {
  font-weight: 400;
  color: var(--ink-soft);
}

.walk-budget-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.walk-budget-row input[type="range"] {
  width: 100%;
  accent-color: var(--sea);
}

.walk-budget-row output {
  min-width: 5.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--sea-deep);
  text-align: right;
}

.walk-unlimited {
  margin-top: 0.45rem;
}

.bus-inspector {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line);
}

.bus-inspector summary {
  cursor: pointer;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--sea-deep);
  margin-bottom: 0.55rem;
}

.bus-inspector-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.bus-inspector .field {
  margin-bottom: 0.55rem;
}

.bus-inspector-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.leaflet-tooltip.bus-stop-label {
  background: #fffef8;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(16, 42, 50, 0.28);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 0.28rem 0.45rem;
  white-space: nowrap;
  max-width: min(280px, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.leaflet-tooltip.bus-stop-label::before {
  border-top-color: var(--ink);
}

.leaflet-container {
  font-family: var(--font-body);
  background: #e8eef0;
}

.leaflet-interactive {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 10px 28px rgba(16, 42, 50, 0.16) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  color: var(--ink) !important;
  background: rgba(255, 255, 255, 0.96) !important;
  border-bottom-color: rgba(16, 42, 50, 0.08) !important;
}

.leaflet-control-zoom a:hover {
  background: #ffffff !important;
  color: var(--sea-deep) !important;
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.72) !important;
  color: var(--ink-soft);
  border-radius: 8px 0 0 0;
  margin: 0 !important;
  padding: 2px 8px !important;
}

.endpoint-marker {
  background: transparent;
  border: 0;
}

.endpoint-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 4px;
  background: var(--pin, var(--sea));
  border: 2.5px solid #ffffff;
  box-shadow: 0 8px 18px rgba(16, 42, 50, 0.28);
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
}

.endpoint-pin span {
  transform: rotate(45deg);
  color: #ffffff;
  font: 700 0.72rem/1 var(--font-body);
  letter-spacing: 0.02em;
}

.cta.secondary {
  background: #1f7a4d;
  margin-top: 0;
  font-size: 0.95rem;
  padding: 0.7rem 0.85rem;
}

.cta.secondary:hover {
  background: #17633e;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: 600 0.9rem/1.2 var(--font-body);
  color: var(--ink-soft);
  cursor: pointer;
}

.ghost-btn:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.map-panel {
  grid-column: 2;
  grid-row: 1;
  min-height: 420px;
  border: 1px solid rgba(16, 42, 50, 0.08);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 22px 48px rgba(16, 42, 50, 0.1);
  animation: rise 0.65s 0.08s ease both;
  background: #e8eef0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.results {
  grid-column: 2;
  grid-row: 2;
  padding: 1.1rem 1.2rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  animation: rise 0.5s ease both;
}

.results[hidden] {
  display: none;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.results-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.results-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.objective-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.objective-tabs button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font: 600 0.85rem/1.2 var(--font-body);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.objective-tabs button[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.objective-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.variant-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.variant {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  padding: 0.35rem 0.2rem;
  font: 600 0.9rem/1.2 var(--font-body);
  cursor: pointer;
}

.variant.active {
  color: var(--sea-deep);
  border-bottom-color: var(--sea);
}

.journey-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 0.65rem 0.7rem;
  border-top: 2px solid var(--sea);
  background: rgba(215, 235, 230, 0.45);
}

.stat .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 600;
}

.stat .value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.legs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.leg {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  animation: rise 0.35s ease both;
}

.leg:first-child {
  border-top: 0;
  padding-top: 0;
}

.mode-chip {
  min-width: 4.4rem;
  text-align: center;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--ink-soft);
}

.mode-chip[data-mode="WALK"],
.mode-chip[data-mode="TRANSFER"] {
  background: #5b7c86;
}

.mode-chip[data-mode="TRAIN"] {
  background: #c45c26;
}

.mode-chip[data-mode="METRO"] {
  background: #2f6fad;
}

.mode-chip[data-mode="BUS"] {
  background: #1f7a4d;
}

.mode-chip[data-mode="AUTO"] {
  background: #8a5a12;
}

.maps-links {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.55rem;
}

.maps-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.maps-full,
.maps-leg,
.maps-chip,
.maps-place {
  color: var(--sea-deep);
  text-decoration: none;
}

.maps-full {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(15, 107, 99, 0.35);
  background: rgba(215, 235, 230, 0.65);
  font-size: 0.88rem;
  font-weight: 600;
}

.maps-full:hover,
.maps-leg:hover,
.maps-chip:hover,
.maps-place:hover {
  text-decoration: underline;
}

.maps-stops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.maps-chip {
  display: inline-block;
  max-width: 100%;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.maps-place {
  font-weight: inherit;
  border-bottom: 1px dotted rgba(15, 107, 99, 0.45);
}

.leg-maps {
  margin-top: 0.4rem;
}

.maps-leg {
  font-size: 0.8rem;
  font-weight: 600;
}

.leg-body .title {
  font-weight: 600;
}

.leg-body .meta {
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.leg-platforms {
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sea-deep);
}

.leg-platforms-sep {
  opacity: 0.45;
  font-weight: 500;
}

.leg-next-trains {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(10, 74, 70, 0.08);
  border: 1px solid rgba(10, 74, 70, 0.15);
}

.leg-next-trains-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sea-deep);
}

.leg-next-trains-times {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}

.leg-cost {
  font-weight: 600;
  white-space: nowrap;
}

.empty-variant {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast[hidden] {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .status {
    justify-self: start;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .planner,
  .map-panel,
  .results {
    grid-column: 1;
    grid-row: auto;
  }

  .map-panel,
  #map {
    min-height: 320px;
  }

  .journey-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .field-pair {
    grid-template-columns: 1fr;
  }

  .shell {
    padding: 0.85rem;
  }
}
