:root {
  --sky-top: #4a5568;
  --sky-bottom: #1c2431;
  --card-bg: rgba(60, 70, 90, 0.55);
  --card-border: rgba(255,255,255,0.08);
  --divider: rgba(255,255,255,0.12);
  --text-primary: #ffffff;
  --text-secondary: rgba(235,238,245,0.65);
  --text-tertiary: rgba(235,238,245,0.4);
  --accent-blue: #6fc8ff;
  --accent-cyan: #62e0d8;
  --accent-green: #8fe36a;
  --accent-amber: #ffd36a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  background: var(--sky-bottom);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app {
  position: fixed;
  inset: 0;
  /* dvh tracks the *visible* viewport on mobile browsers (accounts for the
     address bar showing/hiding), so the background no longer leaves a gap
     at the bottom the way a plain 100vh/inset:0 combo can on iOS/Android. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Sky background ---------- */
.sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 60% at 30% 0%, rgba(150,163,184,0.45), transparent 60%),
    radial-gradient(ellipse 100% 50% at 80% 10%, rgba(120,133,156,0.35), transparent 55%),
    linear-gradient(180deg, var(--sky-top) 0%, #34405a 35%, var(--sky-bottom) 70%);
  z-index: 0;
}
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 60% 15%, rgba(255,255,255,0.35), transparent),
    radial-gradient(1.5px 1.5px at 80% 40%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 40% 60%, rgba(255,255,255,0.25), transparent);
  opacity: 0.6;
  mix-blend-mode: overlay;
}
#rain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
}

/* ---------- Scroll container (handles bounce + pull to refresh) ---------- */
.scroll-area {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
}
.scroll-content {
  min-height: 100%;
  padding: calc(64px + var(--safe-top)) 16px calc(48px + var(--safe-bottom));
  transition: transform 0.25s cubic-bezier(.19,1,.22,1);
  will-change: transform;
}

/* ---------- Pull to refresh ---------- */
.ptr-indicator {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.ptr-indicator.visible { opacity: 1; }
.ptr-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  transform: rotate(0deg);
}
.ptr-spinner.spinning {
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Header ---------- */
.header {
  text-align: center;
  color: var(--text-primary);
  padding-bottom: 28px;
}
.my-location {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.city {
  margin: 0;
  font-size: clamp(28px, 9vw, 40px);
  font-weight: 500;
  letter-spacing: -0.3px;
  line-height: 1.1;
  text-shadow: 0 1px 12px rgba(0,0,0,0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.temp-line {
  margin-top: 10px;
  font-size: 19px;
  font-weight: 400;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  color: var(--text-primary);
}
.current-temp { font-weight: 600; }
.divider { color: var(--text-tertiary); }
.feels-like { color: var(--text-primary); }
.condition-text {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---------- Forecast Card ---------- */
.forecast-card, .precip-card {
  background: var(--card-bg);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--divider);
}

.forecast-list { padding: 0 16px; }

.forecast-row {
  display: grid;
  grid-template-columns: 62px 44px 30px 1fr 30px;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  color: var(--text-primary);
}
.forecast-row:last-child { border-bottom: none; }
.forecast-row.today .day-label { font-weight: 700; }

.day-label {
  font-size: 17px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.weather-icon { width: 26px; height: 26px; display: block; }
.precip-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-cyan);
  min-height: 13px;
}

.temp-min, .temp-max {
  font-size: 17px;
  text-align: right;
}
.temp-min { color: var(--text-secondary); text-align: left; }
.temp-max { color: var(--text-primary); font-weight: 500; }

.bar-track {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.12);
}
.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
}
.bar-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
  transform: translate(-50%, -50%);
}

/* ---------- Precipitation card ---------- */
.precip-text {
  margin: 0;
  padding: 14px 16px 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.hourly-scroll {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 4px;
  padding: 6px 12px 18px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.hourly-scroll::-webkit-scrollbar { display: none; }

.hour-cell {
  flex: 0 0 auto;
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  scroll-snap-align: start;
}
.hour-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.hour-cell.now .hour-time { color: var(--text-primary); font-weight: 700; }
.hour-cell .weather-icon { width: 24px; height: 24px; }
.hour-precip {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent-cyan);
  min-height: 12px;
}
.hour-temp {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 6px;
}

/* ---------- Details card ---------- */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--divider);
}
.detail-tile {
  background: rgba(40,48,64,0.35);
  padding: 12px 16px 14px;
}
.detail-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.detail-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
}
.detail-value .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 2px;
}
.detail-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: rgba(30,34,44,0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Loading skeleton ---------- */
.skeleton {
  opacity: 0.5;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.6; }
}
.forecast-row.loading * { animation: pulse 1.4s ease-in-out infinite; }

@media (min-width: 480px) {
  .scroll-content { max-width: 460px; margin: 0 auto; }
}
