/* ============================================================
   BeWeather — Liquid Glass, Dark
   Design language follows Apple HIG: Materials, Dark Mode,
   Color, Layout, Motion, Charting.
   ============================================================ */

:root {
  /* Brand */
  --brand: #6c63ff;
  --brand-2: #8a82ff;
  --brand-ink: #c9c5ff;

  /* Dark Mode base — elevated surfaces over true-dark */
  --bg-0: #07070d;
  --bg-1: #0c0c16;

  /* Materials (HIG): translucent vibrancy layers */
  --mat-ultrathin: rgba(255, 255, 255, 0.04);
  --mat-thin:      rgba(255, 255, 255, 0.06);
  --mat-regular:   rgba(255, 255, 255, 0.08);
  --mat-thick:     rgba(20, 20, 34, 0.55);
  --mat-border:    rgba(255, 255, 255, 0.14);
  --mat-border-hi: rgba(255, 255, 255, 0.28);
  --mat-shadow:    0 12px 40px rgba(0, 0, 0, 0.45);

  /* Label colors (HIG vibrancy hierarchy) */
  --label:        rgba(255, 255, 255, 0.96);
  --label-2:      rgba(235, 235, 255, 0.66);
  --label-3:      rgba(235, 235, 255, 0.42);
  --label-4:      rgba(235, 235, 255, 0.26);

  /* Semantic */
  --good: #5dd1a0;
  --warn: #ffcf5c;
  --bad:  #ff7a7a;
  --info: #66c6ff;

  /* Geometry */
  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;
  --gap: 16px;
  --maxw: 1080px;

  --blur: 28px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute wins over component display rules
   (a class selector like `.state{display:flex}` otherwise overrides UA `[hidden]`). */
[hidden] { display: none !important; }

html, body { height: 100%; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, Roboto, Helvetica, Arial, sans-serif;
  color: var(--label);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv01", "tnum";
  overflow-x: hidden;
  min-height: 100svh;
  /* iOS / WebKit polish */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}

/* Let real content stay selectable; keep chrome non-selectable & tidy. */
button, .chip, .segmented, .topbar, .locations, .mapcard__bar {
  -webkit-user-select: none;
  user-select: none;
}
.place__text, .hero__place, .alert__text, .sheet__about { -webkit-user-select: text; user-select: text; }

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------
   Dynamic sky backdrop
   ---------------------------------------------------------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-0);
}
.sky__gradient {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(120% 80% at 50% -10%, #1a1640 0%, transparent 60%),
    linear-gradient(180deg, #0d0b1f 0%, #07070d 70%);
  transition: background 1.4s var(--ease-soft);
  will-change: background;
}
.sky__glow {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  transition: background 1.4s var(--ease-soft), opacity 1.4s var(--ease-soft);
  will-change: transform;
}
.sky__glow--1 {
  top: -20vmax; left: -10vmax;
  background: radial-gradient(circle, rgba(108, 99, 255, 0.55), transparent 65%);
  animation: drift1 26s var(--ease-soft) infinite alternate;
}
.sky__glow--2 {
  bottom: -25vmax; right: -15vmax;
  background: radial-gradient(circle, rgba(120, 90, 200, 0.4), transparent 65%);
  animation: drift2 32s var(--ease-soft) infinite alternate;
}
@keyframes drift1 { to { transform: translate3d(8vmax, 6vmax, 0) scale(1.1); } }
@keyframes drift2 { to { transform: translate3d(-7vmax, -5vmax, 0) scale(1.15); } }

.sky__noise {
  position: absolute; inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}
.sky__precip { position: absolute; inset: 0; pointer-events: none; }

/* Precipitation particles (rain/snow) */
.drop {
  position: absolute;
  top: -10%;
  width: 1.5px;
  height: 64px;
  background: linear-gradient(transparent, rgba(170, 200, 255, 0.55));
  border-radius: 2px;
  animation: fall linear infinite;
}
.flake {
  position: absolute;
  top: -5%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  filter: blur(0.3px);
  animation: snow linear infinite;
}
@keyframes fall { to { transform: translateY(115vh); } }
@keyframes snow {
  to { transform: translateY(110vh) translateX(40px); }
}

/* ----------------------------------------------------------
   Glass material primitive
   ---------------------------------------------------------- */
.glass {
  position: relative;
  background: var(--mat-thin);
  border: 1px solid var(--mat-border);
  border-radius: var(--r-md);
  box-shadow: var(--mat-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
}
/* Specular top-edge highlight — the "liquid glass" sheen */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.4),
    rgba(255, 255, 255, 0.04) 30%,
    transparent 55%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ----------------------------------------------------------
   Top bar
   ---------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) clamp(14px, 4vw, 28px) 12px;
  max-width: var(--maxw);
  margin: 0 auto;
}
.topbar__brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.topbar__logo { border-radius: 8px; box-shadow: 0 4px 14px rgba(108, 99, 255, 0.4); }
.topbar__name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.topbar__name-accent { color: var(--brand-2); }
@media (max-width: 560px) { .topbar__name { display: none; } }

