:root {
  color-scheme: light dark;
  --page: light-dark(#f3f1eb, #17191b);
  --surface: light-dark(#ffffff, #222528);
  --ink: light-dark(#202529, #f4f3ef);
  --muted: light-dark(#667078, #aeb6bc);
  --line: light-dark(#d9d5ca, #3d4247);
  --brand: light-dark(#165b48, #71c7ad);
  --brand-soft: light-dark(#e2f1eb, #203b34);
  --open: light-dark(#176b45, #70d39e);
  --open-soft: light-dark(#e3f3ea, #17392a);
  --closed: light-dark(#a53030, #ff8a8a);
  --closed-soft: light-dark(#f9e7e5, #442426);
  --warning: light-dark(#936214, #ffd176);
  --warning-soft: light-dark(#fff2c7, #493d1f);
  --shadow: light-dark(rgba(25, 31, 34, .14), rgba(0, 0, 0, .38));
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--page);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", Arial, sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--page);
}

.crossing-nav {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.crossing-nav a {
  display: grid;
  min-height: 46px;
  place-items: center;
  color: var(--muted);
  font-size: .84rem;
  text-decoration: none;
}

.crossing-nav a[aria-current="page"] {
  color: var(--brand);
  box-shadow: inset 0 -3px 0 var(--brand);
  font-weight: 700;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 17px 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: 1.25rem;
}

.page-clock {
  display: grid;
  gap: 1px;
  text-align: right;
}

#page-time {
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

#page-date {
  color: var(--muted);
  font-size: .8rem;
  white-space: nowrap;
}

.status-panel {
  margin: 12px;
  padding: 13px 14px 11px;
  border-radius: 14px;
}

.status-panel.open {
  background: var(--open-soft);
}

.status-panel.closed {
  background: var(--closed-soft);
}

.status-panel.loading,
.status-panel.unknown {
  background: var(--warning-soft);
}

.barrier-line {
  font-size: 1rem;
  line-height: 1.42;
}

.barrier-word {
  font-weight: 700;
}

.draw-link {
  color: var(--brand);
  font-weight: 700;
  white-space: nowrap;
}

.status-panel.open .barrier-word {
  color: var(--open);
}

.status-panel.closed .barrier-word {
  color: var(--closed);
}

.freshness {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: var(--muted);
  font-size: .73rem;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--open);
  border-radius: 50%;
}

.freshness.stale .freshness-dot {
  background: var(--warning);
}

.freshness.failed .freshness-dot {
  background: var(--closed);
}

.timeline {
  margin: 0 12px 12px;
  padding: 0;
  color: var(--muted);
  font-size: .78rem;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 7px;
  padding: 1px 2px;
  line-height: 1.25;
}

.timeline time,
.expected-time,
.minutes {
  font-variant-numeric: tabular-nums;
}

.timeline time {
  color: var(--ink);
}

.section-heading {
  padding: 7px 16px 5px;
  color: var(--muted);
  font-size: .76rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.services {
  padding-bottom: 2px;
}

.service {
  position: relative;
  margin: 0 10px 9px;
  overflow: hidden;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 2px 9px var(--shadow);
}

.service-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 10px 12px;
}

.minutes {
  color: var(--brand);
  font-size: 1.24rem;
  font-weight: 700;
  text-align: center;
}

.minutes-label {
  display: block;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 400;
  text-transform: uppercase;
}

.expected-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .71rem;
  font-weight: 400;
}

.route-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.service-heading {
  min-width: 0;
  font-size: .88rem;
  font-weight: 700;
}

.train-toggle {
  min-height: 32px;
  margin: -5px -7px -5px auto;
  padding: 5px 7px;
  color: var(--brand);
  background: transparent;
  border: 0;
  border-bottom: 1px dotted currentColor;
  border-radius: 5px;
  font: inherit;
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.route {
  overflow: hidden;
  color: var(--muted);
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover {
  position: relative;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.popover[hidden] {
  display: none;
}

.popover::before {
  position: absolute;
  top: -7px;
  right: 25px;
  width: 12px;
  height: 12px;
  content: "";
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  transform: rotate(45deg);
}

.popover-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.popover-heading h3 {
  font-size: 1rem;
}

.train-class {
  margin-top: 2px;
  color: var(--muted);
  font-size: .84rem;
}

.close-hint {
  color: var(--muted);
  font-size: .7rem;
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.stat {
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  background: var(--brand-soft);
  border-radius: 9px;
}

.stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: .94rem;
}

.stat span {
  color: var(--muted);
  font-size: .65rem;
}

.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  font-size: .81rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.amenity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 7px;
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: .71rem;
}

.amenity-icon {
  font-size: .85rem;
  line-height: 1;
}

.service-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35;
}

.empty-message,
.error-message {
  margin: 0 12px;
  padding: 18px 14px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 14px;
}

.error-message {
  color: var(--closed);
}

.page-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.page-footer a {
  display: grid;
  min-height: 50px;
  place-items: center;
  color: var(--brand);
  font-size: .78rem;
  text-decoration: none;
}

@media (min-width: 521px) {
  .page-shell {
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 350px) {
  .service-row {
    grid-template-columns: 52px minmax(0, 1fr);
    padding-inline: 9px;
  }

  .route-line {
    display: block;
  }

  .train-toggle {
    margin: 4px 0 0 -7px;
  }

  .popover::before {
    right: auto;
    left: 94px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
