:root {
  --bg: #f5f2ea;
  --card: #fffdf8;
  --ink: #1d1f1c;
  --muted: #6b6f68;
  --line: #e3ddd0;
  --pine: #1f3a2e;
  --sky: #2b4a6f;
  --accent: #b8552f;
  --bar-lo: #4f86c6;
  --bar-hi: #d9783f;
  --shadow: 0 1px 2px rgba(30, 30, 20, .06), 0 4px 16px rgba(30, 30, 20, .05);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d121c;
    --card: #151c29;
    --ink: #e8eaef;
    --muted: #9aa3b2;
    --line: #253043;
    --pine: #0f1a26;
    --accent: #e8906a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* Masthead */
.masthead {
  background: linear-gradient(180deg, var(--pine) 0%, var(--sky) 100%);
  color: #f3efe6;
  padding: 28px 0 26px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.masthead::after {
  /* stylised San Francisco Peaks silhouette */
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 46px;
  background: var(--bg);
  clip-path: polygon(0 100%, 0 78%, 12% 62%, 22% 74%, 34% 40%, 41% 52%, 47% 22%, 53% 38%, 58% 30%, 66% 58%, 76% 50%, 88% 70%, 100% 60%, 100% 100%);
  opacity: 1;
}
.masthead h1 {
  font: 700 clamp(2.3rem, 6vw, 3.6rem)/1.05 var(--serif);
  margin: 2px 0 6px;
  letter-spacing: -.01em;
}
.kicker { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; opacity: .85; }
.sub { margin: 0 0 26px; opacity: .85; font-size: .95rem; }

/* Alerts */
.alerts { margin-bottom: 18px; display: grid; gap: 10px; }
.alert {
  border-left: 5px solid #c0392b;
  background: color-mix(in srgb, #c0392b 10%, var(--card));
  border-radius: 10px;
  padding: 12px 16px;
}
.alert.moderate { border-color: #d68910; background: color-mix(in srgb, #d68910 10%, var(--card)); }
.alert.minor { border-color: #2e86c1; background: color-mix(in srgb, #2e86c1 9%, var(--card)); }
.alert summary { cursor: pointer; font-weight: 650; }
.alert summary small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.alert pre { white-space: pre-wrap; font: .9rem/1.5 var(--sans); margin: 10px 0 0; }

/* Grid & cards */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card h2 {
  font: 700 .78rem/1.2 var(--sans);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 0 0 14px;
}
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .85rem; margin: 14px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }
.err { color: var(--muted); font-size: .9rem; }

/* Now */
.now .hero { display: flex; align-items: center; gap: 14px; }
.now .temp { font: 700 4.2rem/1 var(--serif); letter-spacing: -.03em; }
.now .icon { font-size: 2.6rem; }
.now .desc { font-size: 1.1rem; margin: 6px 0 2px; }
.now .hilo { color: var(--muted); margin: 0 0 12px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0; }
.stats div { display: flex; flex-direction: column; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-weight: 600; }
.stamp { color: var(--muted); font-size: .8rem; margin: 12px 0 0; }

/* Sun */
.sunarc { width: 100%; height: auto; display: block; margin: 0 0 10px; }
.moonrow { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.moonrow .m { font-size: 2.2rem; line-height: 1; }

/* Air */
.aqi { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.aqi .num {
  font: 700 2.4rem/1 var(--serif);
  min-width: 74px; text-align: center;
  padding: 10px 8px; border-radius: 12px; color: #111;
}
.aqi .cat { font-weight: 650; }

/* Hourly */
.hours {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(58px, 1fr);
  overflow-x: auto;
  gap: 4px;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.hour { text-align: center; padding: 6px 2px; border-radius: 10px; }
.hour.night { background: color-mix(in srgb, var(--sky) 9%, transparent); }
.hour .h { font-size: .78rem; color: var(--muted); }
.hour .e { font-size: 1.35rem; margin: 2px 0; }
.hour .t { font-weight: 650; }
.hour .p { font-size: .75rem; color: var(--bar-lo); min-height: 1.1em; }
.hour .pbar { height: 34px; display: flex; align-items: flex-end; justify-content: center; margin-top: 4px; }
.hour .pbar i { display: block; width: 10px; border-radius: 3px 3px 0 0; background: var(--bar-lo); opacity: .75; }

/* Forecast */
.days { list-style: none; margin: 0; padding: 0; }
.days li { border-top: 1px solid var(--line); }
.days li:first-child { border-top: 0; }
.days summary {
  display: grid;
  grid-template-columns: 7.5rem 2rem minmax(0, 1fr) 3rem 2.6rem minmax(80px, 200px) 2.6rem;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}
.days summary::-webkit-details-marker { display: none; }
.days .dn { font-weight: 650; }
.days .de { font-size: 1.4rem; text-align: center; }
.days .ds { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.days .dp { color: var(--bar-lo); font-size: .85rem; text-align: right; }
.days .lo { color: var(--muted); text-align: right; }
.days .hi { font-weight: 650; }
.range { position: relative; height: 6px; background: var(--line); border-radius: 3px; }
.range i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--bar-lo), var(--bar-hi)); }
.days .detail { color: var(--ink); padding: 0 0 14px; margin: 0; font-size: .95rem; }
.days .detail b { display: block; font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* Stars */
.rating { font: 700 1.6rem/1.1 var(--serif); margin: 0 0 4px; }
.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 14px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #5b4b8a, #8fb3ff); }

/* Links */
.links ul { list-style: none; margin: 0; padding: 0; }
.links li { padding: 8px 0; border-top: 1px solid var(--line); }
.links li:first-child { border-top: 0; padding-top: 0; }
.links a { font-weight: 650; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.links span { display: block; color: var(--muted); font-size: .88rem; }

@media (min-width: 901px) {
  .links:last-child { grid-column: span 2; }
}

.footer { color: var(--muted); font-size: .85rem; padding-top: 22px; padding-bottom: 40px; }
.footer p { margin: 0 0 6px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .now { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .days .range, .days .ds { display: none; }
  .days summary { grid-template-columns: 6rem 2rem 1fr 2.6rem 2.6rem; }
}
