/* WX Check: one stylesheet. Colours are tokens on :root; the light set follows the phone's setting. */
:root {
  color-scheme: dark;
  --bg: #0e1114;
  --surface: #171c21;
  --raised: #1f262d;
  --line: #2a323b;
  --ink: #eef2f5;
  --muted: #8f9ba7;
  --accent: #6cb6ff;
  --go: #3ecf7a;
  --caution: #f2b134;
  --nogo: #f2605a;
  --rain: #6cb6ff;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --raised: #eef1f4;
    --line: #d9dfe5;
    --ink: #12171c;
    --muted: #5d6975;
    --accent: #0b69c7;
    --go: #12894a;
    --caution: #a86a00;
    --nogo: #c9302a;
    --rain: #0b69c7;
  }
}

[data-level="go"] { --level: var(--go); }
[data-level="caution"] { --level: var(--caution); }
[data-level="nogo"] { --level: var(--nogo); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 600px;
  padding: 0 12px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h2 { margin: 22px 2px 8px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h3 { margin: 16px 2px 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top ---------- */
.top {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 6px; align-items: center;
  margin: 0 -12px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg);
}
.place {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-weight: 600; text-align: left;
}
.place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place svg { color: var(--accent); }
.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.icon-btn.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.busy svg { animation: none; opacity: .5; } }

.quadbar { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.quadbar select { flex: 1; min-width: 0; background-color: var(--surface); font-weight: 600; text-overflow: ellipsis; }
/* Edit is as wide as the two buttons above it, so the picker lines up with the place field */
.quadbar .btn { flex: none; width: 94px; background: var(--surface); font-weight: 500; }

/* ---------- verdict ---------- */
.verdict {
  margin-top: 12px; padding: 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--level, var(--line)) 55%, var(--line));
  background: color-mix(in srgb, var(--level, var(--surface)) 14%, var(--surface));
}
.verdict-when { color: var(--muted); font-size: 13px; }
.verdict h1 { margin: 2px 0 0; font-size: 30px; line-height: 1.15; font-weight: 750; letter-spacing: -.01em; color: var(--level, var(--ink)); }
.reasons { margin-top: 10px; display: grid; gap: 6px; }
.reasons li { display: flex; gap: 8px; align-items: baseline; }
.reasons li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--level); transform: translateY(-1px); }
.soon { margin-top: 10px; display: flex; gap: 8px; align-items: baseline; }
.soon::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--rain); transform: translateY(-1px); }
.soon.dry::before { background: var(--muted); }
.verdict-day { margin-top: 12px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--level, var(--line)) 30%, var(--line)); color: var(--muted); }
.verdict-day strong { color: var(--ink); font-weight: 600; }
.link { padding: 10px 4px; margin: -10px 0; background: none; border: 0; color: var(--accent); text-decoration: underline; }

/* ---------- zones ---------- */
.zones {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline;
  margin-top: 10px; padding: 12px 12px 12px 16px; min-height: 56px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none;
}
.zones::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--level, var(--line)); }
.zones-label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.zones-label small { margin-left: 4px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 6px; }
.zones-rows { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 4px 0 6px; }
.zones-where { display: flex; align-items: baseline; gap: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.zones-where::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--level, var(--line)); transform: translateY(-1px); }
.zones-what { font-size: 14px; }
.zones-what.first { font-size: 16px; font-weight: 700; color: var(--level, var(--ink)); }
.zones-what.none { color: var(--muted); }
.zones-open { grid-column: 1 / -1; color: var(--accent); font-size: 13px; }

/* ---------- tiles ---------- */
.tiles { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 520px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile:last-child:nth-child(odd) { grid-column: auto; }
}
.tile {
  position: relative; min-width: 0; padding: 10px 10px 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--level, var(--line)); }
