/* ==========================================================================
   Material Design 3 — Air Quality
   Colour roles (--md-sys-color-*) are defaults (Google Blue seed); app.js swaps
   them for a scheme generated from the current AQI category's colour.
   ========================================================================== */
:root {
  --md-sys-color-primary: #435e91;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d8e2ff;
  --md-sys-color-on-primary-container: #2a4678;
  --md-sys-color-secondary: #565e71;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #dbe2f9;
  --md-sys-color-on-secondary-container: #3f4759;
  --md-sys-color-tertiary: #715574;
  --md-sys-color-tertiary-container: #fbd7fc;
  --md-sys-color-on-tertiary-container: #583e5b;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #93000a;
  --md-sys-color-surface: #f9f9ff;
  --md-sys-color-surface-dim: #d9d9e0;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f3f3fa;
  --md-sys-color-surface-container: #ededf4;
  --md-sys-color-surface-container-high: #e8e7ee;
  --md-sys-color-surface-container-highest: #e2e2e9;
  --md-sys-color-on-surface: #1a1b20;
  --md-sys-color-on-surface-variant: #44474f;
  --md-sys-color-outline: #74777f;
  --md-sys-color-outline-variant: #c4c6d0;
  --md-sys-color-inverse-surface: #2f3036;
  --md-sys-color-inverse-on-surface: #f0f0f7;
  --md-sys-color-inverse-primary: #adc7ff;
  --md-sys-color-scrim: #000000;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --md-sys-color-primary: #adc7ff;
    --md-sys-color-on-primary: #0f2f60;
    --md-sys-color-primary-container: #2a4678;
    --md-sys-color-on-primary-container: #d8e2ff;
    --md-sys-color-secondary: #bfc6dc;
    --md-sys-color-on-secondary: #283041;
    --md-sys-color-secondary-container: #3f4759;
    --md-sys-color-on-secondary-container: #dbe2f9;
    --md-sys-color-tertiary: #debcdf;
    --md-sys-color-tertiary-container: #583e5b;
    --md-sys-color-on-tertiary-container: #fbd7fc;
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;
    --md-sys-color-surface: #111318;
    --md-sys-color-surface-dim: #111318;
    --md-sys-color-surface-container-lowest: #0c0e13;
    --md-sys-color-surface-container-low: #1a1b20;
    --md-sys-color-surface-container: #1e1f25;
    --md-sys-color-surface-container-high: #282a2f;
    --md-sys-color-surface-container-highest: #33353a;
    --md-sys-color-on-surface: #e2e2e9;
    --md-sys-color-on-surface-variant: #c4c6d0;
    --md-sys-color-outline: #8e9099;
    --md-sys-color-outline-variant: #44474f;
    --md-sys-color-inverse-surface: #e2e2e9;
    --md-sys-color-inverse-on-surface: #2f3036;
    --md-sys-color-inverse-primary: #435e91;
    --md-sys-color-scrim: #000000;
    color-scheme: dark;
  }
}