.searchwrap { position: relative; flex: 1; min-width: 0; }
.searchfield {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  height: 46px;
  border-radius: var(--r-sm);
}
.searchfield__icon { width: 18px; height: 18px; fill: var(--label-3); flex-shrink: 0; }
.searchfield__input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--label);
  font-size: 16px;
  font-family: inherit;
}
.searchfield__input::placeholder { color: var(--label-3); }
.searchfield__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchfield__locate {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: none; border-radius: 10px;
  background: var(--mat-thin);
  color: var(--brand-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.searchfield__locate svg { width: 19px; height: 19px; }
.searchfield__locate:hover { background: var(--mat-regular); }
.searchfield__locate:active { transform: scale(0.92); }
.searchfield__locate.is-busy { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.searchresults {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  z-index: 50;
  margin: 0; padding: 6px;
  list-style: none;
  border-radius: var(--r-sm);
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.searchresults li {
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  transition: background 0.12s;
}
.searchresults li:hover,
.searchresults li[aria-selected="true"] { background: var(--mat-regular); }
.searchresults .res__name { font-weight: 600; }
.searchresults .res__meta { color: var(--label-3); font-size: 13px; }
.searchresults .res__empty { color: var(--label-3); cursor: default; }

.iconbtn {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: var(--r-sm);
  color: var(--label-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.15s;
}
.iconbtn:hover { color: var(--label); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn--plain { background: none; border: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.iconbtn--plain::before { display: none; }

/* ----------------------------------------------------------
   Saved-location chips
   ---------------------------------------------------------- */
.locations {
  display: flex;
  gap: 8px;
  padding: 4px clamp(14px, 4vw, 28px) 0;
  max-width: var(--maxw);
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.locations::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--mat-thin);
  border: 1px solid var(--mat-border);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--label-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { color: var(--label); background: var(--mat-regular); }
.chip.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), #5a52e0);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}
.chip__temp { font-variant-numeric: tabular-nums; opacity: 0.85; font-size: 13px; }
.chip__x {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: inherit; cursor: pointer; font-size: 11px; line-height: 1;
  margin-left: 2px;
}
.chip__x:hover { background: rgba(255,255,255,0.3); }
.chip--add { color: var(--brand-2); font-weight: 600; }

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */
.content {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px max(clamp(14px, 4vw, 28px), env(safe-area-inset-right))
           40px max(clamp(14px, 4vw, 28px), env(safe-area-inset-left));
}
.report { animation: rise 0.5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gap);
}
.card { padding: 18px; border-radius: var(--r-md); }
.card--lg { padding: 22px; }

/* Staggered card entrance — only when the report first appears (.is-in),
   never on the silent in-place refreshes, and disabled under reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
  .report.is-in > .grid > .card {
    animation: cardIn 0.5s var(--ease, cubic-bezier(.22,.61,.36,1)) both;
  }
  .report.is-in > .grid > .card:nth-child(1)  { animation-delay: 0ms; }
  .report.is-in > .grid > .card:nth-child(2)  { animation-delay: 45ms; }
  .report.is-in > .grid > .card:nth-child(3)  { animation-delay: 90ms; }
  .report.is-in > .grid > .card:nth-child(4)  { animation-delay: 135ms; }
  .report.is-in > .grid > .card:nth-child(5)  { animation-delay: 180ms; }
  .report.is-in > .grid > .card:nth-child(6)  { animation-delay: 215ms; }
  .report.is-in > .grid > .card:nth-child(7)  { animation-delay: 250ms; }
  .report.is-in > .grid > .card:nth-child(8)  { animation-delay: 285ms; }
  .report.is-in > .grid > .card:nth-child(n+9){ animation-delay: 320ms; }
  @keyframes cardIn {
    from { opacity: 0; transform: translateY(12px) scale(0.99); }
    to   { opacity: 1; transform: none; }
  }
}

/* Column spans */
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }
@media (max-width: 880px) {
  .col-8, .col-6 { grid-column: span 12; }
  .col-4 { grid-column: span 6; }
}
@media (max-width: 560px) {
  .col-4, .col-3 { grid-column: span 6; }
}

.card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--label-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card__head svg { width: 15px; height: 15px; fill: currentColor; }

/* ----------------------------------------------------------
   Hero — current conditions
   ---------------------------------------------------------- */
.hero { position: relative; overflow: hidden; }
.hero__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.hero__place { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.hero__region { color: var(--label-2); font-size: 14px; margin-top: 2px; }
.hero__save {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--mat-thin); border: 1px solid var(--mat-border);
  color: var(--label-2); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .2s, color .2s;
}
.hero__save:hover { background: var(--mat-regular); color: var(--label); }
.hero__save svg { width: 15px; height: 15px; }
.hero__save.is-saved { color: var(--brand-2); }

.hero__main {
  display: flex;
  align-items: center;
  gap: clamp(8px, 4vw, 28px);
  margin: 10px 0 6px;
  flex-wrap: wrap;
}
.hero__temp {
  font-size: clamp(72px, 18vw, 128px);
  font-weight: 250;
  line-height: 0.92;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.hero__temp sup { font-size: 0.3em; font-weight: 300; top: -1.4em; }
.hero__icon { font-size: clamp(56px, 12vw, 96px); filter: drop-shadow(0 8px 20px rgba(0,0,0,0.4)); }
.hero__summary { display: flex; flex-direction: column; gap: 4px; }
.hero__cond { font-size: 20px; font-weight: 600; }
.hero__feels { color: var(--label-2); font-size: 15px; }
.hero__hilo { display: flex; gap: 14px; color: var(--label-2); font-size: 15px; margin-top: 8px; }
.hero__hilo b { color: var(--label); font-weight: 600; }

/* ----------------------------------------------------------
   Hourly strip
   ---------------------------------------------------------- */
.hourly {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--mat-border) transparent;
}
.hourly::-webkit-scrollbar { height: 6px; }
.hourly::-webkit-scrollbar-thumb { background: var(--mat-border); border-radius: 3px; }
.hour {
  flex: 0 0 auto;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  border-radius: var(--r-sm);
  scroll-snap-align: start;
  transition: background 0.2s;
}
.hour:hover { background: var(--mat-thin); }
.hour--now { background: var(--mat-regular); }
.hour__time { font-size: 13px; color: var(--label-2); font-weight: 500; }
.hour--now .hour__time { color: var(--brand-2); font-weight: 700; }
.hour__icon { font-size: 24px; }
.hour__temp { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hour__pop {
  font-size: 11px; color: var(--info);
  display: flex; align-items: center; gap: 2px; min-height: 14px;
}
.hour__pop svg { width: 9px; height: 9px; fill: currentColor; }

/* ----------------------------------------------------------
   Rain nowcast (next 2 hours)
   ---------------------------------------------------------- */
.nowcast__summary {
  font-size: 17px; font-weight: 600; margin: 2px 0 14px;
  letter-spacing: -0.01em;
}
.nowcast--dry  .nowcast__summary { color: var(--good, #5dd1a0); }
.nowcast--wet  .nowcast__summary { color: var(--info, #66c6ff); }
.nowcast--soon .nowcast__summary { color: #8fb8ff; }
.nowcast__chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 92px; padding-top: 4px;
}
.nowcast__col {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end; gap: 7px;
}
.nowcast__bar {
  width: 100%; max-width: 26px; border-radius: 5px 5px 3px 3px;
  background: var(--mat-border-hi);
  transition: height 0.5s var(--ease, ease);
}
.nowcast__bar.is-wet {
  background: linear-gradient(180deg, #7cd0ff, #4b8cff);
  box-shadow: 0 2px 10px rgba(80, 150, 255, 0.35);
}
.nowcast__t {
  font-size: 11px; color: var(--label-3);
  font-variant-numeric: tabular-nums; white-space: nowrap; min-height: 13px;
}

/* ----------------------------------------------------------
   Daily forecast
   ---------------------------------------------------------- */
.daily { display: flex; flex-direction: column; }
.day {
  display: grid;
  grid-template-columns: 92px 34px 1fr 96px;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-top: 1px solid var(--mat-border);
}
.day:first-child { border-top: none; }
.day__name { font-weight: 600; font-size: 15px; }
.day__sub { color: var(--label-3); font-size: 12px; }
.day__icon { font-size: 22px; text-align: center; }
.day__pop { font-size: 11px; color: var(--info); text-align: center; }
.day__range { display: flex; align-items: center; gap: 10px; }
.day__lo { color: var(--label-3); font-size: 14px; width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.day__hi { color: var(--label); font-size: 14px; font-weight: 600; width: 30px; font-variant-numeric: tabular-nums; }
.day__bar {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--mat-regular);
  overflow: hidden;
}
.day__bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #5bc8ff, #6c63ff 50%, #ff9d5c);
}

/* ----------------------------------------------------------
   Metric tiles
   ---------------------------------------------------------- */
.metric { display: flex; flex-direction: column; gap: 8px; min-height: 128px; }
.metric__val { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric__val small { font-size: 15px; color: var(--label-2); font-weight: 500; }
.metric__note { color: var(--label-2); font-size: 13px; margin-top: auto; }

/* Wind compass */
.compass {
  position: relative;
  width: 84px; height: 84px;
  margin: 4px auto 0;
  border-radius: 50%;
  border: 1px solid var(--mat-border);
}
.compass__tick { position: absolute; font-size: 9px; color: var(--label-3); }
.compass__n { top: 3px; left: 50%; transform: translateX(-50%); }
.compass__s { bottom: 3px; left: 50%; transform: translateX(-50%); }
.compass__e { right: 5px; top: 50%; transform: translateY(-50%); }
.compass__w { left: 5px; top: 50%; transform: translateY(-50%); }
.compass__arrow {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  transition: transform 0.8s var(--ease);
}
.compass__arrow svg { width: 26px; height: 46px; }

/* UV / AQI gauges */
.gauge { display: flex; align-items: center; gap: 14px; }
.gauge__ring { position: relative; width: 84px; height: 84px; flex-shrink: 0; }
.gauge__ring svg { transform: rotate(-90deg); }
.gauge__center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
}
.gauge__info { display: flex; flex-direction: column; gap: 3px; }
.gauge__level { font-size: 16px; font-weight: 600; }
.gauge__desc { color: var(--label-2); font-size: 12.5px; line-height: 1.35; }

/* Sun arc */
.sun {
  position: relative;
  height: 96px;
  margin-top: 6px;
}
.sun__path { width: 100%; height: 100%; overflow: visible; }
.sun__times {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 13px;
}
.sun__times .t { display: flex; flex-direction: column; gap: 2px; }
.sun__times .t span { color: var(--label-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.sun__times .t b { font-weight: 600; }

/* ----------------------------------------------------------
   Chart card
   ---------------------------------------------------------- */
.chart { width: 100%; overflow: visible; }
.chart__tabs { display: flex; gap: 6px; margin-left: auto; }
.chart__tab {
  padding: 5px 11px;
  border: none; border-radius: 999px;
  background: transparent; color: var(--label-3);
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}
.chart__tab.is-active { background: var(--mat-regular); color: var(--label); }
.chart-line { fill: none; stroke: var(--brand-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#chartFill); opacity: 0.9; }
.chart-grid { stroke: var(--mat-border); stroke-width: 1; }
.chart-bar { fill: var(--info); rx: 2; }
.chart-label { fill: var(--label-3); font-size: 10px; }
.chart-val { fill: var(--label-2); font-size: 10px; font-weight: 600; }
.chart-dot { fill: var(--brand-2); }

/* ----------------------------------------------------------
   Buttons / states
   ---------------------------------------------------------- */
.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--mat-border);
  background: var(--mat-thin);
  color: var(--label);
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), #5a52e0);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 80px 20px;
  text-align: center;
  color: var(--label-2);
}
.state__icon { width: 48px; height: 48px; color: var(--warn); }
.state__title { font-size: 19px; font-weight: 700; color: var(--label); margin: 0; }
.state__msg { margin: 0; max-width: 40ch; }
.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--mat-regular);
  border-top-color: var(--brand-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------
   Footer
   ---------------------------------------------------------- */
.appfoot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px clamp(14px, 4vw, 28px) calc(24px + var(--safe-b));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--label-3);
  font-size: 12.5px;
}
.appfoot__updated {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  padding: 2px 6px;
  margin: -2px -6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s var(--ease-soft), background 0.2s var(--ease-soft);
}
.appfoot__updated:hover { color: var(--label-2); background: rgba(255, 255, 255, 0.06); }
.appfoot__updated:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
/* Subtle "refreshing" cue: dim the report and spin a hint while aria-busy. */
#report[aria-busy="true"] { opacity: 0.72; transition: opacity 0.2s var(--ease-soft); }

/* ----------------------------------------------------------
   Settings sheet
   ---------------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade 0.3s var(--ease-soft);
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 0;
  width: min(480px, 100%);
  transform: translateX(-50%);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 22px calc(28px + var(--safe-b));
  animation: sheetup 0.4s var(--ease);
}
@keyframes sheetup { from { transform: translate(-50%, 100%); } }
.sheet__grabber {
  width: 38px; height: 5px;
  border-radius: 3px;
  background: var(--mat-border-hi);
  margin: 4px auto 12px;
}
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.sheet__title { font-size: 20px; font-weight: 700; margin: 0; }
.sheet__body { display: flex; flex-direction: column; }
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--mat-border);
}
.setting:first-child { border-top: none; }
.setting__label { font-size: 15px; font-weight: 500; display: block; }
.setting__hint { font-size: 12.5px; color: var(--label-3); display: block; margin-top: 2px; }

.segmented {
  display: inline-flex;
  background: var(--mat-thin);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--label-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-checked="true"] {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.4);
}
.segmented button:disabled { opacity: 0.35; cursor: not-allowed; }

.toggle {
  position: relative;
  width: 50px; height: 30px;
  border: none; border-radius: 999px;
  background: var(--mat-regular);
  cursor: pointer; flex-shrink: 0;
  transition: background 0.25s var(--ease-soft);
}
.toggle[aria-checked="true"] { background: var(--brand); }
.toggle__knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.25s var(--ease);
}
.toggle[aria-checked="true"] .toggle__knob { transform: translateX(20px); }

.sheet__about {
  margin: 18px 0 0;
  color: var(--label-3);
  font-size: 13px;
  line-height: 1.5;
}

/* ----------------------------------------------------------
   Weather Icons (erikflowers) — tinted in the brand palette
   ---------------------------------------------------------- */
.wi {
  line-height: 1;
  display: inline-block;
  /* Brand-coloured vector glyphs via gradient-clipped text */
  background: linear-gradient(160deg, var(--brand-2) 0%, var(--brand) 75%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
/* The big hero glyph gets a brighter sheen + soft brand glow */
.hero__icon .wi {
  background: linear-gradient(160deg, #b9b4ff 0%, var(--brand-2) 45%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 6px 18px rgba(108, 99, 255, 0.45));
}
.hour__icon .wi, .day__icon .wi { filter: drop-shadow(0 2px 6px rgba(108, 99, 255, 0.3)); }
.moon__glyph .wi {
  background: linear-gradient(160deg, #d7d3ff, #9a93ff);
  -webkit-background-clip: text; background-clip: text;
}

/* ----------------------------------------------------------
   Extra open-data cards
   ---------------------------------------------------------- */
.card__sub {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--label-4);
  letter-spacing: 0.04em;
  text-transform: none;
}

/* generic progress bar */
.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--mat-regular);
  overflow: hidden;
}
.bar__fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--brand);
  transition: width 0.6s var(--ease);
}

/* Moon */
.moon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--mat-border);
}
.moon__glyph { font-size: 26px; }
.moon__info { display: flex; flex-direction: column; line-height: 1.3; }
.moon__info b { font-weight: 600; font-size: 14px; }
.moon__sub { color: var(--label-3); font-size: 12px; }

/* Air quality grid */
.airgrid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
}
@media (max-width: 480px) { .airgrid { grid-template-columns: 1fr; } }
.polls { display: flex; flex-direction: column; gap: 9px; }
.poll {
  display: grid;
  grid-template-columns: 46px 1fr 78px;
  align-items: center;
  gap: 10px;
}
.poll__label { font-size: 13px; font-weight: 600; color: var(--label-2); }
.poll__bar {
  height: 6px; border-radius: 3px;
  background: var(--mat-regular); overflow: hidden;
}
.poll__fill {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #5dd1a0, #ffcf5c 55%, #ff7a7a);
}
.poll__val { font-size: 12px; color: var(--label-3); text-align: right; font-variant-numeric: tabular-nums; }

/* Pollen */
.pollens {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 480px) { .pollens { grid-template-columns: repeat(2, 1fr); } }
.pollen { display: flex; flex-direction: column; gap: 7px; }
.pollen__top { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.pollen__lvl { font-size: 12px; font-weight: 600; }

/* Place / Wikipedia */
.place__body { display: flex; gap: 18px; align-items: flex-start; }
@media (max-width: 560px) { .place__body { flex-direction: column; } }
.place__img {
  width: 150px; height: 150px;
  object-fit: cover;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  border: 1px solid var(--mat-border);
}
@media (max-width: 560px) { .place__img { width: 100%; height: 180px; } }
.place__content { flex: 1; min-width: 0; }
.place__elev { color: var(--label-2); font-size: 13px; margin-bottom: 8px; }
.place__text {
  margin: 0 0 10px;
  color: var(--label-2);
  font-size: 14.5px;
  line-height: 1.55;
}
.place__link { font-size: 13px; font-weight: 600; }

/* Alerts banner */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-left: 3px solid var(--warn);
}
.alert--bad  { border-left-color: var(--bad);  background: rgba(255, 122, 122, 0.08); }
.alert--warn { border-left-color: var(--warn); background: rgba(255, 207, 92, 0.07); }
.alert--info { border-left-color: var(--info); background: rgba(102, 198, 255, 0.07); }
.alert__icon { font-size: 22px; line-height: 1.2; }
.alert__title { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.alert__level {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; color: #1a1320;
  vertical-align: middle; margin-right: 2px;
}
.alert__text { color: var(--label-2); font-size: 13.5px; line-height: 1.45; }

/* Loading shimmer */
.shimmer {
  height: 16px; width: 70%;
  border-radius: 6px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--mat-thin) 25%, var(--mat-regular) 37%, var(--mat-thin) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
}
.shimmer--sm { width: 45%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ----------------------------------------------------------
   Focus & accessibility (HIG)
   ---------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 6px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Motion — respect reduced-motion preference (HIG: Motion) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .sky__precip { display: none; }
}

/* Light-mode courtesy (app is dark-first; keeps text legible if forced) */
@media (prefers-contrast: more) {
  :root { --label-2: rgba(255,255,255,0.85); --mat-border: rgba(255,255,255,0.3); }
}

/* ----------------------------------------------------------
   Weather radar map (Leaflet + RainViewer)
   ---------------------------------------------------------- */
.mapcard {
  max-width: var(--maxw);
  margin: var(--gap) auto 0;
  padding: 16px;
  border-radius: var(--r-lg);
  content-visibility: auto;
  contain-intrinsic-size: 560px;
}
.mapcard__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.mapcard__title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.mapcard__map {
  height: clamp(320px, 52vh, 480px);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--mat-border);
  background: #0a0a12;
  position: relative;
  z-index: 0;
}
.mapcard__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.mapbtn {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #5a52e0);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(108, 99, 255, 0.4);
  transition: transform 0.15s;
}
.mapbtn:active { transform: scale(0.92); }

.mapscrub {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--mat-regular);
  cursor: pointer;
}
.mapscrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  cursor: grab;
}
.mapscrub::-moz-range-thumb {
  width: 20px; height: 20px; border: 3px solid var(--brand);
  border-radius: 50%; background: #fff; cursor: grab;
}
.maptime__label {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  min-width: 52px;
  text-align: right;
}
.maptime__label.is-future { color: var(--brand-2); }
.maptag {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-3);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--mat-thin);
  white-space: nowrap;
}
.maptag.is-future { color: var(--brand-2); background: rgba(108, 99, 255, 0.16); }

