
:root {
  color-scheme: dark;
  --bg: #020910;
  --panel: rgba(5, 17, 23, 0.82);
  --panel-strong: rgba(4, 14, 20, 0.94);
  --line: rgba(87, 190, 198, 0.22);
  --line-strong: rgba(88, 224, 226, 0.48);
  --text: #eef5f2;
  --muted: #8da8aa;
  --cyan: #52e4e5;
  --river: #39bded;
  --central: #FF0000;
  --second: #FF5A1F;
  --fourth: #a33038;
  --active-color: var(--central);
  --font: "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior: none;
}

html {
  background: #020a10;
}

html.is-page-fullscreen,
html.is-page-fullscreen body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html.is-page-fullscreen #app {
  min-height: 100%;
}

button { font: inherit; }
button:focus-visible,
[tabindex="0"]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

#app,
#scene,
#scene canvas,
#labels-layer,
#terrain-labels {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#app {
  isolation: isolate;
  background:
    radial-gradient(circle at 55% 46%, rgba(17, 67, 72, 0.2), transparent 43%),
    linear-gradient(180deg, #06131b 0%, #020910 68%, #01060b 100%);
}

#app::before,
#app::after {
  content: "";
  position: fixed;
  z-index: 1;
  pointer-events: none;
}

#app::before {
  inset: 0;
  background:
    linear-gradient(rgba(77, 190, 195, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 190, 195, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.65), transparent 88%);
}

#app::after {
  inset: 0;
  box-shadow: inset 0 0 140px rgba(0, 4, 8, 0.78);
}

/* V21: a one-tap mobile browser fullscreen entry. The browser address bar
   remains system UI until the user grants fullscreen from a gesture. */
.mobile-fullscreen-prompt {
  position: fixed;
  z-index: 60;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 9px 8px 12px;
  border: 1px solid rgba(82,228,229,.38);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(4,22,29,.97), rgba(5,42,48,.92));
  box-shadow: 0 14px 34px rgba(0,0,0,.42), 0 0 22px rgba(82,228,229,.12);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}
.mobile-fullscreen-prompt.is-visible { display: flex; }
.mobile-fullscreen-prompt.is-hidden { display: none !important; }
.mobile-fullscreen-prompt__copy { min-width: 0; flex: 1 1 auto; }
.mobile-fullscreen-prompt__copy strong,
.mobile-fullscreen-prompt__copy span { display: block; }
.mobile-fullscreen-prompt__copy strong { color: #f4fbf7; font-size: 12px; letter-spacing: .08em; }
.mobile-fullscreen-prompt__copy span { margin-top: 3px; color: #9ab6b6; font-size: 10px; line-height: 1.35; }
.mobile-fullscreen-prompt button {
  min-height: 32px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
#mobile-fullscreen-action {
  padding: 0 11px;
  border: 1px solid rgba(82,228,229,.7);
  background: linear-gradient(135deg, #2c9ca0, #14696f);
  color: #f5ffff;
  font-size: 11px;
  font-weight: 700;
}
#mobile-fullscreen-dismiss {
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #8da8aa;
  font-size: 10px;
}
#mobile-fullscreen-action:active,
#mobile-fullscreen-dismiss:active { transform: translateY(1px); }

@media (orientation: landscape) and (pointer: coarse), (orientation: portrait) and (pointer: coarse), (orientation: landscape) and (max-width: 900px), (orientation: portrait) and (max-height: 900px), (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .mobile-fullscreen-prompt.is-device { display: flex; }
}

#scene { z-index: 0; }
#scene canvas { display: block; touch-action: none; cursor: grab; }
#scene canvas:active { cursor: grabbing; }
#terrain-labels { z-index: 3; overflow: hidden; pointer-events: none; }
#labels-layer { z-index: 5; overflow: hidden; pointer-events: none; }

.glass-panel {
  background: linear-gradient(145deg, rgba(7, 24, 31, 0.92), rgba(3, 12, 18, 0.72));
  border: 1px solid var(--line);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(159, 242, 243, 0.035);
  backdrop-filter: blur(16px) saturate(118%);
  -webkit-backdrop-filter: blur(16px) saturate(118%);
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: #020a10;
  transition: opacity .65s ease, visibility .65s ease;
}

.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading p { margin: 12px 0 0; font-size: 15px; letter-spacing: .12em; }
.loading small { color: var(--muted); font-size: 11px; }

.loading__rings { position: relative; width: 76px; height: 76px; }
.loading__rings i {
  position: absolute;
  inset: calc(var(--i, 0) * 10px);
  border: 1px solid rgba(82, 228, 229, calc(.65 - var(--i, 0) * .16));
  border-radius: 50%;
  animation: scan 2.2s linear infinite;
}
.loading__rings i:nth-child(2) { --i: 1; animation-direction: reverse; }
.loading__rings i:nth-child(3) { --i: 2; }
.loading__rings::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--central);
  box-shadow: 0 0 22px var(--central);
  transform: translate(-50%, -50%);
}
@keyframes scan { to { transform: rotate(360deg) scale(.96); } }

.commandbar {
  position: fixed;
  z-index: 12;
  top: 18px;
  left: 20px;
  right: 20px;
  min-height: 70px;
  display: grid;
  grid-template-columns: minmax(270px, 1fr) auto minmax(170px, .7fr);
  align-items: center;
  gap: 22px;
  padding: 10px 12px 10px 16px;
  border-radius: 7px;
}

.commandbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(82,228,229,.36), transparent);
}

.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-star {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid rgba(239,77,69,.72);
  border-radius: 5px;
  background: rgba(116, 23, 22, .78);
  box-shadow: 0 0 28px rgba(239,77,69,.18);
}
.brand-star svg { width: 22px; fill: #ffe8bf; }
.brand-lockup h1 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: .045em; font-weight: 680; white-space: nowrap; }
.brand-lockup p { margin: 5px 0 0; color: var(--muted); font-size: 10px; letter-spacing: .12em; white-space: nowrap; }

