:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #14213d;
  --muted: #5f6b82;
  --line: #dde3ee;
  --brand: #073590;
  --accent: #f1c933;
  --accent-text: #14213d;
  --chip: #e9eef8;
  --error: #b3261e;
  --note: #fff6d6;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1422;
    --surface: #182033;
    --text: #e8ecf5;
    --muted: #9aa5bd;
    --line: #2a3550;
    --brand: #8fb2ff;
    --accent: #f1c933;
    --accent-text: #14213d;
    --chip: #232d46;
    --error: #ff8a80;
    --note: #3a3320;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}

.top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 12px 0 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--brand);
}

h3 {
  margin: 0;
  font-size: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--chip);
  border-radius: 999px;
  padding: 4px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px;
  border-radius: 999px;
}

.tab.on {
  background: var(--surface);
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}

.form {
  display: grid;
  gap: 16px;
}

.field-label {
  font-weight: 600;
  margin-bottom: 8px;
}

.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 13px;
  margin-left: 8px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.row > input {
  flex: 1 1 140px;
  min-width: 0;
}

.time-window {
  display: grid;
  gap: 8px;
}

.time-row {
  align-items: center;
}

.time-row input {
  flex: 1 1 100px;
  min-width: 0;
}

input[type="date"],
input[type="time"],
input[type="number"],
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 44px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin-right: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 999px;
}

.chip.on {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--surface);
  font-weight: 600;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.stepper button {
  border: 0;
  background: var(--chip);
  color: var(--text);
  font-size: 22px;
  width: 44px;
  height: 44px;
}

.stepper button:disabled {
  opacity: 0.35;
}

.stepper output {
  min-width: 40px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

.btn.wide {
  width: 100%;
  font-size: 17px;
}

.btn:disabled {
  opacity: 0.5;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.fare {
  display: grid;
  gap: 10px;
}

.fare-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.price {
  text-align: right;
  white-space: nowrap;
}

.price-main {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
}

.price-sub {
  font-size: 12px;
  color: var(--muted);
}

.leg {
  display: grid;
  grid-template-columns: 64px 1fr;
  column-gap: 8px;
}

.leg-label {
  grid-row: span 2;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding-top: 2px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions .btn {
  flex: 1 1 140px;
}

.other-dates ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.other-dates li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.note {
  background: var(--note);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.error {
  color: var(--error);
}

footer {
  text-align: center;
  margin-top: 24px;
}

.segmented {
  display: flex;
  gap: 4px;
  background: var(--chip);
  border-radius: 999px;
  padding: 4px;
  margin: 10px 0;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px;
  min-height: 36px;
  border-radius: 999px;
}

.segmented button.on {
  background: var(--surface);
  color: var(--text);
}

.group {
  margin: 8px 0;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
}

.group-flag {
  font-size: 24px;
  line-height: 1;
}

.group-name {
  flex: 1;
  display: grid;
}

.group-price {
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
}

.group-chevron {
  color: var(--muted);
}

.group .fare {
  margin-left: 8px;
}

.cities {
  display: grid;
  gap: 12px;
}

.city {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.city-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.city-row select {
  flex: 1;
  min-width: 0;
}

.city-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--surface);
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--chip);
  color: var(--text);
  font-size: 22px;
  flex: none;
}

.stay-row {
  align-items: center;
}

.switch {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.switch input {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  accent-color: var(--brand);
  flex: none;
}

.leg-times {
  display: grid;
  gap: 12px;
}

.leg-times summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  cursor: pointer;
}

.leg-times[open] summary {
  margin-bottom: 12px;
}

.leg-times .field + .field {
  margin-top: 12px;
}

.trip-route {
  font-size: 16px;
}

.trip-legs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.trip-leg {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.trip-stay {
  padding: 4px 0 4px 12px;
  border-left: 2px dashed var(--line);
  margin-left: 4px;
}

.center {
  text-align: center;
  margin: 0;
}