.mapcard__legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--label-3);
}
.legend__label { white-space: nowrap; }
.legend__bar { height: 8px; border-radius: 4px; flex: 1; max-width: 280px; }
.legend__bar--rain {
  background: linear-gradient(90deg, #1b3a8f 0%, #2b7fff 35%, #6c63ff 65%, #ff6cab 100%);
}
.legend__bar--cloud {
  background: linear-gradient(90deg, rgba(255,255,255,0.12), rgba(255,255,255,0.9));
}

/* Leaflet dark theming */
.leaflet-container {
  background: #0a0a12;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  /* Let Leaflet own all gestures inside the map (pinch-zoom, pan) */
  touch-action: none;
}
.leaflet-bar { border: none !important; box-shadow: var(--mat-shadow); }
.leaflet-touch .leaflet-bar a, .leaflet-control-zoom a {
  background: var(--mat-thick) !important;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  color: var(--label) !important;
  border-color: var(--mat-border) !important;
  width: 34px; height: 34px; line-height: 34px;
}
.leaflet-control-zoom a:hover { background: rgba(40,40,60,0.8) !important; }
.leaflet-control-attribution {
  background: rgba(7, 7, 13, 0.6) !important;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--label-3) !important;
  font-size: 10px !important;
  border-radius: 8px 0 0 0;
  padding: 2px 8px !important;
}
.leaflet-control-attribution a { color: var(--label-2) !important; }