.route-switch {
  display: flex;
  align-items: center;
  padding: 4px;
  border: 1px solid rgba(88, 190, 198, .16);
  border-radius: 5px;
  background: rgba(2, 11, 16, .74);
}
.route-tab {
  --tab-color: var(--central);
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 0;
  border-right: 1px solid rgba(88,190,198,.12);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.route-tab:last-child { border-right: 0; }
.route-tab[data-route="second"] { --tab-color: var(--second); }
.route-tab[data-route="fourth"] { --tab-color: var(--fourth); }
.route-tab--all { --tab-color: var(--cyan); }
.route-tab i { width: 6px; height: 6px; border-radius: 50%; background: var(--tab-color); box-shadow: 0 0 9px var(--tab-color); opacity: .55; }
.route-tab:hover { color: var(--text); }
.route-tab.is-active { color: #fff; background: color-mix(in srgb, var(--tab-color) 16%, transparent); box-shadow: inset 0 -2px 0 var(--tab-color); }
.route-tab.is-active i { opacity: 1; }

.commandbar__actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.primary-button,
.icon-button,
.play-button,
.text-button,
.detail-close,
.node-detail__actions button {
  border: 0;
  color: var(--text);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, opacity .2s ease, border-color .2s ease;
}
.primary-button:disabled,
.icon-button:disabled,
.play-button:disabled,
.text-button:disabled { opacity: .38; cursor: not-allowed; }
.primary-button {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--active-color) 70%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--active-color) 72%, #081219);
  font-size: 12px;
  font-weight: 650;
  box-shadow: 0 0 22px color-mix(in srgb, var(--active-color) 22%, transparent);
}
.primary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#route-toggle {
  justify-content: center;
  gap: 0;
  text-align: center;
  font-size: 13px;
}
#route-toggle span {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  line-height: 1;
  white-space: nowrap;
  font-size: inherit;
}
.icon-button {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(8, 23, 29, .84);
}
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.route-overview {
  position: fixed;
  z-index: 8;
  top: 108px;
  left: 20px;
  width: 258px;
  padding: 16px 17px 15px;
  border-radius: 6px;
}
.route-overview__eyebrow { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.route-overview__eyebrow i { width: 20px; height: 2px; background: var(--active-color); box-shadow: 0 0 8px var(--active-color); }
.route-overview h2 { margin: 12px 0 8px; font-size: 17px; font-weight: 650; letter-spacing: .03em; }
.route-overview > p { margin: 0; color: #a8bbba; font-size: 11px; line-height: 1.75; }
.route-overview__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(88,190,198,.12); }
.route-overview__meta span { display: flex; flex-direction: column; gap: 4px; }
.route-overview__meta small { color: #607f82; font-size: 8px; letter-spacing: .14em; }
.route-overview__meta strong { color: #dce9e7; font-size: 10px; font-weight: 570; }

.mouse-help {
  position: fixed;
  z-index: 8;
  top: 108px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 9px 11px;
  border-radius: 6px;
}
.mouse-help > span { display: flex; align-items: center; gap: 6px; padding: 0 11px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.mouse-help > span + span { border-left: 1px solid rgba(88,190,198,.14); }
.mouse-help b { color: #dbe8e6; font-size: 9px; font-weight: 620; }
.mouse-icon { position: relative; width: 13px; height: 19px; border: 1px solid #6a8f92; border-radius: 7px; }
.mouse-icon::after { content: ""; position: absolute; top: 1px; width: 5px; height: 7px; background: rgba(82,228,229,.58); }
.mouse-icon--wheel::after { left: 3px; width: 3px; height: 6px; border-radius: 2px; }
.mouse-icon--left::after { left: 1px; border-radius: 6px 0 2px 0; }
.mouse-icon--right::after { right: 1px; border-radius: 0 6px 0 2px; }

.legend {
  position: fixed;
  z-index: 8;
  left: 20px;
  bottom: 100px;
  width: 218px;
  padding: 15px 16px;
  border-radius: 6px;
}
.panel-heading { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 11px; font-weight: 650; letter-spacing: .12em; }
.panel-heading i { height: 1px; flex: 1; background: linear-gradient(90deg, rgba(82,228,229,.35), transparent); }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 14px; }
.legend-row { display: flex; align-items: center; gap: 8px; color: #92aaab; font-size: 10px; }
.legend-mountain { width: 22px; height: 12px; background: linear-gradient(135deg, transparent 42%, #6f9690 43% 52%, transparent 53%), linear-gradient(45deg, transparent 42%, #97b3aa 43% 52%, transparent 53%); }
.legend-river { width: 23px; height: 8px; border-bottom: 2px solid var(--river); border-radius: 50%; transform: rotate(-8deg); box-shadow: 0 3px 8px rgba(57,189,237,.35); }
.legend-node { width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: #f6e7c5; box-shadow: 0 0 9px #f3cd7a; }
.legend-direction { width: 22px; height: 2px; position: relative; background: var(--central); }
.legend-direction::after { content: ""; position: absolute; right: -1px; top: -3px; width: 6px; height: 6px; border-top: 2px solid var(--central); border-right: 2px solid var(--central); transform: rotate(45deg); }
.legend-routes { display: grid; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(88,190,198,.12); }
.legend-routes span { display: flex; align-items: center; gap: 9px; color: #a8bbba; font-size: 9px; }
.route-color { width: 28px; height: 2px; background: var(--central); box-shadow: 0 0 8px var(--central); }
.route-color--second { background: var(--second); box-shadow: 0 0 8px var(--second); }
.route-color--fourth { background: var(--fourth); box-shadow: 0 0 8px var(--fourth); }

.node-detail {
  position: fixed;
  z-index: 9;
  right: 20px;
  bottom: 100px;
  width: 326px;
  padding: 14px 15px 13px;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(18px);
  transition: opacity .28s ease, transform .28s ease, visibility .28s ease;
}
.node-detail.is-visible { opacity: 1; visibility: visible; transform: translateX(0); }
.node-detail__header { display: flex; align-items: center; gap: 11px; }
.node-detail__index { display: flex; align-items: baseline; }
.node-detail__index strong { font-size: 25px; color: var(--active-color); line-height: 1; font-weight: 720; }
.node-detail__index small { color: #647c7f; font-size: 9px; margin-left: 3px; }
.node-detail__route { display: flex; align-items: center; gap: 7px; color: #9fb4b4; font-size: 9px; }
.node-detail__route i { width: 16px; height: 2px; background: var(--active-color); box-shadow: 0 0 7px var(--active-color); }
.detail-close { margin-left: auto; width: 27px; height: 27px; background: transparent; color: #789295; font-size: 18px; }
.detail-close:hover { color: #fff; }
.node-detail__meta { display: flex; gap: 12px; margin-top: 12px; color: #78a0a0; font-size: 9px; letter-spacing: .05em; }
.node-detail h2 { margin: 7px 0 7px; font-size: 20px; line-height: 1.25; font-weight: 680; }
.node-detail__copy-wrap { position: relative; max-height: 104px; overflow: hidden; transition: max-height .28s ease; }
.node-detail__copy-wrap::after { content: ""; position: absolute; inset: auto 0 0; height: 28px; background: linear-gradient(180deg, transparent, rgba(3, 14, 19, .96)); pointer-events: none; opacity: 1; transition: opacity .2s ease; }
.node-detail.is-copy-expanded .node-detail__copy-wrap { max-height: min(42vh, 360px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(85,177,180,.35) transparent; }
.node-detail.is-copy-expanded .node-detail__copy-wrap::after { opacity: 0; }
.node-detail__copy-wrap p { min-height: 46px; margin: 0; padding-bottom: 14px; color: #afc0bd; font-size: 11px; line-height: 1.75; }
.detail-copy-toggle { display: none; width: 100%; height: 25px; margin: 2px 0 0; border: 1px solid rgba(88,190,198,.18); border-radius: 3px; background: rgba(7,22,28,.72); color: #9db7b6; font-size: 9px; cursor: pointer; }
.detail-copy-toggle.is-visible { display: block; }
.detail-copy-toggle:hover { color: #fff; border-color: rgba(82,228,229,.42); }
.node-detail__actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 11px; padding-top: 10px; border-top: 1px solid rgba(88,190,198,.11); }
.node-detail__actions button { height: 28px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px solid rgba(88,190,198,.15); border-radius: 4px; background: rgba(7,22,28,.72); color: #98acad; font-size: 9px; }
.node-detail__actions button:hover:not(:disabled) { border-color: rgba(82,228,229,.4); color: #fff; }
.node-detail__actions button:disabled { opacity: .28; cursor: not-allowed; }
.node-detail__actions svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.playback {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 20px;
  width: min(720px, calc(100vw - 520px));
  min-width: 520px;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 12px;
  border-radius: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 14px);
  transition: opacity .3s ease, transform .3s ease, visibility .3s ease;
}
.playback.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.play-button { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 4px; background: var(--active-color); color: #fff; box-shadow: 0 0 18px color-mix(in srgb, var(--active-color) 24%, transparent); }
.play-button svg { grid-area: 1/1; width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.play-button .icon-play { display: none; }
.play-button.is-paused .icon-pause { display: none; }
.play-button.is-paused .icon-play { display: block; }
.playback__main { flex: 1; min-width: 0; }
.playback__meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: #9bb0b0; font-size: 9px; }
.playback__meta > span:last-child { display: flex; align-items: baseline; gap: 4px; color: #68888a; }
.playback__meta strong { color: var(--active-color); font-size: 12px; }
.playback__meta b { font-size: 9px; font-weight: 550; }
.playback__meta i { font-style: normal; }
.progress-track { position: relative; height: 14px; cursor: pointer; }
.progress-track::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1px; background: rgba(132,167,167,.25); }
.progress-fill { position: absolute; left: 0; top: 5px; width: 0; height: 2px; background: var(--active-color); box-shadow: 0 0 9px var(--active-color); }
.timeline-nodes { position: absolute; inset: 0; }
.timeline-node { position: absolute; top: 3px; width: 8px; height: 8px; margin-left: -4px; padding: 0; border: 1px solid #789294; border-radius: 50%; background: #071319; cursor: pointer; transition: background .2s ease, transform .2s ease, border-color .2s ease; }
.timeline-node.is-lit { border-color: #e9f0e8; background: var(--active-color); box-shadow: 0 0 7px var(--active-color); }
.timeline-node.is-current { transform: scale(1.5); }
.text-button { height: 32px; display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; background: transparent; color: #8da5a6; font-size: 9px; }
.text-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.text-button:hover { color: #fff; }

.terrain-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(179, 226, 222, .62);
  font-size: 9px;
  letter-spacing: .13em;
  text-shadow: 0 2px 8px #000;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}
.terrain-label::after { content: none; display: none; }
.terrain-label.is-river { color: rgba(74, 200, 239, .84); font-size: 8px; }
.terrain-label.is-river::after { background: linear-gradient(90deg, transparent, rgba(57,189,237,.85), transparent); }

.map-label {
  --route-color: var(--central);
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px 4px 4px;
  border: 1px solid color-mix(in srgb, var(--route-color) 48%, transparent);
  border-radius: 4px;
  background: rgba(3, 12, 17, .9);
  box-shadow: 0 6px 18px rgba(0,0,0,.34);
  color: #eaf1ee;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 11px)) scale(.84);
  transform-origin: 50% 100%;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease, border-color .2s ease;
}
.map-label.is-visible { opacity: .88; transform: translate(-50%, calc(-100% - 11px)) scale(1); pointer-events: auto; cursor: pointer; }
.map-label.is-important { border-color: color-mix(in srgb, var(--route-color) 68%, transparent); }
.map-label.is-important .map-label__number { background: color-mix(in srgb, var(--route-color) 78%, #40595a); }
.map-label.is-important.is-visible { opacity: .96; }
.map-label:hover,
.map-label.is-current { z-index: 20; opacity: 1; border-color: var(--route-color); box-shadow: 0 0 18px color-mix(in srgb, var(--route-color) 24%, transparent); }
.map-label__number { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 3px; background: #40595a; color: #eff5f2; font-size: 7px; }
.map-label.is-lit .map-label__number { background: var(--route-color); }

.coordinates {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(104,152,155,.45);
  font-size: 7px;
  letter-spacing: .1em;
  transform: translateX(-50%);
  pointer-events: none;
}
.coordinates i { width: 80px; height: 1px; background: linear-gradient(90deg, transparent, rgba(82,228,229,.36), transparent); }
.coordinates b { margin-left: 4px; font-weight: 500; }
.data-credit { position: fixed; z-index: 7; right: 20px; bottom: 8px; color: rgba(127,161,161,.4); font-size: 7px; letter-spacing: .04em; pointer-events: none; }

@media (orientation: landscape) and (max-width: 1180px), (orientation: portrait) and (max-height: 1180px) {
  .commandbar { grid-template-columns: auto 1fr auto; gap: 12px; }
  .brand-lockup p { display: none; }
  .route-tab { padding: 0 9px; }
  .route-overview { width: 230px; }
  .playback { width: calc(100vw - 500px); min-width: 440px; }
}

@media (orientation: landscape) and (max-width: 900px), (orientation: portrait) and (max-height: 900px) {
  .commandbar { left: 12px; right: 12px; top: 12px; min-height: 116px; grid-template-columns: 1fr auto; grid-template-rows: 48px 44px; padding: 7px 9px; }
  .route-switch { grid-column: 1 / -1; grid-row: 2; width: 100%; overflow-x: auto; }
  .route-tab { flex: 1; justify-content: center; }
  .route-overview { top: 142px; left: 12px; }
  .mouse-help { top: 142px; right: 12px; }
  .legend { left: 12px; bottom: 92px; }
  .node-detail { right: 12px; bottom: 92px; }
  .playback { left: 250px; right: 350px; width: auto; min-width: 0; transform: translate(0, 14px); }
  .playback.is-visible { transform: translate(0, 0); }
}

@media (orientation: landscape) and (max-width: 680px), (orientation: portrait) and (max-height: 680px) {
  .commandbar { min-height: 110px; grid-template-rows: 44px 42px; }
  .brand-star { width: 34px; height: 34px; }
  .brand-lockup h1 { max-width: 160px; font-size: 14px; line-height: 1.25; white-space: normal; }
  .primary-button { height: 36px; padding: 0 10px; }
  .icon-button { width: 36px; height: 36px; }
  .route-tab { min-width: 86px; padding: 0 8px; font-size: 12px; }
  #route-toggle { font-size: 12px; }
  .route-overview { display: none; }
  .mouse-help { top: auto; right: 10px; bottom: 82px; padding: 7px 5px; }
  .mouse-help > span { padding: 0 7px; }
  .mouse-help > span { font-size: 0; }
  .mouse-help b { display: none; }
  .legend { display: none; }
  .node-detail { left: 10px; right: 10px; bottom: 144px; width: auto; }
  .node-detail > p { min-height: 40px; }
  .playback { left: 10px; right: 10px; bottom: 10px; height: 60px; }
  .text-button span { display: none; }
  .coordinates,
  .data-credit { display: none; }
  .map-label { font-size: 8px; }
}

@media (orientation: landscape) and (prefers-reduced-motion: reduce), (orientation: portrait) and (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* V2 — 真实 DEM 展陈界面覆写 */
:root {
  --bg: #01080d;
  --panel: rgba(2, 16, 21, .84);
  --panel-strong: rgba(2, 14, 19, .94);
  --line: rgba(73, 186, 188, .25);
  --line-strong: rgba(86, 222, 220, .5);
  --central: #FF0000;
  --active-color: var(--central);
}
#app {
  background: radial-gradient(circle at 52% 45%, rgba(18, 57, 56, .14), transparent 48%), #01080d;
}
#app::before { opacity: .48; }
.glass-panel {
  background: linear-gradient(145deg, rgba(3, 21, 27, .91), rgba(2, 12, 17, .78));
  border-color: rgba(74, 189, 190, .28);
  box-shadow: 0 16px 38px rgba(0,0,0,.32), inset 0 0 24px rgba(45,181,181,.025);
  backdrop-filter: blur(14px);
}
.commandbar { border-radius: 4px; }
.brand-star { border-radius: 3px; background: linear-gradient(145deg, #8d2821, #4d1718); }
.brand-lockup h1 { font-size: 19px; letter-spacing: .055em; }
.brand-lockup p { color: #779295; font-size: 9px; letter-spacing: .1em; }
.route-switch, .primary-button, .icon-button, .route-overview, .mouse-help, .legend, .node-detail, .playback { border-radius: 3px; }
.route-overview { width: 250px; padding: 17px 17px 15px; }
.route-overview__eyebrow { letter-spacing: .11em; }
.route-overview__eyebrow b { margin-left: auto; color: #668487; font-size: 8px; font-weight: 500; }
.route-overview h2 { margin-top: 15px; font-size: 19px; }
.legend { width: 250px; bottom: 126px; }
.elevation-strip {
  display: grid;
  grid-template-columns: auto 12px auto 1fr;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  padding: 11px 0 10px;
  border-top: 1px solid rgba(88,190,198,.11);
  border-bottom: 1px solid rgba(88,190,198,.11);
  color: #627f80;
  font-size: 7px;
}
.elevation-strip i { width: 12px; height: 42px; background: linear-gradient(#f1f3ea, #8c8067 30%, #3d6447 61%, #17382a); border: 1px solid rgba(255,255,255,.15); }
.elevation-strip b { color: #88a1a0; font-size: 8px; font-weight: 500; line-height: 1.7; }
.legend-routes { margin-top: 11px; padding-top: 0; border-top: 0; }
.node-detail { top: 220px; bottom: auto; width: 290px; padding: 16px 16px 14px; }
.node-detail h2 { font-size: 22px; }
.playback {
  left: 20px;
  right: 20px;
  bottom: 18px;
  width: auto;
  min-width: 0;
  height: 90px;
  padding: 13px 16px;
  transform: translateY(14px);
}
.playback.is-visible { transform: translateY(0); }
.play-button { width: 48px; height: 48px; border-radius: 50%; background: rgba(6,24,29,.86); border: 1px solid #d9e7df; box-shadow: none; }
.progress-track { height: 8px; }
.timeline-node { width: 12px; height: 12px; }
.coordinates { bottom: 112px; }
.data-credit { bottom: 113px; right: 22px; }
.map-label { color: #ffe8c4; font-size: 10px; text-shadow: 0 2px 8px #000, 0 0 10px rgba(255,79,58,.28); }
.map-label::before { background: #fff0c8; box-shadow: 0 0 11px var(--route-color); }
.terrain-label { color: rgba(226,214,174,.55); }
@media (orientation: landscape) and (max-width: 1180px), (orientation: portrait) and (max-height: 1180px) {
  .commandbar { gap: 10px; }
  .route-tab { padding: 0 8px; }
  .route-overview, .legend { width: 218px; }
  .node-detail { width: 272px; }
}
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .route-overview, .legend { display: none; }
  .node-detail { top: 166px; right: 12px; width: 268px; }
  .mouse-help { right: 12px; }
  .brand-lockup h1 { font-size: 16px; }
  .route-tab { padding: 0 7px; }
  .playback { left: 12px; right: 12px; }
}
@media (orientation: landscape) and (max-width: 900px), (orientation: portrait) and (max-height: 900px) {
  .playback { left: 12px; right: 12px; bottom: 12px; height: 74px; }
  .legend { bottom: 100px; width: 232px; }
  .node-detail { top: auto; right: 12px; bottom: 100px; width: min(310px, calc(100vw - 24px)); }
  .coordinates, .data-credit { display: none; }
}

/* V5 — 全景信息架构、省界与标注系统 */
.commandbar {
  top: 14px;
  left: 14px;
  right: 14px;
  min-height: 60px;
  padding: 0 14px;
  border-color: rgba(99, 203, 204, .28);
  background: linear-gradient(180deg, rgba(3,19,24,.96), rgba(2,14,19,.9));
}
.route-overview {
  top: 86px;
  left: 14px;
  bottom: 342px;
  width: 260px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.route-overview h2 { margin: 13px 0 7px; font-size: 18px; }
.route-overview > p { flex: 0 0 auto; font-size: 10px; line-height: 1.65; }
.route-overview__meta { margin-top: 12px; padding-top: 11px; }
.route-overview__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 0 10px;
  border-top: 1px solid rgba(92,190,190,.12);
  border-bottom: 1px solid rgba(92,190,190,.12);
}
.route-overview__stats span { display: grid; gap: 4px; }
.route-overview__stats small { color: #678184; font-size: 8px; letter-spacing: .08em; }
.route-overview__stats strong { color: #f25a47; font-size: 16px; font-weight: 680; letter-spacing: .03em; }
.route-overview__nodes { min-height: 0; margin-top: 11px; display: flex; flex: 1; flex-direction: column; }
.route-overview__nodes-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: #dce7df; font-size: 10px; letter-spacing: .09em; }
.route-overview__nodes-title small { color: #617d80; font-size: 8px; letter-spacing: .03em; }
.route-overview__nodes ol { min-height: 0; margin: 0; padding: 0 3px 0 0; list-style: none; overflow: auto; scrollbar-width: thin; scrollbar-color: rgba(85,177,180,.22) transparent; }
.route-overview__nodes li { margin: 0; }
.route-overview__nodes button {
  width: 100%;
  min-height: 25px;
  padding: 0 2px;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid rgba(93,170,173,.07);
  background: transparent;
  color: #a8b8b5;
  font: 500 9px/1.2 "Microsoft YaHei", sans-serif;
  text-align: left;
  cursor: pointer;
}
.route-overview__nodes button:hover { color: #fff1d4; background: rgba(244,78,60,.055); }
.route-overview__nodes button b { color: #ed5a48; font-size: 8px; font-weight: 700; }
.route-overview__nodes button small { color: #60777a; font-size: 7px; }
.legend { left: 14px; bottom: 138px; width: 260px; padding: 13px 16px; }
.legend-grid { gap: 8px 12px; }
.legend-river { height: 1px; border: 0; border-bottom: 1px dashed rgba(235,216,170,.72); transform: none; }
.elevation-strip { margin-top: 10px; padding: 8px 0; }
.elevation-strip i { height: 32px; }
.legend-routes { margin-top: 8px; gap: 6px; }
.mouse-help { top: 86px; right: 14px; }
.node-detail { top: 222px; right: 14px; width: 286px; padding: 16px 16px 14px; }
.node-detail::before {
  content: "历史节点档案";
  display: block;
  margin: -4px 0 11px;
  color: #6c8788;
  font-size: 8px;
  letter-spacing: .16em;
}
.node-detail__meta { padding: 8px 0; border-top: 1px solid rgba(90,183,185,.1); border-bottom: 1px solid rgba(90,183,185,.1); }
.playback {
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 108px;
  padding: 12px 16px 23px;
  background: linear-gradient(180deg, rgba(3,19,24,.95), rgba(2,13,18,.93));
}
.playback__meta { margin-bottom: 8px; }
.progress-track { height: 28px; }
.progress-track::before { top: 6px; }
.progress-fill { top: 5px; }
.timeline-node { top: 0; width: 11px; height: 11px; }
.timeline-node::after {
  content: "";
  position: absolute;
  top: 17px;
  left: 50%;
  width: 74px;
  transform: translateX(-50%);
  color: #71888a;
  font: 500 7px/1.15 "Microsoft YaHei", sans-serif;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}
.timeline-node.has-label::after { content: attr(data-short); }
.coordinates { bottom: 132px; }
.data-credit { bottom: 133px; }
.province-label {
  position: absolute;
  z-index: 2;
  display: block;
  transform: translate(-50%, -50%);
  color: rgba(237, 221, 181, .68);
  font: 650 15px/1 "STSong", "SimSun", serif;
  letter-spacing: .22em;
  text-shadow: 0 2px 7px rgba(0,0,0,.95), 0 0 14px rgba(4,11,12,.9);
  white-space: nowrap;
  pointer-events: none;
}
.terrain-label { color: rgba(213,205,174,.55); font-size: 8px; }
.map-label { background: rgba(4,13,16,.72); border-color: rgba(224,193,141,.22); }

@media (orientation: landscape) and (max-width: 1250px), (orientation: portrait) and (max-height: 1250px) {
  .route-overview { width: 232px; }
  .legend { width: 232px; }
  .province-label { font-size: 13px; }
}
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .route-overview, .legend { display: none; }
  .playback { height: 82px; padding-bottom: 13px; }
  .timeline-node::after { display: none; }
}

/* V6 — 柔化贴地省界、增强水系与月份时间轴 */
.legend-river {
  width: 25px; height: 7px; border: 0; border-bottom: 3px solid #4aaee8;
  border-radius: 50%; transform: rotate(-7deg); box-shadow: 0 2px 8px rgba(74,174,232,.34);
}
.legend-boundary { width: 25px; height: 1px; border-bottom: 1px solid rgba(214,202,166,.48); }
.playback { height: 154px; padding: 12px 16px 16px; flex-direction: column; align-items: stretch; gap: 8px; }
.legend { bottom: 190px; }
.timeline-heading {
  height: 24px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(83,182,187,.12);
}
.timeline-heading__title { display: flex; align-items: baseline; gap: 12px; }
.timeline-heading__title strong { color: #edf2eb; font-size: 15px; letter-spacing: .08em; }
.timeline-heading__title span { color: #789194; font-size: 9px; letter-spacing: .06em; }
.timeline-annotation-toggle {
  height: 26px; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px;
  border: 1px solid rgba(87,184,188,.2); border-radius: 2px; background: rgba(6,27,32,.58);
  color: #8aa4a5; font: 500 8px/1 "Microsoft YaHei", sans-serif;
}
.timeline-annotation-toggle svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.timeline-annotation-toggle.is-active { border-color: rgba(239,77,69,.5); color: #f1d6cf; background: rgba(139,43,37,.16); }
.playback__content { min-height: 0; display: flex; align-items: stretch; gap: 14px; }
.playback__controls {
  width: 64px; flex: 0 0 64px; display: grid; grid-template-columns: 1fr; align-content: center;
  justify-items: center; gap: 5px; padding-right: 12px; border-right: 1px solid rgba(85,177,181,.15);
}
.playback__controls .play-button { width: 45px; height: 45px; }
.playback__controls .text-button { height: 19px; padding: 0 4px; font-size: 8px; }
.playback__main { position: relative; min-height: 84px; padding: 0 12px 0 8px; overflow: visible; }
.playback__meta { margin: 0; height: 16px; }
.timeline-calendar {
  position: relative; height: 25px; margin-top: 1px;
  border-left: 1px dashed rgba(113,155,157,.3); border-right: 1px dashed rgba(113,155,157,.3);
}
.timeline-months, .timeline-years { position: absolute; inset: 0; pointer-events: none; }
.timeline-month {
  position: absolute; top: 11px; transform: translateX(-50%); color: #6f888a;
  font: 500 7px/1 "Microsoft YaHei", sans-serif; white-space: nowrap;
}
.timeline-month::before {
  content: ""; position: absolute; left: 50%; top: 10px; width: 1px; height: 6px; background: rgba(105,151,153,.25);
}
.timeline-year {
  position: absolute; top: 0; transform: translateX(-50%); color: #a7bab6;
  font: 600 8px/1 "Microsoft YaHei", sans-serif; white-space: nowrap;
}
.progress-track { height: 44px; margin-top: 0; overflow: visible; }
.progress-track::before {
  top: 7px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, rgba(102,27,28,.82), rgba(212,83,75,.84));
  box-shadow: 0 0 8px rgba(222,75,64,.16);
}
.progress-track::after {
  content: ""; position: absolute; right: -2px; top: 3px; width: 10px; height: 10px;
  border-top: 3px solid rgba(212,83,75,.84); border-right: 3px solid rgba(212,83,75,.84); transform: rotate(45deg);
}
.progress-fill { top: 6px; height: 5px; border-radius: 4px; opacity: .88; }
.timeline-node { top: 2px; width: 12px; height: 12px; margin-left: -6px; border-width: 1.5px; }
.timeline-node::after { top: 22px; width: 90px; color: #71898a; font-size: 7px; line-height: 1.2; }
.timeline-node.is-current::after { color: var(--active-color); font-weight: 700; }
.playback.show-all-annotations .timeline-node::after { content: attr(data-short); }
.coordinates { bottom: 174px; }
.data-credit { bottom: 175px; }
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .playback { height: 122px; }
  .timeline-heading { display: none; }
  .timeline-month:nth-child(even) { display: none; }
  .coordinates, .data-credit { bottom: 140px; }
}
@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px) {
  .playback { left: 8px; right: 8px; bottom: 8px; height: 104px; padding: 8px 10px; }
  .playback__controls { width: 48px; flex-basis: 48px; }
  .playback__controls .play-button { width: 38px; height: 38px; }
  .timeline-year { font-size: 7px; }
  .timeline-month, .timeline-node::after { display: none; }
}

/* V7 — 贴地自然水系、事件密度时间轴、史料影像卡 */
.legend-river {
  height: 6px;
  border-bottom: 3px solid rgba(79, 157, 173, .9);
  box-shadow: none;
  filter: drop-shadow(0 1px 1px rgba(2, 13, 18, .72));
}
.node-detail { width: 310px; }
.node-detail__media {
  display: none;
  margin: 10px 0 9px;
  overflow: hidden;
  border: 1px solid rgba(116, 164, 158, .18);
  background: rgba(2, 11, 15, .72);
}
.node-detail__media.is-visible { display: block; }
.node-detail__media-image {
  position: relative;
  height: 118px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(111, 85, 57, .22), rgba(4, 16, 19, .68)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
}
.node-detail__media img {
  width: 100%; height: 100%; display: block; object-fit: cover;
  filter: saturate(.58) sepia(.18) contrast(1.06) brightness(.84);
  transition: opacity .25s ease;
}
.node-detail__media figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 28px; padding: 5px 8px; color: #829796; font-size: 7px; line-height: 1.4;
}
.node-detail__media figcaption span { min-width: 0; }
.node-detail__media figcaption a { flex: 0 0 auto; color: #b5a27a; text-decoration: none; }
.node-detail__media figcaption a:hover { color: #f0d7a7; }
.node-detail__media-offline {
  position: absolute; inset: 0; display: none; place-items: center; padding: 16px;
  color: #718888; font-size: 9px; line-height: 1.6; text-align: center;
}
.node-detail__media.has-error img { opacity: 0; }
.node-detail__media.has-error .node-detail__media-offline { display: grid; }
.timeline-heading__title em {
  color: #627b7d; font: normal 500 7px/1 "Microsoft YaHei", sans-serif; letter-spacing: .03em;
}
.playback { height: 178px; }
.legend { bottom: 214px; }
.playback__main { min-height: 106px; }
.timeline-calendar { height: 29px; }
.timeline-month { top: 13px; color: #6b8284; }
.timeline-month::before { top: 9px; height: 5px; }
.progress-track { height: 65px; }
.timeline-node::after { top: 21px; width: 76px; font-size: 7px; }
.timeline-node.label-row-1::after { top: 33px; }
.timeline-node.label-row-2::after { top: 45px; }
.timeline-gap-layer { position: absolute; inset: 0; pointer-events: none; }
.timeline-gap-marker {
  position: absolute; top: -3px; height: 20px; transform: translateX(-50%);
  border-left: 1px dashed rgba(204, 177, 126, .42);
}
.timeline-gap-marker::before,
.timeline-gap-marker::after {
  content: ""; position: absolute; top: 7px; width: 5px; height: 5px;
  border-top: 1px solid rgba(204,177,126,.6); border-right: 1px solid rgba(204,177,126,.6);
}
.timeline-gap-marker::before { left: -9px; transform: rotate(-135deg); }
.timeline-gap-marker::after { left: 3px; transform: rotate(45deg); }
.timeline-gap-marker span {
  position: absolute; left: 50%; top: -13px; transform: translateX(-50%);
  padding: 1px 5px; background: rgba(4,18,22,.9); color: #b9a477;
  font: 600 7px/1.3 "Microsoft YaHei", sans-serif; white-space: nowrap;
}
.coordinates { bottom: 198px; }
.data-credit { bottom: 199px; }
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .playback { height: 136px; }
  .coordinates, .data-credit { bottom: 154px; }
}
@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px) {
  .playback { height: 108px; }
  .node-detail__media-image { height: 96px; }
  .timeline-gap-marker span { display: none; }
}

/* V11 — 沙盘渲染控制台 */
.sandbox-console {
  position: fixed;
  z-index: 11;
  top: 86px;
  left: 286px;
  width: 238px;
  padding: 14px;
  border-radius: 6px;
  color: #dfeae7;
}
.sandbox-console__title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(87,190,198,.14);
  font-size: 11px;
  font-weight: 680;
  letter-spacing: .11em;
}
.sandbox-console__title svg {
  width: 15px;
  fill: none;
  stroke: #64d9dc;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sandbox-console__section { margin-top: 12px; }
.sandbox-console__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #7f999a;
  font-size: 8px;
  letter-spacing: .08em;
}
.sandbox-console__label output { color: #adc1bf; letter-spacing: 0; }
.render-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid rgba(85,181,185,.14);
  border-radius: 4px;
  background: rgba(1,9,13,.56);
}
.render-mode {
  height: 31px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #718c8e;
  font-size: 9px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease;
}
.render-mode:hover { color: #d9e8e5; }
.render-mode.is-active {
  color: #f2f7f4;
  background: linear-gradient(180deg, rgba(47,142,153,.72), rgba(21,91,104,.78));
  box-shadow: inset 0 0 0 1px rgba(101,222,224,.28), 0 0 13px rgba(51,187,194,.12);
}
.render-legend {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #6e898b;
  font-size: 7px;
}
.render-legend__bar {
  height: 5px;
  border-radius: 5px;
  background: linear-gradient(90deg, #123b29 0%, #37894d 32%, #a99239 62%, #b86c32 82%, #e8ece6 100%);
  opacity: .82;
}
.render-legend[data-mode="simulation"] .render-legend__bar {
  background: linear-gradient(90deg, #173329, #456146 45%, #8b7756 72%, #d5d8cc);
}
.render-legend[data-mode="contour"] .render-legend__bar {
  background: repeating-linear-gradient(90deg, #173338 0 12px, #65c8cb 12px 13px, #173338 13px 25px);
}
.layer-toggle {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr 30px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(82,184,190,.14);
  border-radius: 4px;
  background: rgba(2,13,18,.52);
  color: #93a9a8;
  text-align: left;
  cursor: pointer;
}
.layer-toggle:hover { border-color: rgba(69,199,207,.35); }
.layer-toggle.is-active {
  border-color: rgba(43,190,215,.52);
  background: linear-gradient(90deg, rgba(19,88,101,.42), rgba(3,19,25,.64));
  color: #d9eff0;
}
.layer-toggle__icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: rgba(31,104,115,.28);
}
.layer-toggle__icon svg { width: 15px; fill: none; stroke: #42c5dc; stroke-width: 1.8; }
.layer-toggle__copy { display: grid; gap: 3px; }
.layer-toggle__copy strong { font-size: 9px; font-weight: 620; }
.layer-toggle__copy small { color: #607b7e; font-size: 7px; }
.layer-toggle__switch {
  position: relative;
  width: 29px;
  height: 16px;
  border-radius: 10px;
  background: #173137;
  box-shadow: inset 0 0 0 1px rgba(112,154,158,.22);
}
.layer-toggle__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #789092;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.layer-toggle.is-active .layer-toggle__switch::after {
  transform: translateX(13px);
  background: #61d7e4;
  box-shadow: 0 0 9px rgba(70,205,224,.72);
}
.hydro-strength {
  width: 100%;
  height: 3px;
  accent-color: #39bed4;
  cursor: pointer;
}
.sandbox-console__layer-divider {
  height: 1px;
  margin: 12px 0;
  background: linear-gradient(90deg, rgba(199,145,77,.28), rgba(199,145,77,0));
}
.layer-toggle--mountain:hover { border-color: rgba(218,164,91,.42); }
.layer-toggle--mountain.is-active {
  border-color: rgba(213,155,78,.56);
  background: linear-gradient(90deg, rgba(91,57,25,.46), rgba(20,17,13,.66));
  color: #f1e2ca;
}
.layer-toggle--mountain .layer-toggle__icon { background: rgba(124,79,36,.34); }
.layer-toggle--mountain .layer-toggle__icon svg { stroke: #d9a45d; }
.layer-toggle--mountain .layer-toggle__copy small { color: #927759; }
.layer-toggle--mountain .layer-toggle__switch { background: #392c20; }
.layer-toggle--mountain.is-active .layer-toggle__switch::after {
  background: #e0aa60;
  box-shadow: 0 0 9px rgba(219,158,75,.68);
}
.mountain-strength { accent-color: #d69b4f; }
.sandbox-console__note {
  margin: 8px 1px 0;
  color: #567174;
  font-size: 7px;
  line-height: 1.55;
}
@media (orientation: landscape) and (max-width: 1250px), (orientation: portrait) and (max-height: 1250px) {
  .sandbox-console { left: 258px; width: 218px; }
}
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .sandbox-console { left: 14px; width: 224px; }
}
@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px) {
  .sandbox-console { top: 132px; left: 8px; width: 208px; padding: 10px; }
  .sandbox-console__note, .render-legend { display: none; }
}

/* V13 — 三个完全独立、自动避让的左侧模块 */
.left-rail {
  position: fixed;
  z-index: 11;
  top: 86px;
  bottom: 158px;
  left: 14px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(84,177,181,.24) transparent;
}
.left-rail .route-overview,
.left-rail .sandbox-console,
.left-rail .legend {
  position: relative;
  inset: auto;
  width: 100%;
  flex: 0 0 auto;
}
.left-rail > .glass-panel {
  border: 1px solid rgba(73, 166, 172, .28);
  background: linear-gradient(145deg, rgba(3, 24, 29, .96), rgba(2, 15, 21, .91));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .26), inset 0 1px rgba(147, 232, 226, .025);
}
.left-rail .route-overview {
  display: block;
  padding: 13px 15px 12px;
  overflow: hidden;
}
.left-rail .route-overview h2 { margin: 10px 0 5px; font-size: 16px; }
.left-rail .route-overview > p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 9px;
  line-height: 1.55;
}
.left-rail .route-overview__meta { margin-top: 9px; padding-top: 8px; }
.left-rail .route-overview__stats { margin-top: 8px; padding: 8px 0 7px; }
.left-rail .route-overview__stats strong { font-size: 14px; }
.left-rail .route-overview__nodes { margin-top: 8px; display: block; }
.route-overview__nodes-title { margin: 0; }
.route-overview__nodes-title > span { display: flex; align-items: baseline; gap: 7px; }
.nodes-toggle {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border: 1px solid rgba(87,184,188,.15);
  border-radius: 3px;
  background: rgba(4,20,25,.55);
  color: #789395;
  font-size: 8px;
  cursor: pointer;
}
.nodes-toggle:hover { color: #dce8e5; border-color: rgba(82,228,229,.34); }
.nodes-toggle svg {
  width: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .22s ease;
}
.route-overview.is-nodes-expanded .nodes-toggle svg { transform: rotate(180deg); }
.left-rail .route-overview__nodes ol {
  min-height: 0;
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height .32s ease, margin-top .25s ease, opacity .2s ease;
}
.left-rail .route-overview.is-nodes-expanded .route-overview__nodes ol {
  max-height: 310px;
  margin-top: 7px;
  opacity: 1;
  pointer-events: auto;
}
.left-rail .sandbox-console { padding: 13px 14px; }
.left-rail .sandbox-console__section { margin-top: 10px; }
.left-rail .legend {
  display: block;
  padding: 13px 16px;
  margin: 0;
}
@media (orientation: landscape) and (max-width: 1250px), (orientation: portrait) and (max-height: 1250px) {
  .left-rail { width: 232px; }
}
@media (orientation: landscape) and (max-width: 1050px), (orientation: portrait) and (max-height: 1050px) {
  .left-rail { left: 12px; bottom: 138px; width: 228px; }
}
@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px) {
  .left-rail { top: 132px; bottom: 118px; left: 8px; width: 210px; }
  .left-rail .sandbox-console { width: 100%; padding: 10px; }
}

/* V15 mobile interaction shell */
.mobile-panel-toggle,
.mobile-panel-close,
.mobile-panel-backdrop,
.touch-help { display: none; }

@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px) {
  :root {
    --mobile-header-height: 104px;
    --mobile-timeline-height: 106px;
  }

  html,
  body,
  #app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body { -webkit-text-size-adjust: 100%; }
  button { -webkit-tap-highlight-color: transparent; }

  #app::before { background-size: 28px 28px; }
  #app::after { box-shadow: inset 0 0 62px rgba(0, 4, 8, .72); }

  .commandbar {
    top: max(7px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    min-height: 92px;
    padding: 7px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 40px 39px;
    align-items: center;
    gap: 6px 8px;
    border-radius: 8px;
  }

  .brand-lockup { grid-column: 1; grid-row: 1; gap: 9px; min-width: 0; }
  .brand-star { width: 34px; height: 34px; border-radius: 6px; }
  .brand-star svg { width: 19px; }
  .brand-lockup h1 {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    letter-spacing: .02em;
  }
  .brand-lockup p { display: none; }

  .commandbar__actions {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }

  .commandbar__actions button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 6px;
  }
  .commandbar__actions button svg { width: 18px; height: 18px; }
  .commandbar__actions .primary-button span { display: none; }
  .mobile-panel-toggle { display: grid !important; }

  .route-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    padding: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .route-switch::-webkit-scrollbar { display: none; }
  .route-tab {
    flex: 0 0 auto;
    min-width: 92px;
    height: 34px;
    padding: 0 10px;
    scroll-snap-align: start;
    font-size: 13px;
  }
  .route-tab--all { min-width: 82px; }

  .left-rail {
    display: flex;
    position: fixed;
    z-index: 31;
    top: calc(max(7px, env(safe-area-inset-top)) + var(--mobile-header-height));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--mobile-timeline-height));
    left: 8px;
    width: min(88vw, 342px);
    padding: 44px 8px 10px;
    gap: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(87, 190, 198, .28);
    border-radius: 10px;
    background: linear-gradient(160deg, rgba(5, 22, 28, .98), rgba(2, 10, 15, .96));
    box-shadow: 18px 0 48px rgba(0, 0, 0, .58);
    transform: translateX(calc(-100% - 20px));
    transition: transform .3s cubic-bezier(.22,.8,.22,1);
    -webkit-overflow-scrolling: touch;
  }
  .left-rail.is-mobile-open { transform: translateX(0); }
  .left-rail > .glass-panel {
    position: static;
    width: 100%;
    flex: 0 0 auto;
    margin: 0;
  }
  .left-rail .route-overview,
  .left-rail .sandbox-console,
  .left-rail .legend { padding: 13px 14px; }
  .left-rail .route-overview__nodes ol { max-height: 0; }
  .left-rail .route-overview.is-nodes-expanded .route-overview__nodes ol { max-height: 42vh; }

  .mobile-panel-close {
    display: grid;
    position: absolute;
    z-index: 2;
    top: 7px;
    right: 7px;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(82, 228, 229, .24);
    border-radius: 6px;
    background: rgba(6, 24, 31, .9);
    color: #d8efec;
    font-size: 22px;
  }

  .mobile-panel-backdrop {
    display: block;
    position: fixed;
    z-index: 30;
    inset: 0;
    padding: 0;
    border: 0;
    background: rgba(0, 5, 9, .56);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease, visibility .25s ease;
  }
  .mobile-panel-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mouse-help { display: none !important; }
  .touch-help {
    display: flex;
    position: fixed;
    z-index: 11;
    left: 50%;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--mobile-timeline-height) + 8px);
    transform: translateX(-50%);
    align-items: center;
    gap: 7px;
    max-width: calc(100vw - 20px);
    padding: 7px 10px;
    border-radius: 99px;
    color: #b8cccc;
    font-size: 9px;
    white-space: nowrap;
    pointer-events: none;
  }
  .touch-help span { display: inline-flex; align-items: center; gap: 4px; }
  .touch-help i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(82,228,229,.6);
  }

  .playback {
    z-index: 20;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    height: 98px;
    padding: 7px 9px 9px;
    border-radius: 9px;
    transform: translateY(calc(100% + 20px));
  }
  .playback.is-visible { transform: translateY(0); }
  .timeline-heading { height: 24px; margin: 0 0 4px; }
  .timeline-heading__title { gap: 6px; min-width: 0; }
  .timeline-heading__title strong { font-size: 12px; }
  .timeline-heading__title span { font-size: 9px; }
  .timeline-heading__title em,
  .timeline-annotation-toggle { display: none; }
  .playback__content { grid-template-columns: 44px minmax(0,1fr); gap: 8px; }
  .playback__controls { width: 44px; min-width: 44px; gap: 0; }
  .play-button { width: 42px; height: 42px; }
  .text-button { display: none; }
  .playback__main { min-width: 0; overflow: hidden; }
  .playback__meta { height: 20px; font-size: 9px; }
  .playback__meta > span:first-child {
    max-width: 68%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .playback__meta strong { font-size: 15px; }
  .timeline-calendar { height: 16px; overflow: hidden; }
  .timeline-months span { font-size: 7px; }
  .timeline-years span { font-size: 7px; }
  .progress-track { height: 25px; margin-top: 2px; }
  .timeline-node { width: 12px; height: 12px; }
  .timeline-node__label { display: none !important; }

  .node-detail {
    z-index: 28;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--mobile-timeline-height) + 6px);
    width: auto;
    max-height: calc(100dvh - var(--mobile-header-height) - var(--mobile-timeline-height) - 28px);
    padding: 14px;
    overflow-y: auto;
    border-radius: 10px;
    transform: translateY(24px);
    -webkit-overflow-scrolling: touch;
  }
  .node-detail.is-visible { transform: translateY(0); }
  .node-detail__header { position: sticky; top: -14px; z-index: 2; padding-top: 2px; background: rgba(4,14,20,.94); }
  .detail-close { width: 38px; height: 38px; }
  .node-detail h2 { font-size: 20px; }
  .node-detail__media-image { min-height: 132px; }
  .node-detail__actions button { min-height: 42px; }

  .coordinates,
  .data-credit { display: none; }
  .terrain-label { font-size: 9px; opacity: .78; }
  .map-label { font-size: 10px; }
}

@media (max-width: 760px) and (orientation: landscape), (max-height: 760px) and (orientation: portrait) {
  :root { --mobile-header-height: 62px; --mobile-timeline-height: 82px; }
  .commandbar {
    grid-template-columns: minmax(120px,.7fr) minmax(0,1.5fr) auto;
    grid-template-rows: 44px;
    min-height: 52px;
  }
  .brand-lockup { grid-column: 1; grid-row: 1; }
  .brand-star { width: 32px; height: 32px; }
  .brand-lockup h1 { max-width: 22vw; }
  .route-switch { grid-column: 2; grid-row: 1; }
  .commandbar__actions { grid-column: 3; grid-row: 1; }
  .playback { height: 74px; }
  .timeline-heading { display: none; }
  .touch-help { bottom: calc(max(6px, env(safe-area-inset-bottom)) + 82px); }
  .node-detail { max-height: calc(100dvh - 158px); }
}

/* V16 compact landscape phone: 844×390 / 915×412 class viewports */
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  :root {
    --mobile-header-height: 54px;
    --mobile-timeline-height: 64px;
  }

  .commandbar {
    top: max(4px, env(safe-area-inset-top));
    left: max(4px, env(safe-area-inset-left));
    right: max(4px, env(safe-area-inset-right));
    min-height: 48px;
    height: 48px;
    padding: 4px 5px;
    display: grid;
    grid-template-columns: minmax(132px, .48fr) minmax(330px, 1.45fr) auto;
    grid-template-rows: 40px;
    gap: 5px;
    border-radius: 6px;
  }
  .brand-lockup { grid-column: 1; grid-row: 1; gap: 6px; }
  .brand-star { width: 30px; height: 30px; }
  .brand-star svg { width: 17px; }
  .brand-lockup h1 { max-width: 120px; font-size: 12px; letter-spacing: 0; }
  .brand-lockup p { display: none; }

  .route-switch {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    height: 36px;
    padding: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .route-switch::-webkit-scrollbar { display: none; }
  .route-tab {
    flex: 1 0 76px;
    min-width: 76px;
    height: 31px;
    padding: 0 7px;
    font-size: 11px;
  }
  .route-tab--all { min-width: 64px; }

  .commandbar__actions { grid-column: 3; grid-row: 1; gap: 4px; }
  .commandbar__actions button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
  }
  .commandbar__actions button svg { width: 15px; height: 15px; }

  .left-rail {
    display: flex;
    top: calc(max(4px, env(safe-area-inset-top)) + 54px);
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 64px);
    left: max(4px, env(safe-area-inset-left));
    width: 184px;
    padding: 5px;
    gap: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 6px;
    transform: translateX(calc(-100% - 12px));
  }
  .left-rail.is-mobile-open { transform: translateX(0); }
  .left-rail > .glass-panel { border-radius: 5px; }
  .left-rail .route-overview,
  .left-rail .sandbox-console,
  .left-rail .legend { padding: 8px 9px; }
  .left-rail .route-overview__eyebrow { margin-bottom: 6px; font-size: 8px; }
  .left-rail .route-overview h2 { margin: 4px 0 5px; font-size: 14px; line-height: 1.25; }
  .left-rail .route-overview > p { margin: 0; font-size: 8px; line-height: 1.45; }
  .left-rail .route-overview__history {
    margin-top: 6px !important;
    padding: 6px 0 0;
    border-top: 1px solid rgba(87,190,198,.15);
    color: #9db1b1;
  }
  .left-rail .route-overview__meta { margin-top: 6px; padding-top: 6px; }
  .left-rail .route-overview__stats { margin-top: 5px; padding: 5px 0; }
  .left-rail .route-overview__meta small,
  .left-rail .route-overview__stats small { font-size: 7px; }
  .left-rail .route-overview__meta strong { font-size: 9px; }
  .left-rail .route-overview__stats strong { font-size: 12px; }
  .left-rail .route-overview__nodes { margin-top: 5px; }
  .left-rail .route-overview.is-nodes-expanded .route-overview__nodes ol { max-height: 34vh; }

  .left-rail .sandbox-console__title,
  .left-rail .panel-heading { font-size: 9px; }
  .left-rail .sandbox-console__section { margin-top: 6px; }
  .left-rail .sandbox-console__label { font-size: 7px; }
  .left-rail .render-switch { height: 30px; }
  .left-rail .render-mode { font-size: 8px; }
  .left-rail .render-legend { margin-top: 5px; }
  .left-rail .legend-grid { gap: 5px 8px; }
  .left-rail .legend-row { font-size: 8px; }
  .left-rail .elevation-strip { margin-top: 7px; padding-top: 7px; }
  .left-rail .legend-routes { margin-top: 7px; padding-top: 7px; }

  .mobile-panel-close {
    display: grid;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  .mobile-panel-backdrop { display: none !important; }

  .node-detail {
    top: calc(max(4px, env(safe-area-inset-top)) + 54px);
    right: max(4px, env(safe-area-inset-right));
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 64px);
    left: auto;
    width: min(28vw, 236px);
    max-height: none;
    padding: 9px;
    border-radius: 6px;
    overflow-y: auto;
  }
  .node-detail__header { position: static; padding: 0; background: transparent; }
  .node-detail__index strong { font-size: 17px; }
  .node-detail__meta { margin-top: 5px; font-size: 8px; }
  .node-detail h2 { margin: 6px 0; font-size: 17px; }
  .node-detail__media { margin: 6px 0; }
  .node-detail__media-image { min-height: 88px; max-height: 116px; }
  .node-detail__media figcaption { font-size: 7px; }
  .node-detail > p { margin: 6px 0; font-size: 8px; line-height: 1.5; }
  .node-detail__actions { margin-top: 7px; gap: 5px; }
  .node-detail__actions button { min-height: 30px; font-size: 8px; }
  .detail-close { width: 28px; height: 28px; }

  .playback {
    left: max(4px, env(safe-area-inset-left));
    right: max(4px, env(safe-area-inset-right));
    bottom: max(4px, env(safe-area-inset-bottom));
    height: 58px;
    padding: 3px 7px;
    border-radius: 6px;
  }
  .timeline-heading { display: none; }
  .playback__content { height: 100%; grid-template-columns: 48px minmax(0,1fr); gap: 7px; }
  .playback__controls {
    width: 48px;
    min-width: 48px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-right: 1px solid rgba(87,190,198,.16);
  }
  .play-button { width: 31px; height: 31px; min-width: 31px; }
  .play-button svg { width: 14px; height: 14px; }
  .playback__controls .text-button {
    display: inline-flex;
    width: 42px;
    height: 17px;
    padding: 0;
    justify-content: center;
    gap: 2px;
    color: #a9bbbb;
    font-size: 7px;
  }
  .playback__controls .text-button span { display: inline; }
  .playback__controls .text-button svg { width: 10px; height: 10px; }
  .playback__main { min-width: 0; padding: 1px 0; }
  .playback__meta { height: 16px; font-size: 7px; }
  .playback__meta strong { font-size: 12px; }
  .timeline-calendar { height: 11px; }
  .timeline-months span,
  .timeline-years span { font-size: 6px; }
  .progress-track { height: 19px; margin-top: 0; }
  .timeline-node { width: 9px; height: 9px; }
  .timeline-gap { font-size: 6px; }

  .touch-help { display: none; }
  .terrain-label { font-size: 7px; }
  .map-label { font-size: 8px; }
}

/* V17: compact landscape information controls */
.edge-panel-toggle { display: none; }
#fullscreen-toggle .fullscreen-exit { display: none; }
#fullscreen-toggle.is-active .fullscreen-enter { display: none; }
#fullscreen-toggle.is-active .fullscreen-exit { display: block; }
#page-fullscreen-toggle .fullscreen-exit { display: none; }
#page-fullscreen-toggle.is-active .fullscreen-enter { display: none; }
#page-fullscreen-toggle.is-active .fullscreen-exit { display: block; }

#app.is-map-focus .brand-lockup,
#app.is-map-focus .route-switch,
#app.is-map-focus #route-toggle,
#app.is-map-focus .edge-panel-toggle,
#app.is-map-focus .left-rail,
#app.is-map-focus .mobile-panel-backdrop,
#app.is-map-focus .mouse-help,
#app.is-map-focus .touch-help,
#app.is-map-focus .node-detail,
#app.is-map-focus .playback,
#app.is-map-focus .coordinates,
#app.is-map-focus .data-credit { display: none !important; }
#app.is-map-focus .commandbar {
  left: auto;
  width: 48px;
  min-width: 48px;
  padding: 4px;
  grid-template-columns: 40px;
  grid-template-rows: 40px;
  background: rgba(3,16,22,.78);
}
#app.is-map-focus .commandbar__actions { grid-column: 1; grid-row: 1; }
#app.is-map-focus #fullscreen-toggle { display: grid; }
#app.is-map-focus #page-fullscreen-toggle { display: none; }
#app.is-map-focus .commandbar__actions {
  display: block;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
#app.is-map-focus #fullscreen-toggle {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(82,228,229,.48);
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
}

@media (orientation: landscape) and (max-width: 760px), (orientation: portrait) and (max-height: 760px), (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .edge-panel-toggle {
    display: flex !important;
    position: fixed;
    z-index: 27;
    left: max(4px, env(safe-area-inset-left));
    top: 50%;
    width: 34px;
    height: 78px;
    padding: 7px 4px;
    transform: translateY(-50%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid rgba(82,228,229,.52);
    border-left-color: rgba(82,228,229,.8);
    border-radius: 0 7px 7px 0;
    background: linear-gradient(180deg, rgba(8,42,51,.96), rgba(4,20,27,.96));
    color: #d8efec;
    box-shadow: 4px 0 18px rgba(0,0,0,.42), 0 0 12px rgba(82,228,229,.1);
    transition: opacity .2s ease, transform .24s ease;
  }
  .edge-panel-toggle svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
  }
  .edge-panel-toggle span {
    font: 600 9px/1.1 "Microsoft YaHei", sans-serif;
    writing-mode: vertical-rl;
    letter-spacing: .12em;
  }
  .edge-panel-toggle.is-open {
    opacity: 0;
    pointer-events: none;
    transform: translate(-110%, -50%);
  }
}

@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  :root { --mobile-timeline-height: 70px; }

  .left-rail { bottom: calc(max(4px, env(safe-area-inset-bottom)) + 70px); }

  .node-detail {
    top: calc(max(4px, env(safe-area-inset-top)) + 54px);
    right: max(4px, env(safe-area-inset-right));
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 68px);
    width: min(31vw, 264px);
    padding: 7px 8px;
    overflow: hidden;
  }
  .node-detail__header { min-height: 20px; gap: 7px; }
  .node-detail__index strong { font-size: 16px; }
  .node-detail__index small,
  .node-detail__route { font-size: 7px; }
  .node-detail__meta {
    margin-top: 3px;
    padding: 4px 0;
    gap: 7px;
    font-size: 7px;
    white-space: nowrap;
  }
  .node-detail h2 { margin: 4px 0; font-size: 15px; line-height: 1.15; }
  .node-detail__media { margin: 4px 0; }
  .node-detail__media-image { height: 64px; min-height: 64px; max-height: 64px; }
  .node-detail__media figcaption { min-height: 12px; padding: 2px 4px; font-size: 6px; line-height: 1.2; }
  .node-detail__media figcaption a { font-size: 6px; }
  .node-detail > p {
    min-height: 0;
    margin: 4px 0;
    font-size: 7px;
    line-height: 1.42;
  }
  .node-detail__actions {
    margin-top: 4px;
    padding-top: 4px;
    gap: 4px;
  }
  .node-detail__actions button { min-height: 24px; height: 24px; padding: 0 6px; font-size: 7px; }
  .detail-close { width: 24px; height: 24px; font-size: 15px; }

  .playback {
    height: 64px;
    padding: 3px 7px;
  }
  .playback__content { grid-template-columns: 48px minmax(0,1fr); }
  .playback__controls { height: 58px; }
  .playback__meta { height: 14px; }
  .timeline-calendar { height: 17px; overflow: visible; }
  .timeline-month { top: 8px; font-size: 5.5px !important; }
  .timeline-month.is-minor { color: #637c7f; opacity: .78; }
  .timeline-month.is-major { color: #b1c3bf; font-weight: 650; }
  .timeline-month::before { top: 7px; height: 4px; }
  .timeline-year { top: -1px; font-size: 6px !important; }
  .progress-track { height: 18px; }
  .timeline-node { top: 1px; }
  .timeline-gap-marker { top: -1px; }
}

/* V18: tighter phone landscape layout and aligned sandbox controls */
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  :root { --mobile-timeline-height: 58px; }

  .left-rail {
    left: max(4px, env(safe-area-inset-left));
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 58px);
    width: 166px;
    padding: 4px;
    gap: 5px;
    transform: translateX(calc(-100% - 12px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .left-rail.is-mobile-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .left-rail .route-overview,
  .left-rail .sandbox-console,
  .left-rail .legend { padding: 7px; }
  .left-rail .route-overview h2 { font-size: 13px; }
  .left-rail .route-overview > p,
  .left-rail .route-overview__history { font-size: 7.5px; }
  .left-rail .sandbox-console__section { margin-top: 5px; }
  .left-rail .sandbox-console__label { margin-bottom: 4px; }
  .left-rail .render-switch {
    width: 100%;
    height: 27px;
    min-height: 27px;
    padding: 2px;
    gap: 2px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    overflow: hidden;
    box-sizing: border-box;
  }
  .left-rail .render-mode {
    width: 100%;
    min-width: 0;
    height: 21px;
    min-height: 21px;
    margin: 0;
    padding: 0;
    align-self: stretch;
    transform: none;
    line-height: 21px;
    box-sizing: border-box;
  }

  /* Keep the route control legible in narrow landscape phones. */
  .commandbar__actions #route-toggle {
    width: auto;
    min-width: 76px;
    padding: 0 8px;
    gap: 5px;
  }
  .commandbar__actions #route-toggle span {
    display: inline-flex;
    font-size: 11px;
    white-space: nowrap;
  }
  .commandbar__actions #route-toggle svg { width: 14px; height: 14px; }
  .commandbar__actions #fullscreen-toggle {
    width: 34px;
    min-width: 34px;
  }

  .node-detail {
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 56px);
    width: min(30vw, 252px);
    padding: 6px 8px;
  }
  .node-detail::before {
    margin: -1px 0 2px;
    font-size: 6.5px;
    line-height: 1;
    letter-spacing: .12em;
  }
  .node-detail__header { min-height: 18px; gap: 6px; }
  .node-detail__index strong { font-size: 15px; }
  .node-detail__meta {
    margin-top: 2px;
    padding: 3px 0;
    font-size: 6.8px;
  }
  .node-detail h2 { margin: 3px 0; font-size: 14px; }
  .node-detail__media { margin: 3px 0; }
  .node-detail__media-image {
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    object-fit: cover;
  }
  .node-detail__media figcaption {
    min-height: 10px;
    padding: 2px 4px;
    font-size: 5.8px;
  }
  .node-detail > p {
    margin: 3px 0;
    font-size: 6.8px;
    line-height: 1.35;
  }
  .node-detail__actions {
    margin-top: 3px;
    padding-top: 3px;
  }
  .node-detail__actions button {
    min-height: 21px;
    height: 21px;
    font-size: 6.5px;
  }
  .detail-close { width: 21px; height: 21px; font-size: 13px; }

  .playback {
    height: 52px;
    padding: 2px 6px;
  }
  .playback__content {
    grid-template-columns: 43px minmax(0, 1fr);
    gap: 6px;
  }
  .playback__controls {
    width: 43px;
    min-width: 43px;
    height: 48px;
    gap: 1px;
  }
  .play-button { width: 27px; height: 27px; min-width: 27px; }
  .play-button svg { width: 12px; height: 12px; }
  .playback__controls .text-button {
    width: 39px;
    height: 14px;
    font-size: 6.5px;
  }
  .playback__controls .text-button svg { width: 9px; height: 9px; }
  .playback__main { padding: 0; }
  .playback__meta { height: 12px; font-size: 6.5px; }
  .playback__meta strong { font-size: 11px; }
  .timeline-calendar { height: 14px; }
  .timeline-month { top: 6px; font-size: 5px !important; }
  .timeline-month::before { top: 6px; height: 3px; }
  .timeline-year { top: -1px; font-size: 5.5px !important; }
  .progress-track { height: 15px; }
  .timeline-node { top: 0; width: 8px; height: 8px; }
  .timeline-gap-marker { top: -2px; }
}

/* V19: keep the timeline docked in map focus mode */
#app.is-map-focus .playback {
  display: flex !important;
  position: fixed;
  left: max(4px, env(safe-area-inset-left));
  right: max(4px, env(safe-area-inset-right));
  bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 38;
}
#app.is-map-focus .playback:not(.is-visible) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#app.is-map-focus .playback.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* V23: mobile-first detail card — media is preserved, body scrolls, navigation stays usable. */
.node-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.node-detail__scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(82,228,229,.35) transparent;
}
.node-detail__media-image {
  background: rgba(1, 9, 13, .94);
}
.node-detail__media img {
  object-fit: contain;
  object-position: center;
}
.node-detail__actions {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg, rgba(3,14,19,.74), rgba(3,14,19,.98));
}

/* V24: mobile landscape composition refinement. */
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .mobile-panel-close { display: none !important; }
  .node-detail {
    right: max(5px, env(safe-area-inset-right));
    width: min(28vw, 238px);
  }
}

@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .node-detail {
    top: calc(max(4px, env(safe-area-inset-top)) + 54px);
    right: max(4px, env(safe-area-inset-right));
    bottom: calc(max(4px, env(safe-area-inset-bottom)) + 62px);
    width: min(34vw, 286px);
    padding: 8px;
  }
  .node-detail__scroll { padding: 0 1px 2px 0; }
  .node-detail__media { margin: 5px 0; }
  .node-detail__media-image { height: 92px; min-height: 92px; max-height: 92px; }
  .node-detail__media figcaption { min-height: 16px; padding: 2px 5px; font-size: 6px; }
  .node-detail__copy-wrap { max-height: 48px; }
  .node-detail.is-copy-expanded .node-detail__copy-wrap { max-height: none; overflow: visible; }
  .node-detail__copy-wrap p { min-height: 0; padding-bottom: 6px; font-size: 8px; line-height: 1.5; }
  .detail-copy-toggle { height: 24px; margin-top: 3px; font-size: 7px; }
  .node-detail__actions { margin-top: 5px; padding-top: 5px; gap: 5px; }
  .node-detail__actions button { flex: 1 1 0; justify-content: center; min-height: 28px; height: 28px; font-size: 7.5px; }

  .commandbar__actions { gap: 4px; }
  .commandbar__actions #page-fullscreen-toggle,
  .commandbar__actions #fullscreen-toggle { width: 34px; min-width: 34px; }
  #page-fullscreen-toggle { border-color: rgba(82,228,229,.44); }
}
/* V24 final override: keep more map space beside the history card in mobile landscape. */
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .node-detail {
    width: min(28vw, 238px) !important;
    right: max(5px, env(safe-area-inset-right));
  }
}

/* V26: concise route brief and a stable, scan-friendly elevation key. */
.route-overview__history { display: none !important; }
.elevation-strip b {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  column-gap: 9px;
  row-gap: 2px;
  align-content: center;
  white-space: nowrap;
  line-height: 1.25;
}
.elevation-strip b span { display: block; }
@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .left-rail .elevation-strip {
    grid-template-columns: auto 10px auto minmax(0, 1fr);
    gap: 5px;
  }
  .left-rail .elevation-strip i { width: 10px; height: 36px; }
  .left-rail .elevation-strip b {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 6px;
    font-size: 7px;
  }
}

/* V27: portrait phone layout — content is stacked into explicit, non-overlapping zones. */
@media (max-width: 0px) and (max-height: 0px) {
  :root {
    --portrait-header-height: 106px;
    --portrait-timeline-height: 94px;
    --portrait-mini-timeline-height: 42px;
    --portrait-gap: 8px;
  }

  .commandbar {
    top: max(6px, env(safe-area-inset-top));
    left: 6px;
    right: 6px;
    min-height: 96px;
    padding: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 39px 38px;
    gap: 5px 6px;
  }
  .brand-lockup h1 { max-width: 48vw; font-size: 14px; }
  .commandbar__actions { gap: 5px; }
  .commandbar__actions button { width: 38px; min-width: 38px; height: 38px; min-height: 38px; }
  .route-switch { gap: 3px; padding: 2px; }
  .route-tab { min-width: 86px; height: 33px; padding: 0 9px; font-size: 12px; }

  .mobile-panel-toggle {
    top: calc(max(6px, env(safe-area-inset-top)) + var(--portrait-header-height) + 10px);
    transform: none;
    height: 64px;
    z-index: 27;
  }
  .commandbar { z-index: 32; }
  .mobile-panel-backdrop {
    top: calc(max(6px, env(safe-area-inset-top)) + var(--portrait-header-height));
    bottom: 0;
  }
  .edge-panel-toggle.is-open { transform: translateX(-110%); }

  .left-rail {
    top: auto;
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-mini-timeline-height));
    left: 6px;
    right: 6px;
    width: auto;
    height: min(51dvh, 450px);
    padding: 18px 8px 10px;
    gap: 8px;
    border-radius: 14px 14px 0 0;
    transform: translateY(calc(100% + 18px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 -18px 44px rgba(0, 0, 0, .48);
  }
  .left-rail::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 4px;
    border-radius: 4px;
    transform: translateX(-50%);
    background: rgba(138,202,204,.65);
  }
  .left-rail.is-mobile-open {
    transform: translateY(0) !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .left-rail .route-overview,
  .left-rail .sandbox-console,
  .left-rail .legend { padding: 11px 12px; }
  .left-rail .route-overview__nodes ol { max-height: 0; }
  .left-rail .route-overview.is-nodes-expanded .route-overview__nodes ol { max-height: 38vh; }

  .playback {
    left: 6px;
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    height: var(--portrait-timeline-height);
    padding: 8px;
    border-radius: 8px;
    transform: translateY(calc(100% + 20px));
  }
  .playback.is-visible {
    transform: translateY(0) !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  #app.has-portrait-sheet .playback {
    height: var(--portrait-mini-timeline-height);
    padding: 4px 8px;
    border-radius: 7px;
    transform: translateY(0) !important;
  }
  #app.has-portrait-sheet .timeline-heading,
  #app.has-portrait-sheet .playback__meta,
  #app.has-portrait-sheet .timeline-calendar { display: none; }
  #app.has-portrait-sheet .playback__content { display: flex; align-items: center; gap: 8px; }
  #app.has-portrait-sheet .playback__controls { width: 30px; min-width: 30px; }
  #app.has-portrait-sheet .play-button { width: 28px; height: 28px; }
  #app.has-portrait-sheet .progress-track { flex: 1; height: 24px; margin: 0; }
  #app.has-portrait-sheet .timeline-node { width: 8px; height: 8px; }
  .timeline-heading { display: flex; height: 22px; margin-bottom: 3px; }
  .timeline-heading__title strong { font-size: 11px; }
  .timeline-heading__title span { font-size: 8px; }
  .playback__content { grid-template-columns: 42px minmax(0, 1fr); gap: 7px; }
  .playback__controls { width: 42px; min-width: 42px; }
  .play-button { width: 40px; height: 40px; }
  .playback__meta { font-size: 8px; }
  .playback__meta strong { font-size: 14px; }
  .timeline-calendar { height: 15px; }
  .timeline-months span,
  .timeline-years span { font-size: 6px; }
  .progress-track { height: 23px; }
  .timeline-node { width: 10px; height: 10px; }

  .node-detail {
    top: auto;
    left: 6px;
    right: 6px;
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-mini-timeline-height));
    width: auto;
    height: min(47dvh, 420px);
    max-height: none;
    padding: 18px 11px 11px;
    border-radius: 14px 14px 0 0;
    transform: translateY(18px);
  }
  .node-detail::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 4px;
    border-radius: 4px;
    transform: translateX(-50%);
    background: rgba(138,202,204,.65);
  }
  .node-detail__header { position: relative; top: auto; padding: 0; background: transparent; }
  .node-detail__media-image { min-height: 118px; height: min(31vh, 190px); }
  .node-detail__actions button { min-height: 38px; }
  .detail-close { width: 32px; height: 32px; }

  .node-detail__media {
    margin: 8px 0 7px;
  }
  .node-detail__media-image { height: min(18vh, 132px); min-height: 84px; }
  .node-detail__media figcaption { min-height: 22px; }
  .node-detail__copy-wrap {
    max-height: 58px;
    overflow-y: auto;
  }
  .node-detail__copy-wrap::after { display: none; }
  .node-detail__copy-wrap p { min-height: 0; padding-bottom: 3px; font-size: 10px; line-height: 1.55; }
  .detail-copy-toggle { display: none !important; }
  .node-detail__actions { margin-top: 6px; padding-top: 6px; }
  .node-detail__actions button { min-height: 34px; }

  .terrain-label { font-size: 8px; opacity: .68; }
  .map-label { font-size: 9px; }
}

@media (max-width: 0px) and (max-height: 0px) {
  #app.has-portrait-sheet .mobile-panel-toggle { opacity: 0; pointer-events: none; }
}

/* V29: portrait phone redesign — map-first shell with distinct navigation layers. */
@media (max-width: 0px) and (max-height: 0px) {
  :root {
    --portrait-header-height: 98px;
    --portrait-timeline-height: 88px;
    --portrait-sheet-height: min(48dvh, 430px);
  }

  .commandbar {
    top: max(6px, env(safe-area-inset-top));
    left: 6px;
    right: 6px;
    min-height: 90px;
    padding: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 38px 36px;
    gap: 5px 6px;
    border-radius: 9px;
  }
  .brand-lockup { gap: 7px; }
  .brand-star { width: 32px; height: 32px; }
  .brand-star svg { width: 18px; }
  .brand-lockup h1 {
    max-width: none;
    font-size: clamp(12px, 3.6vw, 14px);
    white-space: nowrap;
  }
  .commandbar__actions { gap: 5px; }
  .commandbar__actions button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }
  /* Portrait already dedicates the full screen to the map. Keep the route action
     and true page fullscreen; remove the second, visually ambiguous focus mode. */
  #fullscreen-toggle { display: none !important; }
  .route-switch { height: 36px; gap: 3px; padding: 2px; }
  .route-tab {
    min-width: 88px;
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }
  .route-tab--all { min-width: 76px; }

  .mobile-panel-toggle {
    top: 48%;
    left: 0;
    width: 32px;
    height: 72px;
    transform: translateY(-50%);
    border-radius: 0 8px 8px 0;
  }
  .edge-panel-toggle.is-open { transform: translate(-110%, -50%); }

  .playback {
    left: 6px;
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    height: var(--portrait-timeline-height);
    padding: 7px 8px 8px;
    border-radius: 9px;
    transition: opacity .22s ease, transform .28s ease, visibility .22s ease;
  }
  .timeline-heading { height: 18px; margin-bottom: 2px; }
  .timeline-heading__title strong { font-size: 11px; }
  .playback__content { grid-template-columns: 40px minmax(0, 1fr); gap: 7px; }
  .playback__controls { width: 40px; min-width: 40px; }
  .play-button { width: 38px; height: 38px; }
  .playback__meta { height: 17px; }
  .timeline-calendar { height: 13px; }
  .progress-track { height: 22px; }

  /* Only historical node detail replaces the timeline. The reference drawer stays
     on the left, so its direction and purpose remain visually distinct. */
  #app.has-portrait-sheet .playback {
    display: flex;
    height: var(--portrait-timeline-height);
    padding: 7px 8px 8px;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(calc(100% + 18px)) !important;
  }
  #app.has-portrait-sheet .timeline-heading { display: flex; }
  #app.has-portrait-sheet .playback__meta { display: flex; }
  #app.has-portrait-sheet .timeline-calendar { display: block; }
  #app.has-portrait-sheet .playback__content { display: grid; }
  #app.has-portrait-sheet .playback__controls { width: 40px; min-width: 40px; }
  #app.has-portrait-sheet .play-button { width: 38px; height: 38px; }
  #app.has-portrait-sheet .progress-track { height: 22px; margin-top: 2px; }
  #app.has-portrait-sheet .timeline-node { width: 10px; height: 10px; }

  .node-detail {
    left: 6px;
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    width: auto;
    height: var(--portrait-sheet-height);
    max-height: calc(100dvh - var(--portrait-header-height) - max(18px, env(safe-area-inset-top)));
    border-radius: 14px 14px 9px 9px;
    box-shadow: 0 -16px 46px rgba(0, 0, 0, .54);
  }
  .left-rail {
    top: calc(max(6px, env(safe-area-inset-top)) + var(--portrait-header-height) + 4px);
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-timeline-height) + 10px);
    left: 6px;
    right: auto;
    width: min(84vw, 320px);
    height: auto;
    max-height: none;
    padding: 9px 8px 10px;
    border-radius: 9px;
    transform: translateX(calc(-100% - 18px)) !important;
    box-shadow: 14px 0 38px rgba(0, 0, 0, .5);
  }
  .left-rail.is-mobile-open {
    transform: translateX(0) !important;
  }
  .node-detail {
    top: auto;
    padding: 20px 11px 10px;
    transform: translateY(calc(100% + 18px));
  }
  .node-detail.is-visible { transform: translateY(0); }
  .left-rail::before { display: none; }
  .node-detail::before {
    top: 8px;
    width: 42px;
    height: 4px;
  }
  .mobile-panel-close {
    top: 12px;
    right: 10px;
    width: 36px;
    height: 36px;
  }
  .mobile-panel-backdrop {
    top: calc(max(6px, env(safe-area-inset-top)) + var(--portrait-header-height));
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-timeline-height) + 6px);
    background: rgba(0, 5, 9, .36);
  }

  .node-detail__header { min-height: 34px; }
  .node-detail__index strong { font-size: 22px; }
  .node-detail__meta { margin-top: 7px; padding: 6px 0; }
  .node-detail h2 { margin: 7px 0 6px; font-size: 19px; }
  .node-detail__media { margin: 6px 0; }
  .node-detail__media-image {
    height: clamp(92px, 15dvh, 132px);
    min-height: 92px;
  }
  .node-detail__copy-wrap { max-height: 62px; }
  .node-detail__copy-wrap p { font-size: 10px; line-height: 1.55; }
  .node-detail__actions {
    margin-top: 6px;
    padding-top: 7px;
    gap: 7px;
  }
  .node-detail__actions button {
    flex: 1 1 0;
    justify-content: center;
    min-height: 42px;
    font-size: 10px;
  }

  .touch-help { display: none !important; }
}

@media (max-width: 0px) and (max-height: 0px) {
  .brand-lockup h1 { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .route-tab { min-width: 82px; }
  .node-detail__media-image { height: 96px; }
}

/* V30: portrait-only interaction corrections. Landscape rules remain untouched. */
@media (max-width: 0px) and (max-height: 0px) {
  /* Replace page fullscreen with the map-focus action in the same header slot. */
  #fullscreen-toggle { display: grid !important; }
  #page-fullscreen-toggle { display: none !important; }
  .node-detail { touch-action: pan-y; will-change: transform, opacity; }
}

/* V31: portrait-only immersive controls and three-zone map/detail/timeline layout. */
.portrait-map-zoom { display: none; }
@media (max-width: 0px) and (max-height: 0px) {
  :root {
    --portrait-timeline-height: 92px;
    --portrait-detail-height: min(34dvh, 304px);
  }

  /* Keep the timeline visible when the node archive opens. */
  #app.has-portrait-sheet .playback {
    display: flex !important;
    height: var(--portrait-timeline-height) !important;
    padding: 7px 8px 8px !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
  }
  #app.has-portrait-sheet .timeline-heading { display: flex !important; }
  #app.has-portrait-sheet .playback__meta { display: flex !important; }
  #app.has-portrait-sheet .timeline-calendar { display: block !important; }
  #app.has-portrait-sheet .playback__content { display: grid !important; }
  #app.has-portrait-sheet .progress-track { height: 22px !important; margin-top: 2px !important; }

  /* A compact replay action sits directly below play, as in landscape. */
  .playback__content { grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
  .playback__controls,
  #app.has-portrait-sheet .playback__controls {
    display: flex !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 58px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
  }
  .playback__controls .play-button,
  #app.has-portrait-sheet .play-button { width: 36px !important; height: 36px !important; }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    display: inline-flex !important;
    width: 42px;
    height: 18px;
    min-height: 18px;
    padding: 0 2px;
    gap: 2px;
    justify-content: center;
    font-size: 8px;
  }
  .playback__controls .text-button span { display: inline !important; }

  /* Node information now occupies its own band above the persistent timeline. */
  .node-detail {
    top: auto !important;
    left: 6px;
    right: 6px;
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-timeline-height) + 7px) !important;
    width: auto;
    height: var(--portrait-detail-height) !important;
    max-height: calc(100dvh - var(--portrait-header-height) - var(--portrait-timeline-height) - 25px) !important;
    padding: 17px 10px 8px;
    border-radius: 12px;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, .5);
  }
  .node-detail::before { top: 6px; width: 38px; }
  .node-detail__header { min-height: 28px; }
  .node-detail__index strong { font-size: 19px; }
  .node-detail__meta { margin-top: 4px; padding: 4px 0; }
  .node-detail h2 { margin: 4px 0; font-size: 17px; }
  .node-detail__media { margin: 4px 0; }
  .node-detail__media-image { height: clamp(74px, 11dvh, 104px); min-height: 74px; }
  .node-detail__copy-wrap { max-height: 42px; }
  .node-detail__copy-wrap p { font-size: 9px; line-height: 1.45; }
  .node-detail__actions { margin-top: 4px; padding-top: 4px; gap: 6px; }
  .node-detail__actions button { min-height: 32px; height: 32px; font-size: 9px; }

  /* In map focus, remove the inherited toolbar shell and show three independent squares. */
  #app.is-map-focus .commandbar {
    top: calc(max(8px, env(safe-area-inset-top)) + 2px) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    left: auto !important;
    width: 44px !important;
    min-width: 44px !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    display: block !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  #app.is-map-focus .commandbar::before,
  #app.is-map-focus .commandbar::after { display: none !important; }
  #app.is-map-focus .commandbar__actions {
    display: flex !important;
    width: 44px !important;
    height: auto !important;
    padding: 0 !important;
    flex-direction: column;
    gap: 7px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  #app.is-map-focus .portrait-map-zoom,
  #app.is-map-focus #fullscreen-toggle {
    display: grid !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    place-items: center;
    border: 1px solid rgba(82, 228, 229, .5) !important;
    border-radius: 10px !important;
    background: linear-gradient(180deg, rgba(7, 31, 39, .94), rgba(3, 16, 22, .94)) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .38) !important;
  }
  #app.is-map-focus .portrait-map-zoom svg,
  #app.is-map-focus #fullscreen-toggle svg { width: 21px; height: 21px; }
  #app.is-map-focus #fullscreen-toggle { order: 3; }
  #app.is-map-focus #portrait-zoom-in { order: 1; }
  #app.is-map-focus #portrait-zoom-out { order: 2; }
}

/* V32: portrait header parity, single-action map focus, aligned playback stack. */
@media (max-width: 0px) and (max-height: 0px) {
  /* Match landscape: route generation + map focus + page zoom/fullscreen. */
  .portrait-map-zoom,
  #portrait-zoom-in,
  #portrait-zoom-out { display: none !important; }
  #fullscreen-toggle,
  #page-fullscreen-toggle { display: grid !important; }

  /* Map focus deliberately exposes only its close/return action. */
  #app.is-map-focus .portrait-map-zoom,
  #app.is-map-focus #portrait-zoom-in,
  #app.is-map-focus #portrait-zoom-out,
  #app.is-map-focus #page-fullscreen-toggle { display: none !important; }
  #app.is-map-focus .commandbar__actions {
    display: grid !important;
    grid-template-columns: 44px !important;
    grid-template-rows: 44px !important;
    gap: 0 !important;
  }
  #app.is-map-focus #fullscreen-toggle {
    display: grid !important;
    order: initial !important;
  }

  /* Keep play and replay centred in one fixed vertical control column. */
  .playback,
  #app.has-portrait-sheet .playback {
    box-sizing: border-box;
  }
  .playback__content,
  #app.has-portrait-sheet .playback__content {
    min-height: 0 !important;
    flex: 1 1 auto;
    align-items: center !important;
    grid-template-columns: 46px minmax(0, 1fr) !important;
    gap: 6px !important;
  }
  .playback__controls,
  #app.has-portrait-sheet .playback__controls {
    box-sizing: border-box;
    align-self: stretch;
    width: 46px !important;
    min-width: 46px !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 5px 0 0 !important;
    display: grid !important;
    grid-template-columns: 38px !important;
    grid-template-rows: 38px 17px !important;
    place-content: center !important;
    justify-items: center !important;
    align-items: center !important;
    row-gap: 1px !important;
  }
  .playback__controls .play-button,
  #app.has-portrait-sheet .playback__controls .play-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
  }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    box-sizing: border-box;
    width: 38px !important;
    min-width: 38px !important;
    height: 17px !important;
    min-height: 17px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    line-height: 1 !important;
  }
  .playback__controls .text-button svg {
    width: 10px !important;
    height: 10px !important;
    flex: 0 0 10px;
  }
}

/* V33: portrait-only node archive and timeline use two non-overlapping bottom bands. */
@media (max-width: 0px) and (max-height: 0px) {
  :root {
    --portrait-timeline-height: 102px;
    --portrait-detail-height: min(33dvh, 296px);
  }

  /* Timeline keeps the same geometry before and after a node card opens. */
  .playback,
  #app.has-portrait-sheet .playback {
    left: 6px !important;
    right: 6px !important;
    bottom: max(6px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: var(--portrait-timeline-height) !important;
    min-height: var(--portrait-timeline-height) !important;
    padding: 7px 8px 8px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 21px minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 3px !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
  }
  .timeline-heading,
  #app.has-portrait-sheet .timeline-heading {
    display: flex !important;
    height: 21px !important;
    min-height: 21px !important;
    margin: 0 !important;
    align-items: center;
  }
  .timeline-heading__title { min-width: 0; gap: 9px; }
  .timeline-heading__title strong { flex: 0 0 auto; font-size: 12px; }
  .timeline-heading__title span { font-size: 8px; white-space: nowrap; }

  .playback__content,
  #app.has-portrait-sheet .playback__content {
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    align-items: stretch !important;
    gap: 7px !important;
  }

  /* Landscape-style round play button with replay centred directly beneath. */
  .playback__controls,
  #app.has-portrait-sheet .playback__controls {
    width: 52px !important;
    min-width: 52px !important;
    height: 63px !important;
    min-height: 63px !important;
    padding: 0 7px 0 0 !important;
    display: grid !important;
    grid-template-columns: 44px !important;
    grid-template-rows: 43px 18px !important;
    place-content: center !important;
    place-items: center !important;
    row-gap: 2px !important;
    border-right: 1px solid rgba(87, 190, 198, .16) !important;
  }
  .playback__controls .play-button,
  #app.has-portrait-sheet .playback__controls .play-button {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    border-radius: 50% !important;
  }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 18px !important;
    min-height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    font-size: 8px !important;
    line-height: 1 !important;
  }
  .playback__controls .text-button span { display: inline !important; }
  .playback__controls .text-button svg {
    width: 11px !important;
    height: 11px !important;
    flex: 0 0 11px;
  }

  .playback__main,
  #app.has-portrait-sheet .playback__main {
    min-width: 0 !important;
    min-height: 0 !important;
    height: 63px !important;
    padding: 0 2px 0 0 !important;
    display: grid !important;
    grid-template-rows: 18px 15px 28px !important;
    align-content: stretch !important;
    overflow: visible !important;
  }
  .playback__meta,
  #app.has-portrait-sheet .playback__meta {
    display: flex !important;
    height: 18px !important;
    min-height: 18px !important;
    margin: 0 !important;
    align-items: center !important;
  }
  .playback__meta > span:first-child {
    max-width: 68%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .timeline-calendar,
  #app.has-portrait-sheet .timeline-calendar {
    display: block !important;
    height: 15px !important;
    min-height: 15px !important;
    margin: 0 !important;
  }
  .progress-track,
  #app.has-portrait-sheet .progress-track {
    height: 28px !important;
    min-height: 28px !important;
    margin: 0 !important;
  }

  /* The node archive is a separate card above the timeline, never replacing it. */
  .node-detail {
    top: auto !important;
    left: 6px !important;
    right: 6px !important;
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--portrait-timeline-height) + 8px) !important;
    width: auto !important;
    height: var(--portrait-detail-height) !important;
    max-height: calc(100dvh - var(--portrait-header-height) - var(--portrait-timeline-height) - 28px) !important;
    padding: 17px 10px 8px !important;
    overflow: hidden !important;
  }
  .node-detail__scroll { min-height: 0; overflow-y: auto; }
  .node-detail__actions {
    flex: 0 0 auto;
    margin-top: 4px !important;
    padding-top: 5px !important;
  }

  /* Keep the portrait playback controls comfortably inside their column. */
  .playback__controls .play-button,
  #app.has-portrait-sheet .playback__controls .play-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
  }
  .playback__controls .play-button svg,
  #app.has-portrait-sheet .playback__controls .play-button svg {
    width: 14px !important;
    height: 14px !important;
  }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 16px !important;
    min-height: 16px !important;
    gap: 2px !important;
    font-size: 7.5px !important;
  }
  .playback__controls .text-button svg,
  #app.has-portrait-sheet .playback__controls .text-button svg {
    width: 9px !important;
    height: 9px !important;
    flex: 0 0 9px !important;
  }

  /* Preserve the full archival frame without changing the media box size. */
  .node-detail__media img { object-fit: contain; }
}

