/* All text colours below meet WCAG AA (4.5:1) on every surface they sit on,
   and field borders meet 3:1, in both themes. */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #eeede6;
  --text: #1a1b1d;
  --muted: #5f6166;
  --faint: #66686d;
  --line: #e1dfd7;
  --field-border: #85878c;
  --accent: #0b6e4f;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe6;
  --ok: #1d7a3b;
  --warn: #9a5700;
  --warn-bg: #fcefd9;
  --bad: #b42318;
  --focus: #1a5fd0;
  --shadow: 0 1px 2px rgb(20 20 15 / 0.05), 0 4px 14px rgb(20 20 15 / 0.05);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101113;
    --surface: #18191c;
    --surface-2: #222327;
    --text: #ebeae5;
    --muted: #a6a8ad;
    --faint: #989aa0;
    --line: #2b2c31;
    --field-border: #74767c;
    --accent: #4cc293;
    --accent-ink: #082018;
    --accent-soft: #163428;
    --ok: #6fd18e;
    --warn: #f2b65c;
    --warn-bg: #33260e;
    --bad: #ff8b7b;
    --focus: #8ab4f8;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101113;
  --surface: #18191c;
  --surface-2: #222327;
  --text: #ebeae5;
  --muted: #a6a8ad;
  --faint: #989aa0;
  --line: #2b2c31;
  --field-border: #74767c;
  --accent: #4cc293;
  --accent-ink: #082018;
  --accent-soft: #163428;
  --ok: #6fd18e;
  --warn: #f2b65c;
  --warn-bg: #33260e;
  --bad: #ff8b7b;
  --focus: #8ab4f8;
  --shadow: none;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

/* Masthead */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.wordmark {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
}

.toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.toggle__track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--field-border);
  transition: background 0.15s;
}

.toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.toggle[aria-pressed="true"] .toggle__track {
  background: var(--accent);
}

.toggle[aria-pressed="true"] .toggle__thumb {
  transform: translateX(14px);
}

/* Boards */

.boards {
  display: grid;
  gap: 28px;
  margin-bottom: 28px;
}

.board__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.board__heading {
  min-width: 0;
}

.board__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.board__title:focus {
  outline: none;
}

.board__title:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.board__kind {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: 3px;
}

.board__status {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.board__status.is-error {
  color: var(--bad);
}

.board__actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.icon-button,
.text-button {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
}

.text-button {
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.text-button.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.icon-button:hover,
.text-button:not(.is-primary):hover {
  background: var(--surface-2);
}

.icon-button.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

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

.notice {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.9rem;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 4px;
}

.departures {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dep {
  position: relative;
}

.dep + .dep {
  border-top: 1px solid var(--line);
}

.dep__visual {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: center;
  padding: 14px 16px;
}

/* The sentence a screen reader reads covers the whole row, so touch
   exploration (VoiceOver, TalkBack) finds it wherever the finger lands. */
.dep__spoken {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.dep--cancelled .dep__dest,
.dep--cancelled .dep__eta {
  color: var(--faint);
  text-decoration: line-through;
}

.dep__eta {
  line-height: 1;
  font-weight: 750;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

.dep__eta small {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
}

.dep__eta--now {
  color: var(--accent);
  font-size: 1.35rem;
}

.dep__main {
  min-width: 0;
}

.dep__where {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 650;
}

.dep__dest {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex: none;
  display: inline-block;
  min-width: 36px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.dep__times {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-top: 3px;
  font-size: 0.9rem;
  color: var(--muted);
}

.dep__times s,
.dep__arrival s {
  color: var(--faint);
}

.dep__clock {
  color: var(--text);
  font-weight: 600;
}

.status {
  font-weight: 650;
}

.status--ok {
  color: var(--ok);
}

.status--late {
  color: var(--warn);
}

.status--bad {
  color: var(--bad);
}

.status--planned {
  font-weight: 400;
  color: var(--faint);
}

.dep__arrival {
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--muted);
}

.dep__arrival strong {
  color: var(--text);
  font-weight: 600;
}

.dep__side {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
}

.dep__platform {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.dep__platform--stop {
  font-size: 0.95rem;
  font-weight: 650;
}

.occupancy {
  display: inline-flex;
  gap: 2px;
  margin-top: 6px;
  align-items: flex-end;
}

.occupancy i {
  width: 4px;
  border-radius: 1px;
  background: var(--line);
}

.occupancy i:nth-child(1) {
  height: 6px;
}

.occupancy i:nth-child(2) {
  height: 9px;
}

.occupancy i:nth-child(3) {
  height: 12px;
}

.occupancy i.on {
  background: var(--muted);
}

.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

.skeleton {
  height: 72px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton + .skeleton {
  border-top: 1px solid var(--line);
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.more {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.more:hover {
  background: var(--surface-2);
}

/* Finder */

.finder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.finder__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}

.finder__summary::-webkit-details-marker {
  display: none;
}

.finder__summary::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}

.finder[open] > .finder__summary::before {
  transform: rotate(45deg);
}

.finder__body {
  padding: 0 16px 16px;
}

.welcome {
  margin-bottom: 16px;
  color: var(--muted);
}

.welcome p {
  margin: 0 0 8px;
}

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

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.example {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.example:hover {
  background: var(--surface-2);
}

.mode {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 3px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
}

.mode__option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode__option span {
  display: block;
  min-width: 84px;
  padding: 7px 16px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.mode__option input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--field-border);
}

.mode__option input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.route {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
}

.field {
  position: relative;
  min-width: 0;
}

.field__label {
  display: block;
  margin-bottom: 4px;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field__optional {
  font-weight: 400;
}

.field__control {
  position: relative;
}

.field__input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
}

.field__input::placeholder {
  color: var(--faint);
  opacity: 1;
}

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field__input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.field__clear {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.field__clear:hover {
  background: var(--surface-2);
  color: var(--text);
}

.swap {
  width: 44px;
  height: 44px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.swap svg {
  transform: rotate(90deg);
}

.swap:hover {
  background: var(--surface-2);
}

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.16);
  max-height: 320px;
  overflow-y: auto;
}

.suggestion {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}

.suggestion[aria-selected="true"] {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.suggestion__name {
  font-weight: 600;
}

.suggestion__meta {
  flex: none;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.suggestion--empty {
  cursor: default;
  color: var(--muted);
}

.lines {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.lines__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-width: 44px;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--bg);
  font-weight: 650;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--chip-bg, var(--accent));
  background: var(--chip-bg, var(--accent));
  color: var(--chip-ink, var(--accent-ink));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--chip-bg, var(--accent));
}

.preview:not(:empty) {
  margin-top: 20px;
}

.footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
  max-width: 62ch;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton,
  .icon-button.is-spinning svg {
    animation: none;
  }

  .toggle__track,
  .toggle__thumb,
  .finder__summary::before {
    transition: none;
  }
}

@media (max-width: 600px) {
  .page {
    padding-top: 20px;
  }

  .masthead {
    flex-wrap: wrap;
  }

  .route {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Stacked fields: the swap button sits between them on the right. */
  .swap {
    justify-self: end;
    width: 44px;
    height: 36px;
    margin: 6px 0 -8px;
    position: relative;
    z-index: 1;
  }

  .swap svg {
    transform: none;
  }

  .board__head {
    flex-wrap: wrap;
  }

  .dep__visual {
    grid-template-columns: 62px minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px 14px;
  }

  .dep__eta {
    font-size: 1.4rem;
  }
}
