/* Vendored — no external CDN. */
  @font-face {
    font-family: "InterVar";
    src: url("/vendor/inter-var.woff2") format("woff2");
    font-weight: 100 900; font-style: normal; font-display: swap;
  }

  /* tailwindcss.com-style neutral + blue system */
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --fg: #111827;
    --fg-dim: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-weak: #eff6ff;
    --ring: rgba(37, 99, 235, .35);
    --r: 10px;
    --r-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(17 24 39 / .06);
    --shadow-md: 0 6px 20px -6px rgb(17 24 39 / .18);
    --sheet-peek: 128px; /* visible height of the collapsed mobile bottom sheet */
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0b0f19;
      --surface: #111827;
      --surface-2: #1a2130;
      --fg: #f3f4f6;
      --fg-dim: #9aa4b2;
      --border: #2a3446;
      --accent: #60a5fa;
      --accent-weak: #172033;
      --ring: rgba(96, 165, 250, .4);
      --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .4);
      --shadow-md: 0 8px 24px -8px rgb(0 0 0 / .55);
    }
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    font-family: "InterVar", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px; line-height: 1.5; letter-spacing: -0.006em;
    color: var(--fg); background: var(--bg);
    display: flex; overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }
  button { font-family: inherit; }

  /* ---------- Sidebar ---------- */
  #side {
    width: 340px; flex: 0 0 340px; height: 100%;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; z-index: 10;
  }
  #sheet-handle { display: none; } /* mobile only */
  #side header {
    padding: 16px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 9px;
    font-weight: 600; font-size: 15px; letter-spacing: -0.02em;
  }
  #search-wrap { padding: 14px 18px; position: relative; }
  #search {
    width: 100%; padding: 9px 12px; font: inherit;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface); color: var(--fg);
    transition: box-shadow .15s, border-color .15s;
  }
  #search::placeholder { color: var(--fg-dim); }
  #search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
  #results {
    position: absolute; left: 18px; right: 18px; top: calc(100% - 4px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
    box-shadow: var(--shadow-md); overflow: hidden; z-index: 20;
  }
  #results button {
    display: block; width: 100%; text-align: left; padding: 9px 12px;
    border: 0; border-bottom: 1px solid var(--border);
    background: transparent; color: var(--fg); font: inherit; cursor: pointer;
  }
  #results button:last-child { border-bottom: 0; }
  #results button:hover { background: var(--accent-weak); }

  #detail { flex: 1; overflow-y: auto; padding: 6px 18px 20px; }
  .placeholder { color: var(--fg-dim); padding: 28px 4px; text-align: center; font-size: 13px; }
  .loc-name { font-weight: 650; font-size: 16px; letter-spacing: -0.02em; margin: 10px 0 2px; }
  .loc-sub { color: var(--fg-dim); font-size: 12px; margin-bottom: 14px; }

  /* current conditions */
  .now {
    display: flex; gap: 16px; align-items: center; padding: 16px;
    border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--shadow-sm); margin-bottom: 16px;
  }
  .now-sym { font-size: 42px; line-height: 1; }
  .now-temp { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
  .now-meta { font-size: 12px; color: var(--fg-dim); margin-top: 3px; }

  /* 7-day cards */
  .days { display: flex; flex-direction: column; gap: 10px; }
  .day {
    border: 1px solid var(--border); border-left: 3px solid var(--wx-accent, var(--border));
    border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm);
    transition: box-shadow .18s;
  }
  .day:hover { box-shadow: var(--shadow-md); }
  .day-head {
    display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center;
    gap: 12px; width: 100%; padding: 12px 14px; border: 0; background: transparent;
    color: var(--fg); font: inherit; cursor: pointer; text-align: left;
  }
  .day-sym { font-size: 22px; }
  .day-name { font-weight: 600; letter-spacing: -0.01em; }
  .day-rain { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
  .day-temps { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
  .day-temps b { font-weight: 650; }
  .day-temps .lo { color: var(--fg-dim); }
  .hours { padding: 2px 14px 12px; border-top: 1px solid var(--border); }

  table.fc { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  table.fc th {
    text-align: left; font-size: 10px; font-weight: 600; color: var(--fg-dim);
    text-transform: uppercase; letter-spacing: .05em; padding: 6px 4px;
  }
  table.fc th.num, table.fc td.num { text-align: right; }
  table.fc td { padding: 5px 4px; border-top: 1px solid var(--border); }
  table.fc .z { color: var(--fg-dim); }
  .rain-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-right: 4px; }
  .arrow { display: inline-block; }

  /* weather-class tints — soft wash over the surface, both themes */
  .wx-sunny    { --wx-accent: #f59e0b; background: linear-gradient(115deg, rgb(245 158 11 / .14), rgb(59 130 246 / .05)), var(--surface); }
  .wx-fair     { --wx-accent: #60a5fa; background: linear-gradient(115deg, rgb(96 165 250 / .13), rgb(255 255 255 / .02)), var(--surface); }
  .wx-cloudy   { --wx-accent: #94a3b8; background: linear-gradient(115deg, rgb(148 163 184 / .16), rgb(100 116 139 / .07)), var(--surface); }
  .wx-overcast { --wx-accent: #64748b; background: linear-gradient(115deg, rgb(100 116 139 / .22), rgb(71 85 105 / .12)), var(--surface); }
  .wx-showers  { --wx-accent: #3b82f6; background: linear-gradient(115deg, rgb(59 130 246 / .18), rgb(37 99 235 / .09)), var(--surface); }
  .wx-rain     { --wx-accent: #2563eb; background: linear-gradient(115deg, rgb(37 99 235 / .24), rgb(29 78 216 / .12)), var(--surface); }

  /* ---------- Map + overlays ---------- */
  #main { position: relative; flex: 1; height: 100%; }
  #map { position: absolute; inset: 0; }

  .overlay {
    position: absolute; background: var(--surface); color: var(--fg);
    border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md);
  }
  #bar {
    top: 14px; left: 14px; padding: 6px;
    display: inline-flex; align-items: center;
  }
  #layers { display: inline-flex; gap: 2px; padding: 0; background: transparent; border-radius: var(--r-sm); }
  #layers button {
    border: 0; background: transparent; color: var(--fg-dim);
    padding: 6px 11px; border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer;
    white-space: nowrap; transition: background .15s, color .15s;
  }
  #layers button:hover:not(:disabled):not([aria-pressed="true"]) { color: var(--fg); }
  #layers button[aria-pressed="true"] {
    background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); font-weight: 600;
  }
  #layers button:disabled { opacity: .38; cursor: not-allowed; }

  /* ---- bottom time bar: mini forecast graph + time slider ---- */
  #timebar {
    left: 50%; transform: translateX(-50%); bottom: 14px;
    width: min(680px, calc(100% - 108px));
    padding: 9px 12px 10px;
    display: flex; flex-direction: column; gap: 7px;
  }
  #timebar[hidden] { display: none; }
  #spark-wrap { display: flex; flex-direction: column; gap: 3px; }
  #spark-wrap[hidden] { display: none; }
  #spark-head {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px;
    font-size: 11px;
  }
  #spark-place { font-weight: 600; letter-spacing: -.01em; }
  #spark-range { color: var(--fg-dim); font-variant-numeric: tabular-nums; margin-right: auto; }
  #spark-legend { display: inline-flex; gap: 12px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
  #spark-plot { position: relative; }
  #spark { width: 100%; height: 72px; display: block; cursor: crosshair; touch-action: none; }
  #spark-tip {
    position: absolute; z-index: 5; pointer-events: none;
    transform: translate(-50%, -100%);
    background: var(--fg); color: var(--bg);
    border-radius: 7px; padding: 5px 8px; font-size: 11px; line-height: 1.35;
    white-space: nowrap; box-shadow: var(--shadow-md);
    font-variant-numeric: tabular-nums;
  }
  #spark-tip[hidden] { display: none; }
  #spark-tip b { font-weight: 650; }
  #spark-tip .st-time { display: block; opacity: .7; font-size: 10px; margin-bottom: 1px; }
  #timerow { display: flex; align-items: center; gap: 10px; }
  #timerow[hidden] { display: none; }
  #time { flex: 1; accent-color: var(--accent); }
  #time:disabled { opacity: .4; }
  #stamp { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg-dim); }
  #play {
    border: 1px solid var(--border); background: var(--surface); color: inherit;
    border-radius: var(--r-sm); width: 32px; height: 32px; cursor: pointer; flex: none;
    transition: background .15s;
  }
  #play:hover { background: var(--surface-2); }

  /* the centred time bar is offset by the sidebar, so it can reach the map's
     bottom corners — lift the corner UI above it when it is shown */
  #main.has-timebar .maplibregl-ctrl-bottom-left,
  #main.has-timebar .maplibregl-ctrl-bottom-right {
    bottom: calc(14px + var(--timebar-h, 120px) + 12px);
  }

  /* legend: bottom-right, stacked above the zoom control (and above the time
     bar when it is shown) */
  #legend { right: 14px; bottom: 88px; padding: 10px 13px; max-width: 250px; }
  #main.has-timebar #legend { bottom: calc(14px + var(--timebar-h, 120px) + 12px + 74px); }
  #legend .title { font-size: 12px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.01em; }
  #legend .bar { height: 12px; border-radius: 4px; }
  #legend .scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; margin-top: 4px; }

  .maplibregl-popup-content { color: #111827; border-radius: var(--r); box-shadow: var(--shadow-md); }
  .maplibregl-popup-close-button { color: #111827; }
  .maplibregl-ctrl-group { border-radius: var(--r-sm) !important; box-shadow: var(--shadow-md) !important; }



/* ---------- Sidebar footer: geolocation + language + legal ---------- */
#side-foot {
  border-top: 1px solid var(--border); padding: 10px 18px;
  display: flex; flex-direction: column; gap: 9px; font-size: 12px;
}
#foot-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#geo-toggle {
  align-self: flex-start; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--fg-dim); font: inherit;
  padding: 4px 9px; cursor: pointer;
}
#geo-toggle:hover { color: var(--fg); }
#geo-toggle.on { color: var(--accent); border-color: var(--accent); }
#lang { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
#lang button {
  border: 0; background: var(--surface); color: var(--fg-dim);
  padding: 3px 8px; font: inherit; font-weight: 600; cursor: pointer;
}
#lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }
#side-foot nav { display: flex; gap: 12px; }
#side-foot a { color: var(--fg-dim); text-decoration: none; }
#side-foot a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Geolocation consent prompt ---------- */
#geo-ask {
  position: absolute; left: 50%; top: 74px; transform: translateX(-50%);
  z-index: 6; align-items: center; gap: 10px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md);
  padding: 8px 10px 8px 12px; font-size: 13px;
}
#geo-ask:not([hidden]) { display: flex; }
#geo-ask[hidden] { display: none; }
#geo-ask-body { display: flex; align-items: center; gap: 8px; }
#geo-ask-icon { font-size: 15px; line-height: 1; }
#geo-ask-btns { display: flex; gap: 6px; }
#geo-ask button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--fg);
  border-radius: var(--r-sm); padding: 5px 12px; font: inherit; font-weight: 500; cursor: pointer;
}
#geo-ask button:hover { border-color: var(--fg-dim); }
#geo-ask #geo-yes { background: var(--accent); border-color: var(--accent); color: #fff; }

