:root {
  --bg: #0a0c10;
  --panel: rgba(16, 20, 27, 0.82);
  --panel-solid: #10141b;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.20);
  --fg: #eef2f7;
  --fg-dim: #98a4b6;
  --accent: #4ea3ff;
  --accent-soft: rgba(78, 163, 255, 0.16);
  --warn: #ffb648;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

canvas#view { display: block; width: 100%; height: 100%; outline: none;
  /* ⚠ **常开**，不要只挂在 body.touch 上：Windows 触摸屏在“鼠标模式”下，
     手指在画布上拖动也会被浏览器当成滚动/缩放手势，页面跟着滚 ✗（展方 2026-09-28 补的触摸屏支持） */
  touch-action: none; }

/* 触摸端关掉浏览器自带手势 —— 否则在画面上滑动会变成"页面滚动 / 双指缩放页面"。
   注：OrbitControls 构造时也会把 `touchAction` 直接写在 canvas 的 style 上，
   所以实测 it 已经是 none 了；这条主要是把"为什么该是 none"写在看得见的地方。 */
body.touch canvas#view { touch-action: none; }
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* 上面只管住了 canvas。**浮层也要各自关**：手指落在浮层上时，浏览器会按那个元素的
   `touch-action` 判断"这是不是滚动/缩放手势"，一旦它认定开始了手势，事件就变成
   `cancelable: false`，我们再 `preventDefault()` 也没用（控制台会刷
   "Ignored attempt to cancel a touchstart event ... scrolling is in progress"），
   捏合/滑动会断在半路。CDP 真实触摸实测出来的。
   ⚠ `#detail` 要保住 `overflow:auto` 的触摸滚动，所以**不在**这个清单里。 */
body.touch #hotspots,
body.touch .hs,
body.touch #hint,
body.touch #panelhud,
body.touch #joystick,
body.touch #tap-ripple { touch-action: none; }

/* ============ 加载页 ============ */
#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #07090c;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#poster {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0.30;
  filter: saturate(0.85) brightness(0.7);
}
#loader::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 0%, rgba(7, 9, 12, 0.72) 55%, #07090c 100%);
}

.loader-inner {
  position: relative; z-index: 2;
  width: min(520px, 86vw);
  text-align: center;
}
.loader-inner h1 {
  font-size: 26px; font-weight: 600; letter-spacing: 0.14em; margin-bottom: 10px;
}
.loader-inner .sub {
  font-size: 13px; color: var(--fg-dim); letter-spacing: 0.06em; margin-bottom: 34px;
}
.bar-track {
  height: 3px; background: rgba(255, 255, 255, 0.10);
  border-radius: 3px; overflow: hidden;
}
.bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #8fd0ff);
  border-radius: 3px;
  transition: width 0.25s ease;
}
.loader-meta {
  display: flex; justify-content: space-between;
  margin-top: 12px; font-size: 12px; color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
#loader-error {
  display: none; margin-top: 20px; padding: 14px 16px;
  background: rgba(255, 90, 90, 0.10); border: 1px solid rgba(255, 90, 90, 0.35);
  border-radius: var(--radius); font-size: 12.5px; line-height: 1.8;
  color: #ffcaca; text-align: left; word-break: break-all;
  white-space: pre-line;
}
#loader-error.show { display: block; }

/* ============ 加载屏上的「操控方式」选择（展方 2026-09-28） ============
   ⚠ 这里的样式**不能依赖 body.touch** —— 这一刻还没决定用哪套操控。
   按钮做得很“厚”（触摸屏上手指点得中），同时鼠标点也不别扭。 */
