:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65717c;
  --line: #d8dee4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b7791f;
  --danger: #b42318;
  --ok: #13795b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.status-panel {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-panel span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

.segmented {
  display: inline-flex;
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.segmented button,
#refresh-button {
  min-height: 40px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.segmented button {
  min-width: 84px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
}

#refresh-button {
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

#refresh-button:hover {
  background: var(--accent-dark);
}

.message {
  margin: 4px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}

.message.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

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

.arrival {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.route-stack {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.route {
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #202124;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  white-space: nowrap;
}

.direction {
  min-width: 44px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
}

.direction.inbound {
  background: #0f766e;
}

.direction.outbound {
  background: #475569;
}

.details {
  min-width: 0;
}

.headsign {
  margin: 0 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 800;
}

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

.time {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 2px solid var(--ok);
  border-radius: 6px;
  color: var(--ok);
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
}

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

.time.very-delayed {
  border-color: var(--danger);
  color: var(--danger);
}

.time.now {
  background: rgba(19, 121, 91, 0.1);
}

.empty {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 680px) {
  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .status-panel {
    justify-items: start;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .arrival {
    grid-template-columns: 82px minmax(0, 1fr);
  }

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