/* ---------- thema-tokens ---------- */
:root {
  --bg: #eef0f6;
  --appbar: #3d6be0;
  --appbar-text: #ffffff;
  --round-bg: rgba(255, 255, 255, .16);
  --round-border: rgba(255, 255, 255, .45);
  --pill: #dfe6fb;
  --pill-text: #12151c;
  --seg-bg: #dde3f3;
  --seg-text: #3d6be0;
  --seg-on: #3d6be0;
  --seg-on-text: #ffffff;
  --text: #12151c;
  --muted: #6b7280;
  --line: #8b909b;
  --grid: #d5d9e2;
  --area: #2b4ea3;
  --cursor: #d9483f;
  --now: #c2c7d1;
  --clock-face: #dfe6fb;
  --clock-hand: #3d6be0;
  --drop: #b4b8c1;
  --drop-wet: #3d6be0;
  --temp: #f2a33a;
  --wind: #e0443d;
  --chip: #eef0f6;
  --sheet: #ffffff;
  --beer: #f2a900;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --appbar: #141414; --appbar-text: #fff;
    --round-bg: #2c2c2c; --round-border: #3a3a3a; --pill: #2c2c2c; --pill-text: #fff;
    --seg-bg: #2c2c2c; --seg-text: #fff; --seg-on: #2650b8; --seg-on-text: #fff;
    --text: #f2f2f2; --muted: #9b9b9b; --line: #6a6a6a; --grid: #2d2d2d; --area: #2450b4;
    --cursor: #e0453c; --now: #8a8a8a; --clock-face: #ffffff; --clock-hand: #141414;
    --drop: #8f8f8f; --drop-wet: #6f9cff; --chip: #2a2a2a; --sheet: #1f1f1f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --appbar: #141414; --appbar-text: #fff;
  --round-bg: #2c2c2c; --round-border: #3a3a3a; --pill: #2c2c2c; --pill-text: #fff;
  --seg-bg: #2c2c2c; --seg-text: #fff; --seg-on: #2650b8; --seg-on-text: #fff;
  --text: #f2f2f2; --muted: #9b9b9b; --line: #6a6a6a; --grid: #2d2d2d; --area: #2450b4;
  --cursor: #e0453c; --now: #8a8a8a; --clock-face: #ffffff; --clock-hand: #141414;
  --drop: #8f8f8f; --drop-wet: #6f9cff; --chip: #2a2a2a; --sheet: #1f1f1f;
  color-scheme: dark;
}