/* Location pin */
.map-pin { position: relative; }
.map-pin__dot {
  position: absolute; inset: 0;
  width: 14px; height: 14px; margin: 2px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.5);
  z-index: 2;
}
.map-pin__pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.5);
  animation: pinpulse 2s var(--ease-soft) infinite;
}
@keyframes pinpulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* City value labels on the temp/wind/pressure layers */
.citylabel-wrap { pointer-events: none; }
.citylabel {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
  padding: 3px 7px; border-radius: 9px; white-space: nowrap;
  background: rgba(10, 10, 18, 0.62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.citylabel b { font-size: 14px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.citylabel i { font-size: 9.5px; font-style: normal; color: rgba(255, 255, 255, 0.72); letter-spacing: 0.01em; }

/* Colour legend for the value layers */
.mapfx--legend {
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--peek) + 12px);
  width: min(360px, calc(100vw - 28px));
  display: flex; flex-direction: column; gap: 5px;
  padding: 10px 14px; border-radius: 16px;
  transition: bottom 0.46s var(--ease);
}
body[data-sheet="mini"] .mapfx--legend { bottom: calc(var(--mini) + 12px); }
.vlegend__title { font-size: 12px; font-weight: 600; color: var(--label); }
.vlegend__title i { color: var(--label-3); font-style: normal; font-weight: 500; }
.vlegend__bar { height: 9px; border-radius: 5px; display: block; }
.vlegend__ticks {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--label-3); font-variant-numeric: tabular-nums;
}
@media (max-width: 820px) {
  body[data-sheet="expanded"] .mapfx--legend { opacity: 0; pointer-events: none; }
}

