:root{
  --bg: #0b1021;
  --panel: rgba(16, 24, 40, 0.86);
  --panel2: rgba(16, 24, 40, 0.65);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --accent: #22c55e;
  --warn: #f59e0b;
  --bad: #fb7185;
}

[data-theme="light"]{
  --bg: #f6f7fb;
  --panel: rgba(255,255,255,0.92);
  --panel2: rgba(255,255,255,0.70);
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --accent: #16a34a;
  --warn: #b45309;
  --bad: #be123c;
}

*{box-sizing:border-box}
html{ overflow-x: hidden; }
.hidden{ display:none !important; }
*:focus-visible{
  outline: 2px solid rgba(245,158,11,0.8);
  outline-offset: 2px;
}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color:var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(245,158,11,0.10), transparent 35%),
    radial-gradient(circle at 80% 0%, rgba(99,102,241,0.12), transparent 40%),
    var(--bg);
}

.offline{
  position: sticky;
  top: 0;
  z-index: 120;
  background: rgba(190,18,60,0.18);
  border-bottom: 1px solid rgba(190,18,60,0.45);
  backdrop-filter: blur(8px);
}
.offline-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 14px;
  display:flex;
  gap:10px;
  align-items:center;
  color: var(--text);
}

.snowfx{
  pointer-events:none;
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  opacity: 0;
  transition: opacity 250ms ease;
}
body.snowing .snowfx{ opacity: 0.9; }
.flake{
  position:absolute;
  top:-20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(226,232,240,0.85);
  filter: blur(0.2px);
  animation: fall linear infinite;
}
@keyframes fall{
  to { transform: translateY(110vh); }
}

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  backdrop-filter: blur(10px);
  background: rgba(2, 6, 23, 0.55);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .topbar{ background: rgba(255,255,255,0.60); }

.topbar-inner{
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:12px 14px;
  flex-wrap: wrap;
}
.brand-title{font-weight:700; letter-spacing:0.2px}
.brand-sub{font-size:12px; color:var(--muted)}

.controls{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.select,.input{
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
  min-width: 0;
}
.input{ width: 240px; max-width: 100%; }
.btn{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(34,197,94,0.18), rgba(34,197,94,0.10));
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor:pointer;
}
.btn:hover{ border-color: rgba(34,197,94,0.45); }
.btn-secondary{ background: var(--panel2); }
.btn-sm{ padding: 6px 10px; font-size: 12px; }
.search{ display:flex; gap:8px; align-items:center; }
.search .input{ flex: 1 1 auto; }

.top-search{ width: min(520px, 100%); }
.card-hd-left{ display:flex; flex-direction:column; gap:6px; min-width: 0; }
.card-hd-right{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.select-title{
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
  padding-top: 9px;
  padding-bottom: 9px;
}

.hero{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(99,102,241,0.15), rgba(16,24,40,0.10));
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
}
.hero-title{
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 14px;
}
.hero-sub{ margin-top: 4px; }

.info-btn{
  margin-left: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-size: 12px;
}
.info-btn:hover{ border-color: rgba(148,163,184,0.35); }

.popover{
  position: fixed;
  z-index: 220;
  width: min(360px, calc(100vw - 24px));
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.45);
  padding: 10px 12px;
}
.popover-title{ font-weight: 800; margin-bottom: 6px; }
.popover-body{ color: var(--text); }

.statusbar{
  padding: 0 14px 12px 14px;
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}
.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:4px 10px;
  font-size:12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  max-width: 100%;
}
.pill-ok{ border-color: rgba(34,197,94,0.55); }
.pill-warn{ border-color: rgba(245,158,11,0.65); }
.pill-bad{ border-color: rgba(251,113,133,0.65); }
.pill-neutral{ border-color: var(--border); }
.muted{ color: var(--muted); font-size: 12px; }
.accent{ color: var(--warn); }

