:root {
  --bg-top: #131c33;
  --bg-bottom: #0a0f1f;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f2f5ff;
  --muted: #8b93ad;
  --warm: #ffd166;
  --cool: #5cc8ff;
  --ok: #5fd08a;
  --off: #6b7390;
  --gap: clamp(12px, 2.2vh, 26px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-bottom);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

img { -webkit-user-drag: none; user-select: none; }

#app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  grid-template-rows: auto 2fr 1fr auto;
  grid-template-areas:
    "top      top"
    "now      forecast"
    "now      sun"
    "precip   precip";
  gap: var(--gap);
  padding: calc(env(safe-area-inset-top) + var(--gap))
           calc(env(safe-area-inset-right) + var(--gap))
           calc(env(safe-area-inset-bottom) + var(--gap))
           calc(env(safe-area-inset-left) + var(--gap));
  background: radial-gradient(120% 120% at 70% 0%, var(--bg-top), var(--bg-bottom) 70%);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: clamp(18px, 2.6vh, 30px);
}

/* Topbar */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(6px, 1vw, 14px);
}
.greeting { font-size: clamp(20px, 3.4vh, 34px); font-weight: 600; letter-spacing: 0.2px; }
.topbar-right { display: flex; align-items: center; gap: clamp(10px, 1.6vw, 20px); }
.clock { font-size: clamp(20px, 3.4vh, 34px); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px currentColor; color: var(--ok); }
.status-dot.offline { background: var(--off); color: var(--off); box-shadow: none; }

/* Now / hero */
.now {
  grid-area: now;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 28px);
  padding: clamp(10px, 2vh, 24px);
}
.now-icon { width: clamp(150px, 30vh, 300px); height: clamp(150px, 30vh, 300px); flex: 0 0 auto; }
.now-text { display: flex; flex-direction: column; }
.now-temp { font-size: clamp(64px, 15vh, 150px); font-weight: 700; line-height: 0.95; letter-spacing: -2px; }
.now-desc { font-size: clamp(26px, 4.6vh, 52px); font-weight: 600; margin-top: 0.1em; }
.now-feels { font-size: clamp(16px, 2.6vh, 28px); color: var(--muted); margin-top: 0.35em; }

/* Forecast */
.forecast { grid-area: forecast; display: flex; gap: var(--gap); }
.day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 1.6vh, 18px);
  gap: clamp(2px, 0.8vh, 8px);
}
.day-label { font-size: clamp(15px, 2.4vh, 26px); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.day-icon { width: clamp(70px, 13vh, 130px); height: clamp(70px, 13vh, 130px); }
.day-temps { display: flex; align-items: baseline; gap: 0.5em; }
.t-max { font-size: clamp(30px, 5vh, 56px); font-weight: 700; color: var(--warm); }
.t-min { font-size: clamp(20px, 3.4vh, 38px); font-weight: 600; color: var(--muted); }

/* Sun */
.sun { grid-area: sun; display: flex; align-items: center; justify-content: space-around; padding: clamp(6px, 1.4vh, 16px); }
.sun-item { display: flex; align-items: center; gap: clamp(6px, 1vw, 14px); }
.sun-icon { width: clamp(48px, 8.5vh, 86px); height: clamp(48px, 8.5vh, 86px); }
.sun-time { font-size: clamp(24px, 4vh, 44px); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Precip */
.precip { grid-area: precip; display: flex; flex-direction: column; padding: clamp(10px, 1.8vh, 20px) clamp(14px, 2vw, 26px); gap: clamp(6px, 1.2vh, 12px); }
.precip-head { display: flex; align-items: baseline; justify-content: space-between; }
.precip-title { font-size: clamp(16px, 2.6vh, 28px); font-weight: 600; }
.precip-summary { font-size: clamp(15px, 2.4vh, 26px); font-weight: 600; color: var(--cool); }
.precip-bars { flex: 1; display: flex; align-items: flex-end; gap: clamp(4px, 0.8vw, 10px); min-height: clamp(40px, 8vh, 90px); }
.precip-bars .bar {
  flex: 1;
  min-height: 4px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--cool), #2f7fb8);
  transition: height 0.5s ease;
}
.precip-bars .bar.dry { background: rgba(255, 255, 255, 0.08); }
.precip-axis { display: flex; justify-content: space-between; font-size: clamp(13px, 1.9vh, 20px); color: var(--muted); }

/* Stale data dim */
#app.stale .now-temp, #app.stale .now-icon { opacity: 0.85; }