.pick { display: none; margin-top: 26px; }
.pick.show { display: block; }   /* 默认隐藏：加载到 100% 后才由 control.js 显示 */
.pick-title {
  font-size: 12.5px; color: var(--fg-dim); letter-spacing: 0.10em; margin-bottom: 12px;
}
.pick-btns { display: flex; gap: 12px; }
.pick-btns button {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 12px; cursor: pointer;
  font-family: var(--font); color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.pick-btns button:hover { background: rgba(255, 255, 255, 0.10); }
.pick-btns button:active { transform: scale(0.985); }
.pick-btns button.on {
  background: var(--accent-soft); border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pick-btns b { font-size: 16px; font-weight: 600; letter-spacing: 0.06em; }
.pick-btns span { font-size: 11.5px; line-height: 1.6; color: var(--fg-dim); }
.pick-hint {
  margin-top: 12px; min-height: 18px;
  font-size: 11.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums;
}

/* 触摸屏：选择阶段也要能点（这时 body.touch 还没加），所以按钮撑大一点 */
@media (pointer: coarse) {
  .pick-btns { flex-direction: column; }
  .pick-btns button { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 20px 18px; text-align: left; }
  .pick-btns b { flex: 0 0 68px; }
  .pick-btns span { text-align: left; }
}

/* ============ 顶栏 ============ */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(7, 9, 12, 0.80), transparent);
  pointer-events: none;
  opacity: 0; transition: opacity 0.5s ease 0.2s;
}
body.ready #topbar { opacity: 1; }
#topbar > * { pointer-events: auto; }

.brand { font-size: 13px; letter-spacing: 0.16em; font-weight: 600; }
.brand span { color: var(--fg-dim); font-weight: 400; letter-spacing: 0.06em; margin-left: 8px; }

.seg {
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; backdrop-filter: blur(14px);
}
.seg button {
  font: inherit; font-size: 12.5px; color: var(--fg-dim);
  background: transparent; border: 0; cursor: pointer;
  padding: 6px 13px; border-radius: 7px;
  transition: background 0.18s, color 0.18s;
}
.seg button:hover { color: var(--fg); background: rgba(255, 255, 255, 0.06); }
.seg button.on { color: var(--fg); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(78, 163, 255, 0.35); }
/* 空的段（模式按钮全去掉后，只剩 #mode-seg 这个纯锚点）：不占位、也不露出一个空药丸 */
.seg:empty { display: none; }

.spacer { flex: 1; }

.icon-btn {
  font: inherit; font-size: 12.5px; color: var(--fg-dim);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 12px; cursor: pointer;
  backdrop-filter: blur(14px); transition: color 0.18s, border-color 0.18s;
  flex: none; white-space: nowrap;   /* 窄屏下别把“操作说明”拆成两行 */
}
.icon-btn:hover { color: var(--fg); border-color: var(--line-strong); }

/* 「进入全屏 / 离开全屏」按钮：**只要设备支持元素全屏就一直显示**。
   原来写的是「进了全屏才出现」，结果点完「开始逛展」收起提示后，
   顶栏上既没有进入全屏的入口、也没有离开全屏的出口。
   文字随状态切换（进入全屏 ⇄ 离开全屏），逻辑见 ui/fullscreen.js 的 sync()。
   ⚠ 判断依据是**能力**（can-fullscreen），不是状态：
     iPhone Safari / 微信没有 `requestFullscreen`，按钮直接不出现，
     免得点了一直弹“不支持”。
   ⚠ F11 那种浏览器自带全屏**不会**设置 document.fullscreenElement，
     所以那时按钮写的是「进入全屏」，点它仍能把画面切成元素全屏。 */
#btn-fullscreen { display: none; }
body.can-fullscreen #btn-fullscreen { display: inline-block; }
.icon-btn.on { color: var(--accent); border-color: rgba(78, 163, 255, 0.45); }

/* ============ 准星（平常静止，锁到东西才呼吸） ============ */
#crosshair {
  position: fixed; left: 50%; top: 50%; z-index: 30;
  width: 30px; height: 30px; margin: -15px 0 0 -15px;
  opacity: 0; transition: opacity 0.5s ease 0.4s;
  pointer-events: none;
}
body.ready #crosshair { opacity: 1; }

/* 空闲态：小小一圈，完全静止，不打扰看展品 */
#crosshair .ring {
  position: absolute; inset: 9px;
  border-radius: 50%;
  border: 1.2px solid rgba(255, 255, 255, 0.50);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  transition: border-color 0.22s ease, opacity 0.22s ease;
}
#crosshair .dot {
  position: absolute; left: 50%; top: 50%;
  width: 2.5px; height: 2.5px; margin: -1.25px 0 0 -1.25px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.55);
  transition: background 0.22s ease;
}

