:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64706d;
  --line: #d9e0dc;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --accent: #1d7f6e;
  --accent-dark: #0d5148;
  --route: #e05f3b;
  --shadow: 0 18px 50px rgba(27, 36, 32, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  min-height: 100vh;
}

.map-panel {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 100vh;
  min-height: 520px;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: #dbe5e1;
}

.map-status {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 500;
  max-width: min(420px, calc(100% - 36px));
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.trip-panel {
  position: relative;
  z-index: 2;
  min-width: 0;
  padding: 32px 28px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: auto;
}

.trip-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.02;
  letter-spacing: 0;
}

.intro {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.trip-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0;
}

.trip-stats div {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.trip-stats span {
  display: block;
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.trip-stats small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.stops-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stop-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.stop-card:hover,
.stop-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(29, 127, 110, 0.12);
}

.stop-number,
.marker-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent-dark);
  font-size: 13px;
  font-weight: 850;
}

.stop-card h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.stop-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.segment-meta {
  margin-top: 9px;
  color: var(--route);
  font-size: 12px;
  font-weight: 800;
}

.source-note {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.leaflet-popup-content {
  margin: 12px;
  color: var(--ink);
  font-family: inherit;
}

.popup-title {
  margin: 0 0 4px;
  font-weight: 850;
}

.popup-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .map-panel {
    position: relative;
    height: 58vh;
    min-height: 380px;
  }

  .trip-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .trip-panel {
    padding: 24px 18px;
  }

  .trip-stats,
  .toolbar {
    grid-template-columns: 1fr;
  }
}
