:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #141922;
  --panel-raised: #1a202b;
  --panel-soft: #11161e;
  --border: #2b3240;
  --border-bright: #3d4657;
  --text: #f4f1f8;
  --muted: #9ca6b7;
  --accent: #c084fc;
  --accent-strong: #a855f7;
  --good: #22c55e;
  --caution: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 18px 45px rgb(0 0 0 / 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgb(192 132 252 / 0.11), transparent 30rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
  background: rgb(13 17 23 / 0.86);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  border-radius: 10px;
  box-shadow: 0 0 20px rgb(192 132 252 / 0.15);
}

.brand span {
  display: grid;
}

.brand strong {
  font-size: 1.08rem;
  letter-spacing: 0.015em;
}

.brand small {
  color: var(--muted);
  font-size: 0.7rem;
}

.network-note {
  display: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.network-note::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--network-color, var(--good));
  box-shadow: 0 0 8px var(--network-color, var(--good));
}

.leaflet-tile-pane {
  filter: brightness(0.72) saturate(0.7) contrast(1.12);
}

.app-layout {
  display: grid;
  gap: 16px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.input-panel,
.map-panel,
.results {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgb(20 25 34 / 0.94);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 20px;
}

.section-heading h1,
.timeline-heading h2,
.verdict h2 {
  margin: 0;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.section-heading h1 {
  max-width: 22ch;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.08;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#route-form {
  margin-top: 22px;
}

.route-inputs {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: #cbd2dd;
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  outline: none;
  background: var(--panel-soft);
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input::placeholder {
  color: #646e7e;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(192 132 252 / 0.13);
}

.waypoint-list {
  display: grid;
  gap: 12px;
}

.waypoint-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
}

.remove-waypoint {
  width: 42px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.remove-waypoint:hover,
.remove-waypoint:focus-visible {
  border-color: var(--bad);
  color: #fca5a5;
}

.text-button {
  justify-self: start;
  padding: 3px 1px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.trip-options {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #170d20;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 30px rgb(168 85 247 / 0.24);
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  filter: saturate(0.6);
  opacity: 0.75;
}

.button-spinner {
  display: none;
  width: 17px;
  height: 17px;
  margin-left: 10px;
  border: 2px solid rgb(23 13 32 / 0.25);
  border-top-color: #170d20;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.primary-button.is-loading .button-spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.form-status {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.form-status.is-error {
  padding: 10px 12px;
  border: 1px solid rgb(239 68 68 / 0.4);
  border-radius: 9px;
  background: rgb(239 68 68 / 0.09);
  color: #fca5a5;
}

.map-panel {
  position: relative;
  min-height: 360px;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #10151d;
}

.map-placeholder {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 30px;
  background:
    linear-gradient(rgb(13 17 23 / 0.4), rgb(13 17 23 / 0.82)),
    repeating-linear-gradient(135deg, transparent 0 24px, rgb(192 132 252 / 0.025) 24px 25px);
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.map-placeholder[hidden] {
  display: none;
}

.map-placeholder strong {
  color: #d8dce5;
  font-size: 0.95rem;
}

.map-placeholder span:last-child {
  max-width: 34ch;
  font-size: 0.78rem;
  line-height: 1.45;
}

.map-placeholder-icon {
  color: var(--accent);
  font-size: 2.5rem;
}

/* The global `* { box-sizing: border-box }` reset breaks Leaflet's tile
   layout (tiles rely on content-box) → scrambled/gapped tiles. Restore
   content-box inside the map only. */
.leaflet-container,
.leaflet-container * {
  box-sizing: content-box;
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-control-attribution {
  background: rgb(13 17 23 / 0.8) !important;
  color: #aab2c0;
}

.leaflet-control-attribution a {
  color: #d8b4fe;
}

.leaflet-bar a {
  border-color: var(--border) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
}

.leaflet-tooltip.roadcast-tooltip {
  padding: 8px 10px;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: #11161e;
  color: var(--text);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.45);
  font-size: 0.75rem;
}

.roadcast-tooltip::before {
  border-top-color: #11161e !important;
}

.results {
  min-width: 0;
  padding: 16px;
}

.results[hidden] {
  display: none;
}

.verdict {
  display: grid;
  gap: 16px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid currentColor;
  border-radius: 14px;
  position: relative;
}

.verdict::after {
  content: "";
  position: absolute;
  right: -36px;
  bottom: -70px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: currentColor;
  filter: blur(70px);
  opacity: 0.18;
}

.verdict.good { color: var(--good); background: rgb(34 197 94 / 0.06); }
.verdict.caution { color: var(--caution); background: rgb(245 158 11 / 0.06); }
.verdict.bad { color: var(--bad); background: rgb(239 68 68 / 0.07); }

.verdict .eyebrow,
.verdict h2 {
  color: inherit;
}

.verdict h2 {
  font-size: clamp(2.1rem, 9vw, 3.5rem);
  line-height: 0.95;
}

#verdict-reason {
  max-width: 56ch;
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}

.trip-summary {
  display: flex;
  gap: 22px;
  margin: 0;
  position: relative;
  z-index: 1;
}

.trip-summary div {
  display: grid;
  gap: 3px;
}

.trip-summary dt {
  color: var(--muted);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trip-summary dd {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.timeline-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 4px 12px;
}

.timeline-heading h2 {
  font-size: 1.1rem;
}

.timeline-heading > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.7rem;
}

.timeline {
  display: flex;
  gap: 10px;
  max-width: 100%;
  padding: 2px 2px 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--border-bright) transparent;
}

.weather-card {
  flex: 0 0 170px;
  min-height: 240px;
  padding: 14px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--category-color);
  border-radius: 12px;
  outline: none;
  background: var(--panel-raised);
  color: var(--text);
  text-align: left;
  scroll-snap-align: start;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.weather-card:hover,
.weather-card:focus-visible,
.weather-card.is-active {
  border-color: var(--category-color);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3), 0 0 0 2px color-mix(in srgb, var(--category-color) 25%, transparent);
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-time {
  font-size: 0.84rem;
  font-weight: 800;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--category-color);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--category-color);
  box-shadow: 0 0 7px var(--category-color);
}

.card-temp {
  margin: 17px 0 3px;
  font-size: 2.35rem;
  font-weight: 780;
  letter-spacing: -0.06em;
  line-height: 1;
}

.card-condition {
  min-height: 2.5em;
  margin: 0 0 13px;
  color: #c9d0dc;
  font-size: 0.76rem;
  line-height: 1.3;
}

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 0;
}

