:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1c20;
  --muted: #6b7280;
  --border: #e2e4e9;
  --ontime: #157a3d;
  --delayed: #b45309;
  --late: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1e2126;
    --text: #eceef1;
    --muted: #9aa1ac;
    --border: #2c2f36;
    --ontime: #4ade80;
    --delayed: #fbbf24;
    --late: #f87171;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
}

header {
  max-width: 900px;
  margin: 0 auto 20px;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

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

.direction-toggle {
  display: none;
  gap: 8px;
  margin-top: 12px;
}

.toggle-btn {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--muted);
  cursor: pointer;
}

.toggle-btn[aria-selected="true"] {
  color: var(--text);
  border-color: var(--text);
}

main {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  main {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 699px) {
  .direction-toggle {
    display: flex;
  }

  .board {
    display: none;
  }

  .board.active {
    display: block;
  }
}

.board {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.board h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr.past {
  opacity: 0.45;
}

tr.next td {
  font-size: 1.1rem;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
}

.loc-abbr {
  display: none;
}

@media (max-width: 699px) {
  .loc-full {
    display: none;
  }

  .loc-abbr {
    display: inline;
  }
}

.expected-time.delayed {
  color: var(--delayed);
}

.expected-time.late {
  color: var(--late);
}

.delay-tag {
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: super;
}

.delay-tag.delayed {
  color: var(--delayed);
}

.delay-tag.late {
  color: var(--late);
}

.live-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  vertical-align: middle;
}

.live-icon-dot {
  --dot-color: var(--ontime);
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot-color);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--dot-color) 60%, transparent);
  animation: live-pulse 1.8s ease-out infinite;
}

.live-icon-dot.delayed {
  --dot-color: var(--delayed);
}

.live-icon-dot.late {
  --dot-color: var(--late);
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--dot-color) 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--dot-color) 0%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-icon-dot {
    animation: none;
  }
}

.badge.ontime {
  color: var(--ontime);
  background: color-mix(in srgb, var(--ontime) 15%, transparent);
}

.badge.delayed {
  color: var(--delayed);
  background: color-mix(in srgb, var(--delayed) 18%, transparent);
}

.badge.late {
  color: var(--late);
  background: color-mix(in srgb, var(--late) 18%, transparent);
}

.badge.scheduled-only {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 15%, transparent);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 4px;
}
