:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --body-glow: rgba(15, 107, 77, 0.08);
  --body-glow-end: rgba(245, 247, 242, 0);
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --text: #17211c;
  --muted: #64716b;
  --label: #2a3832;
  --border: #d9e1dc;
  --primary: #0f6b4d;
  --primary-dark: #0a4f39;
  --on-primary: #ffffff;
  --accent: #245d8f;
  --warning: #a85f00;
  --error: #7a1c1c;
  --focus-ring: rgba(36, 93, 143, 0.18);
  --toggle-track: #dfe8e2;
  --toggle-thumb: #ffffff;
  --toggle-icon-active: #0f6b4d;
  --toggle-icon-muted: #8a9992;
  --badge-eav-text: #073f2d;
  --badge-eav-bg: #d9efe7;
  --badge-air-text: #633900;
  --badge-air-bg: #ffe3b5;
  --shadow: 0 16px 36px rgba(22, 33, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101614;
  --body-glow: rgba(56, 180, 135, 0.14);
  --body-glow-end: rgba(16, 22, 20, 0);
  --surface: #151d1a;
  --surface-muted: #1c2824;
  --text: #f1f7f3;
  --muted: #a5b3ad;
  --label: #d8e3de;
  --border: #2b3934;
  --primary: #43c191;
  --primary-dark: #38ad82;
  --on-primary: #06110d;
  --accent: #8cbfec;
  --warning: #f0b35e;
  --error: #f3a5a5;
  --focus-ring: rgba(140, 191, 236, 0.2);
  --toggle-track: #22302b;
  --toggle-thumb: #0f1815;
  --toggle-icon-active: #f0b35e;
  --toggle-icon-muted: #6f8078;
  --badge-eav-text: #bdf0dc;
  --badge-eav-bg: #123d2e;
  --badge-air-text: #ffd999;
  --badge-air-bg: #4b3214;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101614;
    --body-glow: rgba(56, 180, 135, 0.14);
    --body-glow-end: rgba(16, 22, 20, 0);
    --surface: #151d1a;
    --surface-muted: #1c2824;
    --text: #f1f7f3;
    --muted: #a5b3ad;
    --label: #d8e3de;
    --border: #2b3934;
    --primary: #43c191;
    --primary-dark: #38ad82;
    --on-primary: #06110d;
    --accent: #8cbfec;
    --warning: #f0b35e;
    --error: #f3a5a5;
    --focus-ring: rgba(140, 191, 236, 0.2);
    --toggle-track: #22302b;
    --toggle-thumb: #0f1815;
    --toggle-icon-active: #f0b35e;
    --toggle-icon-muted: #6f8078;
    --badge-eav-text: #bdf0dc;
    --badge-eav-bg: #123d2e;
    --badge-air-text: #ffd999;
    --badge-air-bg: #4b3214;
    --shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, var(--body-glow), var(--body-glow-end) 260px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 20px 14px 32px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 18px;
}

.eyebrow,
.status,
.summary,
.meta,
.hint {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
  line-height: 1.2;
}

.status {
  margin: 0 0 3px;
  white-space: nowrap;
  font-size: 0.9rem;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.theme-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: 74px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  color: var(--text);
  background: var(--toggle-track);
  isolation: isolate;
}

.theme-toggle:hover {
  background: var(--surface-muted);
}

.theme-toggle::before {
  position: absolute;
  z-index: -1;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--toggle-thumb);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  content: "";
  transition: transform 160ms ease;
}

.theme-toggle.is-dark::before {
  transform: translateX(100%);
}

.theme-icon {
  display: grid;
  min-width: 30px;
  min-height: 30px;
  place-items: center;
  color: var(--toggle-icon-muted);
}

.theme-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-toggle:not(.is-dark) .sun-icon,
.theme-toggle.is-dark .moon-icon {
  color: var(--toggle-icon-active);
}

.search-panel,
.results-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 16px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--label);
}

select,
input[type="time"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

select:focus,
input[type="time"]:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.swap-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface-muted);
  font-size: 1.35rem;
  line-height: 1;
}

.time-field {
  grid-column: 1 / 2;
}

.line-field {
  grid-column: 2 / 4;
}

.actions {
  display: flex;
  gap: 10px;
  grid-column: span 3;
}

.secondary-button {
  min-width: 132px;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.results-section {
  margin-top: 14px;
  overflow: hidden;
}

.results-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}

.results-heading h2,
.summary {
  margin-bottom: 12px;
}

.summary {
  font-size: 0.9rem;
  text-align: right;
}

.results {
  display: grid;
  gap: 1px;
  background: var(--border);
}

.trip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 14px 16px;
  background: var(--surface);
}

.time-stack {
  display: grid;
  gap: 2px;
  min-width: 62px;
}

.time {
  font-size: 1.35rem;
  font-weight: 850;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

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

.route {
  min-width: 0;
}

.route strong {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-aside {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.badge {
  display: inline-flex;
  min-width: 48px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.badge.eav {
  color: var(--badge-eav-text);
  background: var(--badge-eav-bg);
}

.badge.air {
  color: var(--badge-air-text);
  background: var(--badge-air-bg);
}

.meta {
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state,
.error-state {
  padding: 18px 16px 20px;
  background: var(--surface);
}

.empty-state p,
.error-state p {
  margin: 0;
}

.empty-state strong,
.error-state strong {
  display: block;
  margin-bottom: 6px;
}

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

.hint {
  font-size: 0.92rem;
}

.app-footer {
  padding: 18px 8px 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

@media (max-width: 720px) {
  .app {
    padding: 14px 10px 24px;
  }

  .app-header {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.75rem;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .search-form .field:nth-of-type(2),
  .time-field,
  .line-field {
    grid-column: 1 / -1;
  }

  .swap-button {
    grid-column: 2;
    grid-row: 1;
  }

  .actions {
    grid-column: 1 / -1;
  }

  .secondary-button {
    flex: 1;
  }

  .results-heading {
    display: block;
  }

  .summary {
    text-align: left;
  }

  .trip {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .time-stack {
    grid-column: 1 / -1;
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 10px;
  }

  .route strong,
  .route span {
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .app-header {
    display: block;
  }

  .status {
    margin-top: 10px;
  }

  .search-panel {
    padding: 14px;
  }

  .trip {
    gap: 10px;
    padding: 13px 14px;
  }

  .time {
    font-size: 1.2rem;
  }
}