/* 锁到展项：转蓝 + 开始呼吸，作为"可以交互"的明确信号 */
#crosshair.hot .ring {
  border-color: rgba(150, 205, 255, 0.95);
  animation: chBreathe 1.5s ease-in-out infinite;
}
#crosshair.hot .dot { background: #c6e4ff; }
@keyframes chBreathe {
  0%, 100% { transform: scale(1);    opacity: 0.55; }
  50%      { transform: scale(1.42); opacity: 1; }
}

/* 交互提示（不用先按 Esc 释放鼠标） */
#crosshair .prompt {
  position: absolute; left: 50%; top: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px; border-radius: 999px;
  background: rgba(14, 18, 24, 0.80);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 4px) scale(0.94);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#crosshair .prompt b {
  font: 600 10.5px/1 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: #0d1117; background: #d3e8ff;
  border-radius: 5px; padding: 4px 6px;
}
#crosshair .prompt em {
  font-style: normal; font-size: 12px; color: rgba(238, 242, 247, 0.94);
  max-width: 210px; overflow: hidden; text-overflow: ellipsis;
}
#crosshair.hot .prompt { opacity: 1; transform: translate(-50%, 4px) scale(1); }

/* ============ 热点标记 ============ */
/* 刻意做轻：细描边小圆点，不脉冲；标签只在靠近(near)或悬停时出现，
   避免几十个标签同时糊在屏幕上。 */
#hotspots { position: fixed; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }

.hs {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 7px;
  pointer-events: auto; cursor: pointer;
  will-change: transform, opacity;
  white-space: nowrap;
  transition: opacity 0.25s linear;
}
/* 藏起来的标记（JS 加 .off）**不许再拦触摸**：看不见却还在的命中区会吃掉
   从它上面开始的手指 —— 滑动和双指捉合都会莫名失效。
   圆环要单独写一条：触摸端它自己就是 `pointer-events:auto` 的。 */
.hs.off,
.hs.off .hs-ring { pointer-events: none; }
.hs-ring {
  width: 11px; height: 11px; flex: none; border-radius: 50%;
  background: rgba(78, 163, 255, 0.14);
  border: 1.5px solid rgba(78, 163, 255, 0.62);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.hs-label {
  font-size: 11px; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(16, 20, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(8px);
  color: rgba(238, 242, 247, 0.92);
  opacity: 0; transform: translateX(-3px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
/* 带外链的展板（名单里写了 `link`）标签后面跟一个 ↗ 角标：
   让人一眼看出"点它是跳出去"，而不是像其它板那样"拿在手上"看图。
   只是视觉暗示，不影响命中（`.hs-ext` 在 `pointer-events:none` 的标签里面）。 */
.hs-ext {
  display: inline-block; margin-left: 3px;
  font-style: normal; font-size: 9px; line-height: 1;
  color: var(--accent); opacity: 0.9;
  transform: translateY(-1px);
}
.hs:hover .hs-ring,
.hs.near .hs-ring {
  background: rgba(78, 163, 255, 0.32);
  border-color: rgba(140, 200, 255, 0.95);
}
.hs:hover .hs-ring { transform: scale(1.3); }
.hs:hover .hs-label,
.hs.near .hs-label { opacity: 1; transform: translateX(0); }

/* 就近高亮：外圈加一层细光环，比放大尺寸更不打扰 */
.hs.active .hs-ring {
  background: rgba(78, 163, 255, 0.42);
  border-color: #a8d4ff;
  box-shadow: 0 0 0 4px rgba(78, 163, 255, 0.14);
}

/* 触摸端：去掉标签的 backdrop-filter。
   24 个标签每个都是一个 backdrop-blur 层，手机 GPU 上很贵（要回读背景再模糊），
   而一转头会横着同时扫过一整排展板，正好是最卡的时候。
   改成实色一点的面板，视觉差别很小。

   顺手把标签变成**不吃事件的说明文字**：它盖在画面上，手指从它上面开始滑动时
   会被它整个吃掉（canvas 收不到 touchstart）—— 滑动转视角没反应，
   松手反而变成"点开这块展板"。
   ⚠ 但这**不等于点标签没反应**：canvas 的"短按"判定里会补一层命中测试
   （`hotspots.js` 的 `openHotspotAt`，圆环和标签都算），所以
   拖动仍然转视角、原地短按仍然能点开。详见 touch.js 的手势分区说明。 */
body.touch .hs-label {
  backdrop-filter: none;
  background: rgba(16, 20, 27, 0.86);
}

/* 触摸端：去掉常驻的 will-change。
   24 个元素 ×`will-change: transform,opacity` = 24 个常驻合成层，手机上吃显存/带宽。 */
body.touch .hs { will-change: auto; }

/* 触摸端把其余“毛玻璃”也统一关掉。
   这些面板**一直挂在屏幕上**，而 backdrop-filter 要回读背景再模糊 —— 手机上得不偿失。
   掉模糊后只是稍微透一点，远看几乎没差别。 */
body.touch #minimap,
body.touch #detail,
body.touch #hint,
body.touch #panelhud,
body.touch .seg,
body.touch .icon-btn,
body.touch .help-card { backdrop-filter: none; }

/* ============ 详情面板 ============ */
#detail {
  position: fixed; right: 18px; bottom: 18px; z-index: 45;
  width: min(360px, calc(100% - 36px));
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 18px 20px 20px;
  transform: translateY(14px); opacity: 0; pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.28s;
}
#detail.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
#detail .cat {
  display: inline-block; font-size: 10.5px; letter-spacing: 0.14em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 9px;
}
#detail h2 { font-size: 18px; font-weight: 600; margin-bottom: 9px; letter-spacing: 0.02em; }
#detail p { font-size: 12.8px; line-height: 1.85; color: var(--fg-dim); }
#detail dl {
  margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12px;
}
#detail dt { color: var(--fg-dim); }
#detail dd { color: var(--fg); font-variant-numeric: tabular-nums; text-align: right; }
#detail .close {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 7px;
  background: transparent; border: 1px solid var(--line);
  color: var(--fg-dim); cursor: pointer; font-size: 15px; line-height: 1;
  transition: color 0.18s, border-color 0.18s;
}
#detail .close:hover { color: var(--fg); border-color: var(--line-strong); }

