:root {
  --ink: #f6efe2;
  --ink-dim: rgba(246, 239, 226, 0.66);
  --ink-faint: rgba(246, 239, 226, 0.42);
  --gold: #d8a94e;
  --gold-soft: rgba(216, 169, 78, 0.18);
  --panel: rgba(20, 17, 13, 0.66);
  --panel-solid: rgba(18, 15, 12, 0.9);
  --line: rgba(246, 236, 218, 0.16);
  --line-soft: rgba(246, 236, 218, 0.08);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Times New Roman", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #100e0b;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body { overscroll-behavior: none; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #2a241b 0%, #13100c 60%, #0c0a08 100%);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 8, 6, 0.62) 0%, rgba(10, 8, 6, 0.14) 18%, rgba(10, 8, 6, 0) 38%, rgba(10, 8, 6, 0) 62%, rgba(10, 8, 6, 0.62) 100%);
  mix-blend-mode: multiply;
}

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

/* ---------- 标题 ---------- */
.header {
  top: 0;
  left: 0;
  padding: clamp(18px, 2.6vw, 34px) clamp(16px, 3vw, 40px);
  max-width: min(560px, 78vw);
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 10.5px;
  letter-spacing: 0.34em;
  color: var(--gold);
  text-transform: uppercase;
}
.header h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(28px, 3.4vw, 46px);
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.5);
}
.sub {
  margin: 10px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
}
.header::after {
  content: "";
  display: block;
  width: 58px;
  height: 1px;
  margin-top: 16px;
  background: linear-gradient(90deg, var(--gold), rgba(216, 169, 78, 0));
}

/* ---------- 工具 ---------- */
.tools {
  top: clamp(16px, 2.4vw, 30px);
  right: clamp(14px, 2.4vw, 32px);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 62vw;
}

