.journey-dialog {
  position: fixed;
  inset: 0;
  width: min(34rem, calc(100% - 2rem));
  max-width: none;
  max-height: min(44rem, calc(100% - 2rem));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--fg);
  box-shadow: 0 16px 54px #10161055;
  overflow: hidden;
}

.journey-dialog[open] {
  display: flex;
  flex-direction: column;
}

.journey-dialog::backdrop { background: #10161084; }
html:has(.journey-dialog[open]) { overflow: hidden; }

.journey-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px 13px;
}

.journey-heading { font-size: clamp(20px, 5vw, 26px); line-height: 1.18; letter-spacing: -.025em; }
.journey-title { margin-top: 6px; font-size: 15px; font-weight: 760; }
.journey-detail { margin-top: 3px; color: var(--muted); font-size: 13px; }

.journey-close {
  flex: 0 0 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
  font-size: 23px;
  line-height: 1;
}

.journey-destination {
  margin: 0 18px 12px;
  color: var(--muted);
  font-size: 13px;
}

.journey-destination strong { color: var(--fg); }

.journey-progress {
  flex: 0 0 auto;
  margin: 0 18px 12px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
  color: var(--muted);
}

.journey-progress--next {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  border-inline-start: 4px solid var(--yellow);
  background: var(--yellow-soft);
  color: var(--fg);
}

.journey-progress strong { font-size: 16px; }

.journey-body {
  position: relative;
  min-height: 0;
  padding: 0 18px 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.journey-stops { padding: 0; margin: 0; list-style: none; }

.journey-stop {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 5px 12px;
  min-height: 42px;
  margin-inline-start: 10px;
  padding: 8px 8px 8px 16px;
  border-inline-start: 2px solid var(--line);
  font-size: 14px;
}

.journey-stop::before {
  position: absolute;
  inset-inline-start: -6px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--card);
  content: '';
}

.journey-stop--timed { grid-template-columns: minmax(0, 1fr) minmax(0, 40%); }
.journey-stop-labels { display: grid; gap: 2px; min-width: 0; }
.journey-stop-name { overflow-wrap: anywhere; }
.journey-stop-status { color: var(--muted); font-size: 11px; font-weight: 720; }
.journey-stop[data-state='next'] { background: var(--yellow-soft); border-radius: 0 8px 8px 0; font-weight: 760; }
.journey-stop[data-state='next']::before { border-color: #936c00; background: var(--yellow); }
.journey-stop[data-state='current']::before { border-color: var(--green); background: var(--green); }
.journey-stop[data-state='skipped'] .journey-stop-name { color: var(--muted); text-decoration: line-through; }
.journey-stop[data-state='passed'] .journey-stop-name { color: var(--muted); }
.journey-stop--continuation { border-top: 1px solid var(--line); }
.journey-stop--continuation::before { top: auto; bottom: 4px; }
.journey-stop-continuation { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 740; }

.journey-call {
  display: grid;
  justify-items: end;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.journey-call-values, .journey-call-meta {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 6px;
}

.journey-call-time { font-size: 15px; font-weight: 800; }
.journey-countdown { font-size: 12px; font-weight: 740; color: var(--green); }
.journey-call-source { font-size: 11px; font-weight: 600; color: var(--muted); }

.journey-delay {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--green-soft);
  color: var(--green);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 730;
  line-height: 1.18;
}

.journey-delay--late { background: #fae4db; color: #8f2f25; }
.journey-delay--early { background: #e5f1f8; color: #185378; }
.journey-delay--unknown { background: var(--soft); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
:root[data-theme='dark'] .journey-delay--late { background: #58332b; color: #ffd1c4; }
:root[data-theme='dark'] .journey-delay--early { background: #273f52; color: #b6dcf6; }

.journey-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.journey-link {
  min-height: 44px;
  text-align: start;
  font-weight: 720;
  text-decoration: underline;
  text-underline-offset: .15em;
}

.network-popup .journey-link { color: #254d35; }

@media (max-width: 620px) {
  .journey-dialog {
    inset: auto 0 0;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 20px 20px 0 0;
  }
  .journey-stop--timed { grid-template-columns: minmax(0, 1fr) minmax(0, 43%); }
}