/* ============ 展板查看：底部细条（照片本体是 3D 场景里的面片） ============ */
#panelhud {
  position: fixed; left: 50%; bottom: 22px; z-index: 55;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  font-size: 12.5px; color: var(--fg);
  white-space: nowrap;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
}
/* ⚠ 整条胶囊**只有 × 是可点的**，其余部分（含提示文字）一律让触摸穿透到 canvas。
   原来写的是 `.show { pointer-events: auto }`，整条胶囊都在吃触摸 ——
   双指捉合时只要有一根手指落在胶囊上，canvas 就只收到一根，
   削合根本不成立（真机 + CDP 真实触摸实测：落在胶囊上 100% → 100% 毫无反应）。 */
#panelhud.show { transform: translate(-50%, 0); opacity: 1; pointer-events: none; }
/* 只在“已显示”时才让 × 可点，否则隐形的按钮还能被点到 */
#panelhud.show #pv-close { pointer-events: auto; }
#pv-title { font-weight: 600; letter-spacing: 0.02em; }
.pv-sep { width: 1px; height: 14px; background: var(--line-strong); }
#pv-zoom { color: var(--fg-dim); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.pv-tip { color: var(--fg-dim); }
.pv-tip b {
  display: inline-block; min-width: 14px; padding: 0 4px; margin: 0 1px;
  color: var(--fg); border: 1px solid var(--line-strong); border-radius: 4px;
}
#pv-close {
  width: 26px; height: 26px; border-radius: 50%;
  background: transparent; border: 1px solid var(--line);
  color: var(--fg-dim); cursor: pointer; font-size: 15px; line-height: 1;
  transition: color 0.18s, border-color 0.18s;
}
#pv-close:hover { color: var(--fg); border-color: var(--line-strong); }

/* 看展板时所有标记都隐形了（见 ui/hotspots.js），隐形的它们还会阻止手势。
   这条是安全网：JS 那边也会同步把 pointerEvents 置 none。 */
body.panel-open .hs { pointer-events: none; }

/* 拿着展板时把准星隐掉，免得分心 */
body.panel-open #crosshair { opacity: 0; }

