:root {
  --ink: #12151a;
  --muted: #5c6672;
  --line: #d5dbe3;
  --panel: #f4f6f8;
  --accent: #0b6e4f;
  --accent-soft: rgba(11, 110, 79, 0.12);
  --rail-w: 300px;
  --font: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #e8eef2;
}

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

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-height: 0;
  z-index: 5;
}

.rail__brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.rail__brand a {
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}

.rail__brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.rail__section {
  padding: 0.75rem 0.85rem 0.5rem;
  border-bottom: 1px solid var(--line);
  min-height: 0;
}

.rail__section--agency {
  flex: 0 0 auto;
  padding-bottom: 0.75rem;
}

.rail__section--routes {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail__section h2,
.rail__label {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
}

.rail__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.rail__search,
.rail__select {
  width: 100%;
  margin-bottom: 0.45rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 0.88rem;
  color: inherit;
}

.rail__select {
  margin-bottom: 0;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6672' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 1.8rem;
}

.route-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.route-list li label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  padding: 0.45rem 0.35rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
  color: inherit;
}

.route-list li label:hover {
  background: rgba(0, 0, 0, 0.04);
}

.route-swatch {
  width: 10px;
  height: 10px;
  margin-top: 0.35rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

.route-list li label strong {
  font-size: 0.92rem;
}

.route-list li label em {
  display: block;
  font-style: normal;
  font-size: 0.75rem;
  color: var(--muted);
}

.rail__hint {
  padding: 0.5rem 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.rail__status {
  padding: 0.65rem 1rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.rail__footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fare-link {
  display: block;
  margin: 0.75rem 0.85rem 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.fare-link:hover {
  filter: brightness(1.06);
}

.fare-link[hidden] {
  display: none;
}

.map-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: #dce5ec;
}

.rail-toggle {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.vehicle-icon {
  background: transparent !important;
  border: 0 !important;
}

.vehicle-dot {
  width: 16px;
  height: 16px;
  margin: 2px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.vehicle-arrow {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.vehicle-arrow svg {
  display: block;
}

.vehicle-arrow path {
  fill: var(--vehicle-color, #0b6e4f);
  stroke: #fff;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.vehicle-popup .leaflet-popup-content,
.stop-popup .leaflet-popup-content {
  margin: 0.65rem 0.8rem;
  font-family: var(--font);
  line-height: 1.35;
  min-width: 140px;
}

.vp__title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.vp__line {
  font-size: 0.86rem;
}

.vp__meta {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

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

  .rail {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.18);
  }

  .rail.is-open {
    transform: translateX(0);
  }

  .rail-toggle {
    display: block;
  }
}

/* —— API docs page —— */
body.docs {
  height: auto;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(11, 110, 79, 0.12), transparent 55%),
    linear-gradient(180deg, #eef3f6 0%, #e4ebf0 100%);
}

.docs-shell {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

.docs-hero {
  margin-bottom: 2rem;
}

.docs-brand {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.docs-brand a {
  text-decoration: none;
  color: var(--muted);
}

.docs-brand a:hover {
  color: var(--accent);
}

.docs-hero h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.85rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.docs-dek {
  margin: 0 0 1.1rem;
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 36rem;
}

.docs-base {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.75rem;
  margin: 0;
  padding: 0.7rem 0.85rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.docs-base span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-base code,
.docs-code code,
.docs-table code {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.docs-section {
  margin-bottom: 1.75rem;
}

.docs-section h2 {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-table {
  display: grid;
  gap: 0;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.docs-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  line-height: 1.35;
}

.docs-row:first-child {
  border-top: 0;
}

.docs-row--head {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.03);
}

.docs-code {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: #1a1f24;
  color: #e8eef2;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.docs-note {
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.docs-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.docs-links a {
  font-weight: 600;
  text-decoration: none;
}

.docs-links a:hover {
  text-decoration: underline;
}

.docs-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}

.docs-footer a {
  text-decoration: none;
}

.docs-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .docs-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
