/* Layout: road-sign masthead, trip form bar, two-column results (findings left, map right), stacking under 900px. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #15202b;
  --muted: #5b6b7a;
  --line: #d5dce3;
  --sign: #0b6e4f;          /* Australian guide-sign green */
  --sign-ink: #ffffff;
  --focus: #1f6feb;

  --dry: #e1e7ec;
  --r1: #9cc9f5;
  --r2: #3d8be0;
  --r3: #1b3fa8;
  --r4: #6a2bb0;

  --aws-advice: #f2c400;     /* Australian Warning System levels */
  --aws-watch: #f07d00;
  --aws-emergency: #d7262e;
  --ok: #1d8a52;

  --font-display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Barlow", "Helvetica Neue", Arial, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f161c; --surface: #17212a; --ink: #e6edf3; --muted: #93a3b2; --line: #2a3742;
    --sign: #1f8f68; --sign-ink: #ffffff; --focus: #58a6ff;
    --dry: #26323c; --r1: #6fa9e0; --r2: #3a86e0; --r3: #4a6fe8; --r4: #a06ae6;
    --ok: #3fbf7f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f161c; --surface: #17212a; --ink: #e6edf3; --muted: #93a3b2; --line: #2a3742;
  --sign: #1f8f68; --sign-ink: #ffffff; --focus: #58a6ff;
  --dry: #26323c; --r1: #6fa9e0; --r2: #3a86e0; --r3: #4a6fe8; --r4: #a06ae6;
  --ok: #3fbf7f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: inherit; }
.wrap { max-width: 1160px; margin: 0 auto; padding-inline: 16px; }

.masthead {
  background: var(--sign);
  color: var(--sign-ink);
  padding-top: env(safe-area-inset-top, 0px);
}
.masthead-inner { padding-block: 14px; }
.brand { display: flex; gap: 14px; align-items: center; }
.sign {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 2.5px solid currentColor; border-radius: 7px;
  font: 700 28px/1 var(--font-display);
}
h1 { margin: 0; font: 700 1.9rem/1 var(--font-display); letter-spacing: .01em; }
.tag { margin: 4px 0 0; font-size: .95rem; opacity: .9; }