/* ============ 3D 物件“拿在手里”的遮罩（z 50） ============ */
/* 盖住所有操作 UI —— 顶栏 / 小地图 / HUD / 摇杆提示都是 z ≤ 45 —— 只留 #panelhud（z 55）。
   中间留一圈透明，正好是“拿在手里”的模型，所以它是遮罩而不是蒙版。
   ⚠ 这层同时是**拖动旋转的接入口**：触摸输入挂在 canvas 上，盖住之后
     走路/转头就不会和拖动打架（见 ui/panelview.js 的 bindModelDrag）。 */
#modelmask {
  position: fixed; inset: 0; z-index: 50; display: none;
  touch-action: none;                 /* 拖动不要被浏览器当成滚动 / 下拉刷新 */
  background: radial-gradient(circle at 50% 46%, rgba(0, 0, 0, 0) 20%, rgba(4, 8, 12, 0.55) 62%);
}
body.model-open #modelmask { display: block; }

/* 淡出除查看器胶囊以外的所有界面元素：顶栏 / 小地图 / HUD / 提示。
   遮罩层已经让它们点不到了，这一条是让它们也“看不见”—— 拿着模型时就是一个干净的观察状态。 */
body.model-open #topbar,
body.model-open #minimap,
body.model-open #stats,
body.model-open #hint,
body.model-open #crosshair {
  opacity: 0 !important; pointer-events: none !important;
  transition: opacity 0.2s;
}

/* 3D 模式下换一条提示（拖动旋转 / 捏合缩放） */
.pv-tip-model { display: none; }
body.model-open .pv-tip-model { display: inline; }
body.model-open .pv-tip-desktop,
body.model-open .pv-tip-touch { display: none; }

/* ============ 小地图（右上角，跟随视角旋转） ============ */
#minimap {
  position: fixed; right: 18px; top: 62px; z-index: 40;
  width: 160px; height: 160px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); backdrop-filter: blur(14px);
  overflow: hidden;
  opacity: 0; transition: opacity 0.4s ease 0.3s;
}
body.ready #minimap { opacity: 1; }
#minimap.hide { opacity: 0 !important; }
#minimap canvas { display: block; width: 100%; height: 100%; }

/* ============ 帮助 ============ */
#help {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 7, 10, 0.72); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s;
}
#help.show { opacity: 1; visibility: visible; }
.help-card {
  width: min(560px, 90%); max-height: 84%; overflow: auto;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 28px 30px;
}
.help-card h2 { font-size: 17px; margin-bottom: 6px; letter-spacing: 0.08em; }
.help-card .lead { font-size: 12.5px; color: var(--fg-dim); margin-bottom: 22px; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 22px; }
.key-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--fg-dim);
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.key-row b {
  flex: none; min-width: 62px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11px; font-weight: 600; color: var(--fg);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 7px; text-align: center;
}
.help-foot { margin-top: 22px; font-size: 11.5px; color: var(--fg-dim); line-height: 1.9; }

/* ============ 外链弹窗（视频 / PDF 站内看，不跳转） ============ */
/* 只服务"站内塞不下"的东西：mp4 和 pdf。图片展板仍然走 3D 手持面片（见 ui/panelview.js
   开头那段"为什么不做成全屏 overlay"），这里不要去接管它。
   z 62 > #help(60)：两个弹窗都开着时它在上层。 */