/* Momentum scrolling on horizontal strips (iOS) */
.hourly, .locations, .searchresults { -webkit-overflow-scrolling: touch; }

@media (prefers-reduced-motion: reduce) {
  .map-pin__pulse { animation: none; }
}

/* ==========================================================
   Full-screen map + sliding sheet (Apple-Maps / Buienradar)
   ========================================================== */
:root { --peek: 48svh; --mini: 46px; --topbar-h: 60px; }

/* The page itself doesn't scroll — the sheet does. */
body { overflow: hidden; height: 100svh; }

/* Live radar as the full-viewport backdrop */
.mapbg { position: fixed; inset: 0; z-index: 1; background: #0a0a12; }
.mapbg__scrim {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, rgba(7,7,13,0.45) 0%, transparent 18% 64%, rgba(7,7,13,0.30) 100%);
}

/* Top bar floats full-width over the map */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  max-width: none; margin: 0; z-index: 40;
  padding: calc(10px + var(--safe-t)) max(14px, env(safe-area-inset-right))
           10px max(14px, env(safe-area-inset-left));
}

/* Map layer toolbar — a compact icon switcher beside the settings button.
   Seven layers don't fit as text chips, so it's icons-only with hover
   tooltips (title) and aria-labels for assistive tech. Scrolls if cramped. */
