:root {
  --bg1: #0b1026;
  --bg2: #1b2a4a;
  --bg3: #2a3d66;
  --card: linear-gradient(160deg, rgba(16, 26, 48, 0.55), rgba(10, 16, 34, 0.42));
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.74);
  --accent: #4da3ff;
  --radius: 22px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: #0b1026;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* ---------- Cinematic scene layers ---------- */
#scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.scene-pane {
  position: absolute; inset: -6%;
  background-size: cover; background-position: center 38%; background-repeat: no-repeat;
  opacity: 0; transition: opacity 1.4s ease;
}
.scene-pane.on { opacity: 1; animation: kenburns 42s ease-in-out infinite alternate; }
@keyframes kenburns {
  from { transform: scale(1.02) translate(0, 0); }
  to   { transform: scale(1.15) translate(-1.2%, 1%); }
}
#grade {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  transition: background 1.4s ease;
}
/* Readability scrim over photo + effects, under content */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(4, 8, 20, 0.44) 0%, rgba(4, 8, 20, 0.10) 30%,
    rgba(4, 8, 20, 0.10) 58%, rgba(4, 8, 20, 0.54) 100%);
}

/* ---------- Location picker ---------- */
.picker {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(var(--sat) + 56px) 20px 20px;
  background: linear-gradient(180deg, rgba(8, 13, 30, 0.42), rgba(8, 13, 30, 0.74));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
}

.picker-card { width: 100%; max-width: 480px; }
.picker-card h1 { font-size: 2.2rem; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.02em; text-shadow: 0 2px 18px rgba(0,0,0,0.4); }
.picker-sub { color: var(--text-dim); margin: 0 0 18px; font-size: 1.02rem; }

#pickerInput {
  width: 100%;
  padding: 15px 18px;
  font-size: 1.05rem;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: rgba(10, 16, 34, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  outline: none;
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
}
#pickerInput::placeholder { color: var(--text-dim); }
#pickerInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,163,255,0.25); }

.picker-results { margin-top: 8px; }
.picker-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  margin: 6px 0;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(12, 20, 38, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.picker-result:hover, .picker-result:focus { border-color: var(--accent); }
.picker-result small { display: block; color: var(--text-dim); font-size: 0.85rem; }

.ghost-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(12, 20, 38, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}
.ghost-btn.small { margin-top: 0; padding: 7px 15px; font-size: 0.85rem; }
.ghost-btn:hover { border-color: rgba(255,255,255,0.3); }

.saved-list { list-style: none; padding: 0; margin: 8px 0 0; }
.saved-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 6px 0;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(12, 20, 38, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.saved-list button.name { background: none; border: none; color: var(--text); font-size: 1rem; cursor: pointer; padding: 4px; }
.saved-list button.del { background: none; border: none; color: var(--text-dim); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }

/* ---------- Layout ---------- */
#app { padding: calc(var(--sat) + 12px) 16px calc(var(--sab) + 24px); max-width: 720px; margin: 0 auto; position: relative; z-index: 4; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 18px;
}
.loc-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; cursor: pointer;
  display: flex; align-items: center; gap: 4px; padding: 4px;
  text-shadow: 0 2px 14px rgba(0,0,0,0.45);
}
.loc-btn .chev { color: var(--text-dim); font-size: 1.5rem; line-height: 1; }
.unit-btn {
  background: rgba(12, 20, 38, 0.5); border: 1px solid var(--card-border); color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px; padding: 9px 18px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}

/* ---------- Alerts ---------- */
.alert { margin: 0 0 12px; }
.alert summary {
  list-style: none;
  cursor: pointer;
  background: rgba(255, 59, 48, 0.24);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 59, 48, 0.55);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-weight: 600;
}
.alert summary::-webkit-details-marker { display: none; }
.alert .alert-body {
  background: rgba(255, 59, 48, 0.10);
  border: 1px solid rgba(255, 59, 48, 0.35);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: var(--text-dim);
}
.alert.watch summary { background: rgba(255, 149, 0, 0.22); border-color: rgba(255,149,0,0.55); }
.alert.watch .alert-body { background: rgba(255,149,0,0.08); border-color: rgba(255,149,0,0.35); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 10px 0 30px; }
.hero-icon svg {
  width: 96px; height: 96px;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.35));
}
.hero-temp {
  font-size: clamp(6.5rem, 30vw, 10rem);
  font-weight: 200;
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 2px 0 6px;
  text-shadow: 0 6px 40px rgba(0,0,0,0.4);
}
.hero-cond { font-size: 1.3rem; font-weight: 500; letter-spacing: 0.01em; text-shadow: 0 2px 12px rgba(0,0,0,0.4); }
.hero-hilo { margin-top: 8px; font-size: 1.05rem; color: var(--text-dim); letter-spacing: 0.04em; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 14px;
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  box-shadow: 0 12px 36px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.10);
}
.card h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); margin: 0 0 12px; font-weight: 600; }
.card h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); margin: 0 0 8px; font-weight: 600; }