#media {
  position: fixed; inset: 0; z-index: 62;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 7, 10, 0.78); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s;
}
#media.show { opacity: 1; visibility: visible; }
.media-card {
  width: min(1080px, 94%); max-height: 90%;
  display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.media-bar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line);
}
#media-title {
  flex: 1; min-width: 0; font-size: 13px; letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#media-open {
  flex: none; font-size: 11.5px; color: var(--fg-dim); text-decoration: none;
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px;
  transition: color 0.18s, border-color 0.18s;
}
#media-open:hover { color: var(--fg); border-color: var(--line-strong); }
#media-close {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  background: transparent; border: 1px solid var(--line);
  color: var(--fg-dim); cursor: pointer; font-size: 15px; line-height: 1;
  transition: color 0.18s, border-color 0.18s;
}
#media-close:hover { color: var(--fg); border-color: var(--line-strong); }
.media-body { flex: 1; min-height: 0; background: #05070a; }
.media-body video { display: block; width: 100%; max-height: 78vh; background: #000; }
.media-body iframe { display: block; width: 100%; height: 78vh; border: 0; background: #fff; }
body.touch .media-card { backdrop-filter: none; }
body.landscape.short .media-body video,
body.landscape.short .media-body iframe { height: 62vh; max-height: 62vh; }

/* ============ 中央提示 ============ */
#hint {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  z-index: 35; padding: 9px 18px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; backdrop-filter: blur(14px);
  font-size: 12.5px; letter-spacing: 0.05em; color: var(--fg);
  opacity: 0; transition: opacity 0.35s; pointer-events: none;
  white-space: nowrap;
}
#hint.show { opacity: 1; }

/* ============ 状态角标（调试用，左下角让位给小地图） ============ */
#stats {
  position: fixed; left: 18px; bottom: 18px; z-index: 40;
  font-family: ui-monospace, Consolas, monospace; font-size: 11px;
  color: var(--fg-dim); text-align: left; line-height: 1.75;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; backdrop-filter: blur(14px);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#stats.show { opacity: 1; }

/* 手机端收敛 */
@media (max-width: 820px) {
  #minimap { width: 112px; height: 112px; right: 12px; top: 56px; }
  #detail { right: 12px; bottom: 12px; left: 12px; width: auto; }
  .brand span { display: none; }
  #stats { display: none; }
}

/* ============ 手机端虚拟摇杆 ============ */
/*
  它**只是画出来的**：pointer-events:none，手指其实按在下面的 canvas 上。
   好处是"按在摇杆上"和"按在画面上"是同一套代码，手指滑出摇杆也不会断掉。
   JS 会给它设 left/top 跟到手指按下的位置；松手时清掉内联样式，它就回到这里定义的家。
*/
#joystick {
  position: fixed; left: 92px; top: calc(100% - 108px);
  width: 0; height: 0; z-index: 28;
  pointer-events: none;
  opacity: 0; transition: opacity 0.18s ease;
}
body.touch #joystick { opacity: 0.34; }          /* 静止时留一点影子，让人知道这儿能按 */
body.touch #joystick.active { opacity: 0.95; }
body.touch.mode-orbit #joystick { opacity: 0; }  /* 环视模式用不上 */

#joy-ring {
  position: absolute; left: 0; top: 0;
  width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.30);
  background: rgba(16, 20, 27, 0.30);
  backdrop-filter: blur(6px);
}
#joy-knob {
  position: absolute; left: 0; top: 0;
  width: 46px; height: 46px; margin: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(238, 242, 247, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* "点哪走哪"的落点提示：一圈收拢的光环 */
#tap-ripple {
  position: fixed; z-index: 27; pointer-events: none;
  width: 0; height: 0;
}
#tap-ripple i {
  position: absolute; left: 0; top: 0;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 2px solid rgba(140, 200, 255, 0.9);
  opacity: 0;
}
#tap-ripple.show i { animation: tap-ripple 0.62s ease-out; }
@keyframes tap-ripple {
  0%   { transform: scale(0.35); opacity: 0.95; }
  100% { transform: scale(1.5);  opacity: 0; }
}

/* ============ 横屏守卫（手机端按横屏设计） ============ */
#rotate {
  position: fixed; inset: 0; z-index: 90;   /* 低于加载页(100)，所以加载时不会挡着进度 */
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: #07090c; text-align: center; padding: 24px;
}
/* 显示条件：**画布已经自己转过 90° 了，现在等用户转手机**。
   不用 @media (orientation) —— 那正是微信里不靠谱的东西。
   ⚠ “已收起”（rot-dismissed，点「开始逛展」后加）**必须写进同一个选择器里**，
     不能另写一条 `body.rot-dismissed #rotate { display:none }`：
     那条的特异性是 (1,1,1)，会被这里的 (1,2,1) 压掉，结果点了开始逛展毫无反应
     （实测过：合成事件直接打在 canvas 上不经过命中测试，所以当时没暴露）。 */