:root {
  --font: "Google Sans Flex", "Google Sans", "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shape-xl: 28px;
  --shape-l: 16px;
  --shape-m: 12px;
  --shape-s: 8px;
  --ease: cubic-bezier(0.2, 0, 0, 1);           /* emphasized */
  --ease-decel: cubic-bezier(0.05, 0.7, 0.1, 1); /* emphasized decelerate */
  --gutter: 16px;
  --cat: #34d399;
  --cat-ink: #06121a;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
h1, h2, p { margin: 0; }

body {
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color 0.6s var(--ease), color 0.6s var(--ease);
}

.msr {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
  flex: none;
}

/* ---------- Loading indicator (M3 linear progress, indeterminate) ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 10;
  overflow: hidden; opacity: 0; transition: opacity 0.3s var(--ease);
}
.progress i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: var(--md-sys-color-primary); border-radius: 4px;
  animation: indet 1.6s var(--ease) infinite;
}
body.loading .progress, body.fetching .progress { opacity: 1; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- Layout ---------- */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

/* Top app bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px 16px; flex-wrap: wrap;
  min-height: 64px; padding: 8px 0 12px;
}
.place { display: flex; align-items: center; gap: 12px; min-width: 0; }
.place-icon {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 50%;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-variation-settings: "FILL" 1;
}
.place h1 { font-size: 22px; line-height: 28px; font-weight: 500; letter-spacing: 0; }
.sub { color: var(--md-sys-color-on-surface-variant); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 4px; align-items: center; }

/* State layer shared by all interactive surfaces */
.icon-btn, .segmented button, .chip, .btn-filled, .btn-text, .results button { position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.icon-btn::after, .segmented button::after, .chip::after, .btn-filled::after, .btn-text::after, .results button::after {
  content: ""; position: absolute; inset: 0; background: currentColor; opacity: 0;
  transition: opacity 0.2s var(--ease); pointer-events: none;
}
.icon-btn:hover::after, .segmented button:hover::after, .chip:hover::after, .btn-filled:hover::after, .btn-text:hover::after, .results button:hover::after { opacity: 0.08; }
.icon-btn:active::after, .segmented button:active::after, .chip:active::after, .btn-filled:active::after, .btn-text:active::after, .results button:active::after { opacity: 0.12; }
:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }

.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--md-sys-color-on-surface-variant);
}
.icon-btn.spin .msr { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#displayBtn[aria-pressed="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* Connected button group (M3 Expressive): separate pieces, 2px gap, pill outer corners,
   tight inner corners. The selected piece morphs to a full pill. */
.segmented { display: inline-flex; gap: 2px; height: 40px; margin-right: 4px; }
.segmented button {
  border: 0;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
  font: 500 14px/20px var(--font); letter-spacing: 0.01em;
  padding: 0 18px; min-width: 64px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-radius 0.35s var(--ease);
}
.segmented button:first-child { border-radius: 20px 6px 6px 20px; }
.segmented button:last-child { border-radius: 6px 20px 20px 6px; }
.segmented .check { font-size: 18px; width: 0; opacity: 0; margin-right: -6px; transition: width 0.3s var(--ease), opacity 0.2s, margin 0.3s var(--ease); }
.segmented button[aria-pressed="true"] { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); border-radius: 20px; }
.segmented button[aria-pressed="true"] .check { width: 18px; opacity: 1; margin-right: 0; }

/* Assist chip for the stale state */
.chip-stale {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 8px 0 6px; border-radius: var(--shape-s);
  background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container);
  font-size: 12px; font-weight: 500;
}
.chip-stale .msr { font-size: 16px; }
.chip-stale[hidden] { display: none; }

/* Banner */
.banner {
  display: flex; gap: 16px; align-items: center;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--shape-l);
  padding: 16px 20px; margin-bottom: 16px;
  font-size: 14px;
}
.banner .msr { color: var(--md-sys-color-primary); }
.banner[hidden] { display: none; }

/* Grid of cards */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--shape-xl);
  padding: 24px;
  min-width: 0;
  transition: background-color 0.6s var(--ease);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card h2 { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.01em; }
.card-sub { color: var(--md-sys-color-on-surface-variant); font-size: 12px; }

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .hero, .pollutants, .trend { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  /* Top bar and AQI card stay pinned; the card fills the window below the bar. */
  body:not(.display) .app { padding-top: 0; padding-bottom: 16px; }
  .grid > .foot { grid-column: 2 / 4; }
  body:not(.display) .top-bar {
    position: sticky; top: 0; z-index: 5;
    padding-top: max(20px, env(safe-area-inset-top));
    background: var(--md-sys-color-surface);
    transition: background-color 0.6s var(--ease);
  }
  .hero {
    grid-column: 1 / 2; grid-row: 1 / 4;
    align-self: start; position: sticky; top: var(--bar-h, 96px);
    height: calc(100vh - var(--bar-h, 96px) - 16px);
    height: calc(100dvh - var(--bar-h, 96px) - 16px);
    min-height: fit-content;
  }
  .hero .hero-inner { flex: none; }
  .hero .gauge-wrap { margin-top: 8px; }
  .pollutants { grid-column: 2 / 4; grid-row: 1; }
  .trend { grid-column: 2 / 4; grid-row: 2; }
  .extras { grid-column: 2 / 3; grid-row: 3; }
  .legend { grid-column: 3 / 4; grid-row: 3; }
}

