:root {
  color-scheme: dark;
  --ink: #161916;
  --surface: #21251f;
  --ivory: #f1ecdf;
  --gold: #daba86;
  --muted: #b8b9aa;
  --rule: #41463b;
  --glass: rgba(22, 25, 22, .79);
  --glass-rule: rgba(241, 236, 223, .29);
  --gutter: clamp(18px, 2.7vw, 52px);
  --left: max(var(--gutter), env(safe-area-inset-left));
  --right: max(var(--gutter), env(safe-area-inset-right));
  --sans: "PingFang SC", "HarmonyOS Sans SC", "HarmonyOS Sans", "Source Han Sans SC",
          "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--sans); color: var(--ivory); background: var(--ink); }
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 370px; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button { border: 0; color: inherit; background: none; font: inherit; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, .viewport:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }

.tour-header {
  display: flex; flex: none; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 64px; padding: max(6px, env(safe-area-inset-top)) var(--right) 6px var(--left);
  border-bottom: 1px solid var(--rule); background: var(--ink);
}
.tour-identity, .tour-heading, .return-link { display: flex; align-items: center; }
.tour-identity { gap: clamp(14px, 1.6vw, 25px); }
.tour-format { color: var(--gold); font: 580 clamp(23px, 2vw, 32px)/1 var(--sans); letter-spacing: -.065em; }
.tour-heading { gap: 14px; padding-left: clamp(14px, 1.6vw, 25px); border-left: 1px solid #505346; }
.tour-heading h1 { color: var(--ivory); font-size: clamp(18px, 1.55vw, 25px); font-weight: 590; line-height: 1.35; letter-spacing: .035em; white-space: nowrap; }
.tour-heading > span { color: var(--muted); font-size: .875rem; }
.return-link { gap: 8px; justify-content: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 3px; color: var(--ivory); font-size: .875rem; white-space: nowrap; }
.return-link svg { width: 16px; height: 16px; color: var(--gold); }
.return-link:hover, .return-link:focus-visible { border-color: var(--gold); color: var(--gold); background: var(--surface); }

.tour-main { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.tour-frame { position: relative; isolation: isolate; flex: 1; min-height: 0; background: var(--ink); }
.viewport, .render-surface, .render-surface canvas, .poster { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewport { overflow: hidden; }
.viewport[tabindex] { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.viewport.grabbing { cursor: grabbing; }
.viewport:focus-visible { outline-offset: -4px; }
.render-surface, .render-surface canvas { display: block; pointer-events: none; }
.poster { object-fit: cover; pointer-events: none; }
.tour-frame::after {
  content: ""; position: absolute; inset: auto 0 0; height: min(24%, 156px); pointer-events: none;
  background: linear-gradient(0deg, rgba(13, 16, 13, .68), rgba(13, 16, 13, .23) 50%, transparent);
}

.control-stack, .scene-stepper, .tour-status {
  border: 1px solid var(--glass-rule); border-radius: 4px; background: var(--glass);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.control-stack, .scene-stepper { display: flex; align-items: stretch; }
.control-stack { position: absolute; z-index: 2; top: clamp(14px, 2.4vh, 28px); right: var(--right); padding: 2px; }
.control-stack button, .scene-stepper button {
  display: grid; place-items: center; width: 44px; height: 42px; padding: 0;
  border-radius: 2px; color: var(--ivory);
}
.control-stack button:focus-visible, .scene-stepper button:focus-visible { outline-offset: -3px; }
.control-stack button:hover, .scene-stepper button:hover { background: rgba(241, 236, 223, .12); color: var(--gold); }
.control-stack button:disabled { opacity: .38; cursor: default; }
.control-stack svg, .scene-stepper svg { width: 19px; height: 19px; }
.control-stack .tour-turn { display: flex; justify-content: center; align-items: center; gap: 7px; width: auto; padding: 0 12px; border-right: 1px solid var(--glass-rule); font-size: .875rem; }
.control-stack .tour-turn svg { color: var(--gold); }
.control-stack #fullscreen { border-left: 1px solid var(--glass-rule); }
.control-stack button[aria-pressed=true] { background: var(--gold); color: var(--ink); }
.control-stack button[aria-pressed=true] svg { color: var(--ink); }

.view-footer {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  position: absolute; z-index: 2; left: var(--left); right: var(--right); bottom: clamp(17px, 3.1vh, 36px); pointer-events: none;
}
.view-details { display: flex; min-width: 0; align-items: flex-start; flex-direction: column; gap: 5px; color: #fffaf0; text-shadow: 0 1px 6px #11180fcc; }
.scene-count { display: flex; align-items: center; gap: 9px; color: #fff6e3; font: 580 .82rem/1.4 var(--sans); letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.scene-count::before { content: ""; width: 25px; height: 2px; background: var(--gold); }
.view-details h2 { font-size: clamp(28px, 3.35vw, 51px); font-weight: 560; line-height: 1.22; letter-spacing: .025em; }
.scene-stepper { padding: 1px; pointer-events: auto; }
.scene-stepper button { width: 45px; height: 43px; }
.scene-stepper button + button { border-left: 1px solid var(--glass-rule); }
.scene-stepper svg { width: 16px; height: 16px; }
.tour-status { position: absolute; z-index: 3; top: clamp(14px, 2.4vh, 28px); left: var(--left); max-width: min(80vw, 22em); padding: 8px 13px; border-left: 2px solid var(--gold); color: var(--ivory); font-size: .875rem; pointer-events: none; }

.tour-panel {
  display: grid; flex: none; grid-template-columns: minmax(112px, 12%) minmax(0, 1fr); align-items: center; gap: 18px;
  padding: 12px var(--right) max(12px, env(safe-area-inset-bottom)) var(--left); border-top: 1px solid var(--rule); background: var(--surface);
}
.panel-head { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; gap: 4px; }
.panel-title { position: relative; display: flex; align-items: center; gap: 1px; }
.panel-title h2 { color: var(--ivory); font-size: 1rem; font-weight: 570; line-height: 1.3; }
.panel-toggle { display: grid; place-items: center; width: 35px; height: 34px; padding: 0; color: var(--muted); }
.panel-toggle::before { content: ""; position: absolute; inset: 0; }
.panel-toggle svg { width: 18px; height: 18px; transition: transform .18s; }
.panel-toggle[aria-expanded=false] svg { transform: rotate(180deg); }
.panel-toggle:hover { color: var(--gold); }
.panel-head p { font-size: .78rem; line-height: 1.5; color: var(--muted); white-space: nowrap; }
.touch-hint { display: none; }
.scene-strip { display: flex; min-width: 0; align-items: stretch; gap: 7px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #676b5d var(--surface); }
.scene-link { display: block; position: relative; flex: 1 0 76px; min-width: 0; max-width: 160px; padding-bottom: 2px; }
.scene-link img { display: block; width: 100%; height: clamp(41px, 3.6vw, 63px); border: 1px solid transparent; border-radius: 2px; object-fit: cover; opacity: .73; }
.scene-name { display: flex; align-items: center; gap: 5px; padding: 5px 2px 0; font-size: .795rem; font-weight: 470; line-height: 1.3; white-space: nowrap; color: var(--muted); }
.scene-link:hover img { opacity: 1; }
.scene-link:hover .scene-name { color: var(--ivory); }
.scene-link[aria-current=true] img { border: 2px solid var(--gold); opacity: 1; }
.scene-link[aria-current=true] .scene-name { color: var(--gold); font-weight: 630; }
.scene-link[aria-current=true] .scene-name::before { content: ""; width: 4px; height: 4px; background: var(--gold); }
.scene-link:focus-visible { outline-offset: -2px; }
.tour-panel.tray-closed { display: block; padding-block: 3px max(3px, env(safe-area-inset-bottom)); }
.tour-panel.tray-closed .panel-head { flex-direction: row; align-items: center; justify-content: space-between; }
.tour-immersive .tour-header, .tour-immersive .tour-panel { display: none; }
.tour-immersive .control-stack { top: max(14px, env(safe-area-inset-top)); }
.tour-immersive .view-footer { bottom: max(17px, env(safe-area-inset-bottom)); }

@media (pointer: coarse) { .touch-hint { display: inline; } .desktop-hint { display: none; } }
@media (min-width: 851px) and (max-width:1050px) { .tour-panel { grid-template-columns: 123px minmax(0, 1fr); gap: 12px; } }
@media (max-width: 850px) {
  .tour-panel { grid-template-columns: 1fr; gap: 5px; padding: 6px 0 max(8px, env(safe-area-inset-bottom)); }
  .panel-head { flex-flow: row; align-items: center; justify-content: space-between; padding-left: var(--left); padding-right: var(--right); }
  .scene-strip { padding-left: var(--left); padding-right: var(--right); scroll-padding-inline: var(--gutter); }
  .scene-link { flex: 1 0 80px; }
  .scene-link img { height: 46px; }
}
@media (max-width: 560px) {
  :root { --gutter: 16px; }
  .tour-header { min-height: 54px; padding-block: max(2px, env(safe-area-inset-top)) 2px; }
  .tour-identity { gap: 11px; }
  .tour-heading { align-items: flex-start; flex-direction: column; gap: 1px; padding-left: 11px; }
  .tour-heading h1 { font-size: 18px; }
  .tour-heading > span { font-size: .76rem; line-height: 1.25; }
  .return-link { min-height: 39px; padding: 0 9px; font-size: .815rem; gap: 5px; }
  .control-stack { top: 12px; right: max(12px, env(safe-area-inset-right)); }
  .control-stack button { width: 41px; height: 42px; }
  .control-stack .tour-turn { padding-inline: 10px; font-size: .83rem; }
  .scene-stepper button { width: 43px; height: 43px; }
  .view-footer { bottom: 17px; }
  .view-details h2 { font-size: 30px; }
  .tour-status { top: 68px; }
  .panel-head p { font-size: .76rem; }
  .panel-title h2 { font-size: .91rem; }
  .scene-link { flex: 0 0 80px; }
  .scene-link img { height: 45px; }
  .touch-hint { display: inline; }
  .desktop-hint { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body { min-height: 245px; }
  .tour-header { min-height: 42px; padding-block: 0; }
  .tour-panel { grid-template-columns: 112px minmax(0, 1fr); gap: 5px; padding: 5px var(--right) max(5px, env(safe-area-inset-bottom)) var(--left); }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 0; padding: 0; }
  .panel-head p { display: none; }
  .scene-strip { padding: 0; }
  .scene-link { flex: 1 0 67px; }
  .scene-link img { height: 32px; }
  .view-footer { bottom: 11px; }
  .view-details h2 { font-size: 25px; }
  .control-stack { top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .panel-toggle svg { transition: none; } }
