:root {
  --blue: #0b5fff;
  --blue-dark: #0848c4;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #121826;
  --muted: #5b6475;
  --border: #dfe3ea;
  --warn-bg: #fff6dc;
  --warn-text: #6b4e00;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --card: #1a2131;
    --text: #eef1f7;
    --muted: #a3acbd;
    --border: #2b3447;
    --warn-bg: #3a3112;
    --warn-text: #ffe39a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

.view { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }

/* Home */
.home { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: 48px 20px 24px; display: flex; flex-direction: column; align-items: center; }
.logo { margin-bottom: 8px; }
h1 { font-size: 30px; margin: 0 0 28px; text-align: center; }
#search-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.label { font-weight: 600; font-size: 20px; }
#line-input {
  width: 100%; font-size: 40px; font-weight: 700; text-align: center; padding: 16px;
  border: 3px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text);
  letter-spacing: 2px;
}
#line-input:focus { outline: none; border-color: var(--blue); }
.btn-primary {
  width: 100%; min-height: 64px; font-size: 22px; font-weight: 700; color: #fff; background: var(--blue);
  border: 0; border-radius: var(--radius);
}
.btn-primary:active { background: var(--blue-dark); }
.hint { color: var(--muted); font-size: 15px; text-align: center; margin: 4px 0 0; }
.recent { width: 100%; margin-top: 28px; }
.recent p { color: var(--muted); font-size: 15px; margin: 0 0 10px; text-align: center; }
.recent-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { min-width: 64px; min-height: 48px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--border); background: var(--card); color: var(--text); font-weight: 700; font-size: 20px; }
.credits { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar h2 { margin: 0; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-back { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--card); color: var(--text); font-weight: 600; flex-shrink: 0; }

/* Lijst */
.meta { color: var(--muted); font-size: 15px; margin: 14px 16px 4px; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 12px 14px; margin: 12px 16px 0; font-size: 16px; }
.notice button { margin-top: 8px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--blue); color: #fff; font-weight: 600; }
.bus-list { list-style: none; margin: 8px 0 24px; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 640px; align-self: center; }
.bus {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 14px; text-align: left;
  background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: var(--radius);
}
.bus:active { border-color: var(--blue); }
.badge { flex-shrink: 0; min-width: 52px; height: 52px; padding: 0 8px; border-radius: 12px; background: var(--blue); color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.bus-main { display: block; flex: 1; min-width: 0; }
.bus-dest { display: block; font-size: 19px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.bus-dest small { display: block; font-size: 14px; font-weight: 500; color: var(--muted); }
.bus-sub { display: block; color: var(--muted); font-size: 14px; margin-top: 3px; }
.bus-km { flex-shrink: 0; text-align: right; font-size: 22px; font-weight: 800; }
.bus-km small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.bus-arrow { color: var(--muted); font-size: 26px; flex-shrink: 0; }
.empty { margin: 32px 20px; text-align: center; color: var(--muted); font-size: 18px; line-height: 1.5; }
.empty strong { color: var(--text); display: block; font-size: 20px; margin-bottom: 6px; }

/* Kaart */
.view-map { height: 100dvh; position: relative; }
.topbar-float { position: absolute; left: 0; right: 0; top: 0; }
#map { position: absolute; inset: 0; z-index: 1; }
.view-map .topbar { z-index: 500; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500; background: var(--card); border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0 -4px 20px rgba(0,0,0,.15); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big { font-size: 28px; font-weight: 800; }
.small { font-size: 14px; color: var(--muted); }
.sheet-btns { display: flex; flex-direction: column; gap: 8px; }
.btn-secondary { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--card); color: var(--text); font-weight: 600; font-size: 16px; }
.btn-secondary[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); }
.sheet .notice { margin: 12px 0 0; }

.bus-marker { background: var(--blue); color: #fff; font-weight: 800; font-size: 16px; border: 3px solid #fff; border-radius: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.me-marker { width: 20px; height: 20px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-top { top: calc(70px + env(safe-area-inset-top)); }
