:root {
  --bg: #f4f6f9; --fg: #1c2230; --muted: #5f6878; --card: #ffffff; --line: #dde2ea;
  --accent: #1d4ed8; --on-accent: #ffffff; --danger: #b3261e; --ok: #2e7d4f;
  --pick: #e3ebfd; --closed: #fbe9e7;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #10141b; --fg: #e6eaf1; --muted: #9aa3b2; --card: #181e28; --line: #2a3242;
          --accent: #6b9bff; --on-accent: #0b1430; --danger: #f2867d; --ok: #8fc79b;
          --pick: #1d2b4a; --closed: #3a1f1d; }
}
* { 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 96px; }
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 8px; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
section p { margin: 0 0 12px; }
.verdict h2 { font-size: 1.35rem; }
.verdict.alarm { border: 2px solid var(--danger); }
button, select { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; }
button.primary { width: 100%; padding: 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
button.secondary { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); font-weight: 600; }
button.danger { width: 100%; padding: 12px; border: 1px solid var(--danger); border-radius: 10px; background: none; color: var(--danger); font-weight: 600; }
button.link { background: none; border: 0; color: var(--muted); padding: 0; }
#push .link { display: block; margin: 12px auto 0; }
.wide { display: block; width: 100%; }
input, select { width: 100%; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); margin-bottom: 12px; min-width: 0; }
/* iOS draws date fields with its own height and centred text. */
input[type="datetime-local"] { -webkit-appearance: none; appearance: none; min-height: 44px; line-height: 22px; text-align: left; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
label { display: block; margin-bottom: 4px; color: var(--muted); }
a { color: var(--accent); }
a.edit { display: block; text-align: center; margin-top: 10px; }
.hint, small { color: var(--muted); font-size: .8rem; }
table.routes { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: .95rem; }
table.routes td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.routes .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.routes .state { color: var(--muted); font-size: .85rem; white-space: nowrap; }
table.routes tr.pick td { background: var(--pick); font-weight: 600; }
table.routes tr.closed td { background: var(--closed); color: var(--muted); }
table.routes tr.closed .state { color: var(--danger); }
table.routes tr.free td { color: var(--muted); font-style: italic; }
.trips { list-style: none; margin: 0; padding: 0; }
.trips a { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.trips time { color: var(--muted); font-variant-numeric: tabular-nums; }
.trips small { flex-basis: 100%; }
.message { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 5;
           max-width: 32rem; margin: 0 auto; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
           background: var(--card); color: var(--danger); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.message:empty { display: none; }
.message.ok { color: var(--ok); }
