:root {
  --blue: #0b63ce;
  --blue-2: #3d8bfd;
  --ink: #12233a;
  --muted: #5d6b7e;
  --card: rgba(255, 255, 255, 0.97);
  --line: #e3e8ef;
  --chip: #f3f6fa;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(10, 30, 60, 0.18);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --peek: 190px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; }
#map { position: fixed; inset: 0; background: #e4e6e8; }
body[data-style="donker"] #map, body[data-style="satelliet"] #map { background: #1b1f27; }
button { font-family: inherit; touch-action: manipulation; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; z-index: 1000;
  top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l));
  display: flex; gap: 10px; align-items: center;
}
.brand {
  background: var(--blue); color: #fff; font-weight: 700; padding: 0 14px; height: 46px;
  display: flex; align-items: center; gap: 6px;
  border-radius: var(--radius); box-shadow: var(--shadow); white-space: nowrap;
}
.search { position: relative; display: flex; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); height: 46px; }
.search input {
  border: 0; background: transparent; padding: 0 14px; font-size: 16px; /* 16px: geen auto-zoom op iOS */
  width: 280px; outline: none; color: var(--ink); min-width: 0;
}
.search input::-webkit-search-cancel-button { display: none; }
.icon-btn {
  border: 0; background: transparent; color: var(--blue); cursor: pointer;
  width: 46px; height: 46px; display: grid; place-items: center; flex: none;
}
.search .icon-btn { border-left: 1px solid var(--line); }
.icon-btn.busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.layers-btn { display: none; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px 0; list-style: none;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); max-height: 50vh; overflow: auto;
}
.results li { padding: 12px 14px; cursor: pointer; font-size: 15px; line-height: 1.3; }
.results li:hover, .results li.active { background: #eef4fd; }

/* ---------- kaartstijl ---------- */
.style-switch {
  position: fixed; z-index: 1000; left: calc(12px + var(--safe-l)); bottom: 96px;
  display: flex; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; gap: 2px;
}
.style-switch button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: 13px; color: var(--muted);
}
.style-switch button:hover { color: var(--ink); }
.style-switch button[aria-checked="true"] { background: var(--blue); color: #fff; }

/* ---------- panel (desktop) ---------- */
.panel {
  position: fixed; z-index: 1000;
  top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r)); bottom: 12px; width: 360px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto; padding: 18px 18px 12px;
}
.panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.sheet-head section { padding-top: 0; }
.sheet-handle { display: none; }