.container{ max-width: 1100px; margin: 0 auto; padding: 16px 14px 32px; }
.grid{
  display:grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 14px;
  align-items: start; /* prevent tall right column stretching left card */
  min-width: 0;
}
.grid > .card{ align-self: start; min-width: 0; }
@media (max-width: 980px){
  .grid{ grid-template-columns: 1fr; }
  .topbar-inner{ flex-direction: column; align-items: stretch; }
  .controls{ justify-content: stretch; }
  .search{ width: 100%; }
  .input{ width: 100%; }
}

.card{
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
.card-hd{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}
.card-title{ font-weight:700; }
.divider{ height:1px; background: var(--border); margin: 12px 0; }
.section-title{ font-weight:650; font-size: 13px; color: var(--text); margin-bottom: 8px; }

.stats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 700px){ .stats{ grid-template-columns: 1fr; } }
.stat{ padding: 10px; border: 1px solid var(--border); background: var(--panel2); border-radius: 12px; }
.stat-label{ font-size: 12px; color: var(--muted); }
.stat-value{ font-size: 22px; font-weight: 750; margin-top: 6px; }

.hero{
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(99,102,241,0.14), rgba(16,24,40,0.12));
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.hero-metrics{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}
.hero-num{ font-size: 30px; font-weight: 850; letter-spacing: -0.3px; }
.hero-lbl{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.hero-sub{ margin-top: 8px; }
@media (max-width: 700px){
  .hero-metrics{ grid-template-columns: 1fr; }
  .hero-num{ font-size: 28px; }
}

.section-tabs{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.tabs{ display:flex; gap: 8px; align-items:center; }
.panel{ min-width: 0; }

/* Daily forecast */
.daily{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 980px){ .daily{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px){ .daily{ grid-template-columns: 1fr; } }
.day{
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
}
.day:focus{
  outline: 2px solid rgba(245,158,11,0.55);
  outline-offset: 2px;
}
.day-top{ display:flex; justify-content:space-between; gap:10px; align-items:baseline; }
.day-date{ font-weight: 800; }
.day-snow{ font-weight: 850; color: var(--warn); }
.day-meta{ margin-top: 6px; }
.day-narr{ margin-top: 8px; line-height: 1.25; }

.hourly{
  position: relative;
  display:grid;
  grid-auto-flow: column;
  grid-auto-columns: 96px;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom: 6px;
  max-width: 100%;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.35) transparent;
}
.hourly::-webkit-scrollbar{ height: 10px; }
.hourly::-webkit-scrollbar-track{ background: transparent; }
.hourly::-webkit-scrollbar-thumb{
  background: rgba(148,163,184,0.22);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.hourly::-webkit-scrollbar-thumb:hover{ background: rgba(148,163,184,0.35); background-clip: content-box; }

.hourly-wrap{ position: relative; }
.scroll-btn{
  position:absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.45);
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  z-index: 2;
}
.scroll-btn:hover{ border-color: rgba(148,163,184,0.35); }
.scroll-btn-left{ left: 6px; }
.scroll-btn-right{ right: 6px; }
.hour{
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  padding: 10px;
  scroll-snap-align: start;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.hour.wx-tint,
.day.wx-tint{
  --ic: 148,163,184;
  --ica: 0.16;
  --glow: 0;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--panel2), var(--panel2)) padding-box,
    linear-gradient(120deg, rgba(148,163,184,0.14), rgba(var(--ic), var(--ica)), rgba(148,163,184,0.14)) border-box;
  box-shadow:
    0 0 0 1px rgba(var(--ic),0.04),
    0 0 18px rgba(var(--ic), var(--glow));
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.hour.wx-tint:hover,
.day.wx-tint:hover{
  box-shadow:
    0 0 0 1px rgba(var(--ic),0.08),
    0 0 22px rgba(var(--ic), calc(var(--glow) + 0.06));
}
.wx-tint.wx-hazard{
  box-shadow:
    0 0 0 1px rgba(var(--ic),0.12),
    0 0 30px rgba(var(--ic), var(--glow));
}
.intensity{
  --ic: 148,163,184;
  --ica: 0.22;
  --glow: 0;
  height: 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  margin-top: 10px;
  background:
    linear-gradient(var(--panel2), var(--panel2)) padding-box,
    linear-gradient(90deg, rgba(var(--ic),0.10), rgba(var(--ic), var(--ica)), rgba(var(--ic),0.10)) border-box;
  box-shadow:
    0 0 0 1px rgba(var(--ic),0.05),
    0 0 18px rgba(var(--ic), var(--glow));
}
.intensity-hazard{
  box-shadow:
    0 0 0 1px rgba(var(--ic),0.10),
    0 0 26px rgba(var(--ic), var(--glow));
}
@media (max-width: 540px){
  .hourly{ grid-auto-columns: 84px; }
  .hour{ padding: 8px; }
}
.hour-bars{
  display:flex;
  gap:6px;
  align-items:flex-end;
  height: 26px;
  margin-top: 8px;
}
.bar{
  width: 14px;
  border-radius: 999px;
  background: rgba(148,163,184,0.16);
  border: 1px solid rgba(148,163,184,0.22);
}
.bar-snow{
  background: rgba(99,102,241,0.40);
  border-color: rgba(99,102,241,0.55);
}
.bar-rain{
  background: rgba(34,197,94,0.22);
  border-color: rgba(34,197,94,0.35);
}
.bar-dry{
  background: rgba(148,163,184,0.12);
  border-color: rgba(148,163,184,0.22);
}
/* Snow intensity (low→hazard) */
.bar-snow-l1{ background: rgba(250,204,21,0.08); border-color: rgba(250,204,21,0.95); }
.bar-snow-l2{ background: rgba(250,204,21,0.28); border-color: rgba(250,204,21,0.95); }
.bar-snow-l3{ background: rgba(249,115,22,0.40); border-color: rgba(249,115,22,0.95); }
.bar-snow-l4{ background: rgba(239,68,68,0.55); border-color: rgba(239,68,68,0.95); box-shadow: 0 0 0 2px rgba(239,68,68,0.10); }
/* Rain intensity (light→heavy) */
.bar-rain-l1{ background: rgba(56,189,248,0.18); border-color: rgba(56,189,248,0.60); }
.bar-rain-l2{ background: rgba(14,165,233,0.30); border-color: rgba(14,165,233,0.70); }
.bar-rain-l3{ background: rgba(2,132,199,0.42); border-color: rgba(2,132,199,0.82); }
.hour-mini{ white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }
.hour-top{ display:flex; justify-content:space-between; gap:10px; }
.hour-time{ font-size: 12px; color: var(--muted); }
.hour-temp{ font-weight: 700; }
.hour-snow{ margin-top: 6px; font-weight: 700; }
.hour-mini{ margin-top: 6px; font-size: 12px; color: var(--muted); }

.now-marker{
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-left: 2px solid rgba(245,158,11,0.7);
  pointer-events: none;
  z-index: 3;
}
.now-label{
  position:absolute;
  top: 6px;
  left: 8px;
  font-size: 11px;
  color: rgba(245,158,11,0.95);
  background: rgba(2,6,23,0.55);
  border: 1px solid rgba(245,158,11,0.35);
  padding: 2px 6px;
  border-radius: 999px;
}
.temp-line{
  display:none;
}

/* Prevent iOS Safari auto-zoom on inputs */
@media (max-width: 700px){
  .input{ font-size: 16px; }
}

.now-panel .row{ padding: 10px; border: 1px solid var(--border); background: var(--panel2); border-radius: 12px; margin-bottom: 10px; }
.now-panel .row:last-child{ margin-bottom: 0; }
.now-title{ font-weight: 700; }
.now-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
@media (max-width: 700px){ .now-grid{ grid-template-columns: 1fr; } }
.now-panel-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.icon-btn{
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor:pointer;
}
.icon-btn:hover{ border-color: rgba(148,163,184,0.35); }

.radar img{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.outlook-grid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 980px){ .outlook-grid{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px){ .outlook-grid{ grid-template-columns: 1fr; } }
.outlook{
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  padding: 10px;
}

.alerts{
  display:block;
  line-height: 1.35;
}
.alert-link{
  display:block;
  width:100%;
  text-align:left;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  cursor:pointer;
}
.alert-link:hover{ border-color: rgba(245,158,11,0.45); }

.modal{
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2,6,23,0.66);
  backdrop-filter: blur(6px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
}
.modal#weatherModal{ z-index: 210; }
.modal#webcamModal{ z-index: 220; }
.modal#hourModal{ z-index: 230; }
.modal#alertModal{ z-index: 260; } /* alerts always on top */
.modal#helpModal{ z-index: 250; }
.modal-card{ position: relative; }

.radar{
  background: rgba(2,6,23,0.25);
  border-radius: 12px;
}
.radar-frame{
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 8;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 30% 20%, rgba(99,102,241,0.20), transparent 45%), rgba(2,6,23,0.45);
}
.radar-frame img{
  position:absolute;
  inset: 0;
  width:100%;
  height:100%;
  object-fit: cover;
}
#radarOverlay{
  opacity: 0.92;
  mix-blend-mode: multiply;
  filter: contrast(1.15) saturate(1.25);
}

.table-wrap{
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  overflow: auto;
}
table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(148,163,184,0.18);
  text-align: left;
  white-space: nowrap;
}
th{ color: var(--muted); font-weight: 700; }

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.25);
  font-size: 12px;
}
.badge-ok{ border-color: rgba(34,197,94,0.55); }
.badge-warn{ border-color: rgba(245,158,11,0.65); }
.badge-bad{ border-color: rgba(190,18,60,0.65); }