.topbar__layers { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; }
.topbar__layers .mapcard__layers {
  height: 46px; align-items: center; padding: 4px; gap: 2px;
  max-width: 100%; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}
.topbar__layers .mapcard__layers::-webkit-scrollbar { display: none; }
.topbar__layers button {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 10px; scroll-snap-align: center;
}
.layer__icon { width: 19px; height: 19px; flex-shrink: 0; }
.layer__label { display: none; }   /* icons only — names live in title / aria-label */

/* Tablets & phones: the toolbar takes its own full-width row below the
   search field, so the search keeps a comfortable width on the top row. */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar__layers { order: 3; flex-basis: 100%; min-width: 100%; }
  .topbar__layers .mapcard__layers { justify-content: safe center; }
}

/* "Add a key" hint shown when an OWM layer is picked without an API key */
.mapkeyhint {
  left: 50%; transform: translateX(-50%);
  top: calc(var(--topbar-h) + var(--safe-t) + 64px);
  width: min(440px, calc(100vw - 28px));
  display: flex; align-items: center; gap: 13px;
  padding: 14px 16px; border-radius: 18px;
}
.mapkeyhint svg { width: 26px; height: 26px; color: var(--brand-2); flex-shrink: 0; }
.mapkeyhint__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mapkeyhint__body b { font-size: 15px; }
.mapkeyhint__body span { font-size: 12.5px; color: var(--label-3); line-height: 1.3; }
.mapkeyhint .btn { flex-shrink: 0; padding: 9px 14px; font-size: 14px; }
@media (max-width: 520px) {
  .mapkeyhint { flex-wrap: wrap; }
  .mapkeyhint .btn { width: 100%; }
}

