:root {
  --bg: #f6f5f3; --fg: #1d1b19; --muted: #6b655e; --card: #ffffff; --line: #e0dcd6;
  --accent: #7a1f1f; --go: #2e7d4f; --wait: #c0392b; --closed: #d64545; --opened: #2e7d4f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141210; --fg: #ece8e3; --muted: #a39b92; --card: #1f1c19; --line: #35302b;
          --accent: #e59a8f; --go: #5cc488; --wait: #ff7b6b; --closed: #e05a5a; --opened: #3f9d68; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
/* The home-screen app draws under the status bar and iOS reports the safe area as ~0 there:
   keep the header clear of the clock (html.standalone is set in app.js). */
html.standalone body { padding-top: max(40px, calc(env(safe-area-inset-top, 0px) + 24px)); }
main { max-width: 32rem; margin: 0 auto; padding: 16px 0 32px; }
header { display: flex; justify-content: space-between; align-items: baseline; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; }
button.primary { width: 100%; padding: 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--bg); font-weight: 600; }
button.link { background: none; border: 0; color: var(--muted); padding: 0; }
input { width: 100%; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); margin-bottom: 12px; }
label { display: block; margin-bottom: 4px; color: var(--muted); }
a { color: var(--accent); }
.hint, small { color: var(--muted); font-size: .8rem; }
.message { color: var(--wait); min-height: 1.4em; }
.message.ok { color: var(--go); }

.verdict { font-size: 1.5rem; font-weight: 700; margin: 0 0 2px; }
.verdict.go { color: var(--go); }
.verdict.wait { color: var(--wait); }
.timeline { position: relative; height: 28px; margin: 14px 0 4px; border-radius: 6px;
            background: color-mix(in srgb, var(--go) 22%, var(--card)); overflow: hidden; }
.closure { position: absolute; top: 0; bottom: 0; background: var(--closed); }
.now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); opacity: .5; }
.arrive { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: var(--fg); }
.ticks { position: relative; height: 1.2em; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); }
.windows { list-style: none; padding: 0; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.windows li { padding: 2px 0; }

.taps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tap { padding: 26px 8px; border: 0; border-radius: 12px; color: #fff; font-size: 1.25rem; font-weight: 700; }
.tap.closed { background: var(--closed); }
.tap.opened { background: var(--opened); }
.tap.freight { width: 100%; margin-top: 10px; padding: 14px 8px; font-size: 1rem;
             background: var(--bg); color: var(--fg); border: 2px solid var(--line); }
.log { list-style: none; padding: 0; margin: 12px 0 8px; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

.trains { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.trains th, .trains td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.trains th { color: var(--muted); font-weight: 500; }
.trains .quiet { color: var(--muted); }
.delay { color: var(--wait); font-weight: 600; font-size: .85rem; }
.credit { text-align: center; }