/* V34: keep playback actions compact in every horizontal layout. */
@media (orientation: landscape), (orientation: portrait) {
  .playback__controls .play-button,
  #app.has-portrait-sheet .playback__controls .play-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
  }
  .playback__controls .play-button svg,
  #app.has-portrait-sheet .playback__controls .play-button svg {
    width: 14px !important;
    height: 14px !important;
  }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    width: 36px !important;
    min-width: 36px !important;
    height: 16px !important;
    min-height: 16px !important;
    padding: 0 !important;
    gap: 2px !important;
    font-size: 7.5px !important;
  }
  .playback__controls .text-button svg,
  #app.has-portrait-sheet .playback__controls .text-button svg {
    width: 9px !important;
    height: 9px !important;
    flex: 0 0 9px !important;
  }
}

@media (orientation: landscape) and (max-height: 560px), (orientation: portrait) and (max-width: 560px) {
  .playback__controls,
  #app.has-portrait-sheet .playback__controls {
    height: 48px !important;
    min-height: 48px !important;
    gap: 1px !important;
  }
  .playback__controls .play-button,
  #app.has-portrait-sheet .playback__controls .play-button {
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
  }
  .playback__controls .play-button svg,
  #app.has-portrait-sheet .playback__controls .play-button svg {
    width: 11px !important;
    height: 11px !important;
  }
  .playback__controls .text-button,
  #app.has-portrait-sheet .playback__controls .text-button {
    width: 34px !important;
    min-width: 34px !important;
    height: 13px !important;
    min-height: 13px !important;
    font-size: 6.5px !important;
  }
  .playback__controls .text-button svg,
  #app.has-portrait-sheet .playback__controls .text-button svg {
    width: 8px !important;
    height: 8px !important;
    flex: 0 0 8px !important;
  }
}
