:root {
  color-scheme: light;
  --primary: #0052CC;
  --primary-weak: #E6F0FF;
  --countdown: #FF7D00;
  --page: #F7F8FA;
  --text: #1D2129;
  --muted: #86909C;
  --card: #FFFFFF;
  --line: rgba(0, 82, 204, 0.12);
  --line-strong: rgba(0, 82, 204, 0.2);
  --shadow: 0 10px 28px rgba(0, 82, 204, 0.09);
  --shadow-hover: 0 14px 34px rgba(0, 82, 204, 0.15);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(0, 82, 204, 0.08), transparent 260px),
    linear-gradient(180deg, #FFFFFF 0%, var(--page) 230px, var(--page) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  width: min(520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0.02em;
}

h1 {
  color: var(--primary);
  font-size: 28px;
  line-height: 1.18;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.clock {
  min-width: 118px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--primary-weak);
  box-shadow: 0 8px 22px rgba(0, 82, 204, 0.08);
  color: var(--primary);
  text-align: center;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.layout {
  width: min(520px, calc(100% - 32px));
  margin: 0 auto 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.control-panel,
.arrival-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.control-panel::before,
.arrival-panel::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--primary), rgba(0, 82, 204, 0.28));
}

.arrival-panel {
  min-height: 0;
  padding: 22px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(0, 82, 204, 0.1);
}

.station-summary {
  min-width: 0;
  display: grid;
  align-content: center;
}

.summary h2 {
  margin-bottom: 10px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 38px;
  line-height: 1.12;
  font-weight: 950;
  letter-spacing: -0.04em;
}

#directionLabel {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.direction-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.direction-cards button {
  min-width: 0;
  min-height: 102px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 13px;
  border: 1px solid rgba(0, 82, 204, 0.12);
  border-radius: var(--radius);
  background: #FFFFFF;
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 20px rgba(0, 82, 204, 0.06);
}

.direction-cards button:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 82, 204, 0.28);
  box-shadow: 0 12px 26px rgba(0, 82, 204, 0.12);
}

.direction-cards button:active {
  transform: scale(0.98);
}

.direction-cards button.active {
  border-color: rgba(255, 125, 0, 0.3);
  background: linear-gradient(180deg, #FFF3E6 0%, #FFFFFF 100%);
  box-shadow: 0 12px 28px rgba(255, 125, 0, 0.13);
}

.direction-name {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 800;
}

.direction-wait {
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.direction-cards button.active .direction-wait {
  color: var(--countdown);
}

.direction-time {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.next-countdown {
  display: grid;
  align-content: center;
  width: 100%;
  padding: 20px;
  border: 1px solid rgba(255, 125, 0, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #FFF7ED 0%, #FFFFFF 100%);
  box-shadow: 0 10px 26px rgba(255, 125, 0, 0.1);
  text-align: left;
}

.next-countdown::before {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  content: "下一班倒计时";
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
}

.next-countdown span {
  display: block;
  color: var(--countdown);
  font-size: 42px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.next-countdown small {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.train-tracker {
  margin: 16px 0 4px;
  padding: 16px;
  border: 1px solid rgba(0, 82, 204, 0.12);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
  box-shadow: 0 8px 22px rgba(0, 82, 204, 0.07);
}

.tracker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
}

.tracker-head strong {
  color: var(--primary);
  font-weight: 850;
}

.tracker-line {
  display: grid;
  grid-template-columns: minmax(66px, auto) minmax(120px, 1fr) minmax(66px, auto);
  gap: 10px;
  align-items: center;
}

.tracker-station {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-station.current {
  color: var(--primary);
  text-align: right;
}

.tracker-rail {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--primary-weak);
  box-shadow: inset 0 0 0 1px rgba(0, 82, 204, 0.1);
}

.tracker-progress {
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--countdown));
  transition: width 0.9s linear;
}

.tracker-train {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid #FFFFFF;
  border-radius: 999px;
  background: var(--countdown);
  box-shadow: 0 8px 18px rgba(255, 125, 0, 0.28);
  font-size: 16px;
  transition: left 0.9s linear;
}

.tracker-note,
.tracker-empty {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tracker-empty {
  margin: 0;
  text-align: center;
}

.train-strip {
  display: flex;
  gap: 12px;
  margin: 18px -4px 16px;
  padding: 0 4px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 82, 204, 0.32) transparent;
}

.train-strip::-webkit-scrollbar {
  height: 6px;
}

.train-strip::-webkit-scrollbar-track {
  background: transparent;
}

.train-strip::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 82, 204, 0.24);
}

.train-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  min-height: 142px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #FFFFFF;
  box-shadow: 0 8px 22px rgba(0, 82, 204, 0.07);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease;
}

