:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e1e8;
  --panel: #fbfcfd;
  --paper: #ffffff;
  --rail: #d71920;
  --rail-dark: #9f1118;
  --blue: #176b87;
  --green: #16785f;
  --shadow: 0 16px 46px rgba(31, 45, 61, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef3f6;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(390px, 470px) minmax(0, 1fr);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.pill[data-mode="ok"] {
  color: var(--green);
  border-color: rgba(22, 120, 95, 0.25);
  background: #edf8f4;
}

.pill[data-mode="loading"] {
  color: var(--blue);
  border-color: rgba(23, 107, 135, 0.25);
  background: #edf7fb;
}

.pill[data-mode="error"] {
  color: var(--rail-dark);
  border-color: rgba(215, 25, 32, 0.25);
  background: #fff0f1;
}

.search {
  display: grid;
  grid-template-columns: 1fr 150px 128px;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  position: relative;
}

.field span {
  color: #4c5967;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  border: 1px solid #cbd6df;
  background: var(--paper);
  border-radius: 7px;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.station-field {
  grid-column: 1 / -1;
}

.station-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 310px;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.station-results.open {
  display: block;
}

.station-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #edf1f4;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.station-option:hover {
  background: #f4f8fa;
}

.station-option span {
  color: var(--muted);
  font-weight: 800;
}

.station-option.muted {
  color: var(--muted);
  cursor: default;
}

.primary,
.ghost {
  height: 42px;
  border-radius: 7px;
  border: 0;
  font-weight: 850;
  cursor: pointer;
}

.primary {
  grid-column: 1 / -1;
  color: white;
  background: var(--rail);
  box-shadow: 0 10px 22px rgba(215, 25, 32, 0.22);
}

.primary:hover {
  background: var(--rail-dark);
}

.ghost {
  height: 34px;
  padding: 0 10px;
  background: #edf2f5;
  color: #334353;
}

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

.stats div {
  min-width: 0;
  padding: 13px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats b {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.notice {
  border: 1px solid #e8d9a9;
  background: #fff8df;
  color: #6c570f;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #536171;
}

.trip-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
  min-height: 0;
}

.trip-card,
.empty {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 13px;
}

.trip-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px 12px;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.trip-card:hover {
  border-color: rgba(23, 107, 135, 0.45);
  box-shadow: 0 8px 20px rgba(31, 45, 61, 0.08);
}

.city-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.city {
  min-width: 0;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.stay {
  color: var(--green);
  font-weight: 900;
}

.times {
  color: #344457;
  font-size: 13px;
  line-height: 1.45;
}

.times b {
  color: var(--rail-dark);
  margin-right: 4px;
}

.times b + * {
  margin-right: 8px;
}

.meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.option-list {
  display: grid;
  gap: 6px;
  margin-top: 3px;
}

.option-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  padding: 8px;
  border-radius: 7px;
  background: #f3f7f9;
  color: #273849;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.option-row:hover {
  background: #e8f1f5;
}

.option-row strong {
  color: var(--green);
  font-size: 13px;
}

.option-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  line-height: 1.45;
}

.empty.error {
  color: var(--rail-dark);
  background: #fff4f4;
}

.map-wrap {
  min-width: 0;
  min-height: 0;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
}

.marker {
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.28);
}

.marker span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.origin-marker span {
  background: var(--rail);
}

.destination-marker span {
  background: var(--blue);
}

.popup {
  display: grid;
  gap: 4px;
  min-width: 210px;
}

.popup strong {
  font-size: 15px;
}

.popup span {
  color: var(--green);
  font-weight: 900;
}

.popup small {
  color: #4c5967;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(480px, 62vh);
    height: auto;
    overflow: visible;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: auto;
  }

  .trip-list {
    max-height: 360px;
  }

  .map-wrap {
    min-height: 480px;
  }
}

@media (max-width: 560px) {
  .panel {
    padding: 16px;
  }

  .brand {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

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

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

  .city-head {
    display: grid;
    gap: 4px;
  }
}