/* peek-info: on mobile the collapsed sheet header shows the picked place */
#peek-info { display: none; }

/* ---------- Static legal pages ---------- */
.legal {
  max-width: 720px; margin: 0 auto; padding: 40px 24px 64px;
  font-size: 15px; line-height: 1.65;
}
.legal a.back { color: var(--accent); text-decoration: none; font-size: 13px; }
.legal h1 { font-size: 26px; letter-spacing: -0.02em; margin: 18px 0 6px; }
.legal h2 { font-size: 17px; letter-spacing: -0.01em; margin: 28px 0 6px; }
.legal p, .legal ul { margin: 8px 0; }
.legal ul { padding-left: 20px; }
.legal .muted { color: var(--fg-dim); font-size: 13px; }
.legal .lang-switch { float: right; }
.legal .lang-switch a { color: var(--fg-dim); text-decoration: none; margin-left: 8px; }
.legal .lang-switch a[aria-current="true"] { color: var(--fg); font-weight: 600; }

/* ===== mobile: bottom-sheet layout (overrides everything above) ===== */
@media (max-width: 800px) {
    body { display: block; }

    /* the map fills the whole screen */
    #main { position: fixed; inset: 0; }
    #map { position: absolute; inset: 0; }

    /* layer chips: one row, scroll horizontally if they overflow.
       kept above the sheet so the active layer stays visible when it's open */
    #bar {
      top: 8px; left: 8px; right: 8px; padding: 5px; z-index: 21;
      display: flex; align-items: center;
    }
    #layers {
      flex: 1 1 auto; min-width: 0; overflow-x: auto;
      -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    #layers::-webkit-scrollbar { display: none; }

    /* bottom bar sits just above the collapsed sheet */
    #timebar {
      left: 8px; right: 8px; width: auto; transform: none;
      bottom: calc(var(--sheet-peek) + 12px);
    }
    #spark { height: 64px; }
    #stamp { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

    /* zoom buttons are redundant on touch and were crowding the legend /
       precipitation scale — drop them on mobile (pinch to zoom) */
    .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }

    #legend {
      right: 8px; top: auto; bottom: calc(var(--sheet-peek) + 12px);
      max-width: 220px;
    }
    /* The time bar is full-width on mobile. Lift the legend (bottom-right) and
       the attribution (bottom-left, collapsed to just its ⓘ here) so they sit
       just above it. --timebar-h is its measured height, from updateTimebar(). */
    .maplibregl-ctrl-bottom-left { bottom: calc(var(--sheet-peek) - 6px); }
    #main.has-timebar .maplibregl-ctrl-bottom-left,
    #main.has-timebar #legend {
      bottom: calc(var(--sheet-peek) + 12px + var(--timebar-h, 140px) + 10px);
    }

    /* geolocation prompt: a proper card near the top, clear of the sheet + zoom controls */
    #geo-ask {
      left: 8px; right: 8px; top: 56px; bottom: auto;
      transform: none; z-index: 22;
      flex-direction: column; align-items: stretch; gap: 11px;
      padding: 14px; border-radius: 14px;
      box-shadow: 0 14px 34px rgb(0 0 0 / .3);
    }
    #geo-ask-body { gap: 10px; font-size: 14px; }
    #geo-ask-icon { font-size: 20px; }
    #geo-ask-btns { gap: 8px; }
    #geo-ask-btns button { flex: 1; padding: 11px 12px; font-weight: 600; border-radius: 10px; }

    /* content becomes a bottom sheet with two snap positions */
    #side {
      position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
      width: auto; height: 88vh; max-height: 88vh;
      border: 0; border-top: 1px solid var(--border);
      border-radius: 18px 18px 0 0;
      box-shadow: 0 -10px 34px rgb(17 24 39 / .22);
      transform: translateY(calc(88vh - var(--sheet-peek)));
      transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    }
    #side.sheet-open { transform: translateY(0); }
    #sheet-handle {
      display: block; width: 100%; border: 0; background: transparent;
      padding: 9px 0 5px; cursor: pointer; flex: none;
    }
    #sheet-handle::before {
      content: ""; display: block; width: 40px; height: 4px; margin: 0 auto;
      border-radius: 999px; background: var(--border);
    }
    #side header {
      padding: 2px 18px 8px; border-bottom: 0;
      display: flex; align-items: baseline; gap: 8px; min-width: 0;
    }
    #search-wrap { padding: 4px 16px 10px; }
    #detail { border-top: 1px solid var(--border); }
    #side-foot { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); }

    /* collapsed peek: show the picked place in the header, and don't let a tap
       meant to open the sheet land in the search field */
    #side:not(.sheet-open) #peek-info:not([hidden]) {
      display: block; font-weight: 650;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    #side.has-sel:not(.sheet-open) #peek-title { display: none; }
    #side:not(.sheet-open) #search { pointer-events: none; }
    #side:not(.sheet-open) #search-wrap { cursor: pointer; }
  }