.card-metrics div {
  display: grid;
  gap: 1px;
}

.card-metrics dt {
  color: var(--muted);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.card-metrics dd {
  margin: 0;
  font-size: 0.73rem;
  font-weight: 700;
}

.forecast-limit {
  display: block;
  margin-top: 10px;
  color: var(--caution);
  font-size: 0.63rem;
  font-weight: 800;
}

footer {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 16px 28px;
  color: #737e8e;
  font-size: 0.67rem;
  line-height: 1.5;
  text-align: center;
}

footer a {
  color: #aeb7c6;
}

@media (min-width: 620px) {
  .network-note { display: inline; }
  /* minmax(0,1fr) so the wide datetime-local input can't steal width from the
     select (1fr = minmax(auto,1fr) lets its min-content width squeeze the select). */
  .trip-options { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .trip-options .field { min-width: 0; }
  .verdict { grid-template-columns: auto 1fr; align-items: center; }
  .trip-summary { grid-column: 1 / -1; }
  footer { flex-direction: row; justify-content: space-between; padding-inline: 30px; }
}

@media (min-width: 980px) {
  .app-layout {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    grid-template-rows: minmax(590px, calc(100vh - 116px)) auto;
    align-items: stretch;
    padding: 22px;
  }

  .input-panel {
    grid-column: 1;
    grid-row: 1;
    overflow-y: auto;
    padding: 24px;
  }

  .map-panel {
    grid-column: 2;
    grid-row: 1;
    min-height: 590px;
  }

  #map { min-height: 590px; }

  .results {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 20px;
  }

  .verdict {
    grid-template-columns: minmax(150px, auto) 1fr auto;
  }

  .trip-summary {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
