:root {
  --bg: #0e1418; --panel: #151d23; --panel2: #1b252c; --line: #26323b;
  --text: #e4ebef; --mut: #8d9ca6; --acc: #f2a93b; --acc2: #4fb3d9;
  --warm: #ff7a45; --cool: #5fb0ff; --green: #5ccf8a;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--acc2); }

.top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121a1f, var(--bg)); position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .02em; }
.mark { font-family: var(--mono); font-weight: 600; background: var(--acc); color: #1a1206; padding: 2px 7px; border-radius: 3px; font-size: 13px; }
.tabs { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tabs button { background: none; border: 0; color: var(--mut); font: 500 14px var(--sans); padding: 7px 14px; border-radius: 6px; cursor: pointer; }
.tabs button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--acc); }
.run { margin-left: auto; font: 12px var(--mono); color: var(--mut); text-align: right; }

main { flex: 1; display: flex; }
.panel { display: none; width: 100%; }
.panel.on { display: block; }
#local { padding: 16px; max-width: 1180px; margin: 0 auto; display: none; }
#local.on { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
#local .now, #local .days, #local .card:last-child { grid-column: 1 / -1; }
#local.on > * { min-width: 0; }
html, body { overflow-x: hidden; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; }
.card h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; }
.chart canvas { width: 100% !important; height: 210px !important; }

.now { display: flex; gap: 22px; align-items: stretch; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; }
.now .place { font-size: 13px; color: var(--mut); }
.now .big { font: 600 56px/1 var(--mono); letter-spacing: -.02em; }
.now .cond { font-size: 18px; margin-top: 6px; }
.now .stats { display: grid; grid-template-columns: repeat(3, minmax(110px, 1fr)); gap: 10px 22px; margin-left: auto; align-content: center; }
.stat .k { font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .07em; }
.stat .v { font: 600 18px var(--mono); }

.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.day .d { font-weight: 600; }
.day .hl { font: 600 20px var(--mono); margin: 4px 0; }
.day .hl .hi { color: var(--warm); } .day .hl .lo { color: var(--cool); }
.day .x { font-size: 12px; color: var(--mut); line-height: 1.55; }
.day .flag { display: inline-block; margin-top: 4px; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #4a1d14; color: #ffb199; }
.day .flag.smoke { background: #3d3324; color: #e8cf9a; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; font: 12.5px var(--mono); width: 100%; }
th, td { padding: 5px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { color: var(--mut); font-weight: 400; position: sticky; top: 0; background: var(--panel); }
td:first-child, th:first-child { text-align: left; }
tr.daybreak td { border-top: 2px solid var(--acc); }
td.wet { color: var(--green); }

/* Map */
#mapview.on { display: flex; flex-direction: column; height: calc(100vh - 92px); }
.mapwrap { position: relative; flex: 1; }
#map { position: absolute; inset: 0; background: #0b1013; }
.leaflet-container { font-family: var(--sans); }
.layerbar { position: absolute; top: 10px; left: 54px; right: 10px; z-index: 500; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.layerbar button { pointer-events: auto; background: rgba(21,29,35,.92); border: 1px solid var(--line); color: var(--text);
  font: 500 13px var(--sans); padding: 6px 11px; border-radius: 6px; cursor: pointer; backdrop-filter: blur(4px); }
.layerbar button.on { border-color: var(--acc); color: var(--acc); }
.layerbar button.ens { border-style: dashed; }
.layerbar .sep { width: 1px; background: var(--line); margin: 0 4px; }
.picker { display: none; position: relative; width: 100%; pointer-events: auto; background: rgba(21,29,35,.94); border: 1px solid var(--acc);
  border-radius: 6px; padding: 6px 32px 7px 10px; backdrop-filter: blur(4px); }
.picker.ens { border-style: dashed; }
.picker::after { content: ""; position: absolute; right: 13px; top: 50%; width: 9px; height: 9px; margin-top: -7px; border: solid var(--acc);
  border-width: 0 2px 2px 0; transform: rotate(45deg); pointer-events: none; }
.picker .n { display: block; font: 11px/1.3 var(--mono); color: var(--mut); }
.picker .v { display: block; font: 500 13px/1.3 var(--sans); color: var(--acc); }
.picker select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.picker:focus-within { outline: 2px solid var(--acc); outline-offset: 1px; }
.mapfoot { position: absolute; left: 10px; right: 10px; bottom: 12px; z-index: 500; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 8px; pointer-events: none; }
.legend { pointer-events: auto; min-width: 0; max-width: 100%; background: rgba(21,29,35,.94); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.legend .t { color: var(--mut); margin-bottom: 5px; }
.legend .sw { display: flex; }
.legend .sw div { flex: 1 0 26px; text-align: center; }
.legend .sw i { display: block; height: 10px; }
.legend .sw span { font: 10.5px var(--mono); color: var(--mut); }
.legend .cap { width: 340px; max-width: 100%; margin-top: 6px; font-size: 11px; line-height: 1.35; color: var(--mut); }
.probe { pointer-events: auto; flex: none; background: rgba(21,29,35,.94); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: 13px var(--mono); }
.timebar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.play { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--acc); background: none; color: var(--acc); font-size: 16px; cursor: pointer; flex: none; }
.tcol { flex: 1; }
.valid { font: 600 15px var(--mono); display: flex; gap: 10px; align-items: baseline; }
.valid #fhr { color: var(--mut); font-weight: 400; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--acc); }
select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; font: 13px var(--sans); }
footer { font-size: 11.5px; color: var(--mut); padding: 8px 16px; border-top: 1px solid var(--line); }
.empty { padding: 30px; color: var(--mut); }
.mill-pin { width: 12px; height: 12px; border-radius: 50%; background: var(--acc); border: 2px solid #1a1206; box-shadow: 0 0 0 3px rgba(242,169,59,.35); }

@media (max-width: 760px) {
  #local.on { grid-template-columns: 1fr; padding: 10px; }
  .now .stats { margin-left: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .top { position: static; gap: 10px; }
  .days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart canvas { height: 190px !important; }
  .now .big { font-size: 46px; }
  .run { margin-left: 0; text-align: left; width: 100%; }
  .layerbar { left: 50px; }
  .mapfoot { bottom: 21px; flex-direction: column-reverse; align-items: flex-start; } /* clears the attribution, which must stay visible */
  .probe { align-self: flex-end; }
  #mapview.on { height: calc(100vh - 140px); }
  .timebar select#speed { display: none; }
}

/* Too many layers to wrap over the map on a small or short screen: one-row picker instead of chips. */
@media (max-width: 760px), (max-height: 600px) {
  .layerbar.many button, .layerbar.many .sep { display: none; }
  .layerbar.many .picker { display: block; }
}
