/* Saans: the sky is the interface. Its colour follows the live air quality. */
@property --s1 { syntax: "<color>"; inherits: true; initial-value: #3d7fd1; }
@property --s2 { syntax: "<color>"; inherits: true; initial-value: #9cc8f2; }
@property --s3 { syntax: "<color>"; inherits: true; initial-value: #dcebf8; }

:root {
  --s1: #3d7fd1; --s2: #9cc8f2; --s3: #dcebf8;
  --ink: #0d1b2a; --ink-2: rgba(13, 27, 42, .62); --ink-3: rgba(13, 27, 42, .42);
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .82); --hair: rgba(13, 27, 42, .08);
  --accent: #0a84ff; --accent-ink: #fff;
  --on-sky: #ffffff;
  --good: #34c759; --sat: #a3d14b; --mod: #f5c400; --poor: #ff9500; --vpoor: #ff3b30; --sev: #a2221b;
  --radius: 22px; --shadow: 0 10px 30px rgba(13, 27, 42, .08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Noto Sans Devanagari", system-ui, sans-serif;
  color-scheme: light;
}
body[data-cat="none"]          { --s1: #3d7fd1; --s2: #9cc8f2; --s3: #dcebf8; }
body[data-cat="Good"]          { --s1: #1f7ae0; --s2: #6db3f5; --s3: #cfe6fb; }
body[data-cat="Satisfactory"]  { --s1: #3f86bf; --s2: #93c2dc; --s3: #dbe9ee; }
body[data-cat="Moderate"]      { --s1: #7894a6; --s2: #bcc2b4; --s3: #ece4cc; }
body[data-cat="Poor"]          { --s1: #8a7d70; --s2: #c9a57e; --s3: #efd6b4; }
body[data-cat="VeryPoor"]      { --s1: #5f514b; --s2: #9b7a63; --s3: #d1ab88; }
body[data-cat="Severe"]        { --s1: #2d2725; --s2: #5d4639; --s3: #9a7559; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f5f7fa; --ink-2: rgba(245, 247, 250, .68); --ink-3: rgba(245, 247, 250, .45);
    --glass: rgba(22, 26, 32, .55); --glass-strong: rgba(28, 32, 40, .82); --hair: rgba(255, 255, 255, .09);
    --shadow: 0 10px 30px rgba(0, 0, 0, .25); color-scheme: dark;
  }
  :root:not([data-theme="light"]) .sky::after { background: rgba(4, 8, 16, .48); }
}
:root[data-theme="dark"] {
  --ink: #f5f7fa; --ink-2: rgba(245, 247, 250, .68); --ink-3: rgba(245, 247, 250, .45);
  --glass: rgba(22, 26, 32, .55); --glass-strong: rgba(28, 32, 40, .82); --hair: rgba(255, 255, 255, .09); color-scheme: dark;
}
:root[data-theme="dark"] .sky::after { background: rgba(4, 8, 16, .48); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 400 16px/1.45 var(--font); color: var(--ink); background: var(--s2);
  -webkit-font-smoothing: antialiased; padding-bottom: calc(86px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }

.sky {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(180deg, var(--s1) 0%, var(--s2) 55%, var(--s3) 100%);
  transition: --s1 1.6s ease, --s2 1.6s ease, --s3 1.6s ease;
}
.sky::after { content: ""; position: absolute; inset: 0; background: transparent; }
#particles { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }

main { max-width: 620px; margin: 0 auto; padding: 0 16px; }

/* Icons */
.i { display: inline-flex; width: 20px; height: 20px; flex: none; }
.i svg { width: 100%; height: 100%; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 1000; display: flex; justify-content: space-between; align-items: center;
  max-width: 620px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; color: var(--on-sky);
}
.brand { display: flex; align-items: center; gap: 8px; font: 600 19px/1 var(--font-display); letter-spacing: -.01em; }
.brand .mark { width: 26px; height: 26px; }
.segmented { display: flex; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, .22); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.segmented button { border: 0; background: transparent; color: var(--on-sky); font: 500 13px/1 var(--font); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.segmented button.on { background: rgba(255, 255, 255, .92); color: #0d1b2a; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* Hero */
.hero { text-align: center; color: var(--on-sky); padding: 28px 0 26px; text-shadow: 0 1px 12px rgba(0, 0, 0, .12); }
.hero-place { font: 500 20px/1.2 var(--font-display); letter-spacing: -.01em; }
.hero-aqi { font: 200 104px/1 var(--font-display); letter-spacing: -.04em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.hero-cat { font: 500 20px/1.25 var(--font-display); }
.hero-sub { font-size: 15px; opacity: .88; margin-top: 4px; }

/* Glass cards */
.glass {
  background: var(--glass); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--hair); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.label { font-size: 13px; color: var(--ink-2); }
.label.caps { display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .04em; font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.label.caps .i { width: 15px; height: 15px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair .glass { margin: 0; }
.stat .value { font: 500 21px/1.25 var(--font-display); margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stats4 { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); margin: 4px 0 12px; }
.footnote { color: var(--on-sky); opacity: .85; font-size: 12px; text-align: center; margin: 14px 8px 0; text-shadow: 0 1px 8px rgba(0, 0, 0, .15); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px;
  padding: 12px 16px; font: 600 16px/1.2 var(--font); cursor: pointer; background: var(--glass-strong); color: var(--ink);
  transition: transform .15s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn.filled { background: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; padding: 16px; margin: 16px 0 6px; font-size: 17px; border-radius: 16px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.plain { background: transparent; color: var(--accent); padding: 8px 4px; }
.btn .i { width: 18px; height: 18px; }

/* Location */
.locbar { display: grid; gap: 10px; }
.locbar .btn { width: 100%; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; background: var(--hair); }
.search .i { width: 17px; height: 17px; color: var(--ink-3); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 0; font: 400 16px var(--font); color: var(--ink); outline: none; }
.search input::placeholder { color: var(--ink-3); }
.results-list button { display: block; width: 100%; text-align: left; padding: 12px 4px; border: 0; border-top: 1px solid var(--hair); background: none; color: var(--ink); font: 400 15px var(--font); cursor: pointer; }

/* Hourly strip */
.hours { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -6px; padding: 0 6px 2px; }
.hours::-webkit-scrollbar { display: none; }
.hour { flex: none; width: 46px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.hour .t { color: var(--ink-2); font-weight: 500; }
.hour .col { width: 6px; height: 64px; border-radius: 3px; background: var(--hair); position: relative; overflow: hidden; }
.hour .col i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px; }
.hour .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.hour.now .t { color: var(--ink); font-weight: 700; }

/* Days */
.days .row { display: grid; grid-template-columns: 56px 1fr 44px; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--hair); }
.days .row:first-child { border-top: 0; padding-top: 0; }
.days .d { font-weight: 600; }
.days .bar { height: 6px; border-radius: 3px; background: var(--hair); position: relative; }
.days .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.days .m { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Scan */
.large-title { font: 700 34px/1.1 var(--font-display); letter-spacing: -.02em; color: var(--on-sky); margin: 18px 0 6px; text-shadow: 0 1px 12px rgba(0, 0, 0, .12); }
.lede { color: var(--on-sky); opacity: .92; margin: 0 0 8px; font-size: 15px; text-shadow: 0 1px 10px rgba(0, 0, 0, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--hair); background: var(--glass-strong); color: var(--ink); border-radius: 99px; padding: 8px 14px; font: 500 14px var(--font); cursor: pointer; transition: all .2s ease; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.slot { position: relative; aspect-ratio: 1; border-radius: 16px; background: var(--hair); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; font: 500 13px/1.2 var(--font); color: var(--ink-2); cursor: pointer; overflow: hidden; transition: transform .15s ease; }
.slot:active { transform: scale(.97); }
.slot .i { width: 24px; height: 24px; color: var(--accent); }
.slot small { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slot .x { position: absolute; top: 6px; right: 6px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .5); backdrop-filter: blur(10px); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.slot .x .i { width: 14px; height: 14px; color: #fff; }
.slot .tagline { position: absolute; left: 6px; bottom: 6px; z-index: 2; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .45); padding: 2px 7px; border-radius: 99px; backdrop-filter: blur(10px); }

.progress { display: flex; gap: 16px; align-items: flex-start; }
.progress ol { margin: 0; padding: 0; list-style: none; font-size: 15px; color: var(--ink-3); display: grid; gap: 8px; }
.progress li { display: flex; gap: 8px; align-items: center; transition: color .3s; }
.progress li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--hair); flex: none; transition: background .3s; }
.progress li.done { color: var(--ink); }
.progress li.done::before { background: var(--good); }
.ring { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--hair); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.headline { font: 600 21px/1.3 var(--font-display); letter-spacing: -.01em; margin: 0 0 8px; }
.summary { margin: 0 0 12px; color: var(--ink-2); }
.notice { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.notice .i { color: var(--poor); width: 18px; height: 18px; margin-top: 1px; }

.src { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hair); }
.src:first-of-type { border-top: 0; padding-top: 0; }
.rank { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--glass-strong); display: grid; place-items: center; font: 600 14px var(--font); }
.src h4 { margin: 2px 0 4px; font: 600 16px/1.3 var(--font); }
.src p { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: 500 11px/1 var(--font); padding: 4px 8px; border-radius: 99px; background: var(--hair); color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.tag.alert { background: rgba(255, 59, 48, .14); color: #d70015; }
.tag.law { background: rgba(10, 132, 255, .14); color: var(--accent); }

.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ph { position: relative; border-radius: 14px; overflow: hidden; background: #000; }
.ph img { display: block; width: 100%; }
.ph .bx { position: absolute; border: 2px solid #ff453a; border-radius: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); }
.ph .bx span { position: absolute; top: -20px; left: -2px; background: #ff453a; color: #fff; font: 600 10px/1 var(--font); padding: 4px 6px; border-radius: 5px; white-space: nowrap; }
.ph .cap { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff; font-size: 11px; line-height: 1.3; padding: 18px 8px 7px; }

.room-aqi { font: 300 44px/1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.room-cat { font: 600 17px var(--font-display); margin-top: 4px; }
.meter { height: 10px; border-radius: 5px; overflow: hidden; display: flex; background: var(--hair); margin: 16px 0 8px; }
.meter .out { background: #8e9ba8; } .meter .in { background: var(--vpoor); }
.meter-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); }
.meter-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.small { font-size: 12px; color: var(--ink-3); margin: 10px 0 0; }

.act { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hair); }
.act:first-of-type { border-top: 0; padding-top: 0; }
.act .cost { flex: none; min-width: 52px; text-align: center; font: 600 12px/1 var(--font); padding: 6px 8px; border-radius: 99px; height: fit-content; background: var(--hair); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.act .cost.free { background: rgba(52, 199, 89, .16); color: #248a3d; }
.act .cost.tip { background: rgba(10, 132, 255, .12); color: var(--accent); }
.act p { margin: 0; font-size: 15px; }
.act small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 3px; }

textarea { width: 100%; min-height: 230px; border: 0; border-radius: 14px; padding: 12px; font: 400 14px/1.5 var(--font); background: var(--hair); color: var(--ink); resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1 1 120px; font-size: 15px; padding: 11px 12px; }

/* Map */
.map-wrap { padding: 0; overflow: hidden; }
#map { height: 440px; }
.stats4 .glass { padding: 12px 14px; }
.stats4 b { display: block; font: 600 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.stats4 span { font-size: 12px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 4px 20px; font-size: 13px; color: var(--on-sky); text-shadow: 0 1px 8px rgba(0, 0, 0, .2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; border: 1.5px solid #fff; vertical-align: -1px; }
.leaflet-popup-content-wrapper { border-radius: 14px; font-family: var(--font); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; justify-content: center; gap: 4px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--glass-strong); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 1px solid var(--hair);
}
.tabbar button { flex: 0 1 140px; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; color: var(--ink-3); font: 500 11px var(--font); cursor: pointer; padding: 4px 0; }
.tabbar button .i { width: 24px; height: 24px; }
.tabbar button.active { color: var(--accent); }

.tab { display: none; animation: rise .45s cubic-bezier(.2, .8, .2, 1); }
.tab.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .tab, .reveal { animation: none; }
  .sky { transition: none; }
}
@media (max-width: 380px) {
  .hero-aqi { font-size: 88px; }
  .slots { grid-template-columns: repeat(2, 1fr); }
}
.locbar.compact { padding: 8px; }
.locbar.compact #locBtn { display: none; }

.leaflet-tile-pane { filter: saturate(.55) contrast(.95) brightness(1.04); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(.92) hue-rotate(180deg) saturate(.4) brightness(.9); } }

.legend { display: block; }
.legend span { display: inline-block; margin: 0 12px 6px 0; }
.legend-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; opacity: .9; margin: 10px 0 6px; }
.legend i.sq { border-radius: 3px; }
.aqi-label { font: 700 11px/18px var(--font); color: #1c1c1e; text-align: center; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }

.hero-cig { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; padding: 7px 14px; border-radius: 99px; background: rgba(255,255,255,.2); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font-size: 14px; font-weight: 500; }
.hero-cig .i { width: 18px; height: 18px; }
.smoke-row { display: flex; align-items: baseline; gap: 10px; }
.smoke-num { font: 300 52px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.smoke-txt { font: 600 17px var(--font-display); }
.tag.risk-high { background: rgba(255, 59, 48, .16); color: #d70015; }
.tag.risk-medium { background: rgba(255, 149, 0, .18); color: #c93400; }
.tag.risk-low { background: rgba(52, 199, 89, .16); color: #248a3d; }
.cig-pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 5px 10px; border-radius: 99px; background: var(--hair); font-size: 13px; font-weight: 500; }
.cig-pill .i { width: 16px; height: 16px; }
.room-cat .was { margin-left: 10px; font-size: 13px; font-weight: 500; color: var(--ink-3); text-decoration: line-through; }
.chip.wi.on { background: var(--good); border-color: var(--good); color: #fff; }

.legend i.cone { background: rgba(10, 132, 255, .25); border: 1.5px dashed #0a84ff; }

.ph .src-bx { border-color: #ffd60a; }
.ph .src-bx span { background: #ffd60a; color: #1c1c1e; }

.photos { align-items: start; }

.report-card { display: block; width: 100%; border-radius: 16px; margin-top: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
#hotspots a { color: var(--accent); text-decoration: none; font-weight: 500; }
a.btn { text-decoration: none; }
