:root {
  --bg: #061014;
  --panel: #0a1a1f;
  --panel-2: #0c2026;
  --line: #17383f;
  --ink: #e9fbf7;
  --sub: #9bb9b7;
  --muted: #628184;
  --teal: #38e0bf;
  --teal-2: #0f8f84;
  --amber: #ffc46b;
  --red: #ff6b5e;
  --shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 16% -10%, rgba(24, 128, 118, .22), transparent 62%),
    radial-gradient(700px 520px at 110% 18%, rgba(255, 173, 80, .09), transparent 60%),
    linear-gradient(180deg, #061014 0%, #071317 52%, #050d10 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .17;
  background-image:
    linear-gradient(rgba(117, 219, 203, .10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(117, 219, 203, .10) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
}

a { color: var(--teal); text-decoration: none; }
button { font: inherit; }
svg { display: block; }

.backdrop { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .34; }
.orb-a { width: 420px; height: 420px; left: -180px; top: -150px; background: #0e8d82; }
.orb-b { width: 360px; height: 360px; right: -160px; top: 32%; background: #9a5b18; opacity: .16; }

.nav-top {
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: 1040px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  color: #b7d2cf;
  border: 1px solid #21484e;
  border-radius: 11px;
  background: rgba(7, 20, 24, .76);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 650;
}
.back-link:hover { color: var(--teal); border-color: var(--teal-2); }
.back-link svg { width: 16px; height: 16px; fill: currentColor; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #284a4f;
  border-radius: 99px;
  background: rgba(9, 27, 31, .8);
  color: #a9c3c2;
  font-size: 12px;
  white-space: nowrap;
}
.pill i, .live i, .rail i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #5f8082;
  display: inline-block;
  flex: 0 0 auto;
}
.pill.on { border-color: #1d6b60; background: #0b2b26; color: #c9fff1; }
.pill.on i { background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.pill.bad { border-color: #62322b; background: #281412; color: #ffb9ad; }
.pill.bad i { background: var(--red); }
.pill.warn { border-color: #6d4b22; background: #281c0e; color: #ffd39a; }
.pill.warn i { background: var(--amber); }
.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #21484e;
  border-radius: 11px;
  background: rgba(7, 20, 24, .76);
  color: #b7d2cf;
  cursor: pointer;
}
.icon-btn:hover { color: var(--teal); border-color: var(--teal-2); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

.stage {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 20px max(30px, env(safe-area-inset-bottom));
}

.nav-card {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border: 1px solid #1b4349;
  border-radius: 26px;
  background:
    radial-gradient(700px 300px at 10% 0%, rgba(44, 213, 186, .12), transparent 64%),
    linear-gradient(155deg, rgba(14, 37, 43, .96), rgba(7, 22, 26, .98));
  box-shadow: var(--shadow);
}
.nav-card:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(130deg, rgba(56, 224, 191, .24), transparent 30%, transparent 72%, rgba(255, 180, 90, .08));
  mask: linear-gradient(#000, transparent 42%);
  opacity: .55;
}
.nav-card > * { position: relative; z-index: 1; }

.card-head { display: flex; align-items: flex-start; gap: 14px; }
.kicker { color: #6fa9a6; font-size: 10.5px; font-weight: 750; letter-spacing: 2.1px; }
h1 { margin: 8px 0 0; font-size: clamp(24px, 4vw, 34px); line-height: 1.15; letter-spacing: -.5px; }
.live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid rgba(56, 224, 191, .28);
  border-radius: 99px;
  color: #a8fff0;
  background: rgba(15, 78, 70, .28);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.4px;
  white-space: nowrap;
}
.live i { background: var(--teal); box-shadow: 0 0 12px var(--teal); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.route {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 24px;
  padding: 15px 16px;
  border: 1px solid #173a40;
  border-radius: 16px;
  background: rgba(4, 16, 19, .48);
}
.place { min-width: 0; flex: 1; }
.place .tag { display: block; color: #6e9293; font-size: 10px; letter-spacing: 1.3px; margin-bottom: 5px; }
.place b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(17px, 3vw, 23px); letter-spacing: .2px; }
.place small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; color: var(--sub); font-size: 12px; }
.place.to { text-align: right; }
.place.to .tag { color: #b99053; }
.route-arrow { position: relative; width: 86px; height: 30px; flex: 0 0 auto; color: #3be1c2; }
.route-arrow .route-line {
  position: absolute;
  left: 0;
  right: 12px;
  top: 50%;
  border-top: 1px dashed rgba(59, 225, 194, .45);
}
.route-arrow svg { position: absolute; right: 0; top: 3px; width: 24px; height: 24px; fill: currentColor; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-top: 26px; }
.distance-block { min-width: 0; }
.label { color: #87a7a7; font-size: 12px; letter-spacing: 1.2px; }
.distance { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; line-height: .9; }
.distance span { font-size: clamp(70px, 16vw, 116px); font-weight: 820; letter-spacing: -6px; font-variant-numeric: tabular-nums; }
.distance em { font-style: normal; color: #8ab0ae; font-size: clamp(18px, 3vw, 24px); font-weight: 650; letter-spacing: 0; }
.distance-note { margin-top: 12px; min-height: 18px; color: #8fb0ae; font-size: 12.5px; }
.limit-block { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-bottom: 3px; }
.limit-sign {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background: #f7fbf8;
  border: 10px solid #f04b43;
  color: #091214;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .06), 0 18px 34px rgba(0, 0, 0, .22);
}
.limit-sign span { display: block; font-size: 44px; font-weight: 900; line-height: .92; font-variant-numeric: tabular-nums; }
.limit-sign small { display: block; margin-top: 3px; color: #4a5c5d; font-size: 10px; font-weight: 800; letter-spacing: 2px; }
.speed-now { display: flex; align-items: baseline; gap: 5px; color: #a5c2c0; font-size: 12px; }
.speed-now b { color: var(--ink); font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
body[data-overspeed="true"] .limit-sign { border-color: #ff3b30; box-shadow: 0 0 0 5px rgba(255, 59, 48, .16), 0 0 34px rgba(255, 59, 48, .38); animation: warn 1s ease-in-out infinite; }
body[data-overspeed="true"] .speed-now b { color: var(--red); }
@keyframes warn { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }

.eta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}
.eta { padding: 13px 14px; border: 1px solid #173a40; border-radius: 13px; background: rgba(7, 26, 29, .55); }
.eta span { display: block; color: #6f9292; font-size: 11px; letter-spacing: .5px; }
.eta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 5px; font-size: 18px; font-variant-numeric: tabular-nums; }

.road {
  position: relative;
  height: 98px;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid #16383d;
  border-radius: 15px;
  background: linear-gradient(180deg, #0b252a, #08191d);
  perspective: 300px;
}
.road-bed {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -34%;
  height: 150%;
  background: linear-gradient(180deg, #163e42, #0c2428);
  clip-path: polygon(36% 0, 64% 0, 100% 100%, 0 100%);
  opacity: .72;
}
.road-dash {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 82%;
  background: repeating-linear-gradient(to top, rgba(255, 207, 128, .9) 0 12px, transparent 12px 26px);
  transform: translateX(-50%);
  animation: roadMove 1.1s linear infinite;
}
@keyframes roadMove { to { background-position-y: 26px; } }
.road-truck, .road-flag { position: absolute; bottom: 15px; color: #d9fff7; }
.road-truck { left: 12%; width: 48px; }
.road-truck svg { width: 100%; height: auto; fill: currentColor; }
.road-flag { right: 12%; width: 22px; color: #ffc46b; }
.road-flag svg { width: 100%; height: auto; fill: currentColor; }
.road-label { position: absolute; left: 16px; top: 10px; color: #628b8b; font-size: 10px; letter-spacing: 1.4px; }

.hint-bar {
  margin-top: 14px;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid #173a40;
  border-radius: 11px;
  color: #8fb0ae;
  background: rgba(4, 16, 19, .5);
  font-size: 12px;
  line-height: 1.45;
}
.hint-bar.warn { color: #ffd39a; border-color: #5e431f; background: rgba(46, 31, 12, .38); }
.hint-bar.bad { color: #ffb9ad; border-color: #5d312b; background: rgba(43, 20, 18, .38); }

.rail {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 4px 0;
  color: #7e9d9e;
  font-size: 12px;
}
.rail span { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.rail b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.rail i.on { background: var(--teal); box-shadow: 0 0 9px var(--teal); }
.rail i.warn { background: var(--amber); }
.rail i.bad { background: var(--red); }
.rail a { margin-left: auto; color: #9ec5c1; font-size: 12px; white-space: nowrap; }
.rail a:hover { color: var(--teal); }

.notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 15px; }
.note { padding: 14px; border: 1px solid #143238; border-radius: 13px; background: rgba(7, 21, 24, .48); }
.note b { display: block; color: #c7e5e0; font-size: 12px; }
.note span { display: block; margin-top: 5px; color: #719192; font-size: 11.5px; line-height: 1.55; }

body[data-state="offline"] .nav-card { opacity: .78; }
body[data-state="offline"] .live { color: #ffb9ad; border-color: rgba(255, 107, 94, .34); background: rgba(73, 24, 20, .32); }
body[data-state="offline"] .live i { background: var(--red); box-shadow: 0 0 10px var(--red); animation: none; }
body[data-state="waiting"] .live { color: #ffd39a; border-color: rgba(255, 196, 107, .28); background: rgba(71, 49, 18, .26); }
body[data-state="waiting"] .live i { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: none; }
body[data-state="nonav"] .distance span { color: #7e9d9e; }
body[data-state="paused"] .road-dash { animation-play-state: paused; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 50;
  max-width: min(90vw, 520px);
  padding: 10px 14px;
  border: 1px solid #2a5155;
  border-radius: 11px;
  background: rgba(8, 27, 31, .96);
  color: #d8f5ef;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .nav-top { padding-left: 14px; padding-right: 14px; }
  .stage { padding-left: 14px; padding-right: 14px; }
  .nav-card { padding: 19px; border-radius: 21px; }
  .route { gap: 10px; padding: 12px; }
  .route-arrow { width: 48px; }
  .hero { align-items: center; gap: 14px; margin-top: 22px; }
  .distance span { letter-spacing: -4px; }
  .limit-sign { width: 92px; height: 92px; border-width: 8px; }
  .limit-sign span { font-size: 35px; }
  .limit-sign small { font-size: 8px; letter-spacing: 1.4px; }
  .speed-now b { font-size: 18px; }
  .eta { padding: 10px 9px; }
  .eta b { font-size: 15px; }
  .notes { grid-template-columns: 1fr; }
  .rail { gap: 10px; }
  .rail a { font-size: 11px; }
}

@media (max-width: 430px) {
  .back-link span { display: none; }
  .back-link { width: 38px; padding: 0; justify-content: center; }
  .pill { font-size: 11px; padding: 0 8px; }
  .nav-card { padding: 16px; }
  h1 { font-size: 23px; }
  .route { align-items: flex-start; }
  .place b { font-size: 16px; }
  .place small { font-size: 11px; }
  .route-arrow { margin-top: 18px; width: 34px; }
  .route-arrow .route-line { right: 8px; }
  .route-arrow svg { width: 19px; height: 19px; top: 6px; }
  .distance span { font-size: 64px; letter-spacing: -3px; }
  .distance em { font-size: 17px; }
  .limit-sign { width: 78px; height: 78px; border-width: 7px; }
  .limit-sign span { font-size: 30px; }
  .limit-sign small { font-size: 7px; }
  .speed-now { font-size: 10px; }
  .speed-now b { font-size: 16px; }
  .eta-grid { gap: 6px; }
  .eta { padding: 9px 7px; }
  .eta span { font-size: 9.5px; }
  .eta b { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .live i, .road-dash, body[data-overspeed="true"] .limit-sign { animation: none; }
}

body[data-state="nonav"] .live { color: #ffd39a; border-color: rgba(255, 196, 107, .30); background: rgba(71, 49, 18, .30); }
body[data-state="nonav"] .live i { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: none; }
body[data-state="paused"] .live { color: #ffd39a; border-color: rgba(255, 196, 107, .30); background: rgba(71, 49, 18, .30); }
body[data-state="paused"] .live i { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: none; }
body[data-overspeed="true"] .live { color: #ffb9ad; border-color: rgba(255, 107, 94, .40); background: rgba(73, 24, 20, .36); }
body[data-overspeed="true"] .live i { background: var(--red); box-shadow: 0 0 10px var(--red); animation: none; }
body[data-overspeed="true"] .distance-note { color: #ffb9ad; }