body.touch.fake-landscape:not(.rot-dismissed) #rotate { display: flex; }
.rot-phone {
  position: relative; width: 54px; height: 88px; margin-bottom: 22px;
  border: 2px solid var(--fg-dim); border-radius: 10px;
  animation: rot-tip 2.6s ease-in-out infinite;
}
.rot-phone::after {
  content: ''; position: absolute; left: 50%; bottom: 7px;
  width: 18px; height: 2px; margin-left: -9px;
  background: var(--fg-dim); border-radius: 2px;
}
/* ⚠ 这个动画的**转动方向就是用户要转的方向**（逆时针），
   必须和 `body.fake-landscape #app` 的自转方向对应：
   画布转 +90° ⇒ 用户转 −90°（逆时针）。改一个必须改另一个。 */
@keyframes rot-tip {
  0%, 42%   { transform: rotate(0deg); }
  58%, 100% { transform: rotate(-90deg); }
}
.rot-title { font-size: 19px; font-weight: 600; letter-spacing: 0.12em; }
.rot-sub { margin-top: 8px; font-size: 12.5px; color: var(--fg-dim); line-height: 1.9; max-width: 320px; }
.rot-btns { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; justify-content: center; }
.rot-btns button {
  font: inherit; font-size: 12.5px; padding: 9px 16px; border-radius: 9px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--fg-dim);
}
.rot-btns #rot-start {
  color: var(--fg); background: var(--accent-soft); border-color: rgba(78, 163, 255, 0.35);
}

/* ============ 手机横屏且屏幕很矮：所有浮层都要收紧 ============ */
/* 用 JS 写的 body class 而不是 @media (orientation) —— 自转模式下
   `orientation` 报的还是竖屏，靠它分不清“真正看到的朝向”；
   而手机横屏宽度常 ≥ 640，也不会触发上面的 max-width:820，所以单独一套。 */
body.landscape.short #minimap { width: 92px; height: 92px; right: 10px; top: 48px; }
body.landscape.short #topbar { gap: 10px; padding: 8px 12px; }
body.landscape.short .brand { font-size: 12px; letter-spacing: 0.10em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.landscape.short .seg button { padding: 5px 10px; font-size: 12px; }
body.landscape.short .icon-btn { padding: 6px 10px; font-size: 12px; }
body.landscape.short #joystick { left: 74px; top: calc(100% - 76px); }
body.landscape.short #joy-ring { width: 76px; height: 76px; margin: -38px 0 0 -38px; }
body.landscape.short #joy-knob { width: 38px; height: 38px; }
body.landscape.short #hint { bottom: 56px; padding: 7px 14px; font-size: 11.5px; white-space: normal; max-width: 78%; border-radius: 14px; }
body.landscape.short #panelhud { bottom: 10px; padding: 6px 12px; gap: 8px; }
body.landscape.short #detail { max-height: 64%; overflow: auto; padding: 14px 16px 15px; }
body.landscape.short #detail h2 { font-size: 16px; }
body.landscape.short #detail p { font-size: 12px; line-height: 1.7; }
body.landscape.short .help-card { max-height: 90%; padding: 20px 22px; }

/* ============ 操控方式相关的显隐 ============ */
body:not(.touch) #keys-touch,
body.touch #keys-desktop,
body:not(.touch) #foot-touch,
body.touch #foot-desktop,
body:not(.touch) .lead-touch,
body.touch .lead-desktop,
body:not(.touch) .pv-tip-touch,
body.touch .pv-tip-desktop { display: none; }

/* ============ 应用容器（手机自转横屏时就转它） ============ */
/*
  ⚠ 自转后 **`vw/vh` 仍然是真实视口**（`transform` 不改变单位解析）：
     `#app` 里的 `100vh` = 有效**宽**、`100vw` = 有效**高** —— 是反的！
     所以 `#app` 内部**一律不要用 vw/vh**，改用百分比（相对 #app 自身，天然正确）。
     只有 `#app` 自己的尺寸需要真实单位，那是故意的。
*/
#app { position: relative; width: 100%; height: 100%; }

/*
  自转 90°：微信 / 部分手机浏览器根本不会报横屏（`screen.orientation.lock` 不支持、
  `orientationchange` 不触发、viewport 一直是竖的），唯一的办法就是自己转。

  为什么是 `rotate(90deg)`：
  这样**内容的正上方在屏幕的右边缘**，用户**逆时针**转手机（顶部朝左）后内容就正立了。
  ⚠ 方向必须和上面提示动画 `.rot-phone` 一致（那个是 `0 → -90deg`，即逆时针）——
     两个方向打架的话，用户照着动画转，看到的是**倒过来的**展厅。
     （原来的 `rotate(-90deg)` 就是反的，真机上是倒的；改一个必须改另一个。）
  变换推导：局部 (x,y) --translateY(-100%)--> (x, y−H) --rotate(90°)--> (H−y, x)，
  正好铺满视口（H = 元素高 = 100vw = 真实宽）。
  逆变换见 `lib/viewport.js` 的 `toLocal()`。
*/
body.fake-landscape #app {
  position: fixed; top: 0; left: 0;
  width: 100vh;    /* 有效宽 = 真实高 */
  height: 100vw;   /* 有效高 = 真实宽 */
  transform-origin: top left;
  transform: rotate(90deg) translateY(-100%);
}