.train-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
}

.train-card:active {
  transform: translateY(-1px) scale(0.99);
}

.train-card:first-child {
  border-color: rgba(255, 125, 0, 0.28);
  background: linear-gradient(180deg, #FFF3E6 0%, #FFFFFF 100%);
  box-shadow: 0 12px 28px rgba(255, 125, 0, 0.13);
}

.train-card:first-child .train-meta strong,
.train-card:first-child .train-wait {
  color: var(--countdown);
}

.train-card:first-child .train-wait {
  border-color: rgba(255, 125, 0, 0.24);
  background: rgba(255, 125, 0, 0.1);
}

.train-card.disabled,
.train-card.offline,
.train-card.stopped,
.train-card.is-stopped,
.train-card[aria-disabled="true"] {
  border-color: rgba(134, 144, 156, 0.16);
  background: #F2F3F5;
  box-shadow: none;
  color: var(--muted);
  filter: grayscale(0.2);
  opacity: 0.72;
}

.train-card.disabled .train-time,
.train-card.offline .train-time,
.train-card.stopped .train-time,
.train-card.is-stopped .train-time,
.train-card[aria-disabled="true"] .train-time,
.train-card.disabled .train-meta strong,
.train-card.offline .train-meta strong,
.train-card.stopped .train-meta strong,
.train-card.is-stopped .train-meta strong,
.train-card[aria-disabled="true"] .train-meta strong,
.train-card.disabled .train-wait,
.train-card.offline .train-wait,
.train-card.stopped .train-wait,
.train-card.is-stopped .train-wait,
.train-card[aria-disabled="true"] .train-wait {
  color: var(--muted);
}

.train-time {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.train-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.train-meta strong {
  display: inline-block;
  margin-bottom: 2px;
  color: var(--primary);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 850;
}

.train-wait {
  justify-self: start;
  min-width: 86px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 82, 204, 0.13);
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  text-align: center;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.source-line,
.status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.source-line {
  padding-top: 12px;
  border-top: 1px solid rgba(0, 82, 204, 0.08);
}

.empty {
  flex: 1 0 100%;
  padding: 34px 12px;
  border: 1px dashed rgba(0, 82, 204, 0.2);
  border-radius: var(--radius);
  background: var(--primary-weak);
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.control-panel {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

label {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
}

.station-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px;
  gap: 10px;
  align-items: start;
}

.station-combobox {
  position: relative;
  min-width: 0;
}

select,
input,
button {
  min-height: 48px;
  border: 1px solid rgba(0, 82, 204, 0.14);
  border-radius: var(--radius);
  background: #FFFFFF;
  color: var(--text);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease;
}

select,
input {
  width: 100%;
  min-width: 0;
  padding: 0 42px 0 14px;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
  background-color: #FFFFFF;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) 20px,
    calc(100% - 15px) 20px;
  background-size: 7px 7px;
  background-repeat: no-repeat;
  box-shadow: 0 6px 16px rgba(0, 82, 204, 0.05);
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

input {
  cursor: text;
}

input::placeholder {
  color: var(--muted);
  font-weight: 500;
}

input::-webkit-search-decoration,
input::-webkit-search-cancel-button,
input::-webkit-search-results-button,
input::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

select::-ms-expand {
  display: none;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

.station-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid rgba(0, 82, 204, 0.14);
  border-radius: var(--radius);
  background: #FFFFFF;
  box-shadow: 0 16px 36px rgba(0, 82, 204, 0.18);
}

.station-dropdown.open {
  display: grid;
  gap: 4px;
}

.station-option {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.station-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.station-option small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.station-option:hover {
  transform: none;
  background: var(--primary-weak);
  color: var(--primary);
  box-shadow: none;
}

.station-option:active {
  transform: scale(0.98);
}

.empty-option,
.empty-option:hover {
  justify-content: center;
  color: var(--muted);
  background: transparent;
  pointer-events: none;
}

select:hover,
button:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(0, 82, 204, 0.12);
}

button:active,
select:active {
  transform: translateY(0) scale(0.98);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(0, 82, 204, 0.16);
  outline-offset: 2px;
}

#locateButton {
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(0, 82, 204, 0.16);
}

#locateButton:hover {
  background: #0047B3;
  color: #FFFFFF;
}

#locateButton.locating .locate-icon {
  animation: locatePulse 0.9s ease-in-out infinite;
}

.locate-icon {
  position: relative;
  width: 0;
  height: 0;
  transform: rotate(45deg);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 22px solid #FFFFFF;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.14));
}

.locate-icon::after {
  position: absolute;
  left: -3px;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  content: "";
  background: var(--primary);
}

@keyframes locatePulse {
  0%, 100% {
    transform: rotate(45deg) scale(1);
    opacity: 1;
  }
  50% {
    transform: rotate(45deg) scale(0.88);
    opacity: 0.72;
  }
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 82, 204, 0.12);
  border-radius: var(--radius);
  background: var(--primary-weak);
}

#serviceTabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented button {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  color: var(--primary);
  font-size: 15px;
  font-weight: 850;
  white-space: normal;
}

.segmented button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(0, 82, 204, 0.1);
}

.segmented button:active {
  transform: scale(0.97);
}

.segmented button.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 9px 20px rgba(0, 82, 204, 0.22);
}

@media (max-width: 719px) {
  body {
    background:
      radial-gradient(circle at 18% -4%, rgba(0, 82, 204, 0.1), transparent 220px),
      linear-gradient(180deg, #FFFFFF 0%, var(--page) 190px, var(--page) 100%);
  }

  .topbar {
    width: min(100% - 24px, 1180px);
    padding: max(14px, env(safe-area-inset-top)) 0 12px;
  }

  h1 {
    font-size: 24px;
  }

  .clock {
    min-width: 106px;
    min-height: 40px;
    padding: 9px 11px;
    font-size: 16px;
  }

  .layout {
    width: min(100% - 24px, 1180px);
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .arrival-panel {
    min-height: 0;
    padding: 18px;
  }

  .control-panel {
    order: 2;
    padding: 18px;
  }

  .summary {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-bottom: 16px;
  }

  .summary h2 {
    font-size: 34px;
  }

  .next-countdown {
    text-align: left;
  }

  .next-countdown span {
    font-size: 42px;
  }

  .train-card {
    flex-basis: 205px;
  }
}

@media (max-width: 390px) {
  .topbar,
  .layout {
    width: min(100% - 18px, 1180px);
  }

  .topbar {
    gap: 10px;
  }

  h1 {
    font-size: 23px;
  }

  .clock {
    min-width: 98px;
    padding-inline: 9px;
    font-size: 15px;
  }

  .arrival-panel,
  .control-panel {
    padding: 16px;
  }

  .summary h2 {
    font-size: 32px;
  }

  .train-card {
    flex-basis: 190px;
    min-height: 136px;
  }

  #serviceTabs button,
  .segmented button {
    padding-inline: 6px;
    font-size: 13px;
  }
}
