:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --card: #ffffff; --ink: #14181d; --muted: #5b6672; --line: #d9dee4;
  --accent: #1d4ed8; --accent-ink: #ffffff; --warn-bg: #fff4d6; --warn-ink: #5c4300;
  /* kaartklassen: blauw / oranje / geel verschillen ook in helderheid en in randstijl (niet rood-groen) */
  --c-laag: #3b82f6; --c-gemiddeld: #f59e0b; --c-hoog: #fde047;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1419; --card: #182028; --ink: #eef1f4; --muted: #9aa7b4; --line: #2b3640; --accent: #8ab4ff; --accent-ink: #0b1220; --warn-bg: #3b2f0b; --warn-ink: #ffe7a3; }
}
:root[data-theme="dark"] { --bg: #0f1419; --card: #182028; --ink: #eef1f4; --muted: #9aa7b4; --line: #2b3640; --accent: #8ab4ff; --accent-ink: #0b1220; --warn-bg: #3b2f0b; --warn-ink: #ffe7a3; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 24px) env(safe-area-inset-left); }
h1 { font-size: 1.15rem; margin: 0; letter-spacing: .01em; }
h2 { font-size: 1rem; margin: 20px 0 8px; }
h3 { font-size: 1.02rem; margin: 0; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .86rem; }
.err { color: #d14343; min-height: 1.2em; }

button, .btn, select, input { font: inherit; }
button, .btn { min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 600; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: transparent; }
button.small { min-height: 44px; padding: 0 12px; font-size: .9rem; }
button:disabled { opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.top h1 { margin-right: auto; }
.top .ghost { min-height: 44px; padding: 0 10px; font-size: .88rem; }

#banners > div { margin: 0 12px 8px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: .9rem; border: 1px solid var(--line); }
#banners > .demo { font-weight: 700; border: 2px dashed currentColor; }

.advice { margin: 0 12px 10px; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); border-left-width: 6px; }
.advice-kind { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; font-weight: 700; }
.advice-text { font-size: 1.12rem; font-weight: 650; margin: 2px 0 0; }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px 10px; }
@media (max-width: 420px) { .controls { grid-template-columns: 1fr; } }
.label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { border: 0; border-radius: 0; min-height: 48px; padding: 0 4px; font-weight: 600; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

#map { height: 46vh; min-height: 300px; margin: 0 12px; border-radius: 14px; border: 1px solid var(--line); z-index: 0; background: var(--card); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9); } }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9); }
.leaflet-container { font: inherit; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #1d4ed8; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.pin.manual { background: #7c3aed; }
.recpin { width: 30px; height: 30px; border-radius: 50%; background: #111; color: #fff; border: 3px solid #fff; display: grid; place-items: center; font-weight: 800; box-shadow: 0 1px 6px rgba(0,0,0,.5); }

.locbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.locbar .muted { margin-right: auto; }

.timeline { padding: 8px 12px 0; }
.timeline label { font-size: .9rem; }
.timeline output { font-weight: 700; }
input[type="range"] { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; align-items: center; }
.sw { display: inline-block; width: 18px; height: 14px; margin-right: 5px; vertical-align: -2px; }
.sw-laag { background: color-mix(in srgb, var(--c-laag) 35%, transparent); border: 1px dotted var(--c-laag); }
.sw-gemiddeld { background: color-mix(in srgb, var(--c-gemiddeld) 55%, transparent); border: 2px dashed #b45309; }
.sw-hoog { background: var(--c-hoog); border: 3px solid var(--ink); }

main { padding: 0 12px; }
.card, .rec { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.rec header { display: flex; gap: 10px; align-items: center; }
.num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .84rem; white-space: nowrap; }
.chip b { font-weight: 700; }
.chip.lv-hoog { border-width: 2px; border-color: var(--ink); }
.chip.lv-gemiddeld { border-style: dashed; }
.bars { letter-spacing: 1px; margin-right: 4px; font-family: monospace; }
.attract { font-weight: 600; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; font-size: .92rem; }
dt { color: var(--muted); }
dd { margin: 0; }
.access { font-size: .86rem; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 10px; }
details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
details ul { margin: 4px 0 8px; padding-left: 20px; font-size: .92rem; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.actions .wide { grid-column: 1 / -1; }
.empty { color: var(--muted); padding: 8px 0 16px; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
td, th { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.state { font-weight: 700; white-space: nowrap; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); width: min(520px, calc(100vw - 24px)); max-height: 88vh; padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin: 10px 0; font-size: .95rem; }
dialog input:not([type="checkbox"]):not([type="radio"]), dialog select { display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
dialog .opt { display: flex; align-items: center; gap: 10px; min-height: 44px; }
dialog .opt input { width: 22px; height: 22px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; padding: 4px 12px; }
.row { display: flex; gap: 8px; margin: 10px 0; }
.row > * { flex: 1; }
.row input { margin-top: 0 !important; }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.presets button { padding: 0 6px; font-size: .9rem; }
#geo-results button { width: 100%; justify-content: flex-start; text-align: left; margin-bottom: 6px; font-weight: 500; font-size: .9rem; padding: 8px 12px; height: auto; }
.close { width: 100%; margin-top: 8px; }
.stat { display: grid; grid-template-columns: 1fr max-content; gap: 6px 12px; font-size: .95rem; }
.stat b { text-align: right; }

#driving { position: fixed; inset: 0; z-index: 9999; background: #000; color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 28px; text-align: center; }
#driving[hidden] { display: none; }
.driving-main { font-size: 2rem; font-weight: 800; line-height: 1.2; margin: 0; }
.driving-sub { font-size: 1.3rem; margin: 0; }
.driving-note { color: #b9c2cc; margin: 0; }

fieldset { display: flex; flex-wrap: wrap; gap: 0 24px; }