.tile-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tile-value { display: flex; align-items: center; gap: 6px; font-size: 21px; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.tile-value small { font-size: 12px; font-weight: 500; color: var(--muted); }
.tile-value.words { font-size: 17px; min-height: 26px; }
.tile-sub [data-level] { color: var(--level); font-weight: 600; }
.tile-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrow { width: 16px; height: 16px; stroke-width: 2.5; }
.wx { width: 22px; height: 22px; stroke-width: 1.8; }
.wx.wet { color: var(--rain); }

/* ---------- hours ---------- */
.hours {
  display: flex; gap: 4px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -12px; padding-inline: 12px;
  scroll-snap-type: x proximity;
}
.hour {
  flex: none; width: 52px; padding: 8px 0 6px; display: grid; gap: 3px; justify-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  scroll-snap-align: start; font-size: 13px;
}
.hour.night { background: var(--bg); }
.hour[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.hour-time { font-size: 12px; color: var(--muted); }
.hour-bar { width: 32px; height: 6px; border-radius: 3px; background: var(--level); }
.hour .arrow { width: 13px; height: 13px; color: var(--muted); }
.hour-wind { font-weight: 700; font-size: 15px; }
.hour-gust, .hour-temp { color: var(--muted); font-size: 12px; }
.hour-rain { color: var(--rain); font-size: 12px; min-height: 17px; }

.legend { margin: 0 2px; font-size: 12px; color: var(--muted); }

/* ---------- days ---------- */
.days { display: grid; gap: 6px; }
.day {
  width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  min-height: 56px; padding: 8px 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.day[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.day-dot { grid-row: span 2; width: 10px; height: 10px; border-radius: 50%; background: var(--level); }
.day-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.day-fly { color: var(--level); font-weight: 600; text-align: right; white-space: nowrap; }
.day-facts { grid-column: 2 / -1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- links ---------- */
.links { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.links summary { min-height: 48px; padding: 12px 14px; font-weight: 600; cursor: pointer; }
.links summary small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.links h3 {
  margin: 0; padding: 14px 14px 6px; border-top: 1px solid var(--line);
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.links ul { margin: 0 14px 14px; }
.links li + li { border-top: 1px solid var(--line); }
.links a { display: block; padding: 9px 0; min-height: 44px; color: inherit; text-decoration: none; }
.links a b { font-weight: 600; }
.links a b::after { content: " \2197"; color: var(--muted); font-weight: 400; }
.links a small { display: block; color: var(--muted); }

/* ---------- welcome, status ---------- */
.welcome { margin-top: 18vh; text-align: center; display: grid; gap: 14px; justify-items: center; }
.welcome h1 { font-size: 34px; letter-spacing: -.02em; }
.welcome p { color: var(--muted); max-width: 30ch; }
.status { margin: 18px 2px 0; color: var(--muted); font-size: 13px; text-align: center; }
.status.problem { color: var(--caution); }

/* ---------- buttons, fields ---------- */
.btn {
  min-height: 44px; padding: 0 16px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; font-weight: 600;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.danger { color: var(--nogo); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row.end { justify-content: space-between; margin-top: 18px; }
.row input { flex: 1; min-width: 0; }
input, select {
  min-height: 44px; padding: 0 12px; width: 100%;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; /* under 16px iOS zooms into the field */
}
.field { display: grid; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.note { margin-top: 10px; font-size: 13px; color: var(--muted); }
.note:empty { display: none; }
.errors { margin-top: 12px; display: grid; gap: 4px; color: var(--nogo); font-size: 14px; }
.errors:empty { display: none; }

.limit { margin-top: 14px; }
.limit-title { font-weight: 600; }
.limit-title small { font-weight: 400; color: var(--muted); }
.limit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.limit-fields .field { margin-top: 4px; }

/* ---------- sheets ---------- */
dialog {
  width: 100%; max-width: 600px; max-height: 88dvh; margin: auto auto 0; padding: 0;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 20px 20px 0 0;
  overflow-y: auto; overscroll-behavior: contain;
}
dialog::backdrop { background: rgb(0 0 0 / .55); }
.sheet { padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.sheet-head .icon-btn { border: 0; background: none; }
.list { display: grid; gap: 6px; margin-top: 10px; }
.list:empty { display: none; }
.list li { display: flex; gap: 6px; }
.list .pick {
  flex: 1; min-width: 0; min-height: 48px; padding: 6px 12px; text-align: left;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.list .pick b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .pick small { color: var(--muted); }
.list .icon-btn { width: 48px; height: 48px; background: var(--bg); }
.list .pick[data-level] { border-left: 4px solid var(--level); }
.list .pick[aria-pressed="true"] { border-color: var(--ink); border-left-color: var(--level); }
.list .pick small { display: block; }
#compare-btn { margin-top: 12px; }