/* ---------- basis ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

.app {
  max-width: 560px; margin: 0 auto; height: 100dvh; min-height: 560px;
  display: flex; flex-direction: column; background: var(--bg);
}
@media (min-width: 600px) { .app { box-shadow: 0 0 0 1px var(--grid); } }

/* ---------- app bar ---------- */
.appbar {
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
  background: var(--appbar); color: var(--appbar-text);
  padding: calc(env(safe-area-inset-top) + 10px) 14px 12px;
  border-bottom: 1px solid rgba(128, 128, 128, .18);
}
.round {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--round-bg); border: 1px solid var(--round-border); color: var(--appbar-text);
}
.round svg { width: 24px; height: 24px; }
.brand {
  justify-self: center; display: flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0; color: var(--appbar-text);
  font-size: 24px; font-weight: 600; letter-spacing: -.01em;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.brand svg { width: 40px; height: 40px; }
.brand .drops { fill: var(--beer); transition: fill .2s; }
body.camo .brand .drops { fill: #9fd0ff; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; padding: 12px 12px 0; }
.locpill {
  flex: 1; min-width: 0; height: 46px; border: 0; border-radius: 12px;
  background: var(--pill); color: var(--pill-text);
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 40px; position: relative;
  font-size: 19px;
}
.locpill .nav { width: 20px; height: 20px; flex: none; }
.locpill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.locpill .chev { width: 24px; height: 24px; position: absolute; right: 12px; }

.seg { display: inline-flex; background: var(--seg-bg); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; border-radius: 999px; padding: 6px 12px;
  font-weight: 500; color: var(--seg-text); white-space: nowrap;
}
.seg button.on { background: var(--seg-on); color: var(--seg-on-text); }
.seg.range button { min-width: 50px; font-size: 17px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; padding: 8px 6px; font-size: 14px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); padding: 16px 6px 4px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.stat svg { width: 28px; height: 28px; }
.stat b { font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ic-drop path { fill: var(--drop); }
.ic-drop .slash { stroke: var(--drop); }
body.wet-at-cursor .ic-drop path { fill: var(--drop-wet); }
body.wet-at-cursor .ic-drop .slash { display: none; }
.ic-temp path:first-child { fill: var(--temp); }
.ic-wind { fill: var(--wind); transition: transform .3s; }

.headline { text-align: center; margin: 10px 16px 0; font-size: 14px; color: var(--muted); min-height: 20px; }
.headline strong { color: var(--text); font-weight: 600; }

/* ---------- views ---------- */
.views { flex: 1; display: flex; min-height: 0; }
.view { display: none; flex: 1; flex-direction: column; min-width: 0; }
.view.on { display: flex; }
#chart { flex: 1; width: 100%; min-height: 220px; display: block; touch-action: none; cursor: ew-resize; }
#miniChart { width: 100%; height: 130px; display: block; touch-action: none; cursor: ew-resize; flex: none; }
.map-wrap { position: relative; flex: 1; min-height: 220px; margin-top: 12px; }
#map { position: absolute; inset: 0; background: #20262e; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 9px; background: rgba(0, 0, 0, .35) !important; color: #ddd !important; }
.leaflet-control-attribution a { color: #fff !important; }
.rain-canvas { position: absolute; top: 0; left: 0; transition: opacity .15s; image-rendering: pixelated; }
.pin span {
  position: absolute; left: 3px; top: 0; width: 30px; height: 30px; transform: rotate(-45deg);
  background: #2f6bf0; border-radius: 50% 50% 50% 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.pin span::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }

/* weer-lijst */
.hourly { list-style: none; margin: 12px 0 0; padding: 0 12px; overflow: auto; flex: 1; min-height: 0; }
.hourly li {
  display: grid; grid-template-columns: 52px 32px 1fr 56px 68px; align-items: center; gap: 8px;
  padding: 10px 6px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums;
}
.hourly .h { font-weight: 600; }
.hourly svg { width: 28px; height: 28px; }
.hourly .mm { color: var(--muted); font-size: 13px; }
.hourly .t { text-align: right; font-weight: 600; font-size: 17px; }
.hourly .w { display: flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--muted); font-size: 13px; }
.hourly .w svg { width: 14px; height: 14px; fill: var(--wind); }

/* ---------- tab bar ---------- */
.tabbar { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.seg.tabs { flex: 1; height: 50px; padding: 4px; }
.seg.tabs button { flex: 1; font-size: 17px; }
.refresh { width: 46px; height: 46px; border: 0; background: none; color: var(--seg-text); display: grid; place-items: center; }
.refresh svg { width: 32px; height: 32px; }
.refresh.spin svg { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }
.foot { margin: 0; padding: 4px 16px calc(10px + env(safe-area-inset-bottom)); font-size: 10px; color: var(--muted); text-align: center; }

/* ---------- sheets ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: min(480px, 100vw); max-width: 100vw; max-height: 100dvh; margin: auto auto 0;
}
@media (min-width: 600px) { dialog { margin: auto; } }
dialog::backdrop { background: rgba(5, 10, 20, .5); backdrop-filter: blur(2px); }
.sheet {
  background: var(--sheet); border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); max-height: 92dvh; overflow: auto;
}
@media (min-width: 600px) { .sheet { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.x { border: 0; background: var(--chip); border-radius: 50%; width: 34px; height: 34px; }
.hint, .muted { color: var(--muted); font-size: 13px; margin: 6px 0 4px; }
.block { padding: 14px 0; border-bottom: 1px solid var(--grid); display: grid; gap: 10px; }
.block:last-child { border-bottom: 0; }
.block[hidden] { display: none; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 14px; }
.steps .inl { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: var(--seg-on); }
.bmc {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; border-radius: 12px;
  background: #ffdd00; color: #1a1a1a; font-weight: 700; text-decoration: none;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row.sub { font-size: 12px; color: var(--muted); margin-top: -4px; }
.lbl { font-weight: 600; font-size: 14px; }
.big { font-size: 26px; font-weight: 750; color: var(--seg-on); font-variant-numeric: tabular-nums; }
#hours { width: 100%; accent-color: var(--seg-on); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button, .btn {
  border: 1px solid var(--grid); background: var(--chip); border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.btn.small { padding: 6px 14px; }
.btn.primary { background: var(--seg-on); border-color: var(--seg-on); color: #fff; }
input[type=time], input[type=search] {
  font: inherit; color: var(--text); background: var(--chip); border: 1px solid var(--grid); border-radius: 10px; padding: 8px 10px;
}
.inline { display: flex; gap: 8px; margin-top: 10px; }
.inline input { flex: 1; min-width: 0; }
.row-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px;
  border: 0; background: var(--chip); border-radius: 12px; padding: 12px 14px; font-weight: 600; text-align: left;
}
.row-btn svg { width: 18px; height: 18px; color: var(--seg-on); }
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results button { width: 100%; text-align: left; border: 0; background: none; padding: 11px 4px; border-bottom: 1px solid var(--grid); }
.results small { color: var(--muted); display: block; font-size: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 42px; height: 26px; border-radius: 13px; background: var(--grid); position: relative; flex: none; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--seg-on); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--seg-on); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; }
.actions .btn { flex: 1 1 auto; padding: 10px 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.file-warn {
  margin: 12px 16px 0; padding: 12px 14px; border-radius: 12px;
  background: #fff4d6; color: #5c4300; font-size: 14px; line-height: 1.5;
}
.file-warn[hidden] { display: none; }
.file-warn code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
.map-error { display: grid; place-items: center; height: 100%; margin: 0; color: #bbb; font-size: 14px; }
