:root {
  color-scheme: dark;
  --page: #0d1013;
  --surface: rgba(20, 23, 28, .94);
  --control: #1e2229;
  --border: #2b3138;
  --text: #e6e9ee;
  --muted: #8b949e;
  --accent: #4da3ff;
  --active: #17324d;
  --radius: 12px;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--text); background: var(--page); --settings-space: 320px; --views-space: 300px; --scene-center: calc(50% + (var(--settings-space) - var(--views-space)) / 2); --scene-width: calc(100vw - var(--settings-space) - var(--views-space)); }
body:has(#panel.hidden) { --settings-space: 0px; }
body:has(#view-panel.hidden) { --views-space: 0px; }
button, input, select { font: inherit; }
button, select, input[type="url"] { color: inherit; border: 1px solid var(--border); border-radius: 7px; background: var(--control); }
button { min-height: 34px; padding: 7px 10px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover { background: #292f38; border-color: #526273; }
button:active { background: #313b48; }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button.active, button[aria-pressed="true"], .primary { background: var(--active); border-color: var(--accent); color: #cfe6ff; }
a { color: #afc4da; text-decoration: none; }
a:hover { color: var(--text); }
select { padding: 9px 10px; width: 100%; min-height: 38px; }
input[type="url"] { width: 100%; padding: 9px 10px; margin: 10px 0 7px; }
input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
input[type="range"] { width: 100%; height: 17px; margin: 4px 0 7px; accent-color: var(--accent); cursor: pointer; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.glass { background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px #0005; backdrop-filter: blur(10px); }
.subtle { color: var(--muted); font-size: 11px; line-height: 1.6; }
.wide { width: 100%; }
.secondary { background: var(--control); }
.compact { min-height: 28px; padding: 4px 9px; font-size: 11px; }

#viewport { position: fixed; inset: 0; left: var(--settings-space); right: var(--views-space); }
#scene { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
#hotspots { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#hotspots button, .hotspot { position: absolute; pointer-events: auto; white-space: nowrap; font-size: 11px; border: 1px solid #4d8bbe; background: rgba(17,33,49,.88); border-radius: 20px; min-height: 28px; padding: 5px 10px; box-shadow: 0 3px 18px #0006; }
#hotspots button:hover { background: #244b6b; }
#selection-box { position: absolute; border: 1px solid var(--accent); background: rgba(114,181,255,.14); box-shadow: 0 0 0 1px #0006; pointer-events: none; z-index: 8; }

.app-header { position: fixed; z-index: 20; top: 16px; left: 18px; height: 38px; display: flex; align-items: center; gap: 11px; }
.icon-button { width: 38px; height: 38px; padding: 8px; border-radius: 10px; background: var(--surface); }
.icon-button svg { width: 100%; height: 100%; }
.app-title { display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 8px #000; }
.app-title strong { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.version { font-size: 10px; font-weight: 600; color: #9dcaff; border: 1px solid #436887; border-radius: 5px; padding: 2px 5px; background: #152b3b; text-shadow: none; }
.legacy-link { color: var(--muted); border-radius: 6px; padding: 6px; font-size: 11px; }
.panels-toggle { position: fixed; top: 18px; right: 18px; z-index: 20; background: var(--control); font-size: 12px; }
.mode-bar { position: fixed; z-index: 15; left: var(--scene-center); top: 17px; transform: translateX(-50%); display: flex; align-items: center; padding: 5px; gap: 4px; border-radius: 25px; }
.mode-bar button { border-radius: 20px; min-height: 31px; padding: 6px 15px; border-color: transparent; background: transparent; white-space: nowrap; font-size: 12px; }
.mode-bar button.active, .mode-bar button[aria-pressed="true"] { background: var(--active); border-color: var(--accent); }

#panel { position: fixed; z-index: 12; left: 18px; top: 68px; max-height: calc(100vh - 86px); width: 292px; overflow: auto; border-radius: var(--radius); scrollbar-width: thin; scrollbar-color: #4a5058 transparent; }
#view-panel { position: fixed; z-index: 12; right: 18px; top: 68px; width: 272px; max-height: calc(100vh - 86px); overflow: auto; border-radius: var(--radius); scrollbar-width: thin; scrollbar-color: #4a5058 transparent; }
#view-panel .panel-section { padding: 14px; }
#view-panel h2 { color: var(--muted); font-size: 13px; }
.panel-section { padding: 16px; border-bottom: 1px solid var(--border); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
h2 { margin: 0; font-weight: 600; font-size: 12px; letter-spacing: .2px; }
.field-label { display: block; margin-bottom: 7px; font-size: 11px; color: var(--muted); }
.status-line { color: var(--muted); font-size: 11px; line-height: 1.65; margin: 9px 0 0; overflow-wrap: anywhere; }
.scene-section .secondary { margin-top: 10px; }
details summary { color: #a7bbd0; font-size: 11px; cursor: pointer; padding: 3px 0; }
.source-details { margin-top: 9px; }
.advanced-details { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.advanced-details[open] summary { margin-bottom: 11px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.segmented button { font-size: 12px; min-height: 32px; padding: 6px 8px; }
.presets { margin-bottom: 14px; }
.slider-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; margin-top: 7px; }
.slider-label output { color: #9fc8f2; font-variant-numeric: tabular-nums; font-size: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 11px; cursor: pointer; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.button-grid button { font-size: 11px; padding: 7px 5px; min-height: 32px; }
.viewpoint-list { display: grid; gap: 5px; max-height: min(300px, 36vh); overflow: auto; margin-bottom: 11px; padding: 1px; scrollbar-width: thin; scrollbar-color: #626870 var(--control); }
.viewpoint-list button { width: 100%; text-align: left; font-size: 12px; min-height: 36px; padding: 8px 11px; }
.view-action { margin-top: 6px; font-size: 11px; min-height: 32px; }
.runtime-section { border-bottom: 0; }
.status-badge { color: #9bcebe; background: rgba(60,132,107,.13); padding: 3px 6px; font-size: 10px; border-radius: 5px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; margin: 0; }
.stats-grid div { min-width: 0; }
.stats-grid dt { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.stats-grid dd { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats-grid small { font-size: 10px; color: var(--muted); }
.panel-footer { font-size: 10px; line-height: 1.6; color: var(--muted); text-align: center; padding: 13px 15px; }

.experience-panel { position: fixed; z-index: 14; left: var(--scene-center); bottom: 21px; transform: translateX(-50%); width: min(670px, calc(var(--scene-width) - 40px)); padding: 14px; border-radius: var(--radius); }
.experience-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; min-height: 18px; }
.experience-heading strong { font-size: 12px; font-weight: 600; }
#tour-progress { font-size: 11px; color: #8fcaab; font-variant-numeric: tabular-nums; }
.tour-stations { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: thin; }
.tour-stations button { flex: 0 0 auto; font-size: 10px; padding: 5px 8px; min-height: 29px; }
.tour-actions { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 7px; }
.tour-actions button { font-size: 11px; }
#walk-panel .experience-heading .compact { margin-left: auto; white-space: nowrap; }
.walk-body { display: flex; gap: 14px; align-items: center; }
.walk-pad { display: grid; grid-template-columns: repeat(3, 35px); grid-template-rows: repeat(2, 34px); gap: 4px; flex: 0 0 auto; }
.walk-pad button, .look-controls button { font-size: 17px; padding: 3px; user-select: none; -webkit-user-select: none; touch-action: none; }
.walk-pad [data-move="forward"] { grid-area: 1 / 2; }
.walk-pad [data-move="left"] { grid-area: 2 / 1; }
.walk-pad [data-move="back"] { grid-area: 2 / 2; }
.walk-pad [data-move="right"] { grid-area: 2 / 3; }
.look-controls { display: flex; gap: 4px; align-self: flex-end; }
.look-controls button { width: 34px; }
.walk-settings { flex: 1; min-width: 100px; }
.walk-settings .slider-label { margin-top: 0; font-size: 10px; }
.walk-settings input { margin: 2px 0 5px; height: 15px; }

.loading-card { position: fixed; z-index: 25; top: 50%; left: var(--scene-center); transform: translate(-50%, -50%); width: min(350px, calc(100vw - 40px)); padding: 25px; border-radius: 18px; text-align: center; }
.loading-card h1 { font-size: 17px; font-weight: 600; margin: 17px 0 8px; }
.loading-card p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0 0 16px; overflow-wrap: anywhere; }
.loading-card button { margin-top: 13px; }
.loading-indicator { width: 27px; height: 27px; border: 2px solid #2a4057; border-top-color: var(--accent); border-radius: 50%; margin: auto; animation: loading-turn 1s linear infinite; }
progress { width: 100%; height: 5px; border: 0; border-radius: 5px; overflow: hidden; background: #263544; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: #263544; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 5px; transition: width .2s; }
progress::-moz-progress-bar { background: var(--accent); }
.toast { position: fixed; z-index: 30; bottom: 24px; left: var(--scene-center); transform: translateX(-50%); color: var(--text); background: rgba(30,34,41,.97); border: 1px solid #4a5058; border-radius: 9px; padding: 10px 17px; box-shadow: 0 8px 30px #0004; font-size: 12px; max-width: min(560px, calc(100vw - 30px)); text-align: center; pointer-events: none; overflow-wrap: anywhere; }
body:has(#tour-panel:not(.hidden):not([hidden])) .toast, body:has(#walk-panel:not(.hidden):not([hidden])) .toast { bottom: 190px; }
@keyframes loading-turn { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
  .app-title strong { font-size: 13px; }
  .legacy-link { display: none; }
  .mode-bar button { padding: 6px 11px; }
  .experience-heading > .subtle { display: none; }
  .walk-body { flex-wrap: wrap; gap: 9px; }
  .walk-settings { min-width: 140px; }
}
@media (max-width: 900px) {
  :root { font-size: 12px; }
  body { --settings-space: 0px; --views-space: 0px; }
  .app-header { top: max(12px, env(safe-area-inset-top)); left: 12px; }
  .panels-toggle { top: max(14px, env(safe-area-inset-top)); right: 12px; min-height: 34px; padding: 6px 9px; font-size: 11px; }
  .app-title strong { font-size: 13px; }
  .mode-bar { top: max(64px, calc(env(safe-area-inset-top) + 53px)); left: 50%; width: max-content; max-width: calc(100vw - 20px); }
  .mode-bar button { font-size: 11px; padding: 6px 12px; }
  #panel { top: max(112px, calc(env(safe-area-inset-top) + 101px)); left: 12px; max-height: calc(100vh - 130px - env(safe-area-inset-bottom)); width: min(292px, calc(100vw - 24px)); background: rgba(20,23,28,.98); z-index: 18; }
  #view-panel { top: max(112px, calc(env(safe-area-inset-top) + 101px)); right: 12px; width: min(272px, calc(100vw - 24px)); max-height: calc(100vh - 130px - env(safe-area-inset-bottom)); background: rgba(20,23,28,.98); z-index: 18; }
  .experience-panel, .loading-card, .toast { left: 50%; }
  .experience-panel { width: calc(100vw - 24px); bottom: max(12px, env(safe-area-inset-bottom)); padding: 12px; }
  .experience-heading { margin-bottom: 9px; }
  .tour-stations { gap: 5px; }
  .tour-actions button { min-height: 36px; }
  .walk-body { flex-wrap: nowrap; }
  .walk-settings { min-width: 80px; }
  .walk-pad { grid-template-columns: repeat(3, 34px); }
  .look-controls { flex-direction: column; }
  .look-controls button { height: 32px; min-height: 32px; }
  .toast { bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  .app-header { gap: 8px; }
  .app-title { gap: 5px; }
  .app-title strong { font-size: 12px; }
  .mode-bar button { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .loading-indicator { animation-duration: 2s; }
}