/* ---------- Hourly ---------- */
.hourly {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.hour {
  flex: 0 0 66px;
  text-align: center;
  padding: 10px 4px;
  border-radius: 14px;
}
.hour.now { background: rgba(255,255,255,0.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.hour .h-time { font-size: 0.8rem; color: var(--text-dim); }
.hour svg { width: 34px; height: 34px; margin: 6px 0; }
.hour .h-temp { font-size: 1.02rem; font-weight: 600; }
.hour .h-pop { font-size: 0.75rem; color: #7cc4ff; min-height: 1em; font-weight: 600; }

/* ---------- Daily ---------- */
.daily-row {
  display: grid;
  grid-template-columns: 84px 30px 40px 1fr 38px 38px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 1rem;
  cursor: pointer;
}
.daily-row:active { background: rgba(255,255,255,0.05); border-radius: 8px; }
.daily-row:last-child { border-bottom: none; }
.daily-row svg { width: 28px; height: 28px; }
.daily-row .d-pop { font-size: 0.75rem; color: #7cc4ff; text-align: right; font-weight: 600; }
.daily-row .d-low { color: var(--text-dim); text-align: right; }
.daily-row .d-high { text-align: right; font-weight: 600; }
.temp-bar { position: relative; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.18); }
.temp-bar .fill {
  position: absolute; top: 0; bottom: 0; border-radius: 3px;
  background: linear-gradient(90deg, #4da3ff, #ffd60a, #ff9f0a);
}

/* ---------- Detail grid ---------- */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.details-grid .card { margin: 0; }
.detail-val { font-size: 1.7rem; font-weight: 250; margin: 0; letter-spacing: -0.01em; }
.detail-sub { font-size: 0.85rem; color: var(--text-dim); margin: 5px 0 0; }
.card.detail[data-detail] { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease; }
.card.detail[data-detail]:active { transform: scale(0.97); }

/* ---------- Day detail screen (Apple-style) ---------- */
.day-backdrop { position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-end; }
.day-backdrop.hidden { display: none; }
.day-sheet { background: #141414; color: #f5f5f7; width: 100%; max-width: 560px; max-height: 94dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 20px calc(var(--sab, 0px) + 28px); border-radius: 22px 22px 0 0; animation: daySlideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1); touch-action: pan-y; }
@keyframes daySlideUp { from { transform: translateY(60px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.day-grabber { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.3); margin: 6px auto 12px; flex: none; }
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.day-metric-title { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 700; margin: 0 auto; }
.day-metric-title span:first-child { font-size: 1.4rem; }
.day-strip { display: flex; gap: 4px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-cell { flex: 0 0 56px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; color: #f5f5f7; padding: 6px 0; cursor: pointer; border-radius: 12px; }
.day-cell .dl { font-size: 0.8rem; color: #a1a1a6; font-weight: 600; }
.day-cell .dn { font-size: 1.25rem; font-weight: 500; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.day-cell.today .dn { color: #4da3ff; }
.day-cell.sel .dn { background: #f5f5f7; color: #141414; font-weight: 700; }
.day-cell.today.sel .dn { color: #141414; }
.day-title { text-align: center; font-size: 1.15rem; font-weight: 500; margin: 2px 0 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.day-hero { font-size: 3.2rem; font-weight: 300; margin: 0; letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px; }
.day-hero-icon { font-size: 2.4rem; }
.day-hero-sub { color: #a1a1a6; font-size: 1.05rem; margin: 2px 0 14px; }
.day-graph-wrap { position: relative; margin: 6px 0 4px; }
.day-graph { width: 100%; height: 230px; display: block; }
.day-picker-row { position: relative; display: flex; justify-content: flex-end; margin: 4px 0 8px; }
.day-metric-btn { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.14); border: none; color: #fff; font-size: 1.15rem; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.day-metric-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 5; background: #2c2c2e; border-radius: 18px; padding: 8px; min-width: 220px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.day-metric-menu.hidden { display: none; }
.day-metric-menu button { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; color: #f5f5f7; font-size: 1.02rem; padding: 11px 12px; border-radius: 12px; cursor: pointer; text-align: left; }
.day-metric-menu button:active { background: rgba(255,255,255,0.1); }
.day-metric-menu .ck { width: 22px; color: #f5f5f7; font-weight: 700; }
.day-metric-menu .mi { font-size: 1.25rem; width: 28px; text-align: center; }
.day-sec-title { font-size: 1.35rem; font-weight: 700; margin: 26px 0 10px; }
.day-summary { background: #2c2c2e; border-radius: 18px; padding: 16px 18px; font-size: 1.02rem; line-height: 1.5; margin: 0; color: #f5f5f7; }
.day-note { color: #a1a1a6; font-size: 0.92rem; margin: 8px 2px 0; }
.day-sheet .ds-rows { background: #2c2c2e; border-radius: 18px; padding: 6px 18px; margin-top: 4px; }
.day-sheet .ds-row { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 11px 0; }
.day-sheet .ds-row:last-child { border-bottom: none; }
.day-sheet .ds-row .k { color: #f5f5f7; }
.day-sheet .ds-row .v { color: #a1a1a6; text-align: right; }
#dayToggle { margin: 10px 0 2px; }

/* ---------- Detail sheet (tap-to-expand) ---------- */
.ds-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 8, 18, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: ds-fade 0.18s ease;
}
.ds-backdrop.hidden { display: none; }
@keyframes ds-fade { from { opacity: 0; } }
.ds-sheet {
  width: 100%; max-width: 560px; max-height: 88vh;
  background: var(--card-bg, rgba(28, 34, 48, 0.92));
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 22px 22px 0 0;
  border: 1px solid rgba(255,255,255,0.12); border-bottom: none;
  padding: calc(var(--sat, 0px) + 10px) 20px calc(var(--sab, 0px) + 24px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: ds-up 0.25s cubic-bezier(0.32, 0.72, 0.35, 1);
}
@keyframes ds-up { from { transform: translateY(48px); opacity: 0.6; } }
@media (min-width: 640px) {
  .ds-backdrop { align-items: center; padding: 24px; }
  .ds-sheet { border-radius: 22px; border-bottom: 1px solid rgba(255,255,255,0.12); animation: ds-pop 0.2s ease; }
  @keyframes ds-pop { from { transform: scale(0.96); opacity: 0.6; } }
}
.ds-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ds-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.ds-close {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.14); color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer; flex: none;
}
.ds-hero { font-size: 3rem; font-weight: 200; letter-spacing: -0.02em; margin: 2px 0 0; }
.ds-hero-sub { color: var(--text-dim); font-size: 0.95rem; margin: 2px 0 14px; }
.ds-chart { width: 100%; height: 132px; display: block; margin: 6px 0 2px; }
.ds-xlabels { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 0.72rem; margin: 0 2px 12px; }
.ds-rows { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 6px; }
.ds-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 2px; border-bottom: 1px solid rgba(255,255,255,0.1); font-size: 0.95rem; }
.ds-row .k { color: var(--text-dim); }
.ds-row .v { font-weight: 500; text-align: right; }
.ds-note { color: var(--text-dim); font-size: 0.9rem; line-height: 1.5; margin: 12px 2px 0; }
.ds-sec { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); margin: 16px 2px 4px; }
body.ds-open { overflow: hidden; }

/* ---------- Map ---------- */
.map-head { display: flex; align-items: center; justify-content: space-between; }
.map-head h2 { margin: 0; }
#map {
  height: 320px; border-radius: 14px; overflow: hidden;
  background: rgba(6, 10, 22, 0.6); z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
#map .leaflet-container { font-family: inherit; }
.radar-time { color: var(--text-dim); font-size: 0.85rem; margin: 8px 0 0; text-align: right; }
.map-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Layer picker panel */
.layer-wrap { position: relative; }
#layersLabel { font-weight: 600; }
.layer-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 600;
  min-width: 230px; max-width: calc(100vw - 32px);
  max-height: min(360px, 58vh); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: rgba(10, 16, 34, 0.78);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.10);
}
.lp-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); margin: 0 0 8px; font-weight: 600; }
.lp-section + .lp-section { margin-top: 14px; }
.seg { display: flex; background: rgba(255,255,255,0.08); border-radius: 13px; padding: 3px; gap: 3px; }
.seg-btn {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  padding: 9px 6px; border-radius: 10px; font-size: 0.86rem; font-weight: 500; cursor: pointer;
}
.seg-btn.active { background: rgba(255,255,255,0.92); color: #0b1026; font-weight: 700; }
.radio-list { display: flex; flex-direction: column; gap: 2px; }
.radio-opt {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; color: var(--text);
  padding: 9px 8px; border-radius: 11px; font-size: 0.92rem; cursor: pointer; text-align: left;
}
.radio-opt::before {
  content: ''; width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.42); flex: 0 0 auto;
}
.radio-opt.active { background: rgba(255,255,255,0.09); }
.radio-opt.active::before {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 5px, transparent 6px);
}

/* ---------- Footer ---------- */
footer { text-align: center; padding: 8px 0 4px; }
.sources { font-size: 0.8rem; color: var(--text-dim); margin: 0 0 4px; }
.map-attrib { font-size: 0.7rem; color: var(--text-dim); margin: 0 0 4px; opacity: 0.75; line-height: 1.4; }
.updated { font-size: 0.8rem; color: var(--text-dim); margin: 0; opacity: 0.75; }

/* ---------- States ---------- */
.state {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(8,13,30,0.6), rgba(8,13,30,0.85));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px; text-align: center;
}
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.2); border-top-color: #fff;
  animation: spin 0.9s linear infinite; margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { color: #ffb3ab; max-width: 420px; }

@media (min-width: 640px) {
  #map { height: 400px; }
}

/* ---------- Living sky (canvas effects, above the photo) ---------- */
#sky { position: fixed; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
#sky .star {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 0.9; } }
#sky .cloud {
  position: absolute; left: -30vw; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.85), rgba(255,255,255,0) 70%);
  filter: blur(18px); animation: drift 100s linear infinite;
}
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(165vw); } }
#sky .orb { position: absolute; border-radius: 50%; }
#sky .orb.sun {
  top: 10%; right: 12%; width: 130px; height: 130px;
  background: radial-gradient(circle, rgba(255,238,180,0.95), rgba(255,200,90,0.35) 55%, transparent 70%);
  box-shadow: 0 0 90px 30px rgba(255,210,110,0.22);
}
#sky .orb.moon {
  top: 9%; right: 15%; width: 64px; height: 64px;
  background: radial-gradient(circle at 35% 35%, #fdfdf5, #dfe3ee 60%, #aeb6cc);
  box-shadow: 0 0 44px 12px rgba(220,228,245,0.22);
}
#sky .streaks { position: absolute; inset: -25%; }
#sky .streaks.rain {
  background: repeating-linear-gradient(100deg, transparent 0 14px, rgba(174,194,224,0.30) 14px 15px);
  animation: rainfall 0.7s linear infinite;
}
@keyframes rainfall { to { transform: translateY(64px); } }
#sky .streaks.snow {
  background: repeating-linear-gradient(95deg, transparent 0 24px, rgba(255,255,255,0.5) 24px 26px);
  animation: snowfall 3.2s linear infinite;
}
@keyframes snowfall { to { transform: translate(34px, 96px); } }

/* ---------- Rain nowcast card (Apple-style) ---------- */
.nowcast-card { padding: 18px 18px 14px; }
.nc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.nc-seg { flex: 0 0 auto; }
.nc-title { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 2px; }
.nc-sub { font-size: 0.95rem; color: var(--text-dim); margin: 0 0 14px; }
.nc-chart { position: relative; height: 110px; }
.nc-gridlines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; }
.nc-gridlines span { border-top: 1px dashed rgba(255,255,255,0.22); }
.nc-gridlines span:last-child { border-top-style: solid; border-top-color: rgba(255,255,255,0.30); }
.nc-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.nc-bar { flex: 1 1 0; min-width: 0; border-radius: 2px 2px 0 0; background: rgba(124,196,255,0.9); }
.nc-bar.dry { background: rgba(255,255,255,0.10); }
.nc-axis { display: flex; justify-content: space-between; margin-top: 7px; font-size: 0.78rem; color: var(--text-dim); }
.nc-axis span:first-child { color: var(--text); font-weight: 600; }

/* ---------- Map fullscreen ---------- */
#mapCard:fullscreen { padding: 14px; overflow-y: auto; background: rgba(6, 10, 22, 0.94); }
#mapCard:fullscreen #map { height: calc(100dvh - 170px); }

@media (prefers-reduced-motion: reduce) {
  .scene-pane.on { animation: none !important; }
  .scene-pane { transition: none !important; }
  #grade { transition: none !important; }
  #sky .star, #sky .cloud, #sky .streaks { animation: none !important; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- Map overlay legend ---------- */
.map-card { position: relative; }
.map-legend {
  position: absolute; left: 12px; bottom: 44px; z-index: 500;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 11px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  pointer-events: none;
}
.legend-bar { width: 84px; height: 8px; border-radius: 4px; }

/* ---------- Sun arc + UV curve cards ---------- */
#uvCurve { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
#sunArc { width: 100%; height: auto; display: block; margin: 2px 0 4px; }
.arc-horizon { stroke: rgba(255,255,255,0.55); stroke-width: 1.5; }
.arc-track { stroke: rgba(255,255,255,0.28); stroke-width: 2; stroke-dasharray: 5 5; }
.arc-sun { fill: #ffd60a; filter: drop-shadow(0 0 6px rgba(255,214,10,0.9)); }
#sunArc.is-night .arc-sun { fill: rgba(255,255,255,0.35); filter: none; }
#sunArc.is-night .arc-track { stroke: rgba(255,255,255,0.12); }
.sun-times { display: flex; justify-content: space-between; }
.sun-times > div { display: flex; flex-direction: column; }
.sun-times > div:last-child { text-align: right; }
.sun-times .cap { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; }
.sun-times #d-sun, .sun-times #d-sunset { font-size: 17px; font-weight: 700; }

/* ---------- Map expanded mode (works on iOS, no Fullscreen API needed) ---------- */
body.map-lock { overflow: hidden; }
.map-card.map-expanded {
  position: fixed; inset: 0; z-index: 2000;
  margin: 0; border-radius: 0; height: 100dvh; max-height: none;
  display: flex; flex-direction: column;
  background: rgba(6, 10, 22, 0.96);
}
.map-card.map-expanded #map { flex: 1 1 auto; height: auto; min-height: 0; border-radius: 0; }
.map-card.map-expanded .map-legend { bottom: 58px; }
/* Keep the header clear of the iPhone status bar / notch in expanded mode. */
.map-card.map-expanded .map-head {
  padding: calc(var(--sat) + 12px) 14px 10px;
}
.map-card.map-expanded .map-tools { flex-wrap: nowrap; }
.map-card.map-expanded .ghost-btn.small {
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- Hourly temp curve ---------- */
.hourly-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.hourly-scroll .hourly { overflow: visible; width: max-content; }
#hourlyCurve { display: block; width: 1676px; height: 60px; margin-top: 2px; }

/* ---------- Daily "now" dot on today's range bar ---------- */
.temp-now-dot {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.25);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}

/* ---------- Wind compass ---------- */
#windCompass { width: 64px; height: 64px; display: block; margin: 2px auto 0; }
.wc-ring { fill: none; stroke: rgba(255,255,255,0.25); stroke-width: 2; }
.wc-card { fill: rgba(255,255,255,0.6); font-size: 9px; text-anchor: middle; font-weight: 700; font-family: inherit; }
.wc-arrow { fill: #7cc4ff; }
.wc-hub { fill: rgba(255,255,255,0.85); }

/* ---------- AQI scale ---------- */
.aqi-scale {
  position: relative; height: 6px; border-radius: 3px; margin: 8px 0 4px;
  background: linear-gradient(90deg,
    #00e400 0%, #00e400 10%, #ffff00 10%, #ffff00 20%,
    #ff7e00 20%, #ff7e00 30%, #ff0000 30%, #ff0000 40%,
    #8f3f97 40%, #8f3f97 60%, #7e0023 60%, #7e0023 100%);
}
.aqi-marker {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.3);
  transform: translate(-50%, -50%); box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