/* ---------- Hero ---------- */
.hero {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  display: flex; flex-direction: column;
  padding: 28px 24px 32px;
}
.hero-inner {
  flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 8px;
}
.hero-label {
  align-self: stretch; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; letter-spacing: 0.01em;
  white-space: nowrap;
}
.hero-label .msr { font-size: 20px; }
.gauge-wrap { position: relative; width: min(100%, 340px); margin-top: auto; padding-top: 8px; }
.hero-text { margin-bottom: auto; }
.gauge { width: 100%; display: block; overflow: visible; }
.gauge path { fill: none; stroke-width: 18; stroke-linecap: round; }
/* Unfilled part of the arc. Light cards are pale, so the track needs more opacity to stay
   visible (about 1.6:1 against the card while the fill stays at least 3:1 against it).
   Uses stroke-opacity rather than color-mix() so older TV browsers (LG webOS) still draw it. */
.gauge .track { stroke: var(--md-sys-color-on-primary-container); stroke-opacity: 0.3; }
@media (prefers-color-scheme: dark) {
  .gauge .track { stroke-opacity: 0.16; }
}
.gauge .fill {
  stroke: var(--md-sys-color-primary);
  stroke-dasharray: 0 100;
  transition: stroke 0.6s var(--ease);
}
.gauge .knob {
  fill: var(--cat); stroke: var(--md-sys-color-primary-container); stroke-width: 4;
  transition: fill 0.6s var(--ease);
}
.gauge-center { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; }
.aqi-num {
  font-size: clamp(56px, 13vw, 80px); line-height: 1; font-weight: 450;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 144, "ROND" 100;
}
.cat {
  font-size: 28px; line-height: 36px; font-weight: 500; margin-top: 8px;
  text-wrap: balance;
}
.advice { font-size: 16px; line-height: 24px; letter-spacing: 0.03em; max-width: 36ch; margin: 4px auto 0; opacity: 0.86; }
.dominant {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 6px 14px; border-radius: var(--shape-s);
  position: relative; z-index: 0;
  font-size: 14px; font-weight: 500;
}
.dominant::before {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: -1;
  border-radius: inherit; background: var(--md-sys-color-on-primary-container); opacity: 0.08;
}
.dominant:empty { display: none; }
.dominant .msr { font-size: 18px; }
/* Data source chip, right-aligned in the hero label row. */
.hero-label .source {
  margin-left: auto; min-width: 0; padding: 4px 10px 4px 8px; border-radius: var(--shape-s);
  display: flex; align-items: center; gap: 4px;
  position: relative; z-index: 0;
  font-size: 12px; line-height: 16px; font-weight: 500;
}
.hero-label .source::before {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: -1;
  border-radius: inherit; background: var(--md-sys-color-on-primary-container); opacity: 0.08;
}
.hero-label .source .msr { font-size: 16px; flex: none; }
.hero-label .source span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-label .source:empty { display: none; }

