:root {
  --bg: #0f1620;
  --card: #18222f;
  --card2: #1f2c3d;
  --fg: #e7eef6;
  --muted: #9fb3c8;
  --accent: #4ea1ff;
  --border: #2a3a4e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.85rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--card);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.topbar .meta { display: flex; align-items: center; gap: 1rem; }
.adminlink { font-size: 0.85rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.25rem; }

/* Hero current-conditions */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center;
  background: linear-gradient(135deg, var(--card), var(--card2));
  border: 1px solid var(--border); border-radius: 14px;
  padding: 1.25rem 1.5rem; margin-bottom: 1.25rem;
}
.hero-cond { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 1rem; }
.cond-icon { font-size: 1.6rem; }
.hero-temp { font-size: 4rem; font-weight: 700; line-height: 1.05; }
.hero-temp .deg { font-size: 1.8rem; color: var(--muted); font-weight: 500; margin-left: 0.15rem; }
.hero-temprow { display: flex; align-items: center; gap: 1rem; }
.hero-hilo { display: flex; flex-direction: column; font-size: 1rem; line-height: 1.3; }
.hero-hilo .hi { color: #f0a24a; font-weight: 600; }
.hero-hilo .lo { color: #5aa9e0; font-weight: 600; }
.hero-sub { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; color: var(--muted); margin-top: 0.4rem; font-size: 0.95rem; }
.hero-sub b { color: var(--fg); font-weight: 600; }
.trend.rising { color: #f0a24a; }
.trend.falling { color: #5aa9e0; }
.trend.steady { color: var(--muted); }

/* Forecast — both rows scroll horizontally WITHIN the viewport (min-width:0 on
   the flex containers/blocks stops their content from widening the whole page) */
.forecast { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.fc-block { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem; min-width: 0; }
.fc-title { font-size: 0.92rem; color: var(--muted); margin-bottom: 0.5rem; }
/* right-edge fade hints that the row scrolls */
.fc-scroll { position: relative; min-width: 0; }
.fc-scroll::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 32px;
  background: linear-gradient(to right, rgba(24,34,47,0), var(--card)); pointer-events: none; border-radius: 0 8px 8px 0; }
.fc-hourly, .fc-daily { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.35rem; min-width: 0; scrollbar-width: thin; }
.fc-h { flex: 0 0 auto; min-width: 56px; text-align: center; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.3rem; }
.fc-hr { font-size: 0.78rem; color: var(--muted); }
.fc-ic { font-size: 1.3rem; line-height: 1.6; }
.fc-t { font-weight: 600; }
.fc-p { font-size: 0.72rem; color: #5aa9e0; min-height: 0.9rem; }
.fc-d { flex: 0 0 auto; min-width: 74px; text-align: center; background: var(--card2); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.4rem; cursor: pointer; transition: border-color .15s; }
.fc-d:hover { border-color: #46627e; }
.fc-d.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fc-day { font-size: 0.8rem; color: var(--muted); }
.fc-hl { font-size: 0.9rem; margin-top: 0.15rem; }
.hero-sun { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; color: var(--muted); margin-top: 0.3rem; font-size: 0.9rem; }
.hero-sun b { color: var(--fg); font-weight: 600; }
.hero-wind { display: flex; flex-direction: column; align-items: center; }
.compass svg { width: 168px; height: 168px; }

/* Wind compass */
.c-ring { fill: rgba(255,255,255,0.02); stroke: var(--border); stroke-width: 2; }
.c-tick { stroke: #3a4d63; stroke-width: 1.5; }
.c-tick.major { stroke: #6b8199; stroke-width: 2.5; }
.c-card { fill: var(--muted); font-size: 13px; font-weight: 600; text-anchor: middle; }
.c-shaft { stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.c-head { fill: var(--accent); }
.c-hub { fill: var(--accent); }
.c-readout { margin-top: 0.35rem; font-size: 1rem; }
.c-readout .c-spd { font-weight: 700; font-size: 1.15rem; }
.c-readout .c-spdunit { color: var(--muted); }
.c-readout .c-dir { color: var(--accent); font-weight: 600; }
.c-gust { color: var(--muted); font-size: 0.82rem; margin-top: 0.1rem; }

/* Radial gauges */
.gauges {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 1.25rem;
}
.gauge {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.5rem 0.5rem 0.75rem; text-align: center;
}
.gauge svg { width: 100%; max-width: 150px; height: auto; }
.g-bg { fill: none; stroke: #233144; stroke-width: 11; stroke-linecap: round; }
.g-val { fill: none; stroke-width: 11; stroke-linecap: round; transition: stroke-dasharray .4s; }
.g-value { fill: var(--fg); font-size: 26px; font-weight: 700; text-anchor: middle; }
.g-unit { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.g-label { color: var(--muted); font-size: 0.85rem; margin-top: -0.25rem; }

/* SPC severe weather outlook */
.spc-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem; margin-bottom: 1.25rem; }
.spc-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.15rem 0.75rem; margin-bottom: 0.5rem; font-size: 0.92rem; }
.spc-chips { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.25rem; min-width: 0; scrollbar-width: thin; }
.spc-chip { flex: 0 0 auto; min-width: 92px; text-align: center; cursor: pointer; color: var(--fg);
  border: 1px solid var(--s, var(--border)); border-left: 4px solid var(--s, var(--border)); border-radius: 8px;
  padding: 0.5rem 0.55rem; transition: filter .15s;
  background: var(--card2);
  background: color-mix(in srgb, var(--c, var(--card2)) 24%, var(--card2)); }
.spc-chip:hover { filter: brightness(1.12); }
.spc-chip.none { background: var(--card2); border-color: var(--border); border-left-color: var(--border); opacity: 0.7; }
.spc-day { display: block; font-size: 0.72rem; color: var(--muted); }
.spc-risk { display: block; font-size: 1.05rem; font-weight: 700; }
.spc-sub { display: block; font-size: 0.72rem; color: var(--muted); }
.spc-modal-body { flex: 1; overflow: auto; background: #0b1118; display: flex; align-items: flex-start; justify-content: center; }
.spc-img { max-width: 100%; height: auto; display: block; }
@media (max-width: 560px) { .spc-chip { min-height: 44px; } }

/* Radar */
.radar-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem; margin-bottom: 1.25rem;
}
.radar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-size: 0.92rem; }
.radar-tile { height: 220px; border-radius: 8px; overflow: hidden; background: #0b1118; }
.radar-loading { display: flex; height: 100%; align-items: center; justify-content: center; }
.radar-tile .leaflet-container { background: #0b1118; }

.modal { position: fixed; inset: 0; background: rgba(2,8,16,0.82); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  width: min(960px, 100%); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); }
.modal-btn { background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.4rem 0.8rem; cursor: pointer; font-size: 0.9rem; }
.modal-btn.close { margin-left: auto; }
.modal-head input[type=range] { flex: 1; min-width: 120px; max-width: 320px; accent-color: var(--accent); }
.radar-time { white-space: nowrap; }
.radar-map { flex: 1; min-height: 55vh; }

/* On phones, make the radar modal truly full-screen so the header (play/seek/
   close) is never clipped, and drop the seek slider onto its own row. */
@media (max-width: 560px) {
  .modal { padding: 0; align-items: stretch; }
  .modal-box { width: 100%; max-height: 100vh; height: 100dvh; border-radius: 0; border: none; }
  .modal-head { padding: 0.6rem 0.7rem; }
  .modal-head input[type=range] { order: 3; flex-basis: 100%; max-width: none; }
  .modal-btn { min-height: 40px; }
  .radar-map { min-height: 0; }
}
.radar-map .leaflet-container { background: #0b1118; height: 100%; }
.radar-legend { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.8rem; font-size: 0.78rem; color: var(--muted); }
.legend-bar { flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg,#22c55e,#eab308,#f97316,#ef4444,#a855f7); }

.tiles {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  margin-bottom: 1.5rem;
}
@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; justify-items: start; }
  .hero-wind { align-self: center; margin-top: 0.5rem; }
  .hero-temp { font-size: 3.2rem; }
  /* roomier tap targets on touch screens */
  .ranges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
  .ranges button, .daynav button, .daynav #liveBtn,
  .daynav input[type=date], #metric, .modal-btn {
    min-height: 42px; padding: 0.55rem 0.9rem; margin-left: 0;
  }
  .daynav #prevDay, .daynav #nextDay { min-width: 44px; font-size: 1.15rem; }
}
.tile {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.9rem 1rem;
}
.tile .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.tile .value { font-size: 1.7rem; font-weight: 600; margin-top: 0.2rem; }
.tile .unit { font-size: 0.9rem; color: var(--muted); margin-left: 0.15rem; }

.chartcard {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem; margin-bottom: 1.5rem;
}
.chartcontrols { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
/* Constrain the chart so Chart.js (maintainAspectRatio:false) can't grow unbounded — keeps it short on mobile */
.chartbox { position: relative; width: 100%; height: 340px; }
@media (max-width: 640px) { .chartbox { height: 230px; } }
select {
  background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.4rem 0.6rem; font-size: 0.9rem;
}
.ranges button {
  background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0.7rem; margin-left: 0.25rem; cursor: pointer;
}
.ranges button.active { background: var(--accent); color: #04101e; border-color: var(--accent); }

/* Day browser */
.daynav { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.daynav button {
  background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer;
}
.daynav #prevDay, .daynav #nextDay { font-size: 1rem; line-height: 1; padding: 0.35rem 0.6rem; }
.daynav #liveBtn.active { background: var(--accent); color: #04101e; border-color: var(--accent); }
.daynav input[type=date] {
  background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.35rem 0.5rem; color-scheme: dark;
}
.day-heading { color: var(--fg); font-weight: 600; margin-left: 0.25rem; }
.day-sun { margin: 0 0 0.6rem; }
.day-sun:empty { margin: 0; }
.day-summary { margin-bottom: 0.75rem; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.summary-table th, .summary-table td { text-align: right; padding: 0.3rem 0.55rem; border-bottom: 1px solid var(--border); }
.summary-table th:first-child, .summary-table td:first-child { text-align: left; }
.summary-table th { color: var(--muted); font-weight: 500; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.records table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 0.9rem; }
.records h2 { font-size: 1.05rem; }
.records th, .records td { text-align: right; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.records th:first-child, .records td:first-child { text-align: left; }
.records th { color: var(--muted); font-weight: 500; }

footer { max-width: 1000px; margin: 0 auto; padding: 1rem 1.25rem; display: flex; justify-content: space-between; }

/* Admin */
.adminwrap { max-width: 720px; margin: 2rem auto; padding: 0 1.25rem; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { margin-top: 0; font-size: 1.05rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field label { color: var(--muted); font-size: 0.85rem; }
input[type=text], input[type=password], input[type=number] {
  background: var(--card2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.5rem 0.6rem; font-size: 0.95rem;
}
button.btn {
  background: var(--accent); color: #04101e; border: none; border-radius: 6px;
  padding: 0.55rem 1rem; font-size: 0.95rem; font-weight: 600; cursor: pointer;
}
button.btn.secondary { background: var(--card2); color: var(--fg); border: 1px solid var(--border); }
button.btn.danger { background: #b3422f; color: #fff; }
.msg { font-size: 0.9rem; margin-top: 0.5rem; min-height: 1.2em; }
.msg.ok { color: #5fd08a; }
.msg.err { color: #ff8a7a; }
pre.raw { background: var(--card2); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; overflow-x: auto; font-size: 0.8rem; max-height: 320px; }
