:root {
  color-scheme: light;
  --paper: #fffdf7;
  --panel: #ffffff;
  --field: #f2f5ef;
  --ink: #1f2a23;
  --muted: #647069;
  --line: #d7dfd8;
  --line-strong: #bcc9be;
  --green: #207a51;
  --green-deep: #145b3c;
  --green-night: #092d22;
  --orange: #c96d32;
  --blue: #2b7896;
  --red: #b94d3f;
  --shadow: 0 16px 40px rgba(31, 42, 35, 0.13);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  background: #e9efe9;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--green-deep);
}

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

.trip-panel {
  min-height: 100vh;
  max-height: 100vh;
  overflow: auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  z-index: 2;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--green-night);
  color: #fff;
  box-shadow: 0 10px 24px rgba(32, 122, 81, 0.25);
  overflow: hidden;
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand-mark svg,
button svg,
.topline-chip svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--orange);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 300px;
  font-size: clamp(1.46rem, 2.4vw, 1.9rem);
  line-height: 1.04;
}

h2 {
  font-size: 1rem;
}

.planner {
  display: grid;
  gap: 14px;
}

.field,
.select-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.autocomplete-control {
  position: relative;
  display: block;
}

.field input,
.select-field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 13px;
  outline: none;
  text-transform: none;
  font-weight: 650;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.suggestions {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 900;
  display: none;
  max-height: 248px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 5px;
  text-transform: none;
}

.suggestions.show {
  display: grid;
  gap: 4px;
}

.suggestion-option {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  text-align: left;
}

.suggestion-option:hover,
.suggestion-option.active {
  background: var(--field);
}

.suggestion-main {
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.16;
}

.suggestion-meta {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.2;
}

.field input:focus,
.select-field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(32, 122, 81, 0.16);
}

.range-block {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--field);
  border: 1px solid var(--line);
}

.range-label,
.range-ticks,
.section-heading,
.button-row,
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.range-label label,
.range-label output {
  font-size: 0.84rem;
  font-weight: 850;
}

.range-label output {
  color: var(--green-deep);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
  margin: 12px 0 6px;
}

.range-ticks {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.filter-row {
  align-items: stretch;
}

.select-field {
  flex: 1;
  min-width: 0;
}

.button-row button,
.icon-button,
.route-link,
.add-course-button,
.stop-remove-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 850;
}

.primary-button {
  flex: 1;
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(32, 122, 81, 0.24);
}

.ghost-button {
  width: 116px;
  background: #f8ece3;
  color: #7d421e;
}

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  background: var(--field);
  color: var(--muted);
}

.route-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.route-link {
  min-width: 0;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  padding: 0 10px;
}

.route-link.secondary {
  background: #f8ece3;
  color: #7d421e;
}

.route-link.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.summary-grid div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 72px;
}

.summary-grid span {
  display: block;
  font-size: 1.15rem;
  line-height: 1.05;
  font-weight: 900;
}

.summary-grid small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  margin-top: 5px;
}

.status-text {
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  background: #edf5f6;
  border: 1px solid #cfe0e4;
  color: #275b68;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.35;
}

.status-text.error {
  background: #fff0ed;
  border-color: #efc4bb;
  color: #8e352b;
}

.status-text.good {
  background: #edf7ef;
  border-color: #cce2d0;
  color: #226041;
}

.results-shell {
  min-height: 0;
  display: grid;
  gap: 10px;
}

.trip-stops-shell {
  display: grid;
  gap: 10px;
}

.selected-stops-list {
  display: grid;
  gap: 7px;
}

.selected-stop {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 8px;
}

.stop-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.stop-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.stop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 900;
}

.stop-meta {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.stop-remove-button {
  width: 32px;
  min-height: 32px;
  background: var(--field);
  color: var(--muted);
}

.section-heading {
  padding-top: 2px;
}

.results-list {
  display: grid;
  gap: 9px;
}

.course-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
  display: grid;
  gap: 8px;
  text-align: left;
  color: inherit;
  transition:
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.course-card:hover,
.course-card.active,
.course-card.selected {
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 42, 35, 0.12);
}

.course-card.selected {
  background: #f4fbf5;
}

.course-title-row,
.course-meta,
.course-place,
.course-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.course-actions a {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: var(--field);
  padding: 4px 8px;
}

.course-actions {
  padding-top: 1px;
}

.add-course-button {
  min-height: 30px;
  background: var(--green);
  color: #fff;
  padding: 4px 9px;
  font-size: 0.78rem;
}

.add-course-button.selected {
  background: var(--green-night);
}

.course-title-row {
  justify-content: space-between;
  align-items: flex-start;
}

.course-title {
  font-weight: 900;
  line-height: 1.18;
  min-width: 0;
}

.source-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 7px;
  background: #edf3ed;
  color: var(--green-deep);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.source-pill.osm {
  background: #eef4f8;
  color: #25677f;
}

.course-meta span,
.course-place,
.course-actions a {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.course-meta span {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
}

.course-actions a {
  color: var(--green-deep);
  text-decoration: none;
}

.empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  text-align: center;
  padding: 24px;
  font-weight: 750;
}

.empty-state.compact {
  min-height: 86px;
  padding: 16px;
}

.source-note {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
  margin-top: auto;
}

.map-panel {
  min-height: 100vh;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
  background: #dde7dd;
}

.map-topline {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.topline-chip {
  min-height: 38px;
  max-width: min(50vw, 520px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  border: 1px solid rgba(31, 42, 35, 0.12);
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
  padding: 8px 11px;
  font-size: 0.84rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topline-chip.accent {
  color: #7d421e;
  background: rgba(255, 246, 239, 0.94);
}

.leaflet-popup-content {
  margin: 12px;
}

.popup-title {
  font-weight: 900;
  margin-bottom: 6px;
}

.popup-meta {
  display: grid;
  gap: 3px;
  color: #56625b;
  font-size: 0.82rem;
}

.loading {
  position: relative;
}

.loading::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  animation: spin 800ms linear infinite;
}

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

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

  .trip-panel {
    min-height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-panel {
    min-height: 62vh;
  }

  .map-topline {
    top: 12px;
    left: 12px;
    right: 12px;
  }
}

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

  .filter-row,
  .button-row {
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

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

  .topline-chip {
    max-width: 100%;
    font-size: 0.78rem;
  }

  .map-topline {
    align-items: flex-start;
    flex-direction: column;
  }
}
