:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --line: #d9dee5;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --droog: #2e9d4f;
  --licht: #e69500;
  --regen: #d62728;
  --alt: #7b3fe4;
  --warn-bg: #fff4d6;
  --warn-text: #6b4d00;
  --error: #c62828;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e8ebef;
    --muted: #9aa4b0;
    --line: #2c333c;
    --accent: #4c8dff;
    --warn-bg: #3a2f10;
    --warn-text: #ffd97a;
    --error: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent); color: var(--accent-text);
}
.bar h1 { font-size: 1.2rem; margin: 0; font-weight: 650; }
body.test .bar { background: #c25e00; }
.testmode h3 { font-size: 1rem; margin: 14px 0 6px; }
.testmode .field { margin: 8px 0 4px; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 1.4rem; padding: 4px 8px; cursor: pointer; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row .suggest { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; margin: -2px 0 14px; }
.check input { width: 20px; height: 20px; }

.suggest { position: relative; }
.suggestions {
  position: absolute; z-index: 1000; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 20px #0003; max-height: 260px; overflow-y: auto;
}
.suggestions li { padding: 10px 12px; cursor: pointer; }
.suggestions li:hover, .suggestions li[aria-selected=true] { background: color-mix(in srgb, var(--accent) 12%, transparent); }

button { font: inherit; border-radius: 10px; min-height: 46px; padding: 0 16px; cursor: pointer; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; font-weight: 600; width: 100%; }
.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.link { background: none; border: 0; color: inherit; text-decoration: underline; min-height: 0; padding: 0; font-weight: 600; }
button:disabled { opacity: .6; cursor: default; }

.error { color: var(--error); margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 8px 10px; border-radius: 8px; }

.busy { text-align: center; padding: 24px 0; }
.spinner {
  width: 44px; height: 44px; margin: 8px auto 16px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.progress { text-align: left; max-width: 420px; margin: 16px auto 20px; padding-left: 22px; color: var(--muted); }
.progress li:last-child { color: var(--text); font-weight: 600; }

#map { height: 52vh; min-height: 280px; border-radius: var(--radius); border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); margin: 8px 2px 12px; }
.sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.sw.droog { background: var(--droog); } .sw.licht { background: var(--licht); }
.sw.regen { background: var(--regen); } .sw.alt { background: var(--alt); }
.sw.radar { background: linear-gradient(90deg, #96c8ff, #286ee6, #8228aa); height: 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 10px; }
.stats div { min-width: 0; }
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.card p { margin: 6px 0; }
@media (max-width: 380px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.actions .primary { grid-column: 1 / -1; }

.banner.working { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); }
.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--warn-bg); color: var(--warn-text);
  padding: 10px 12px; border-radius: 10px; margin-bottom: 10px;
}

dialog {
  border: 0; border-radius: var(--radius); padding: 18px; width: min(92vw, 420px);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: #0007; }
dialog .actions { grid-template-columns: 1fr 1fr; }
dialog .actions .primary { grid-column: auto; }

.leaflet-tooltip { font-size: .8rem; }

.routes { margin-top: 12px; }
.route-list { list-style: none; margin: 0 0 6px; padding: 0; }
.route-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  min-height: 0; padding: 9px 10px; margin: 0 0 6px; text-align: left;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 5px solid var(--alt);
}
.route-row[aria-pressed=true] { border-color: var(--accent); border-left-color: var(--droog); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.route-row.off { opacity: .65; }
.route-row .name { font-weight: 600; }
.route-row .facts { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

#storage h3 { font-size: 1rem; margin: 14px 0 6px; }
table.storage { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.storage th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 4px 4px 0; }
table.storage td { padding: 5px 4px 5px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.clean { display: grid; gap: 8px; margin-top: 8px; }
.clean .row button { flex: 1; }
.clean select { width: auto; }

.timeline-card { margin-bottom: 12px; padding: 10px 14px; }
.timeline { display: flex; align-items: center; gap: 12px; }
.timeline input[type=range] { flex: 1; accent-color: var(--accent); height: 32px; }
.play { min-height: 40px; width: 44px; padding: 0; font-size: 1.05rem; flex: none; }
.time-label { margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.time-label b { font-size: 1.05rem; }
.small-check { margin: 0; font-size: .9rem; }
.small-check input { width: 18px; height: 18px; }
#radar-src { margin: 2px 0 0; }
.rider { background: #fff; border-radius: 50%; box-shadow: 0 1px 5px #0007; display: flex !important;
  align-items: center; justify-content: center; font-size: 18px; line-height: 1; }
.pause-pin { font-size: 16px; }

/* Rijrichting: pijltjes langs de route */
.dir-arrow svg { width: 16px; height: 16px; display: block; overflow: visible; }
.dir-arrow path { fill: #1b1f24; stroke: #ffffff; stroke-width: 1.6; stroke-linejoin: round; }
