:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #090d14;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: #090d14; color: #fff; }
button, input, select { font: inherit; }

.app-shell { position: relative; min-height: 100vh; overflow-x: hidden; overflow-y: auto; }
.sky { position: fixed; inset: 0; overflow: hidden; background: #090d14; }
.sky-media, .sky-gradient { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-media { object-fit: cover; opacity: 0; transition: opacity 300ms ease; }
.sky.has-image .sky-image, .sky.has-video .sky-video { opacity: 0.72; }
.sky.has-video .sky-image { opacity: 0; }
.sky-gradient { background: linear-gradient(180deg, #3b6fd9, #4a8bd9 55%, #6ab3e0); transition: background 250ms ease, opacity 250ms ease; }
.sky.has-image .sky-gradient, .sky.has-video .sky-gradient { opacity: 0.58; }
.sky[data-condition="rain"] .sky-gradient { background: linear-gradient(180deg, #283846, #405060 55%, #5e6d7a); }
.sky[data-condition="thunderstorm"] .sky-gradient { background: linear-gradient(180deg, #1a1d2e, #30324a 55%, #4a4e6b); }
.sky[data-condition="snow"] .sky-gradient { background: linear-gradient(180deg, #5f7890, #a8bcce 55%, #e4ecf2); }
.sky[data-condition="fog"] .sky-gradient { background: linear-gradient(180deg, #8c8f94, #b3b5b9 55%, #d8d9da); }
.sky[data-condition="cloudy"] .sky-gradient, .sky[data-condition="overcast"] .sky-gradient { background: linear-gradient(180deg, #4b5765, #6c7682 55%, #8e969f); }
.sky[data-condition="windy"] .sky-gradient { background: linear-gradient(180deg, #4a7394, #7ba2c4 55%, #c2d2df); }
.sky[data-condition="hot"] .sky-gradient { background: linear-gradient(180deg, #c05a34, #e08a3e 55%, #f5c668); }
.veil { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(10,14,24,0.08), rgba(10,14,24,0.58) 45%, rgba(10,14,24,0.9)); }

.topbar { position: fixed; top: env(safe-area-inset-top, 0); left: 0; right: 0; z-index: 30; display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 14px 16px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.pill { border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.14); color: #fff; border-radius: 999px; min-height: 38px; padding: 8px 12px; backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
.icon-pill { width: 38px; padding: 0; }
.location-pill { display: flex; align-items: center; gap: 8px; max-width: min(52vw, 250px); text-align: left; }
.location-city, .location-region { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-city { font-weight: 700; font-size: 13px; }
.location-region { color: rgba(255,255,255,0.62); font-size: 11px; }

.content { position: relative; z-index: 10; min-height: 100vh; padding-top: calc(82px + env(safe-area-inset-top, 0)); }
.empty-state, .loading-state { min-height: calc(100vh - 100px); display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; text-align: center; }
.mark { width: 78px; height: 78px; display: grid; place-items: center; border-radius: 24px; background: linear-gradient(135deg, #4a8bff, #7e5bff); font-weight: 900; letter-spacing: -0.08em; }
.primary-button { border: 0; border-radius: 999px; padding: 13px 18px; background: #fff; color: #0c1220; font-weight: 800; }
.build-marker { color: rgba(255,255,255,0.42); font-size: 11px; }
.progress-track { width: min(240px, 70vw); height: 5px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.2); }
.progress-bar { width: 0%; height: 100%; background: #fff; transition: width 150ms linear; }
.loading-state .mark { animation: loading-pulse 1.4s ease-in-out infinite; }
.loading-state p { max-width: 280px; color: rgba(255,255,255,0.76); }

@keyframes loading-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(126,91,255,0); }
  50% { transform: scale(1.05); box-shadow: 0 0 42px rgba(126,91,255,0.36); }
}

.forecast { max-width: 460px; margin: 0 auto; padding: 0 20px 44px; }
.hero { text-align: center; padding: 18px 0 24px; }
.hero-date, .hero-byline, .meta { color: rgba(255,255,255,0.62); font-size: 12px; }
.hero h1 { margin: 6px 0; font-size: 30px; line-height: 1.08; }
.section { border-top: 1px solid rgba(255,255,255,0.16); padding: 22px 0; }
.lede { border-top: 0; text-align: center; font-weight: 600; }
.eyebrow, .label { color: rgba(255,255,255,0.62); text-transform: uppercase; letter-spacing: 0.16em; font-size: 10px; font-weight: 800; }
.current-card { padding: 14px 16px 16px; border: 1px solid rgba(255,255,255,0.18); border-radius: 24px; background: rgba(255,255,255,0.12); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
.current-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: 18px; align-items: center; margin-top: 8px; }
.temperature { font-size: 64px; line-height: 0.95; font-weight: 200; letter-spacing: -0.06em; }
.temperature span:last-child { font-size: 28px; color: rgba(255,255,255,0.65); vertical-align: top; }
.condition { color: rgba(255,255,255,0.82); }
.stats { display: grid; gap: 14px; align-self: center; }
.stats strong, .stats small { display: block; }
.stats strong { margin-top: 4px; font-size: 22px; }
.stats small { color: rgba(255,255,255,0.56); }
.live-dot { margin-left: 6px; color: #72ffab; }
.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.day-card { border-radius: 18px; padding: 12px 8px; text-align: center; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.16); }
.day-card strong, .day-card span { display: block; }
.day-card small { color: rgba(255,255,255,0.58); }
.hourly-head, .hourly-row { display: grid; grid-template-columns: 54px 52px 1fr 66px; gap: 8px; align-items: center; }
.hourly-head { padding-bottom: 8px; color: rgba(255,255,255,0.58); text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; font-weight: 800; }
.hourly-row { padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }
.hourly-row span:last-child { text-align: right; color: rgba(255,255,255,0.68); }
.alerts-list { display: grid; gap: 8px; margin-top: 10px; }
.alert-card { border-radius: 16px; padding: 12px; background: rgba(255,178,74,0.16); border: 1px solid rgba(255,210,137,0.28); }
.signoff p { font-style: italic; }
.signoff-name { color: #9fb8ff; font-weight: 900; letter-spacing: 0.22em; text-transform: uppercase; font-size: 12px; }
.meta { text-align: center; line-height: 1.6; border-top: 1px solid rgba(255,255,255,0.16); padding-top: 20px; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.42); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 76vh; overflow: auto; border-radius: 28px 28px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0)); background: rgba(16,20,30,0.96); border: 1px solid rgba(255,255,255,0.14); }
.grabber { width: 44px; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.28); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.close-sheet { border: 0; color: #fff; background: rgba(255,255,255,0.12); border-radius: 999px; width: 34px; height: 34px; }
.search-box { display: flex; gap: 8px; align-items: center; margin: 14px 0; padding: 12px; border-radius: 16px; background: rgba(255,255,255,0.1); }
.search-box input, .setting-row input, .setting-row select { width: 100%; border: 0; outline: 0; background: transparent; color: #fff; }
.sheet-list { display: grid; gap: 8px; }
.sheet-row, .location-row, .setting-row { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.08); color: #fff; border-radius: 16px; padding: 12px; text-align: left; }
.sheet-row span, .sheet-note { color: rgba(255,255,255,0.62); font-size: 12px; }
.sheet-section-title { color: rgba(255,255,255,0.5); font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; margin: 12px 4px 4px; }

.debug-panel { position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 90; max-height: 46vh; display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,0.22); border-radius: 16px; background: rgba(4,8,14,0.94); color: #dce8ff; box-shadow: 0 18px 60px rgba(0,0,0,0.45); }
.debug-panel[hidden] { display: none; }
.debug-toggle { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0)); z-index: 91; border: 1px solid rgba(255,255,255,0.22); border-radius: 999px; background: rgba(4,8,14,0.88); color: #fff; padding: 9px 12px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.debug-toggle[hidden] { display: none; }
.debug-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.12); font-size: 12px; }
.debug-head div { display: flex; gap: 6px; }
.debug-head button { border: 1px solid rgba(255,255,255,0.2); border-radius: 999px; background: rgba(255,255,255,0.1); color: #fff; padding: 5px 8px; font-size: 11px; }
#debugLog { margin: 0; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@media (min-width: 760px) {
  body { display: grid; place-items: center; }
  .app-shell { width: 402px; min-height: 0; height: 874px; max-height: 92vh; border-radius: 44px; overflow-x: hidden; overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,0.5); }
  .app-shell::-webkit-scrollbar { width: 0; }
  .app-shell { scrollbar-width: none; }
  .sky, .veil { position: absolute; }
  .topbar { position: absolute; }
  .sheet, .sheet-backdrop { left: 50%; right: auto; width: 402px; transform: translateX(-50%); }
  .sheet-backdrop { top: auto; bottom: 0; height: 874px; max-height: 92vh; border-radius: 44px; }
  .debug-panel { left: 50%; right: auto; width: 382px; transform: translateX(-50%); }
  .debug-toggle { left: 50%; right: auto; transform: translateX(126px); }
}