.trip {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.field { display: grid; gap: 4px; min-width: 0; }
label {
  font: 600 .78rem/1.2 var(--font-body);
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.input-row { display: flex; gap: 8px; min-width: 0; }
input[type="text"], input[type="datetime-local"], select {
  width: 100%; min-width: 0;
  font: 500 1rem var(--font-body);
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; height: 44px;
}
select { width: auto; flex: none; }
input:focus-visible, select:focus-visible, button:focus-visible, .dep:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
button { font: 600 1rem var(--font-body); border-radius: 8px; cursor: pointer; height: 44px; }
.primary {
  background: var(--sign); color: var(--sign-ink); border: 0; padding: 0 22px;
  font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .03em;
}
.primary:disabled { opacity: .6; cursor: progress; }
.ghost {
  flex: none; background: transparent; color: var(--ink);
  border: 1px solid var(--line); padding: 0 12px; font-size: .9rem; white-space: nowrap;
}

.matches { grid-column: 1 / -1; display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.match { display: grid; gap: 6px; font-size: .92rem; min-width: 0; }
.match .line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.match .which { font: 600 .74rem var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); flex: none; width: 3.2em; }
.match .found { font-weight: 500; overflow-wrap: anywhere; }
.match .note { color: var(--muted); font-size: .85rem; font-style: italic; }
.match .choices { display: flex; flex-wrap: wrap; gap: 6px; padding-left: calc(3.2em + 8px); align-items: center; }
.match .choices span { color: var(--muted); font-size: .85rem; }
.match .choices button {
  height: auto; min-height: 32px; padding: 4px 10px; font: 500 .85rem var(--font-body);
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; text-align: left;
}
.match .choices button:hover { border-color: var(--sign); }
@media (max-width: 560px) { .match .choices { padding-left: 0; } }

.status { min-height: 1.5em; margin: 12px 2px; color: var(--muted); }
.status.error { color: var(--aws-emergency); font-weight: 600; }

.results {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding-bottom: 32px;
}
.col-main, .col-side { display: grid; gap: 16px; min-width: 0; }
.col-side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2 { margin: 0; font: 700 1.25rem/1.1 var(--font-display); letter-spacing: .02em; text-transform: uppercase; }
.sub { color: var(--muted); font-size: .85rem; }

/* Verdict */
.verdict .eyebrow { font: 600 .78rem var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.verdict .headline { margin: 0; font: 700 clamp(1.6rem, 4vw, 2.2rem)/1.08 var(--font-display); text-wrap: balance; }
.verdict .headline.wet { color: var(--r3); }
.verdict .headline.dry { color: var(--ok); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 0; }
.fact { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.fact dt { font: 600 .74rem var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fact dd { margin: 2px 0 0; font: 500 1.05rem/1.3 var(--font-body); }
.fact dd .num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.advice { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--bg); font-weight: 500; }

/* Flood */
.flood .flood-state { display: flex; gap: 10px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 .82rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.pill.clear { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.advice { background: var(--aws-advice); color: #1a1a1a; }
.pill.watch { background: var(--aws-watch); color: #1a1a1a; }
.pill.emergency { background: var(--aws-emergency); color: #fff; }
.pill.incident { background: var(--dry); color: var(--ink); }
.pill.unknown { background: var(--dry); color: var(--muted); }
.flood-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.flood-list li { border-top: 1px solid var(--line); padding-top: 10px; }
.flood-list .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.flood-list strong { font-weight: 600; }
.flood-list .where { color: var(--muted); font-size: .88rem; }
.flood-list details { margin-top: 6px; font-size: .92rem; }
.flood-list details p { white-space: pre-line; margin: 6px 0 0; color: var(--muted); }
.flood .note { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }

/* Route strip */
.strip-wrap { overflow-x: auto; }
.strip { display: flex; height: 38px; border-radius: 6px; overflow: hidden; min-width: 280px; background: var(--dry); }
.strip .seg { height: 100%; border-right: 1px solid color-mix(in srgb, var(--surface) 55%, transparent); }
.strip .seg:last-child { border-right: 0; }
.strip-axis { position: relative; height: 34px; min-width: 280px; font: 400 .74rem/1.2 var(--font-data); color: var(--muted); font-variant-numeric: tabular-nums; }
.strip-axis span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; text-align: center; }
.strip-axis span:first-child { transform: none; text-align: left; }
.strip-axis span:last-child { transform: translateX(-100%); text-align: right; }
.legend { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.legend li { display: inline-flex; gap: 6px; align-items: center; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.sw.dry, .c0 { background: var(--dry); }
.sw.r1, .c1 { background: var(--r1); }
.sw.r2, .c2 { background: var(--r2); }
.sw.r3, .c3 { background: var(--r3); }
.sw.r4, .c4 { background: var(--r4); }

/* Departure chart */
.chart-scroll { overflow-x: auto; padding-bottom: 4px; }
.departures { display: flex; align-items: flex-end; gap: 3px; height: 150px; min-width: 300px; position: relative; padding-top: 18px; }
.dep {
  flex: 1 1 0; min-width: 4px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch;
  background: none; border: 0; padding: 0; cursor: pointer; position: relative; border-radius: 3px;
}
.dep .bar { border-radius: 3px 3px 0 0; min-height: 3px; }
.dep .bar.c0 { background: var(--ok); opacity: .55; }
.dep:hover .bar { filter: brightness(1.12); }
.dep.selected { box-shadow: inset 0 0 0 2px var(--ink); }
.dep.best::before {
  content: "Best"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  font: 700 .66rem var(--font-body); color: var(--ok); text-transform: uppercase; letter-spacing: .06em;
}
.dep-axis { position: relative; height: 22px; min-width: 300px; font: 400 .72rem var(--font-data); color: var(--muted); }
.dep-axis span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.dep-axis span:first-child { transform: none; }
.hint { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }

/* Routes */
.routes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.route-opt {
  width: 100%; height: auto; min-height: 52px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px;
  align-items: center; text-align: left; padding: 10px 12px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
}
.route-opt[aria-pressed="true"] { border-color: var(--sign); box-shadow: inset 0 0 0 1px var(--sign); background: var(--surface); }
.route-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.route-meta { grid-column: 1; color: var(--muted); font-size: .88rem; font-weight: 500; }
.route-meta .num { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.rain-chip { grid-column: 2; grid-row: 1 / span 2; font: 600 .8rem var(--font-body); padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.rain-chip.c0 { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.rain-chip.c1 { color: #10233d; }
.rain-chip.c2, .rain-chip.c3, .rain-chip.c4 { color: #fff; }
.link-btn { height: auto; background: none; border: 0; padding: 0; color: var(--sign); font: 600 1rem var(--font-body); text-decoration: underline; cursor: pointer; }

/* Alerts */
.alert-form { display: grid; gap: 12px; }
.alert-trip { margin: 0; font-weight: 600; }
.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.alert-grid input[type="time"] { width: 100%; font: 500 1rem var(--font-body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; height: 44px; }
.alert-grid select { width: 100%; }
.days { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.days legend { font: 600 .78rem/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.day { text-transform: none; letter-spacing: 0; font: 500 .9rem var(--font-body); color: var(--ink); }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span { display: inline-block; min-width: 46px; text-align: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; }
.day input:checked + span { background: var(--sign); color: var(--sign-ink); border-color: var(--sign); }
.day input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: flex; gap: 8px; align-items: center; text-transform: none; letter-spacing: 0; font: 500 .92rem var(--font-body); color: var(--ink); }
.alert-form .primary { justify-self: start; }
.saved-title { margin: 18px 0 8px; font: 700 1rem var(--font-display); text-transform: uppercase; letter-spacing: .04em; }
.saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.saved li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; }
.saved-main { display: grid; gap: 2px; min-width: 0; }
.saved-actions { display: flex; gap: 6px; }
.ghost.small { height: 34px; font-size: .85rem; }
.alert-msg { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); font-size: .92rem; }

/* Map */
.map { height: 460px; border-radius: 8px; overflow: hidden; background: var(--dry); }
.map-toggles { margin-top: 8px; font-size: .88rem; }
.map-toggles label { text-transform: none; letter-spacing: 0; font-size: .88rem; color: var(--ink); font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.leaflet-container { font-family: var(--font-body); }
/* OSM has no dark style; dim and invert the base tiles only (radar and route keep true colours). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .map .leaflet-tile-pane > .leaflet-layer:first-child { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
}
:root[data-theme="dark"] .map .leaflet-tile-pane > .leaflet-layer:first-child { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
.credits { font-size: .76rem; color: var(--muted); margin: 0; }

@media (max-width: 900px) {
  .trip { grid-template-columns: 1fr 1fr; }
  .results { grid-template-columns: minmax(0, 1fr); }
  .col-side { position: static; }
  .map { height: 340px; }
}
@media (max-width: 560px) {
  .trip { grid-template-columns: minmax(0, 1fr); }
  .primary, .alert-form .primary { width: 100%; }
  h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