.tool, .icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  cursor: pointer;
  transition: background 0.22s ease, border-color 0.22s ease, color 0.22s ease, transform 0.22s ease;
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
}
.tool svg, .icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool--primary svg { fill: currentColor; stroke: none; }
.tool:hover, .icon-btn:hover { border-color: rgba(216, 169, 78, 0.6); background: rgba(32, 26, 19, 0.8); }
.tool:focus-visible, .icon-btn:focus-visible, .view:focus-visible,
.info-close:focus-visible, .refs-close:focus-visible, .hotspot:focus-visible, .exit-clean:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.tool.is-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #17120b;
}
.tool--primary { border-color: rgba(216, 169, 78, 0.42); }

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 32px;
  border-radius: 999px;
  background: transparent;
  border-color: transparent;
  color: var(--ink-dim);
}
.icon-btn:hover { color: var(--ink); }
.icon-btn[aria-pressed="true"] { color: var(--gold); background: var(--gold-soft); }
.icon-btn.is-on { color: #17120b; background: var(--gold); }

/* ---------- 视角 ---------- */
.views {
  left: clamp(14px, 2.6vw, 36px);
  bottom: clamp(48px, 5vw, 64px);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  max-width: calc(100vw - 28px);
}
.view {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease;
}
.view:hover { color: var(--ink); background: rgba(246, 236, 218, 0.07); }
.view.is-active { color: #191308; background: var(--gold); }

/* ---------- 缩放 ---------- */
.zoom {
  right: clamp(14px, 2.6vw, 34px);
  bottom: clamp(48px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}
.zoom button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 42px;
  height: 38px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.zoom button:hover { background: rgba(246, 236, 218, 0.1); color: var(--gold); }
.zoom-divider { width: 20px; height: 1px; background: var(--line); }

/* ---------- 提示 ---------- */
.hint {
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

/* ---------- 说明卡 ---------- */
.info {
  right: clamp(14px, 2.6vw, 36px);
  bottom: clamp(92px, 7.4vw, 104px);
  width: min(348px, 32vw);
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(32, 26, 19, 0.86), rgba(16, 13, 10, 0.78));
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  transition: opacity 0.32s ease, transform 0.32s ease;
  max-height: calc(100dvh - 240px);
  overflow: auto;
  scrollbar-width: thin;
}
.info:not(.is-open) { opacity: 0; transform: translateY(12px); pointer-events: none; }
.info::-webkit-scrollbar { width: 4px; }
.info::-webkit-scrollbar-thumb { background: rgba(246, 236, 218, 0.2); border-radius: 4px; }

.info-label {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-transform: uppercase;
}
.info h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.info-sub {
  margin: 7px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
}
.info-body {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.82;
  color: rgba(246, 239, 226, 0.82);
}
.info-specs {
  margin: 16px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  font-size: 12px;
}
.info-specs div { display: flex; gap: 12px; align-items: baseline; }
.info-specs dt {
  flex: 0 0 62px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  font-size: 11px;
}
.info-specs dd { margin: 0; color: var(--ink); flex: 1; line-height: 1.6; }
.info-note {
  margin: 16px 0 0;
  font-size: 10.5px;
  color: rgba(246, 239, 226, 0.36);
  letter-spacing: 0.05em;
}
.info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.info-close:hover { color: var(--ink); background: rgba(246, 236, 218, 0.08); }

.tour-progress {
  margin-top: 14px;
  height: 2px;
  background: rgba(246, 236, 218, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.tour-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.3s linear;
}

/* ---------- 热点 ---------- */
.hotspots { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.hotspot {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease, color 0.2s ease;
  white-space: nowrap;
}
.hotspot.is-visible { opacity: 1; }
.hotspot .dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(216, 169, 78, 0.16), 0 0 16px rgba(216, 169, 78, 0.7);
  flex: none;
}
.hotspot .dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(216, 169, 78, 0.55);
  border-radius: 999px;
  animation: ping 3.2s ease-out infinite;
}
.hotspot .label {
  padding: 4px 9px;
  border: 1px solid rgba(246, 236, 218, 0.22);
  border-radius: 999px;
  background: rgba(16, 13, 10, 0.56);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.hotspot:hover .label { border-color: rgba(216, 169, 78, 0.8); background: rgba(28, 22, 15, 0.82); color: #fff; }
.hotspot.is-active .dot { background: #fff; box-shadow: 0 0 0 5px rgba(216, 169, 78, 0.3); }
.hotspot.is-active .label { border-color: var(--gold); color: var(--gold); }

@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- 载入 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: radial-gradient(100% 100% at 50% 40%, #221c14 0%, #100e0b 70%);
  transition: opacity 0.7s ease, visibility 0.7s ease;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; padding: 24px; }
.loader-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.28em;
  color: var(--ink);
}
.loader-bar {
  width: 168px;
  height: 1px;
  margin: 22px auto 16px;
  background: rgba(246, 236, 218, 0.14);
  overflow: hidden;
}
.loader-bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gold);
  animation: slide 1.5s ease-in-out infinite;
}
.loader-tip { margin: 0; font-size: 11px; letter-spacing: 0.16em; color: var(--ink-faint); }
@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

/* ---------- 兜底 ---------- */
.fallback {
  position: absolute;
  inset: 0;
  z-index: 30;
  padding: 32px;
  background: #12100c;
  overflow: auto;
  text-align: center;
}
.fallback p { margin: 6px 0; color: var(--ink); }
.fallback-sub { color: var(--ink-faint); font-size: 12px; }
.fallback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.fallback-grid img { width: 100%; border-radius: 10px; display: block; }

/* ---------- 实景对照 ---------- */
.refs {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 6, 4, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.refs[hidden] { display: none; }
.refs-panel {
  width: min(1080px, 100%);
  max-height: 86dvh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #15120e;
}
.refs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.refs-head h2 { margin: 4px 0 0; font-family: var(--serif); font-weight: 500; font-size: 22px; letter-spacing: 0.05em; }
.refs-close {
  width: 34px; height: 34px; flex: none; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink); font-size: 18px; cursor: pointer;
}
.refs-close:hover { border-color: var(--gold); color: var(--gold); }
.refs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.refs-grid figure { margin: 0; }
.refs-grid img { width: 100%; height: 240px; object-fit: cover; border-radius: 12px; display: block; }
.refs-grid figcaption { margin-top: 8px; font-size: 11.5px; color: var(--ink-faint); letter-spacing: 0.06em; }

/* ---------- 纯净模式 ---------- */
.exit-clean {
  position: absolute;
  z-index: 20;
  right: 18px;
  bottom: calc(18px + var(--safe-b));
  display: none;
  padding: 10px 16px;
  border: 1px solid rgba(246, 236, 218, 0.24);
  border-radius: 999px;
  background: rgba(16, 13, 10, 0.6);
  backdrop-filter: blur(10px);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.app.clean .hud, .app.clean .hotspots { opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
.app.clean .exit-clean { display: block; }

/* ---------- 移动端 ---------- */
@media (max-width: 1080px) {
  .info { width: min(320px, 40vw); }
}

@media (max-width: 860px) {
  .header { max-width: 82vw; padding-top: max(16px, env(safe-area-inset-top)); }
  .eyebrow { font-size: 9.5px; letter-spacing: 0.26em; margin-bottom: 7px; }
  .header h1 { font-size: 27px; letter-spacing: 0.04em; }
  .sub { font-size: 10px; letter-spacing: 0.1em; margin-top: 7px; line-height: 1.6; }
  .header::after { margin-top: 11px; width: 42px; }

  .tools {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    gap: 6px;
    max-width: 60vw;
  }
  .tool { height: 34px; padding: 0 11px; font-size: 11px; gap: 5px; }
  .tool svg { width: 13px; height: 13px; }
  .tool-group { gap: 0; padding: 2px; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 14px; height: 14px; }

  .views {
    left: 10px;
    right: 10px;
    bottom: calc(30px + var(--safe-b));
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: flex-start;
    padding: 4px;
  }
  .views::-webkit-scrollbar { display: none; }
  .view { height: 32px; padding: 0 11px; font-size: 11.5px; }

  .zoom { display: none; }
  .hint {
    left: 12px;
    transform: none;
    bottom: calc(9px + var(--safe-b));
    font-size: 9.5px;
    letter-spacing: 0.04em;
    white-space: normal;
  }

  .info {
    left: 10px;
    right: 10px;
    bottom: calc(10px + var(--safe-b));
    width: auto;
    max-height: 46dvh;
    padding: 18px 18px 16px;
    border-radius: 18px;
    transform: translateY(0);
  }
  .info:not(.is-open) { transform: translateY(calc(100% + 20px)); }
  .info h2 { font-size: 21px; }
  .info-body { font-size: 12.5px; line-height: 1.75; }
  .info-specs { grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .info-specs div { flex-direction: column; gap: 2px; }

  .app.info-open .views,
  .app.info-open .hint { opacity: 0; pointer-events: none; }
  .views, .hint { transition: opacity 0.25s ease; }

  .hotspot { font-size: 10.5px; gap: 6px; }
  .hotspot .label { padding: 3px 7px; }
  .hotspot .dot { width: 7px; height: 7px; }

  .refs-grid { grid-template-columns: 1fr; }
  .refs-grid img { height: 200px; }
  .refs-panel { padding: 16px; }
  .exit-clean { bottom: calc(14px + var(--safe-b)); }
}

@media (max-width: 420px) {
  .header h1 { font-size: 23px; }
  .tool span { display: none; }
  .tool { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .hotspot .dot::after { animation: none; }
  .loader-bar span { animation: none; width: 100%; }
  .info, .view, .tool, .icon-btn { transition: none; }
}