/* ---------- Pollutant tiles ---------- */
.pollutants { container-type: inline-size; }
.tiles { display: grid; gap: 8px; grid-template-columns: 1fr; }
@container (min-width: 400px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@container (min-width: 620px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@supports not (container-type: inline-size) {
  @media (min-width: 480px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
  @media (min-width: 720px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
}
.tile {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--shape-l);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  outline: 2px solid transparent; outline-offset: -2px;
  transition: outline-color 0.3s var(--ease);
}
.tile.dom { outline-color: var(--md-sys-color-primary); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tile-name { font-size: 16px; line-height: 24px; font-weight: 500; }
.tile-name small { display: block; color: var(--md-sys-color-on-surface-variant); font-weight: 400; font-size: 12px; line-height: 16px; }
.tile-idx {
  min-width: 32px; height: 24px; padding: 0 8px; border-radius: 12px;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.tile-val { font-size: 28px; line-height: 36px; font-weight: 400; }
.tile-val small { font-size: 12px; color: var(--md-sys-color-on-surface-variant); margin-left: 4px; }
.tile-desc { color: var(--md-sys-color-on-surface-variant); font-size: 12px; line-height: 16px; letter-spacing: 0.01em; }

/* M3 linear progress (determinate): active segment, gap, track */
.lp { position: relative; display: flex; gap: 4px; height: 4px; }
.lp .a { height: 100%; border-radius: 2px; width: 0; flex: none; transition: width 1s var(--ease-decel); }
.lp .t { height: 100%; border-radius: 2px; flex: 1; background: var(--md-sys-color-secondary-container); }

/* ---------- Chart ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 16px; border-radius: var(--shape-s);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent; color: var(--md-sys-color-on-surface-variant);
  font: 500 14px/20px var(--font); letter-spacing: 0.01em; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip .msr { font-size: 18px; margin-left: -8px; }
.chip[aria-selected="true"] {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
  padding-left: 8px;
}
.chip[aria-selected="true"] .msr { margin-left: 0; }
.chart-wrap { position: relative; width: 100%; touch-action: pan-y; }
#chart { width: 100%; height: 260px; display: block; overflow: visible; }
#chart text { fill: var(--md-sys-color-on-surface-variant); font: 12px var(--font); }
#chart .grid-line { stroke: var(--md-sys-color-outline-variant); stroke-width: 1; opacity: 0.6; }
#chart .now-line { stroke: var(--md-sys-color-on-surface); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: 0.55; }
#chart .now-pill { fill: var(--md-sys-color-inverse-surface); }
#chart .now-text { fill: var(--md-sys-color-inverse-on-surface); font-weight: 500; }
#chart .line { fill: none; stroke: var(--md-sys-color-primary); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
#chart .line.fc { stroke-dasharray: 1 7; stroke-width: 3.5; }
#chart .now-dot { fill: var(--md-sys-color-primary); stroke: var(--md-sys-color-surface-container); stroke-width: 3; }
#chart .hover-dot { fill: var(--md-sys-color-surface-container); stroke: var(--md-sys-color-primary); stroke-width: 3; }
.tooltip {
  position: absolute; top: 0; pointer-events: none;
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  padding: 6px 10px; border-radius: 4px; font-size: 12px; line-height: 16px; white-space: nowrap;
  transform: translateX(-50%);
}
.tooltip b { font-size: 14px; font-weight: 500; }
.chart-note { color: var(--md-sys-color-on-surface-variant); font-size: 12px; margin-top: 8px; }

/* ---------- Details ---------- */
.extras-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat {
  display: flex; align-items: center; gap: 14px;
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--shape-l);
  padding: 12px 16px;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
}
.stat-icon .msr { font-size: 20px; }
.stat .k { color: var(--md-sys-color-on-surface-variant); font-size: 12px; line-height: 16px; letter-spacing: 0.03em; }
.stat .v { font-size: 22px; line-height: 28px; font-weight: 400; }
.stat .v small { font-size: 12px; color: var(--md-sys-color-on-surface-variant); margin-left: 3px; }
.stat .n { color: var(--md-sys-color-on-surface-variant); font-size: 12px; line-height: 16px; }

/* ---------- Legend ---------- */
.legend-list { display: flex; flex-direction: column; gap: 2px; }
.legend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; margin: 0 -12px; border-radius: 100px;
  font-size: 14px;
}
.legend-row .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend-row .rng { margin-left: auto; flex: none; white-space: nowrap; color: var(--md-sys-color-on-surface-variant); }
.legend-row.current { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); font-weight: 600; }
.legend-row.current .rng { color: inherit; }

.foot {
  display: flex; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  color: var(--md-sys-color-on-surface-variant); font-size: 12px; margin-top: 4px; padding: 0 4px;
  grid-column: 1 / -1;
}
.foot a { color: var(--md-sys-color-primary); text-decoration: none; font-weight: 500; }
.foot a:hover { text-decoration: underline; }

/* Skeleton */
.skeleton {
  height: 132px; border-radius: var(--shape-l);
  background: linear-gradient(90deg, var(--md-sys-color-surface-container-high), var(--md-sys-color-surface-container-lowest), var(--md-sys-color-surface-container-high));
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Dialog ---------- */
dialog {
  border: 0; padding: 0;
  border-radius: var(--shape-xl);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  width: min(calc(100vw - 32px), 440px);
}
dialog[open] { animation: dlg-in 0.4s var(--ease-decel); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(-16px) scale(0.96); } }
dialog::backdrop { background: rgba(0, 0, 0, 0.32); }
.dlg { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.dlg-icon { align-self: center; color: var(--md-sys-color-secondary); }
.dlg h2 { font-size: 24px; line-height: 32px; font-weight: 400; text-align: center; margin-top: -4px; }
.dlg-sub { color: var(--md-sys-color-on-surface-variant); text-align: center; margin-top: -8px; }
.btn-filled {
  height: 40px; border: 0; border-radius: 20px; padding: 0 24px 0 16px; cursor: pointer;
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
  font: 500 14px/20px var(--font); letter-spacing: 0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-filled .msr { font-size: 18px; }
.btn-text {
  height: 40px; border: 0; border-radius: 20px; padding: 0 12px; cursor: pointer;
  background: transparent; color: var(--md-sys-color-primary);
  font: 500 14px/20px var(--font); letter-spacing: 0.01em;
}
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Outlined text field with floating label */
.field { position: relative; height: 56px; }
.field .msr { position: absolute; left: 12px; top: 16px; color: var(--md-sys-color-on-surface-variant); pointer-events: none; }
.field input {
  width: 100%; height: 100%; padding: 0 16px 0 48px;
  border: 1px solid var(--md-sys-color-outline); border-radius: 4px;
  background: transparent; color: var(--md-sys-color-on-surface);
  font: 16px var(--font); letter-spacing: 0.03em; outline: none;
}
.field input:hover { border-color: var(--md-sys-color-on-surface); }
.field input:focus { border: 2px solid var(--md-sys-color-primary); padding-left: 47px; }
.field input::-webkit-search-cancel-button { display: none; }
.field label {
  position: absolute; left: 48px; top: 18px; padding: 0 4px; margin-left: -4px;
  color: var(--md-sys-color-on-surface-variant); font-size: 16px; line-height: 20px;
  pointer-events: none; background: var(--md-sys-color-surface-container-high);
  transition: transform 0.2s var(--ease), font-size 0.2s var(--ease), color 0.2s;
  transform-origin: left center;
}
.field input:focus + label, .field input:not(:placeholder-shown) + label {
  transform: translate(-36px, -27px); font-size: 12px;
}
.field input:focus + label { color: var(--md-sys-color-primary); }
.results { list-style: none; margin: 0 -24px; padding: 0; display: flex; flex-direction: column; max-height: 260px; overflow: auto; }
.results:empty { display: none; }
.results li { padding: 0; }
.results li.msg { padding: 12px 24px; color: var(--md-sys-color-on-surface-variant); }
.results button {
  width: 100%; border: 0; background: transparent; color: var(--md-sys-color-on-surface);
  text-align: left; padding: 12px 24px; cursor: pointer; font: 16px/24px var(--font);
  display: flex; align-items: center; gap: 16px;
}
.results button .msr { color: var(--md-sys-color-on-surface-variant); }
.results button small { display: block; color: var(--md-sys-color-on-surface-variant); font-size: 14px; line-height: 20px; }

/* ---------- Display mode (always-on) ---------- */
body.display #refreshBtn,
body.display #locBtn,
body.display .segmented,
body.display .legend,
body.display .extras,
body.display .chips,
body.display .tile-desc,
body.display .chart-note,
body.display .card-sub { display: none; }
body.display .app { max-width: none; transition: transform 2s var(--ease); }
body.display .place h1 { font-size: clamp(22px, 2.4vw, 32px); line-height: 1.25; }
body.display .cat { font-size: clamp(28px, 3vw, 40px); line-height: 1.2; }
body.display .advice { font-size: clamp(16px, 1.5vw, 22px); line-height: 1.45; max-width: 40ch; }
body.display .tile-val { font-size: clamp(28px, 2.4vw, 40px); line-height: 1.2; }
body.display .card { cursor: none; }
@media (min-width: 900px) {
  body.display .app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-top: 12px; padding-bottom: 16px; }
  body.display .grid { flex: 1; min-height: 0; grid-template-columns: 1fr 1.5fr; grid-template-rows: auto 1fr; }
  body.display .hero { grid-column: 1; grid-row: 1 / 3; align-self: stretch; position: static; height: auto; min-height: 0; }
  body.display .hero .hero-inner { flex: 1; position: static; }
  body.display .hero .gauge-wrap { margin-top: auto; }
  body.display .pollutants { grid-column: 2; grid-row: 1; }
  body.display .trend { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; min-height: 200px; }
  body.display .chart-wrap { flex: 1; min-height: 0; }
  body.display #chart { height: 100%; }
  body.display .tiles { grid-template-columns: repeat(3, 1fr); }
  body.display .gauge-wrap { width: min(100%, 58vh); }
  body.display .aqi-num { font-size: min(11vw, 13vh); }
  body.display .grid > .foot { grid-column: 1 / -1; margin-top: 0; }
}

@media (max-width: 599px) {
  .card { padding: 20px 16px; border-radius: 24px; }
  .hero { padding: 24px 16px 28px; }
  #chart { height: 210px; }
  .top-bar { padding-bottom: 8px; }
  .actions { width: 100%; justify-content: space-between; }
  .actions .segmented { margin-right: auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
  .chip { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