/* Settings: a stacked label + supporting text / status line */
.setting--col { flex-direction: column; align-items: stretch; gap: 8px; }
.setting--col .setting__hint { margin-top: 0; }
.setting__meter {
  padding: 9px 12px; border-radius: 10px;
  background: var(--mat-thin); border: 1px solid var(--mat-border);
  color: var(--label-2); font-variant-numeric: tabular-nums;
}

/* Floating map controls */
.mapfx { position: fixed; z-index: 36; }
.mapfx--bottom {
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--peek) + 12px);
  width: min(620px, calc(100vw - 28px));
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 18px;
  transition: left 0.46s var(--ease), bottom 0.46s var(--ease), opacity 0.3s var(--ease-soft);
}
/* Mini detent: drop the timeline down to just above the grab bar */
body[data-sheet="mini"] .mapfx--bottom { bottom: calc(var(--mini) + 12px); }
/* When the sheet is dragged up over the map, fade the floating controls away */
@media (max-width: 820px) {
  body[data-sheet="expanded"] .mapfx {
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s var(--ease-soft);
  }
}
.mapbar__meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; flex-shrink: 0; }
.mapfx--bottom .mapcard__legend { margin: 0; flex-shrink: 0; }
.mapfx--bottom .legend__bar { width: 70px; }
@media (max-width: 520px) {
  .mapfx--bottom .mapcard__legend { display: none; }
}

