:root {
  --bg: #0b0f14;
  --sheet: rgba(14, 18, 24, 0.92);
  --ink: #f2f4f7;
  --muted: #9aa3ad;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #3d9cf0;
  --bike: #9ae6b4;
  --bart: #3b82f6;
  --caltrain: #ef4444;
  --smart: #22c55e;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--sans);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  --sheet-width: 280px;
  display: grid;
  grid-template-columns: var(--sheet-width) 6px 1fr;
  height: 100%;
  min-height: 100dvh;
}

.sheet-resizer {
  position: relative;
  z-index: 600;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
}

.sheet-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--line);
}

.sheet-resizer:hover::after,
.sheet-resizer:focus-visible::after,
.app.is-resizing .sheet-resizer::after {
  width: 2px;
  background: rgba(61, 156, 240, 0.7);
}

.app.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.app.is-resizing .map-pane {
  pointer-events: none;
}

@media (max-width: 800px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(55dvh, 70vw);
    height: auto;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
  }
  .sheet-resizer {
    display: none;
  }
  .sheet {
    order: 1;
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
    gap: 0.65rem;
    border-radius: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.75rem;
  }
  .sheet__brand h1 {
    font-size: 1.15rem;
  }
  .sheet__tag {
    display: none;
  }
  .search {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .search__fields {
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .search-hint {
    display: none;
  }
  .go {
    position: static;
    box-shadow: none;
  }
  .results {
    overflow: visible;
  }
  .credit {
    display: none;
  }
  .map-pane {
    order: 2;
    position: relative;
    height: min(70vw, 65dvh);
    min-height: 55dvh;
  }
}

.search__fields {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.map-pane { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; background: #1a222c; }

.sheet {
  position: relative;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 0.9rem 0.9rem;
  background: var(--sheet);
  backdrop-filter: blur(16px);
  border-right: 0;
  overflow: auto;
  min-width: 0;
}

.sheet__brand h1 {
  margin: 0.15rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.sheet__home {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
}

.sheet__tag {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.search {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  padding: 0.7rem 0.8rem;
}

.when {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.when__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.when__modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.when__btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.55rem 0.25rem;
  cursor: pointer;
}

.when__btn.is-active {
  color: var(--ink);
  border-color: rgba(61, 156, 240, 0.55);
  background: rgba(61, 156, 240, 0.12);
}

#whenInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.7rem 0.8rem;
}

#whenInput:not([hidden]) {
  display: block;
}

.field input:focus {
  outline: 2px solid rgba(61, 156, 240, 0.45);
  outline-offset: 1px;
}

.field__row {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  flex: 0 0 auto;
  width: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}

.swap-row {
  display: flex;
  justify-content: flex-end;
  margin: -0.35rem 0.15rem -0.35rem 0;
}

.swap-btn {
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0.55;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.swap-btn:hover {
  opacity: 1;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.search-hint {
  margin: -0.15rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
}

.go {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #061018;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.go:disabled {
  opacity: 0.55;
  cursor: wait;
}

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

.results {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.option {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.option.is-selected {
  border-color: rgba(61, 156, 240, 0.55);
  background: rgba(61, 156, 240, 0.1);
}

.option .card {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.option.is-selected .card {
  border-color: transparent;
  background: transparent;
}

.option__legs {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--line);
  margin-top: 0;
  padding-top: 0.75rem;
}

.card {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: inherit;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}

.card.is-selected {
  border-color: rgba(61, 156, 240, 0.55);
  background: rgba(61, 156, 240, 0.1);
}

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

.card__time {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card__tag {
  flex-shrink: 0;
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.card__tag[data-kind="bike"] {
  color: #9ae6b4;
  border-color: rgba(154, 230, 180, 0.35);
  background: rgba(154, 230, 180, 0.08);
}

.card__tag[data-kind="bike_rail"] {
  color: #7eb8f0;
  border-color: rgba(61, 156, 240, 0.4);
  background: rgba(61, 156, 240, 0.1);
}

.card__timing {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.35;
}

.card__summary {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.legs {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.25rem;
}

.leg {
  display: grid;
  grid-template-columns: 0.55rem 1fr;
  gap: 0.65rem;
  align-items: start;
}

.leg__dot {
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.35rem;
  border-radius: 50%;
  background: var(--bike);
}

.leg[data-mode="bart"] .leg__dot { background: var(--bart); }
.leg[data-mode="caltrain"] .leg__dot { background: var(--caltrain); }
.leg[data-mode="smart"] .leg__dot { background: var(--smart); }

.leg__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
}

.leg__meta {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.credit {
  margin-top: auto;
  padding-top: 0.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.credit p {
  margin: 0 0 0.35rem;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(14, 18, 24, 0.75) !important;
  color: #9aa3ad !important;
}

.station-label {
  background: none !important;
  border: none !important;
}

.station-label__chip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 7rem;
  max-width: 11rem;
  padding: 0.35rem 0.5rem 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 3px solid var(--stop, #3d9cf0);
  background: rgba(14, 18, 24, 0.92);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  color: #f2f4f7;
  font-family: var(--sans);
  line-height: 1.2;
  white-space: normal;
  pointer-events: none;
}

.station-label__action {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.station-label__name {
  font-size: 0.78rem;
  font-weight: 650;
}
