:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --text: #17201c;
  --muted: #5d6a64;
  --border: #d9dfdc;
  --accent: #0f5132;
  --accent-text: #ffffff;
  --live: #11823b;
  --plan: #6b7570;
  --stale: #a45f00;
  --cancel: #b42318;
  --alert-bg: #fff4d6;
  --alert-text: #6a4a00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1714;
    --surface: #15211d;
    --surface-2: #1c2a25;
    --text: #e7eeea;
    --muted: #97a59f;
    --border: #2a3a34;
    --accent: #3fb47a;
    --accent-text: #06120c;
    --live: #4ade80;
    --plan: #9aa7a1;
    --stale: #f0a63a;
    --cancel: #ff7a6e;
    --alert-bg: #3a3214;
    --alert-text: #f5dd8c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.feed-status {
  font: inherit; font-size: .8rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.feed-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--plan); }
.feed-status.live::before { background: var(--live); }
.feed-status.stale::before { background: var(--stale); }
.feed-status.down::before { background: var(--cancel); }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px; display: grid; gap: 14px; }

.board { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.board-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.board-head h2 { font-size: 1.05rem; margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.board-sub { color: var(--muted); font-size: .8rem; padding: 0 14px 6px; }
.board-note { padding: 10px 14px 14px; color: var(--muted); font-size: .9rem; }
.board-error { padding: 10px 14px 14px; color: var(--cancel); font-size: .9rem; }

.dep { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center;
       padding: 10px 14px; border-top: 1px solid var(--border); }
.line-badge { min-width: 46px; text-align: center; font-weight: 700; font-size: .9rem; padding: 4px 6px;
              border-radius: 8px; background: var(--surface-2); color: var(--text); font-variant-numeric: tabular-nums; }
.dep-main { min-width: 0; }
.dest { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 2px 8px; }
.dep-time { text-align: right; font-variant-numeric: tabular-nums; }
.countdown { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.clock { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.clock s { color: var(--muted); }
.delay-late { color: var(--cancel); font-weight: 600; }
.delay-ok { color: var(--live); font-weight: 600; }

.badge { font-size: .68rem; font-weight: 700; letter-spacing: .03em; padding: 1px 6px; border-radius: 6px;
         border: 1px solid currentColor; text-transform: uppercase; }
.badge.LIVE { color: var(--live); }
.badge.PLAN { color: var(--plan); }
.badge.VERALTET { color: var(--stale); }
.badge.ENTFAELLT { color: var(--cancel); }
.dep.cancelled .dest, .dep.cancelled .countdown { text-decoration: line-through; color: var(--muted); }

.alerts { grid-column: 1 / -1; }
.alerts details { background: var(--alert-bg); color: var(--alert-text); border-radius: 8px; padding: 6px 10px; font-size: .85rem; margin-top: 4px; }
.alerts summary { cursor: pointer; font-weight: 600; }

.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

.fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
       border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); font-size: 2rem; line-height: 1;
       box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; z-index: 6; }

.empty { max-width: 480px; margin: 48px auto; padding: 0 16px; text-align: center; color: var(--muted); }
.empty-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }

.footer { max-width: 720px; margin: 24px auto 0; padding: 0 16px; color: var(--muted); font-size: .78rem; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--border);
       background: var(--surface); color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--cancel); }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

dialog.sheet { border: 0; padding: 0; width: min(560px, 100%); max-height: 92vh; border-radius: var(--radius);
               background: var(--surface); color: var(--text); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 94vh; }
}
.sheet-inner { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.1rem; }
.sheet-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.sheet-actions .primary { margin-left: auto; }

.field { display: grid; gap: 6px; margin: 12px 0; border: 0; padding: 0; }
.field > span, .field legend { font-size: .85rem; color: var(--muted); padding: 0; margin-bottom: 6px; }
input[type=text], input[type=search], input[type=password], select {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.results li button { width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface-2);
                     border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.results .r-name { font-weight: 600; display: block; }
.results .r-meta { font-size: .8rem; color: var(--muted); display: block; }
.results .hint { color: var(--muted); font-size: .9rem; padding: 6px 2px; }

.choice-list { display: grid; gap: 6px; }
.choice-list label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border);
                     border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.choice-list small { color: var(--muted); display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .85rem; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
        background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chosen { margin: 4px 0 8px; }
.error { color: var(--cancel); }
.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .9rem; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
