:root {
  --accent: #E2503C;
  --ink: #141414;
  --ink-soft: #5a5a5a;
  --paper: #ffffff;
  --paper-warm: #fafaf8;
  --line: #e6e4e0;
  --header-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  flex: 0 0 auto;
}

.header__title {
  font-size: clamp(1.25rem, 3.5vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.header__subtitle {
  font-size: clamp(0.7rem, 2vw, 0.85rem);
  color: var(--ink-soft);
  margin-top: 0.15rem;
}

.header__coords {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 340px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink);
  background: var(--paper-warm);
  min-height: 0;
}

.map {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--paper-warm);
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.7rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn:hover { background: var(--ink); color: var(--paper); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: #c73f2d; border-color: #c73f2d; color: #fff; }

.btn--primary[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
}

.controls__step { display: flex; gap: 0.35rem; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
  margin-left: auto;
  user-select: none;
}

.toggle input { accent-color: var(--accent); width: 1rem; height: 1rem; }

/* ---------- Stop list ---------- */

.stop-list {
  list-style: none;
  overflow-y: auto;
  flex: 1 1 auto;
  padding: 0.5rem 0 1.5rem;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .stop-list { scroll-behavior: auto; }
}

.stop-card {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.stop-card:hover { background: #f1efeb; }

.stop-card.is-active {
  background: var(--ink);
  color: var(--paper);
}

.stop-card.is-active .stop-card__caption,
.stop-card.is-active .stop-card__meta { color: #cfcfcf; }

.stop-card__num {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 0.1rem;
}

.stop-card__name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stop-card__caption {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.stop-card__meta {
  font-size: 0.7rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Markers ---------- */

.marker { background: none; border: none; }

.marker__dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.15s;
}

.marker--active .marker__dot {
  transform: scale(1.35);
  background: var(--ink);
  z-index: 1000;
}

.marker--sub .marker__dot {
  background: var(--paper);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.leaflet-marker-icon:focus-visible,
.btn:focus-visible,
.stop-card:focus-visible,
.toggle input:focus-visible,
.popup__link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Popups ---------- */

.leaflet-popup-content-wrapper {
  border-radius: 4px;
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(20, 20, 20, 0.12);
  font-family: "Space Grotesk", sans-serif;
}

.leaflet-popup-content { margin: 0.85rem 1rem; line-height: 1.4; }
.leaflet-popup-tip { border: 1px solid var(--ink); }

.popup__num {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.popup__name { font-size: 1.02rem; font-weight: 700; margin: 0.1rem 0 0.2rem; }

.popup__caption { font-size: 0.83rem; color: var(--ink-soft); font-style: italic; }

.popup__meta {
  font-size: 0.73rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  letter-spacing: 0.03em;
}

.popup__link {
  display: inline-block;
  margin-top: 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}

.popup__link:hover { color: #c73f2d; }

/* ---------- Attribution ---------- */

.leaflet-control-attribution {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.62rem;
  background: rgba(255, 255, 255, 0.85);
}

/* ---------- Mobile: bottom sheet ---------- */

@media (max-width: 720px) {
  .header { padding: 0.7rem 1rem; }
  .header__coords { display: none; }

  .layout { flex-direction: column; }

  .map { order: 1; flex: 1 1 55%; }

  .sidebar {
    order: 2;
    width: 100%;
    flex: 0 0 42%;
    border-right: none;
    border-top: 1px solid var(--ink);
  }

  .stop-list { -webkit-overflow-scrolling: touch; }
}