/* ============ 应用容器结束 ============ */

/* 触摸端**不要准星**：手机是"点哪个标记就开哪个"，屏幕中心那个圈
   既指不了什么事（没有 E 键、没有指针锁定），又正好压在画面正中挡视线。
   连带把 `.hs.active`（对准锁定）和提示文案一起废掉，见 ui/hotspots.js。 */
body.touch #crosshair { display: none; }

/* 触摸端顶部本来就窄，品牌副标题（尺寸/版本那行）先省掉 */
body.touch .brand span { display: none; }

/* 触摸端让品牌名**可压缩**：不写 min-width:0 的话 flex 子项默认按内容宽度撑，
   窄屏（尤其"保持竖屏"后的竖屏）会把顶栏挤到换行，按钮文字被拆成两行。 */
body.touch .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 主动选竖屏是兜底路径，横向空间本来就紧 —— 品牌名挤成"新…"也没意义，干脆让位给控件 */
body.touch.portrait .brand { display: none; }

/* ---- 触摸端竖屏：顶栏一行放不下，允许折行（而不是把按钮挤出屏幕） ----
   实测 390 宽下「漫游/环视 + 展区 + 进入全屏 + 操作说明」需要 386px，
   没折行前更是 463px —— 最后那个按钮直接落在 x=387..462，跑到屏幕外面去了。
   （`.seg` / `.icon-btn` 都是 `flex:none`，永远不会自己缩，所以只能换行 + 收紧一档。）
   换行是**整条栏折成两行**，不是按钮里的字折行 —— `.icon-btn` 有 nowrap。
   宽度够（≥386px）就还是一行，不折腾。

   ⚠ 折到第二行的那几个按钮**靠左对齐**（不要 `margin-left:auto`）：
     小地图固定在右上角（right:12 / top:56，112×112）且和顶栏同为 z-index:40，
     又排在 DOM 后面 —— 按钮一旦贴右就会落在它下面，点击直接被吃掉。
     靠左则整排结束在 x≈148，离小地图（x≥266）还很远，也就不需要按宽度猜折行阈值了。 */
body.touch.portrait #topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
body.touch.portrait .seg button { padding: 5px 9px; font-size: 11.5px; }
body.touch.portrait .icon-btn { padding: 6px 9px; font-size: 11.5px; }
/* 段选按钮不要跟着换行 */
.seg { flex: none; }
.seg button { white-space: nowrap; }

/* 触摸端把热点标记的可点区域放大到 45px 左右 —— 11px 的小圆点手指根本点不中。
   用伪元素扩大命中范围，视觉尺寸不变。

   ⚠ 并且**只让圆环可点**（容器和标签都让路）：
     `.hs` 是 `pointer-events:auto` 的整块（圆环 + 文字标签），手指从标签上
     开始滑动时会被整块吃掉 —— canvas 收不到 touchstart，于是"滑动转视角没反应"
     （松手还可能变成点开展板）。网格扫描实测：走展模式下有 20/800 个采样点
     被这块截住，手机上就是"有时候滑不动"。
     点选统一交给圆环，它的命中区已经被上面的 ::after 扩到 45px 见方，够点。
     桌面端不动：鼠标不存在"从哪儿开始滑"的问题，标签可点更宽容。 */
body.touch .hs { pointer-events: none; }
body.touch .hs-ring { position: relative; pointer-events: auto; }
body.touch .hs-ring::after {
  content: ''; position: absolute; inset: -17px; border-radius: 50%;
}

