:root {
  color-scheme: light;
  --bg: #f3f6f2;
  --panel: #ffffff;
  --panel-2: #e4eee7;
  --ink: #1b201e;
  --muted: #52615b;
  --line: rgba(27, 48, 40, .18);
  --route: #c75d32;
  --green: #34765a;
  --gold: #9a6e25;
  --red: #a84834;
  --blue: #416f91;
  --shadow: 0 18px 42px rgba(32, 52, 42, .10);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #edf3ee 0%, var(--bg) 46%, #fbfcf8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a,
button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

button {
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  border-color: color-mix(in srgb, var(--route) 60%, var(--line));
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px clamp(14px, 3vw, 34px) 12px;
  border-bottom: 1px solid var(--line);
}

.ao-link {
  text-decoration: none;
}

.ao-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font-weight: 900;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 1px 0 0;
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.trip-controls {
  display: flex;
  gap: 10px;
  align-items: end;
}

.trip-controls label {
  display: grid;
  gap: 5px;
}

.trip-controls span {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.trip-controls input,
.trip-controls select {
  height: 38px;
  padding: 0 10px;
  font-weight: 800;
}

.trip-controls input {
  width: 74px;
}

.trip-controls label:nth-child(2) input {
  width: min(290px, 36vw);
}

.arrival-control input {
  width: 118px;
}

.stable-screen {
  width: calc(100% - 28px);
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px 0 26px;
}

.instruction-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, .55fr);
  gap: 14px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(229, 239, 231, .92));
  box-shadow: var(--shadow);
}

.instruction-band h2 {
  margin: 2px 0 0;
  font-size: clamp(2.2rem, 5.4vw, 4.2rem);
  line-height: .94;
  letter-spacing: 0;
}

.instruction-detail {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.22;
  font-weight: 760;
}

.trip-layout {
  display: grid;
  grid-template-columns: minmax(420px, .95fr) minmax(390px, .72fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.map-stack {
  position: sticky;
  top: 10px;
  display: grid;
  gap: 10px;
}

.plan-stack {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.trip-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .9);
}

.trip-nav strong {
  min-width: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.2;
  font-weight: 780;
  text-align: center;
  overflow-wrap: anywhere;
}

.timeline {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
}

.step {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .9);
  cursor: pointer;
}

.step:hover {
  border-color: color-mix(in srgb, var(--route) 42%, var(--line));
}

.step-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--route) 15%, #ffffff);
  color: color-mix(in srgb, var(--ink) 72%, var(--route));
  font-size: .82rem;
  font-weight: 900;
}

.step-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: 104px minmax(120px, .42fr) minmax(0, 1fr);
  gap: 3px 12px;
  align-items: center;
}

.step-copy .label {
  grid-column: 1;
  grid-row: 1 / span 4;
}

.step-copy strong {
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: center;
}

.step strong {
  font-size: clamp(1.05rem, 1.6vw, 1.42rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.step small {
  grid-column: 3;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.22;
  font-weight: 720;
}

.map-panel,
.state-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, .9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#map {
  width: 100%;
  height: min(63vh, 650px);
  min-height: 430px;
  background: #dde8df;
}

.map-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .94);
  color: var(--muted);
  font-size: .74rem;
  line-height: 1;
  font-weight: 780;
}

.map-legend span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.legend-dot {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid #fffaf1;
  color: #fffaf1;
  font-size: .62rem;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(40, 30, 20, .16);
}

.state-panel {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 4px 0;
}

.state-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.state-line .label {
  grid-column: 1 / -1;
}

.state-line strong {
  font-size: 1rem;
  line-height: 1.2;
}

.state-line:last-child {
  border-bottom: 0;
}

.sources {
  grid-template-columns: 1fr;
}

.route-line {
  stroke: var(--route);
}

.leaflet-marker-icon.bus-marker,
.leaflet-marker-icon.stop-marker,
.leaflet-marker-icon.user-marker,
.leaflet-marker-icon.exit-marker,
.leaflet-marker-icon.dest-marker {
  background: transparent;
  border: 0;
}

.pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #fffaf1;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(40, 30, 20, .25);
  color: #fffaf1;
  font-size: 12px;
  font-weight: 900;
}

.pin.bus {
  width: 34px;
  height: 34px;
  background: var(--route);
}

.pin.user {
  background: var(--blue);
}

.pin.stop {
  background: var(--gold);
}

.pin.exit {
  background: var(--red);
}

.pin.dest {
  background: var(--green);
}

.pin.pull,
.legend-dot.pull {
  background: #8d6b2e;
}

.legend-dot.user {
  background: var(--blue);
}

.legend-dot.stop {
  background: var(--gold);
}

.legend-dot.exit {
  background: var(--red);
}

.legend-dot.dest {
  background: var(--green);
}

.fresh {
  color: var(--green);
}

.stale,
.miss {
  color: var(--red);
}

.caution {
  color: var(--gold);
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .trip-controls {
    grid-column: 1 / -1;
    width: 100%;
    flex-wrap: wrap;
  }

  .trip-controls label:nth-child(2) {
    flex: 1;
  }

  .trip-controls label:nth-child(2) input,
  .trip-controls select {
    width: 100%;
  }

  .instruction-band,
  .trip-layout {
    grid-template-columns: 1fr;
  }

  .map-stack {
    display: contents;
  }

  .map-panel {
    order: 1;
  }

  .plan-stack {
    order: 2;
  }

  .state-panel {
    order: 3;
  }

  .step-copy {
    grid-template-columns: 104px minmax(128px, .42fr) minmax(0, 1fr);
  }

  #map {
    height: 48vh;
    min-height: 330px;
  }
}

@media (max-width: 520px) {
  .stable-screen {
    width: calc(100% - 20px);
    padding-top: 10px;
  }

  .trip-controls {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .arrival-control {
    grid-column: 1 / -1;
  }

  .arrival-control input {
    width: 100%;
  }

  .timeline {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .step {
    min-height: 0;
    padding: 10px;
  }

  .step-copy {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .step-copy .label,
  .step-copy strong,
  .step small {
    grid-column: 1;
    grid-row: auto;
  }

  .instruction-band {
    padding: 12px;
  }

  .instruction-band h2 {
    font-size: clamp(1.85rem, 11vw, 2.85rem);
  }

  .instruction-detail {
    font-size: .95rem;
  }

  #map {
    height: 44vh;
    min-height: 300px;
  }

  .state-line {
    padding: 11px 12px;
  }

  .trip-nav {
    grid-template-columns: 1fr 1fr;
  }

  .trip-nav strong {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .trip-nav button:first-child {
    grid-column: 1;
  }

  .trip-nav button:last-child {
    grid-column: 2;
  }
}