/* The sliding information sheet */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 100svh; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--mat-thick);
  -webkit-backdrop-filter: blur(34px) saturate(180%);
  backdrop-filter: blur(34px) saturate(180%);
  border-top: 1px solid var(--mat-border);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(calc(100svh - var(--peek)));
  transition: transform 0.46s var(--ease);
  will-change: transform;
}
.panel.is-dragging { transition: none; }
.panel__grab {
  flex-shrink: 0; width: 100%; border: none; background: none;
  padding: 11px 0 7px; cursor: grab; touch-action: none;
}
.panel__grab:active { cursor: grabbing; }
.panel__grab span {
  display: block; width: 42px; height: 5px; border-radius: 3px;
  background: var(--mat-border-hi); margin: 0 auto;
  transition: background 0.2s;
}
.panel__grab:hover span { background: var(--brand-2); }
.panel .locations { flex-shrink: 0; max-width: none; margin: 0; padding-top: 2px; }
.panel__scroll {
  flex: 1; min-height: 0;
  overflow-y: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.panel[data-state="expanded"] .panel__scroll { overflow-y: auto; }
.panel .content { max-width: none; margin: 0; padding-top: 6px; }
.panel .appfoot { max-width: none; margin: 0; }

/* Narrow single-column card layout inside the sheet (both mobile & desktop) */
.panel .col-8, .panel .col-6, .panel .col-4 { grid-column: span 12; }
.panel .col-3 { grid-column: span 6; }

/* Lift Leaflet's own controls clear of the sheet on phones */
.mapbg .leaflet-bottom.leaflet-right { bottom: calc(var(--peek) + 10px); right: 6px; transition: bottom 0.46s var(--ease); }
.mapbg .leaflet-bottom.leaflet-left  { bottom: calc(var(--peek) + 10px); transition: bottom 0.46s var(--ease); }
body[data-sheet="mini"] .mapbg .leaflet-bottom.leaflet-right { bottom: calc(var(--mini) + 10px); }
body[data-sheet="mini"] .mapbg .leaflet-bottom.leaflet-left  { bottom: calc(var(--mini) + 10px); }

/* Desktop / tablet-landscape: the sheet becomes a left sidebar */
@media (min-width: 821px) {
  .panel {
    left: 0; right: auto; top: 0; bottom: 0;
    width: 420px; height: 100svh;
    transform: none !important;
    border-radius: 0; border-top: none;
    border-right: 1px solid var(--mat-border);
    box-shadow: 24px 0 70px rgba(0, 0, 0, 0.45);
    padding-top: calc(var(--topbar-h) + var(--safe-t));
  }
  .panel__grab { display: none; }
  .panel__scroll { overflow-y: auto; }
  .mapfx--bottom { left: calc(420px + (100vw - 420px) / 2); bottom: 22px; }
  .mapfx--legend { left: calc(420px + (100vw - 420px) / 2); bottom: 22px; }
  .mapkeyhint    { left: calc(420px + (100vw - 420px) / 2); }
  .mapbg .leaflet-bottom.leaflet-right { bottom: 16px; right: 10px; }
  .mapbg .leaflet-bottom.leaflet-left  { bottom: 16px; }
  .topbar { padding-left: 20px; }

  /* Drawer pull on the sidebar edge to hide / reveal the details */
  .paneltoggle {
    display: grid; place-items: center;
    position: fixed; z-index: 38;
    top: 50%; left: 420px; transform: translateY(-50%);
    width: 26px; height: 56px;
    border: 1px solid var(--mat-border); border-left: none;
    border-radius: 0 13px 13px 0;
    background: var(--mat-thick);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    color: var(--label-2); cursor: pointer;
    transition: left 0.46s var(--ease), background 0.2s, color 0.2s;
  }
  .paneltoggle:hover { color: var(--label); background: rgba(40,40,60,0.7); }
  .paneltoggle svg { width: 18px; height: 18px; transition: transform 0.46s var(--ease); }

  body[data-sidebar="hidden"] .panel { transform: translateX(-101%) !important; }
  body[data-sidebar="hidden"] .paneltoggle { left: 0; }
  body[data-sidebar="hidden"] .paneltoggle svg { transform: rotate(180deg); }
  body[data-sidebar="hidden"] .mapfx--bottom,
  body[data-sidebar="hidden"] .mapfx--legend,
  body[data-sidebar="hidden"] .mapkeyhint { left: 50%; }
}

/* The animated Apple-style search field: compact, stretches on focus */
@media (min-width: 821px) {
  .searchwrap {
    flex: 0 0 auto;
    width: 300px;
    margin: 0 auto;
    transition: width 0.42s var(--ease);
  }
  .searchwrap:focus-within { width: 520px; }
  .searchwrap:focus-within .searchfield {
    border-color: var(--mat-border-hi);
    box-shadow: var(--mat-shadow), inset 0 1px 0 rgba(255,255,255,0.12),
                0 0 0 3px rgba(108, 99, 255, 0.22);
  }
  .searchfield { transition: border-color 0.25s, box-shadow 0.25s; }
}

/* The collapse drawer-pull is desktop-only */
@media (max-width: 820px) { .paneltoggle { display: none; } }

/* Roomy desktops: keep the brand visible, search left-aligned in the bar */
@media (min-width: 1100px) {
  .mapfx--bottom { width: 560px; }
}
