:root {
  --bg: #07090e;
  --ink: #f4f7fb;
  --muted: rgba(244, 247, 251, .68);
  --glass: rgba(12, 16, 24, .58);
  --glass-border: rgba(255, 255, 255, .14);
  --accent: #6fd0ff;
  --good: #3ddc8a;
  --warn: #f5c542;
  --bad: #ff6b6b;
  --shadow: 0 12px 40px rgba(0, 0, 0, .38);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body, #map { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: var(--font); overflow: hidden; }
body.light {
  --ink: #141820;
  --muted: rgba(20, 24, 32, .62);
  --glass: rgba(255, 255, 255, .66);
  --glass-border: rgba(20, 24, 32, .1);
  --shadow: 0 12px 36px rgba(20, 24, 32, .16);
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
button, input { font-family: inherit; }

#weather {
  position: absolute; z-index: 1000; top: 14px; left: 14px;
  width: min(320px, calc(100vw - 28px)); padding: 14px 16px 12px;
}
#weather .eyebrow {
  margin: 0; font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
#weather h1 { margin: 2px 0 2px; font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
#area-note { margin: 0 0 8px; font-size: .72rem; }
.wx-now { display: flex; gap: 12px; align-items: flex-start; }
.temp { font-size: 2.6rem; font-weight: 700; line-height: .95; letter-spacing: -.04em; }
#desc { font-size: .95rem; font-weight: 500; }
#wx-extra { font-size: .8rem; margin-top: 2px; }
.forecast {
  list-style: none; margin: 12px 0 0; padding: 10px 0 0;
  border-top: 1px solid var(--glass-border);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.forecast li { text-align: center; font-size: .75rem; }
.forecast .hi { font-weight: 600; display: block; margin-top: 2px; }
.alert-list { margin: 10px 0 0; display: grid; gap: 6px; }
.alert-pill {
  font-size: .75rem; padding: 6px 8px; border-radius: 10px;
  background: rgba(255, 107, 107, .16); border: 1px solid rgba(255, 107, 107, .35);
}
.alert-pill.watch { background: rgba(245, 197, 66, .16); border-color: rgba(245, 197, 66, .4); }
.alert-pill.statement, .alert-pill.advisory { background: rgba(111, 208, 255, .12); border-color: rgba(111, 208, 255, .3); }

#verdict {
  position: absolute; z-index: 1000; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  padding: 10px 16px; min-width: min(280px, 70vw); max-width: min(420px, calc(100vw - 28px));
}
#verdict i {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 197, 66, .25);
}
#verdict i[data-level="clear"] { background: var(--good); box-shadow: 0 0 0 4px rgba(61, 220, 138, .25); }
#verdict i[data-level="icy"] { background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 197, 66, .25); }
#verdict i[data-level="do_not_drive"] { background: var(--bad); box-shadow: 0 0 0 4px rgba(255, 107, 107, .25); }
#verdict strong { display: block; font-size: .95rem; font-weight: 650; }
#verdict small { display: block; color: var(--muted); font-size: .7rem; margin-top: 1px; line-height: 1.3; }

#search {
  position: absolute; z-index: 1000; top: 14px; right: 14px;
  display: flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px;
  width: min(260px, calc(100vw - 28px));
}
#search input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: inherit;
  font-size: 15px; padding: 8px 0; outline: none;
}
#search button, .text-btn, .icon-btn {
  border: 0; background: rgba(255,255,255,.12); color: inherit;
  border-radius: 11px; padding: 7px 10px; cursor: pointer; font-weight: 500;
}
body.light #search button, body.light .text-btn, body.light .icon-btn { background: rgba(0,0,0,.08); }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  list-style: none; margin: 0; padding: 6px;
  background: var(--glass); backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border); border-radius: 14px; box-shadow: var(--shadow);
}
.suggest li { padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: .9rem; }
.suggest li:hover, .suggest li.active { background: rgba(255,255,255,.12); }
body.light .suggest li:hover, body.light .suggest li.active { background: rgba(0,0,0,.08); }

#locate {
  position: absolute; z-index: 1000; top: 68px; right: 14px;
  width: 42px; height: 42px; display: grid; place-items: center; padding: 0;
}

#cams {
  position: absolute; z-index: 1000; top: 238px; left: 14px;
  width: min(300px, calc(100vw - 28px)); max-height: calc(100vh - 360px);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
#cams.collapsed { display: none; }
.cams-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cams-head h2 { margin: 0; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
#cam-count { margin: 2px 0 0; font-size: .75rem; }
#cam-filter {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid var(--glass-border);
  color: inherit; border-radius: 10px; padding: 7px 10px; font-size: .85rem; outline: none;
}
body.light #cam-filter { background: rgba(0,0,0,.05); }
#camlist { overflow: auto; min-height: 0; }
.hwy { margin: 0 0 8px; }
.hwy > button {
  width: 100%; text-align: left; background: transparent; color: inherit; border: 0;
  padding: 6px 4px; font-size: .72rem; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; cursor: pointer; color: var(--muted);
}
.cam {
  display: block; width: 100%; text-align: left; background: transparent; color: inherit;
  border: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: .9rem; line-height: 1.25;
}
.cam:hover, .cam.on { background: rgba(255,255,255,.14); }
body.light .cam:hover, body.light .cam.on { background: rgba(0,0,0,.08); }
.cam small { display: block; color: var(--muted); font-size: .72rem; }