.skeleton{
  position: relative;
  overflow: hidden;
  background: rgba(148,163,184,0.08);
}
.skeleton::after{
  content: "";
  position:absolute;
  inset:-40% -60%;
  background: linear-gradient(90deg, transparent, rgba(148,163,184,0.14), transparent);
  transform: translateX(-40%);
  animation: shimmer 1.1s infinite linear;
}
@keyframes shimmer{
  to{ transform: translateX(40%); }
}
.modal-card{
  width: min(860px, 100%);
  max-height: 85vh;
  overflow:auto;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  padding: 14px;
}
.modal-hd{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 10px;
}
.modal-title{ font-weight: 800; font-size: 16px; }
.modal-actions{ display:flex; gap:10px; align-items:center; }
.modal-body{ color: var(--text); }
.modal-body p{ margin: 10px 0; }
.modal-body a{ color: var(--accent); }

.modal-img{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.25);
}

.webcams{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 980px){ .webcams{ grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px){ .webcams{ grid-template-columns: 1fr; } }
.webcam{
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 12px;
  overflow:hidden;
}
.webcam-hd{ padding: 10px; display:flex; justify-content:space-between; gap:10px; align-items:baseline; }
.webcam img{ width:100%; display:block; border-top: 1px solid var(--border); }

.footer{ padding: 18px 14px; text-align:center; border-top: 1px solid var(--border); background: rgba(2,6,23,0.35); }
[data-theme="light"] .footer{ background: rgba(255,255,255,0.55); }

/* Back to LocalPDX (top-left) */
.back-localpdx{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:12px;
  text-decoration:none;
  font-weight:700;
  letter-spacing:.2px;
  color: inherit;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.back-localpdx:hover{
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.18);
}

.back-arrow{
  font-size: 18px;
  line-height: 1;
  transform: translateY(-1px);
}

.back-text{
  font-size: 13px;
}

/* Mobile: keep it compact */
@media (max-width: 320px){
  .back-text{ display:none; }
  .back-localpdx{ padding:8px; }
}