.place { font-weight: 700; font-size: 18px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-row { display: flex; align-items: center; gap: 12px; }
.now-row img { width: 56px; height: 56px; }
.temp { font-size: 48px; font-weight: 300; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.now-meta { font-size: 15px; line-height: 1.35; min-width: 0; }
.rain-headline { margin-top: 12px; font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.rain-headline::before { content: "💧"; }
.rain-headline.dry::before { content: "☀️"; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--chip); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.stat b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { color: var(--muted); font-size: 11px; }

.rain-chart {
  height: 110px; display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--line); position: relative;
  background: repeating-linear-gradient(to top, transparent 0 36px, #eef1f5 36px 37px);
}
.rain-chart .bar { flex: 1; min-width: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(to top, var(--blue), var(--blue-2)); transition: height .4s ease; }
.rain-chart .bar.dry { background: #e6ebf1; height: 2px !important; }
.rain-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.rain-chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }

.day-list { display: grid; gap: 4px; }
.day { display: grid; grid-template-columns: 54px 36px 1fr auto; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.day img { width: 32px; height: 32px; }
.day .d { font-weight: 600; text-transform: capitalize; }
.day .t { font-variant-numeric: tabular-nums; white-space: nowrap; }
.day .t .min { color: var(--muted); margin-left: 6px; }
.day .r { font-size: 12px; color: var(--blue); }
.report summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.report p { font-size: 14px; line-height: 1.5; white-space: pre-line; }
.credits { font-size: 11px; color: var(--muted); padding-top: 10px; }
.credits a { color: inherit; }

/* ---------- timeline ---------- */
.timeline {
  position: fixed; z-index: 1000; left: calc(12px + var(--safe-l)); right: 384px; bottom: 12px;
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px;
}
.play { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; font-size: 17px; cursor: pointer; flex: none; }
.play:active { transform: scale(.94); }
.tl-main { flex: 1; min-width: 0; }
.tl-label { font-weight: 700; font-size: 15px; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: #eef1f5; color: var(--muted); vertical-align: 2px; }
.badge.future { background: #fff1d6; color: #9a6200; }
#slider { width: 100%; accent-color: var(--blue); height: 28px; margin: 0; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); flex: none; }
.legend i { display: block; width: 90px; height: 10px; border-radius: 5px; background: linear-gradient(to right, #9be1ff, #3fa9f5, #1462d6, #0a2f9e, #ffe600, #ff9b00, #ff2a00, #c3007a); }

/* ---------- kaart-onderdelen ---------- */
.radar-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
/* Leaflet 1.9 zet 'plus-lighter' op tegels; met de 1px-overlap van de
   ondergrond geeft dat lichte lijnen. Gewoon normaal mengen. */
.leaflet-container img.leaflet-tile { mix-blend-mode: normal !important; }
.leaflet-bottom.leaflet-left { bottom: 140px; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a { width: 40px !important; height: 40px !important; line-height: 40px !important; }
.leaflet-control-attribution { font-size: 10px; }
.loc-marker {
  width: 18px; height: 18px; border-radius: 50%; background: var(--blue);
  border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(11,99,206,.35), 0 2px 6px rgba(0,0,0,.3);
}
.toast {
  position: fixed; z-index: 2000; left: 50%; top: calc(76px + var(--safe-t)); transform: translateX(-50%);
  background: rgba(18, 35, 58, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}

/* ---------- mobiel ---------- */
@media (max-width: 760px) {
  .brand { width: 46px; justify-content: center; padding: 0; font-size: 20px; }
  .brand span { display: none; }
  .topbar { right: calc(12px + var(--safe-r)); gap: 8px; }
  .search { flex: 1; min-width: 0; }
  .search input { width: 100%; }
  .layers-btn { display: grid; }
  .leaflet-control-zoom { display: none; }

  .style-switch {
    left: auto; right: calc(12px + var(--safe-r)); bottom: auto; top: calc(64px + var(--safe-t));
    flex-direction: column; padding: 6px; display: none;
  }
  body.layers-open .style-switch { display: flex; }
  .style-switch button { padding: 12px 18px; font-size: 15px; text-align: left; }

  .timeline {
    left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r));
    bottom: auto; top: calc(66px + var(--safe-t)); padding: 6px 12px; gap: 10px;
  }
  body.layers-open .timeline { visibility: hidden; }
  .legend { display: none; }
  .play { width: 42px; height: 42px; }
  .tl-label { font-size: 14px; }

  /* versleepbaar bottom sheet */
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: calc(100dvh - 140px - var(--safe-t)); max-height: 760px;
    border-radius: 20px 20px 0 0; padding: 0;
    overflow: hidden; display: flex; flex-direction: column;
    transform: translateY(var(--sheet-y, calc(100% - var(--peek))));
    transition: transform .32s cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
    box-shadow: 0 -4px 24px rgba(10, 30, 60, .18);
  }
  .panel.dragging { transition: none; }
  .sheet-head { padding: 22px 18px 0; touch-action: none; cursor: grab; flex: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .sheet-head section { border-bottom: 0; padding-bottom: 14px; }
  .sheet-handle {
    display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 120px; height: 24px; border: 0; background: transparent; cursor: pointer; padding: 0;
  }
  .sheet-handle::after {
    content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 5px; border-radius: 3px; background: #c7cfda;
  }
  .sheet-body {
    flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 0 18px calc(16px + var(--safe-b)); border-top: 1px solid var(--line);
  }
  .temp { font-size: 42px; }
  .place { font-size: 17px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .leaflet-bottom.leaflet-right { bottom: calc(var(--peek) - 4px); }
  .leaflet-control-attribution { font-size: 9px; background: rgba(255,255,255,.7) !important; }
}

@media (max-width: 760px) and (max-height: 600px) {
  .panel { height: calc(100dvh - 120px); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .rain-chart .bar { transition: none !important; }
}
