:root {
  --navy: #0B1626; --navy-light: #132238; --navy-mid: #1A2B42;
  --gold: #D4AF37; --silver: #A8B5C4; --white: #F8F9FA; --line: #2A3A52;
  --go: #2fa35a; --caution: #e0a526; --nogo: #d6453d; --rail: minmax(240px, 18.5rem);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--white);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { height: 100vh; height: 100dvh; overflow: hidden; }
a { color: var(--gold); }
button { font: inherit; }
.small { font-size: 0.72rem; }
.quiet { color: var(--silver); }
.mini { font-size: 0.75em; }

.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 8px;
  padding: 8px 10px 6px; padding-top: max(8px, env(safe-area-inset-top)); }

/* Header */
.header { display: flex; align-items: center; gap: 12px; padding: 0 4px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.logo { font-size: clamp(1.35rem, 2.2vw, 1.9rem); font-weight: 800; letter-spacing: -0.03em; color: var(--white); }
.sub { color: var(--gold); font-size: clamp(0.8rem, 1.1vw, 1rem); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.tabs { display: flex; background: var(--navy-light); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { background: none; border: 0; color: var(--silver); padding: 5px 14px; border-radius: 999px; cursor: pointer; font-weight: 650; font-size: 0.9rem; }
.tabs button[aria-selected="true"] { background: var(--gold); color: var(--navy); }
.place { background: var(--navy-light); border: 1px solid var(--line); color: var(--white); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 0.9rem; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place:hover { border-color: var(--gold); }
#live-date { margin-left: auto; font-size: clamp(1.05rem, 1.8vw, 1.6rem); font-weight: 650; letter-spacing: -0.02em; white-space: nowrap; }

/* Main: rail + radar */
.main { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: 8px; min-height: 0; }
.rail { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.rail.scrollable { overflow-y: auto; }
.panel { background: var(--navy-light); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; flex: 0 0 auto; }
.label { color: var(--gold); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }

/* Current */
.clock-row, .temp-row { display: flex; align-items: flex-start; line-height: 0.85; }
#live-time, #current-temp { font-size: clamp(3.4rem, 7vh, 5.4rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.deg { font-size: 1.15rem; color: var(--silver); margin-top: 0.35em; font-weight: 600; }
#condition-icon { font-size: clamp(2.4rem, 5.5vh, 3.6rem); line-height: 1; }
.now-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.wind-now { display: flex; align-items: center; gap: 12px; margin: 6px 0 2px; }
.wind-arrow-wrap { width: clamp(2.9rem, 6.15vh, 4.7rem); height: clamp(2.9rem, 6.15vh, 4.7rem); flex: 0 0 clamp(2.9rem, 6.15vh, 4.7rem); display: grid; place-items: center;
  background: var(--navy-mid); border-radius: 50%; border: 1px solid var(--line); }
#wind-arrow { width: 78%; height: 78%; color: var(--gold); transition: transform 0.4s ease; }
.wind-text { min-width: 0; }
.spd { display: flex; align-items: flex-start; font-size: clamp(2.9rem, 6.15vh, 4.7rem); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 0.85; white-space: nowrap; }
.wind-unit { font-size: 0.78rem; color: var(--silver); margin: 0.5em 0 0 0.18em; font-weight: 600; letter-spacing: 0.02em; line-height: 1; }
.from { color: var(--silver); font-size: 1.05rem; font-weight: 650; margin-top: 0.15em; }
#feels-like { color: var(--silver); font-size: 0.98rem; margin-top: 2px; }
.now-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-top: 6px; font-size: 0.98rem; }
.now-meta span { color: var(--silver); }
.now-meta b { font-weight: 600; color: var(--white); }
.now-meta .span { grid-column: 1 / -1; }
#last-updated { font-size: 0.7rem; }

/* Version panels */
.vhead { display: flex; justify-content: space-between; align-items: baseline; }
.wear-visuals { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.clothing-visual { display: flex; align-items: center; gap: 12px; background: var(--navy-mid); border-radius: 10px; padding: 6px 10px; }
.clothing-visual .emo { font-size: 3.4rem; line-height: 1; }
.clothing-visual .cap { font-size: 0.95rem; color: var(--silver); font-weight: 600; }
.recs { font-size: 0.78rem; line-height: 1.28; }
.recs div { margin: 0 0 2px; }
.badge { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 6px 10px; margin: 6px 0 4px; background: var(--navy-mid); border-left: 6px solid var(--silver); }
.badge .big { font-size: 1.6rem; font-weight: 850; letter-spacing: -0.02em; white-space: nowrap; }
.badge .why { font-size: 0.8rem; color: var(--silver); line-height: 1.25; }
.badge.go { border-color: var(--go); } .badge.go .big { color: var(--go); }
.badge.caution { border-color: var(--caution); } .badge.caution .big { color: var(--caution); }
.badge.nogo { border-color: var(--nogo); } .badge.nogo .big { color: var(--nogo); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 0.92rem; margin-top: 6px; align-items: baseline; }
.kv .k { color: var(--silver); }
.kv .v { font-weight: 650; }
.sev-normal { color: var(--go); } .sev-alert { color: var(--caution); } .sev-danger { color: #f07b3f; } .sev-emergency { color: var(--nogo); }
.sub-label { margin-top: 8px; }
.fire { font-size: 0.85rem; margin-top: 2px; }
.fire .ev { color: #ff8a5c; font-weight: 700; }
.foot { font-size: 0.66rem; color: var(--silver); line-height: 1.25; margin-top: 6px; }

/* 5-day */
#forecast-5day { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; margin-top: 6px; width: 100%; text-align: center; }
.week { padding: 7px 8px 8px; }
.day-cell { min-width: 0; padding: 2px 0; }
.day-cell .d { color: var(--silver); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.02em; }
.day-cell .i { font-size: 1.31rem; line-height: 1.15; }
.day-cell .hl { font-size: 0.88rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-cell .r { color: var(--silver); font-size: 0.73rem; }

/* Alerts */
.alerts { flex: 1 1 auto; min-height: 2.4rem; }
#advisory-body { font-size: 0.78rem; line-height: 1.25; }
.alert-event { font-weight: 700; color: #fbbf24; }
.alert-sev { color: var(--silver); font-size: 0.7rem; }
.alert-head { color: var(--silver); font-size: 0.72rem; margin: 0 0 4px; }
.alert-note { font-size: 0.62rem; color: var(--silver); margin-top: 4px; opacity: 0.85; }

/* Radar */
.radar { position: relative; min-height: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #888888; }
#map { position: absolute; inset: 0; background: #888888; }
.radar-chrome { position: absolute; top: 8px; left: 10px; z-index: 500; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.radar-chrome .label, .chip { background: rgba(11, 22, 38, 0.82); padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }
.chip { color: var(--silver); font-size: 0.72rem; }
.leaflet-container { font: inherit; }
.maplibregl-map, .maplibregl-canvas, .leaflet-pane .maplibregl-map { background: #888888; }
/* CARTO fallback only: invert the dark raster and lift it toward the same mid-gray. Radar is in its own pane, so it is not filtered. */
.leaflet-layer.carto-basemap { filter: grayscale(1) invert(1) brightness(0.55) contrast(0.95); }
/* MapLibre's auto-credit is hidden so one Leaflet bar can show the exact required wording. */
.maplibregl-ctrl-attrib { display: none; }
.leaflet-control-attribution { background: rgba(11,22,38,0.75) !important; color: var(--silver) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--gold) !important; }

/* Hourly strip */
.hourly { background: var(--navy-light); border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 6px; min-height: 0; }
.hourly-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 2px; }
#hourly-body { display: flex; width: 100%; }
.hour-cell { flex: 1 1 0; min-width: 0; text-align: center; padding: 2px 0 1px; border-left: 1px solid var(--line); }
.hour-cell:first-child { border-left: 0; }
.hour-cell .t { color: var(--silver); font-size: 0.62rem; font-weight: 650; letter-spacing: 0.02em; }
.hour-cell .i { font-size: 1rem; line-height: 1.15; }
.hour-cell .v { font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hour-cell .w, .hour-cell .p { color: var(--silver); font-size: 0.62rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; line-height: 1.15; }
.hour-cell .p { color: #7cc4ff; }

/* Footer */
.footer { text-align: center; color: var(--silver); font-size: 0.62rem; line-height: 1.25; padding-bottom: 1px; }
.footer .disclaimer { margin-bottom: 2px; }
.footer .credits a { color: var(--gold); text-decoration: none; }
.footer .credits a:hover { text-decoration: underline; }
.privacy { max-width: 70rem; margin: 4px auto 0; text-align: left; background: var(--navy-light); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

/* Dialogs */
.overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(5, 10, 18, 0.78); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.dialog { background: var(--navy-light); border: 1px solid var(--gold); border-radius: 16px; padding: 22px 24px; width: min(26rem, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.dialog .logo { font-size: 1.9rem; }
.dialog .ask { display: block; margin: 16px 0 8px; color: var(--silver); }
#zip-input { width: 100%; font-size: 1.8rem; text-align: center; letter-spacing: 0.2em; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--navy); color: var(--white); }
#zip-input:focus { outline: 2px solid var(--gold); }
.error { color: #ff8a80; min-height: 1.2em; margin: 8px 0; font-size: 0.9rem; }
.btns { display: flex; gap: 10px; justify-content: center; margin: 10px 0 8px; flex-wrap: wrap; }
.primary, .ghost { border-radius: 999px; padding: 10px 20px; font-weight: 700; cursor: pointer; text-decoration: none; font-size: 1rem; }
.primary { background: var(--gold); color: var(--navy); border: 0; }
.ghost { background: none; color: var(--silver); border: 1px solid var(--line); }
.tip-emoji { font-size: 2.2rem; }
.tip-title { color: var(--gold); font-weight: 800; font-size: 1.3rem; margin: 6px 0; }
.dialog.tip p { line-height: 1.45; font-size: 1.05rem; margin: 8px 0 14px; }

/* Kiosk: big type for wall screens; same single Pi-width rail so the map stays large */
.kiosk { --rail: minmax(240px, 296px); } /* 18.5rem at 16px, same as the Pi column */
.kiosk .tabs, .kiosk .place { display: none; }
html.kiosk { font-size: 18px; }
.kiosk .now-meta, .kiosk #feels-like { font-size: 1.25rem; }
.kiosk .recs, .kiosk .kv, .kiosk #advisory-body { font-size: 1.05rem; }
.kiosk .badge .why { font-size: 0.95rem; }
.kiosk .hour-cell .t, .kiosk .hour-cell .w, .kiosk .hour-cell .p { font-size: 0.82rem; }
.kiosk .hour-cell .v { font-size: 1.05rem; } .kiosk .hour-cell .i { font-size: 1.3rem; }
.kiosk .day-cell .hl { font-size: 1.3rem; } .kiosk .day-cell .i { font-size: 2rem; }
.kiosk .footer { font-size: 0.66rem; }

/* Tablet: same Pi format, slightly narrower rail.
   Let the page scroll so Ranch/Farm alerts stay fully visible instead of
   being clipped at the bottom of a fixed-height rail. */
@media (max-width: 1100px) and (min-width: 641px) {
  :root { --rail: clamp(280px, 38vw, 340px); }
  body { overflow: auto; height: auto; }
  .app { height: auto; min-height: 100dvh; }
  .rail { overflow: visible; }
  .radar { min-height: 420px; }
  .header { gap: 8px; }
  .hour-cell .w { font-size: 0.56rem; letter-spacing: -0.04em; }
  #live-time, #current-temp { font-size: 3.6rem; }
  .spd { font-size: 3.1rem; }
  .wind-arrow-wrap { width: 3.1rem; height: 3.1rem; }
  #condition-icon { font-size: 2.6rem; }
  .clothing-visual .emo { font-size: 2.6rem; }
  .now-meta { font-size: 1rem; }
  .kv { font-size: 0.85rem; }
  .badge .big { font-size: 1.3rem; }
}

/* Phone: one column */
@media (max-width: 640px) {
  body { overflow: auto; height: auto; }
  .app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  .main, .rail { display: contents; }
  .header { order: 0; } .current { order: 1; } .version { order: 2; } .radar { order: 3; height: 52vh; min-height: 300px; }
  .hourly { order: 4; } .week { order: 5; } .alerts { order: 6; } .footer { order: 7; padding-bottom: env(safe-area-inset-bottom); }
  .header { justify-content: space-between; }
  #live-date { margin-left: 0; font-size: 1rem; }
  .tabs { order: 3; width: 100%; } .tabs button { flex: 1; }
  #hourly-body { overflow-x: auto; scrollbar-width: thin; }
  .hour-cell { flex: 0 0 3.4rem; }
}

/* Compact the single rail when it would overflow, instead of adding a second column. */
.rail.compact { gap: 6px; }
.rail.compact .panel { padding: 6px 8px; }
.rail.compact #live-time, .rail.compact #current-temp { font-size: clamp(2.5rem, 5vh, 4rem); }
.rail.compact .spd { font-size: clamp(2.1rem, 4.6vh, 3.4rem); }
.rail.compact .wind-arrow-wrap { width: clamp(2.2rem, 4.4vh, 3.2rem); height: clamp(2.2rem, 4.4vh, 3.2rem); }
.rail.compact #condition-icon { font-size: clamp(1.8rem, 3.8vh, 2.6rem); }
.rail.compact .clothing-visual { padding: 4px 8px; gap: 8px; }
.rail.compact .clothing-visual .emo { font-size: 2.1rem; }
.rail.compact .now-meta, .rail.compact #feels-like { font-size: 0.95rem; }
.rail.compact .badge { padding: 4px 8px; margin: 4px 0 2px; gap: 8px; }
.rail.compact .badge .big { font-size: 1.2rem; }
.rail.compact .badge .why { font-size: 0.72rem; }
.rail.compact .kv { font-size: 0.78rem; gap: 1px 8px; margin-top: 4px; }
.rail.compact .recs { font-size: 0.76rem; }
.rail.compact .day-cell .i { font-size: 1.28rem; }
.rail.compact .day-cell .hl { font-size: 0.95rem; }
.rail.compact .day-cell .d, .rail.compact .day-cell .lo, .rail.compact .day-cell .r { font-size: 0.82rem; }
.rail.compact .sub-label { margin-top: 4px; }

/* Go/no-go (and farm spray) details: collapsible when the rail is tight */
.more { margin-top: 4px; }
.more > summary {
  color: var(--gold); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; cursor: pointer; list-style: none; user-select: none;
}
.more > summary::-webkit-details-marker, .more > summary::marker { display: none; content: ""; }
.more > summary::after { content: " ▾"; }
.more:not([open]) > summary::after { content: " ▸"; }