#cams-open {
  display: none; position: absolute; z-index: 1000; left: 14px; bottom: 86px;
  padding: 10px 14px; font-weight: 600; cursor: pointer; border: 0; color: inherit;
}

#view {
  position: absolute; z-index: 1001; right: 14px; bottom: 86px;
  width: min(340px, calc(100vw - 28px)); padding: 10px;
}
#view img {
  width: 100%; height: 190px; object-fit: cover; border-radius: 12px; background: #111; display: block;
}
#view h3 { margin: 8px 6px 2px; font-size: 1rem; font-weight: 600; }
#view .muted, #view .credit { margin: 0 6px; font-size: .75rem; }
#view .credit { margin-top: 4px; font-weight: 600; }
#view-close { position: absolute; top: 16px; right: 16px; z-index: 2; }

#themes {
  position: absolute; z-index: 1000; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 5px; max-width: calc(100vw - 24px); overflow-x: auto;
}
#themes button {
  border: 0; background: transparent; color: inherit; padding: 8px 13px;
  border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
}
#themes button.on { background: rgba(255,255,255,.2); }
body.light #themes button.on { background: rgba(0,0,0,.1); }

#stamp {
  position: absolute; z-index: 900; left: 14px; bottom: 18px;
  margin: 0; padding: 6px 10px; font-size: 10px; max-width: 280px; line-height: 1.35;
}

.pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: #38bdf8; border: 2px solid #fff;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, .35);
}
.leaflet-container { font-family: var(--font); background: #0b0e14; }
.leaflet-control-attribution {
  background: rgba(12,16,24,.7) !important; color: #d5dbe6 !important;
  backdrop-filter: blur(8px); max-width: 55vw;
}
body.light .leaflet-control-attribution { background: rgba(255,255,255,.8) !important; color: #333 !important; }
.leaflet-control-zoom { border: 0 !important; margin-right: 14px !important; margin-bottom: 86px !important; }
.leaflet-control-zoom a {
  background: var(--glass) !important; color: var(--ink) !important;
  border: 1px solid var(--glass-border) !important; backdrop-filter: blur(18px);
}
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: rgba(56, 189, 248, .28);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: rgba(14, 28, 42, .86); color: #fff; font-family: var(--font);
}

.error-page { display: grid; place-items: center; min-height: 100vh; }
.error-page main { padding: 24px 28px; text-align: center; }
.error-page a { color: var(--accent); }

@media (max-width: 820px) {
  #verdict {
    top: auto; bottom: 86px; left: 14px; right: 14px; transform: none;
    max-width: none; width: auto;
  }
  #stamp { display: none; }
  #locate { top: 68px; }
}
@media (max-width: 560px) {
  #weather { top: 10px; left: 10px; width: calc(100vw - 76px); padding: 10px 12px; }
  #weather h1 { font-size: 1rem; margin-bottom: 4px; }
  .temp { font-size: 2rem; }
  .forecast { display: none; }
  #search { top: 10px; right: 10px; width: 48px; padding: 5px; }
  #search input, #search button { display: none; }
  #search.expanded { width: calc(100vw - 20px); left: 10px; right: 10px; padding: 5px 6px 5px 12px; }
  #search.expanded input, #search.expanded button { display: block; }
  #search:not(.expanded) { justify-content: center; cursor: pointer; }
  #search:not(.expanded)::after { content: "⌕"; font-size: 18px; line-height: 36px; }
  #locate { top: auto; bottom: 86px; right: 10px; }
  #cams {
    top: auto; left: 10px; right: 10px; bottom: 0;
    width: auto; max-height: 62vh; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
    display: none;
  }
  #cams.open { display: flex; }
  #locate { bottom: 108px; }
  #cams-open { display: block; left: 10px; bottom: 108px; }
  body.cams-open #cams-open { display: none; }
  #view { left: 10px; right: 10px; bottom: 108px; width: auto; }
  #view img { height: 160px; }
  #themes { bottom: 10px; left: 10px; right: 10px; transform: none; }
  #themes button { padding: 8px 9px; font-size: 12px; }
  .leaflet-bottom { bottom: 54px; }
  .leaflet-control-attribution {
    margin: 0 10px 0 0 !important;
    max-width: calc(100vw - 20px);
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #verdict { bottom: auto; top: auto; /* placed after weather via flow? keep mid */ top: 132px; left: 10px; right: 10px; }
  .leaflet-control-zoom { display: none; }
}
