:root {
  color-scheme: light;
  --ink: #302832;
  --muted: #665760;
  --pink: #873b62;
  --line: #e9dde3;
  --paper: #fffcfa;
  background: #faf7f4;
  color: var(--ink);
  font: 16px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.wrap { width: min(1100px, calc(100% - 40px)); margin-inline: auto; }
.hero {
  overflow: hidden;
  isolation: isolate;
  position: relative;
  background-color: #fffaf4;
  background-image: linear-gradient(90deg, #fffaf4 5%, #fffaf4f5 36%, #fffaf438 64%, transparent 80%),
    url("/magnolia-hero.jpg");
  background-position: center, right 44%;
  background-size: cover, auto max(540px, 65vw);
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--line);
}
.hero-content { position: relative; padding-block: clamp(40px, 7vw, 88px) clamp(36px, 6vw, 72px); }
h1, h2 { font-family: Georgia, serif; font-weight: 400; line-height: 1.08; }
h1 { font-size: clamp(2.5rem, 6.5vw, 5rem); letter-spacing: -.055em; margin: 0 0 20px; }
h2 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.035em; }
h3 { margin: 0; font-weight: 600; font-size: .95rem; }
a { color: var(--pink); text-underline-offset: 3px; }
.hero p { margin: 4px 0; color: #4e4350; font-size: .95rem; }
main { padding-block: 24px 56px; }
section + section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head > span, .state, .limits, .chart-note { color: var(--muted); font-size: .86rem; }
.sensors { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.sensor, .chart-card { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); padding: 16px; }
.reading { white-space: nowrap; margin-top: 6px; }
.value { font-size: clamp(1.15rem, 2.6vw, 1.8rem); font-variant-numeric: tabular-nums; }
.reading span { color: var(--muted); font-size: .8rem; }
.state { min-height: 1.3em; }
.limits { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; column-gap: 8px; }
button, select { background: #fff9fb; border: 1px solid #cdaabf; border-radius: 8px; color: #67304c; font: inherit; padding: 7px 12px; }
button { cursor: pointer; }
.camera { display: grid; place-items: center; border-radius: 18px; overflow: hidden; background: #e8ebe3; min-height: 160px; text-align: center; }
.camera img { display: block; width: 100%; max-height: 65vh; object-fit: contain; background: #242426; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sensor-chart { min-width: 0; }
.sensor-chart h3 { font-size: 1.15rem; }
.sensor-chart h3 span { color: var(--muted); font-size: .85rem; font-weight: 400; }
.chart-controls { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.chart-controls button { padding: 5px 9px; font-size: .84rem; }
.chart-controls button[aria-pressed="true"] { background: #803553; border-color: #803553; color: white; }
.chart-note { min-height: 1.5em; }
@media (max-width: 720px) { .chart-grid { grid-template-columns: 1fr; } }
canvas { display: block; width: 100%; height: 260px; }
.admin h1 { font-size: clamp(2rem, 5vw, 4rem); margin-top: 20px; }
dt { color: var(--muted); }
dd { margin: 0 0 8px; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { padding: 9px; border-bottom: 1px solid var(--line); }
@media (max-width: 960px) { .sensors { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 540px) { .sensors { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sensor { padding: 12px; } }
.camera-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.camera-tile { display: block; text-align: left; padding: 0; overflow: hidden; border-color: var(--line); background: var(--paper); border-radius: 16px; }
.camera-tile:disabled { cursor: default; color: var(--muted); }
.camera-thumb { display: grid; place-items: center; aspect-ratio: 16 / 9; text-align: center; background: #e8ebe3; color: var(--muted); }
.camera-thumb img { width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.camera-placeholder { padding: 8px; font-size: .88rem; }
.camera-name { display: block; padding: 10px 14px; overflow-wrap: anywhere; }
#camera-dialog { width: min(860px, calc(100% - 32px)); max-height: calc(100% - 32px); border-radius: 16px; border: 1px solid var(--line); padding: 16px; background: var(--paper); color: var(--ink); }
#camera-dialog::backdrop { background: rgb(42 30 39 / 70%); }
.site-footer { border-top: 1px solid var(--line); padding-block: 20px; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.camera-form { display: grid; gap: 8px; max-width: 600px; }
.camera-form input:is([type="url"], [type="text"]) { min-width: 0; border: 1px solid #cdaabf; border-radius: 8px; color: var(--ink); font: inherit; padding: 7px 12px; }
.camera-form button { justify-self: start; margin-top: 8px; }

@media (max-width: 540px) {
  .hero {
    background-image: linear-gradient(90deg, #fffaf4f5 12%, #fffaf4be 55%, #fffaf441),
      url("/magnolia-hero.jpg");
    background-position: center, 67% center;
    background-size: cover;
  }
}

.pm-gauge svg{display:block;width:100%;max-width:220px;margin:auto}.pm-gauge small,.pm-mean{display:block;font-size:.8rem;color:#60535a}.pm-mean{margin:.4rem 0}.sensor-icon{font-size:1.2em}

.caqi-scale{position:relative;margin:2rem 0 .4rem;height:18px;border-radius:8px;background:linear-gradient(to right,#32934b 0 20%,#9bc74b 20% 40%,#f4d03f 40% 60%,#f28c28 60% 80%,#dc2626 80% 100%)}#air-marker{position:absolute;top:-1.5rem;transform:translateX(-50%);color:#342b34}.caqi-labels{display:flex;justify-content:space-between;font-size:.8rem}

/* Explicit homepage section order */
#weather-main { display: flex; flex-direction: column; }
#weather-main > section { order: 0; }
#weather-main > #air-section { order: 1; }
#weather-main > #camera-section { order: 2; }
#weather-main > section[aria-labelledby="history-title"] { order: 3; }
