.route-map-link,
#map-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.route-map-link {
  background: var(--mint);
  color: var(--green);
}

.route-map-link .icon,
#map-back .icon {
  width: 17px;
  height: 17px;
  flex: none;
}

.route-map-link:focus-visible,
#map-back:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.route-map-link:disabled {
  cursor: default;
  opacity: .55;
}

.station-picker-modal .route-map-link {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

.route-map-link-arrow {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.station-picker-modal > .route-map-link {
  margin-bottom: 10px;
}

.station-picker-modal[open]:has(.route-map-link:not([hidden])) {
  height: calc(min(360px, 50svh) + 222px);
}

.station-picker-modal[open]:has(> .route-map-link:not([hidden])) {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.route-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 10px;
}

#map-back {
  background: var(--theme-surface, #fff);
  color: var(--green);
}

.home-route-dialog {
  box-sizing: border-box;
  width: min(440px, calc(100% - 28px));
  max-height: calc(100svh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px;
  border-color: var(--line);
  background: var(--theme-surface, #fff);
  color: var(--ink);
}

.home-route-dialog .modal-top {
  gap: 12px;
  margin-bottom: 14px;
}

.home-route-dialog .modal-top h2 {
  margin: 0;
}

.route-endpoints {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--theme-subtle, var(--bg));
}

.route-endpoints strong {
  display: block;
  color: var(--ink);
  font-size: clamp(16px, 5vw, 20px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.route-endpoints > [aria-hidden="true"] {
  color: var(--muted);
  font-size: 18px;
}

#home-route-detail {
  min-width: 0;
}

#home-route-detail .route-timeline {
  margin-bottom: 12px;
}

#home-route-detail .route-segment {
  min-height: 58px;
}

.home-route-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.home-route-dialog-actions button {
  flex: 1 1 130px;
  min-width: 0;
  min-height: 44px;
  white-space: normal;
  line-height: 1.4;
}

.app-layout[data-map-purpose="station"] :is(.map-route-options, #recent-section) {
  display: none;
}

.app-layout[data-map-purpose="station"] .map-selection-status {
  top: 112px;
}

.app-layout[data-map-purpose="station"] .map-selection button:disabled {
  opacity: .55;
}

.app-layout[data-map-purpose="station"] .map-error {
  top: 145px;
}

.app-layout[data-map-purpose="station"] .map-card .map-canvas {
  top: 172px;
}

@media (max-width: 480px) {
  .home-route-dialog {
    padding: 17px;
  }
}
