/* ============================================================
   松管全景 · 视觉系统
   ------------------------------------------------------------
   Ink        #07090C   夜色底
   Ink-2      #0E1216   面板
   Mint       #8CE3C7   主强调（青瓷绿）
   Brass      #E8C98A   次强调（暖铜）
   Text       #E9EDEF / #9BA6AD / #67727A
   ============================================================ */

:root {
  --ink: #07090c;
  --ink-2: #0d1114;
  --ink-3: #141a1f;
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.05);
  --text: #e9edef;
  --text-2: #9aa6ae;
  --text-3: #66727a;
  --mint: #8ce3c7;
  --mint-deep: #3fae8f;
  --brass: #e8c98a;
  --danger: #ff8f7a;
  --glass: rgba(13, 17, 20, 0.66);
  --glass-strong: rgba(10, 13, 16, 0.86);
  --blur: 22px;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 24px 60px -24px rgba(0,0,0,.85);
  --ease: cubic-bezier(.22,.61,.36,1);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100dvh;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(140, 227, 199, .28); color: #fff; }

:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
  border-radius: 6px;
}

/* 极细噪点，让深色不至于死平板 */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ───────────────────────── 舞台 ───────────────────────── */

#stage {
  position: fixed; inset: 0;
  /* 全景与面板分成两个独立合成层：Chromium 在上层面板做 bitmap 合成时
     可能把面板像素写进 WebGL 画布，形成左边缘的灰蓝色楔形残留。 */
  transform: translateZ(0);
  will-change: transform;
  contain: strict;
}

#pano-host {
  /* 不设不透明背景：Pannellum 容器本身已有 #05070a，
     这里再画一层会在画布未覆盖处露出硬边矩形（灰蓝色楔形残影）。 */
  position: absolute; inset: 0;
  /* 让全景画布成为独立合成层：否则 Chromium 会把覆盖在上面的面板
     与 WebGL 画面交叉合成，切换场景后左边缘残留一块灰蓝色块。 */
  transform: translateZ(0);
  will-change: transform;
  isolation: isolate;
}

/* 解析失败时的兜底提示层 */
#viewer-fail {
  position: absolute; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #131b22, #05070a 70%);
}
#viewer-fail.show { display: flex; }
.fail-card {
  max-width: 460px; width: 100%; padding: 28px 26px;
  background: var(--glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.fail-card h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.fail-card p { color: var(--text-2); font-size: 14px; line-height: 1.75; }
.fail-card code {
  font-family: var(--mono); font-size: 12.5px; color: var(--mint);
  background: rgba(140, 227, 199, .09); padding: 2px 7px; border-radius: 6px;
}

/* 首次进入的引导 */
#hint {
  position: absolute; left: 50%; bottom: calc(132px + var(--safe-b)); z-index: 74;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 14px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
  color: var(--text-2); font-size: 13px; white-space: nowrap; z-index: 55;
  transition: opacity .6s var(--ease), transform .6s var(--ease);
  pointer-events: none;
}
#hint svg { width: 18px; height: 18px; flex: none; color: var(--mint); }
#hint.hide { opacity: 0; transform: translateX(-50%) translateY(8px); }

/* ───────────────────────── 顶部栏 ───────────────────────── */

#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 70;
  display: flex; align-items: center; gap: 14px;
  padding: calc(14px + var(--safe-t)) calc(18px + var(--safe-r)) 14px calc(18px + var(--safe-l));
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5,7,10,.72), rgba(5,7,10,.28) 55%, transparent);
  transition: opacity .5s var(--ease);
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(140,227,199,.22), rgba(232,201,138,.14));
  border: 1px solid rgba(140, 227, 199, .28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.brand-mark svg { width: 21px; height: 21px; color: var(--mint); }
.brand-text { min-width: 0; }
.brand-text h1 {
  font-family: var(--serif); font-weight: 600; font-size: 17px;
  letter-spacing: .12em; line-height: 1.25; white-space: nowrap;
}
.brand-text p {
  font-size: 10.5px; letter-spacing: .26em; color: var(--text-3);
  text-transform: uppercase; white-space: nowrap;
}

#topbar .spacer { flex: 1; }

.top-actions { display: flex; align-items: center; gap: 8px; }

/* 场景标题（顶栏下方，随场景切换淡出淡入） */
/* 标题块放在 #stage 之外的独立图层里：
   与 WebGL 画布不在同一合成上下文，避免 Chromium 把标题块
   「烧」进全景画面（切换场景后左边缘的灰蓝楔形）。 */
#cap-layer {
  position: absolute; inset: 0; z-index: 200; pointer-events: none;
  contain: layout style paint;
}
#scene-cap {
  position: absolute; z-index: 65; pointer-events: none;
  left: calc(22px + var(--safe-l)); top: calc(86px + var(--safe-t));
  padding: 10px 20px 12px 16px;
  /* 无背景 / 无边框 / 无阴影：任何「外框」样式的标题块都会在 Chromium 里
     与下方 WebGL 画布交叉合成，切换场景后左边缘留下灰蓝色楔形。
     改用左侧细线与文字投影来保证可读性与高级感。 */
  border-left: none;
  background: none;
  contain: paint;
}
#scene-cap.swap { opacity: .35; }
#scene-cap::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(140,227,199,.75) 22%, rgba(140,227,199,.35) 78%, transparent);
}
#scene-cap .idx {
  font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--mint);
  opacity: .85;
}
#scene-cap .name {
  font-family: var(--serif); font-size: clamp(24px, 3.2vw, 38px); font-weight: 600;
  letter-spacing: .04em; line-height: 1.15;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .55), 0 1px 2px rgba(0,0,0,.4);
}
#scene-cap .desc {
  margin-top: 6px; max-width: 30ch;
  font-size: 12.5px; color: rgba(233, 237, 239, .68);
  text-shadow: 0 1px 12px rgba(0,0,0,.6);
}

/* ───────────────────────── 通用按钮 ───────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px; border-radius: 999px;
  background: var(--glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line);
  color: var(--text); font-size: 13px; letter-spacing: .01em;
  box-shadow: var(--shadow-1);
  transition: background .2s, border-color .2s, transform .2s var(--ease), color .2s;
  white-space: nowrap;
}
.chip svg { width: 17px; height: 17px; opacity: .85; }
.chip:hover { background: rgba(28, 36, 42, .82); border-color: rgba(255,255,255,.16); }
.chip:active { transform: scale(.975); }
.chip.round { width: 38px; padding: 0; justify-content: center; }
.chip.icon-only { width: 38px; padding: 0; justify-content: center; }
.chip.on { color: #04120d; background: var(--mint); border-color: var(--mint); box-shadow: 0 6px 22px -8px rgba(140,227,199,.7); }
.chip.on svg { opacity: 1; }
.chip .badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: rgba(140, 227, 199, .16); color: var(--mint);
  font-family: var(--mono); font-size: 10.5px; line-height: 1;
}
.chip.on .badge { background: rgba(4,18,13,.2); color: #04120d; }
.chip.ghost { background: rgba(255,255,255,.04); box-shadow: none; }
.chip.ghost:hover { background: rgba(255,255,255,.08); }

.chip .label { display: inline; }
@media (max-width: 720px) {
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand-text h1 { font-size: 15px; letter-spacing: .1em; }
  .brand-text p { font-size: 9px; letter-spacing: .2em; }
  #topbar { gap: 8px; padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 10px calc(14px + var(--safe-l)); }
  .chip .label { display: none; }
  .chip { padding: 0 10px; height: 40px; }
  .chip.round, .chip.icon-only { width: 40px; height: 40px; }
  #btn-wall .badge { display: none; }
  .top-actions { gap: 6px; }
  #topbar .spacer { min-width: 6px; }
  #scene-cap { top: calc(78px + var(--safe-t)); padding: 8px 12px 9px 11px; }
  #scene-cap .name { font-size: 22px; }
  #scene-cap .desc { display: none; }
}

/* ───────────────────────── 右侧工具列 ───────────────────────── */

#tools {
  position: absolute; z-index: 70;
  right: calc(16px + var(--safe-r)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px;
  transition: opacity .5s var(--ease);
}
.tool {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--glass); backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--line); box-shadow: var(--shadow-1);
  color: var(--text); transition: background .2s, transform .2s var(--ease), color .2s, border-color .2s;
}
.tool svg { width: 19px; height: 19px; }
.tool:hover { background: rgba(28, 36, 42, .85); }
.tool:active { transform: scale(.94); }
.tool.on { color: #04120d; background: var(--mint); border-color: var(--mint); }
.tool.zoom { font-family: var(--mono); font-size: 15px; }
#tools .divider { height: 1px; background: var(--line); margin: 2px 6px; }

/* 触屏设备把工具列横排放下方，避免遮挡 */
@media (max-width: 720px) {
  #tools {
    top: auto; bottom: calc(96px + var(--safe-b)); transform: none;
    right: calc(10px + var(--safe-r)); gap: 8px;
  }
  .tool { width: 40px; height: 40px; border-radius: 13px; }
}

/* ───────────────────────── 底部场景导航 ───────────────────────── */

#dock {
  position: absolute; z-index: 70; left: 0; right: 0; bottom: 0;
  padding: 26px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
  background: linear-gradient(to top, rgba(5,7,10,.86), rgba(5,7,10,.4) 46%, transparent);
  transition: opacity .5s var(--ease);
}
.dock-inner { display: flex; align-items: flex-end; gap: 12px; }

.scene-nav {
  display: flex; gap: 9px; overflow-x: auto; overflow-y: hidden;
  padding: 6px 2px 2px; margin: -6px -2px -2px;
  scroll-snap-type: x both; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1; min-width: 0;
  mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 18px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 10px, #000 calc(100% - 18px), transparent);
}
.scene-nav::-webkit-scrollbar { display: none; }

.scene-btn {
  position: relative; flex: none; scroll-snap-align: center;
  width: 152px; height: 78px; border-radius: 13px; overflow: hidden;
  border: 1px solid var(--line);
  background: #0b1013;
  transition: transform .32s var(--ease), border-color .25s, box-shadow .32s var(--ease);
  text-align: left;
}
.scene-btn img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .62;
  transform: scale(1.06); filter: saturate(.9);
  transition: opacity .3s, transform .5s var(--ease), filter .3s;
}
.scene-btn::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(4,6,9,.92) 4%, rgba(4,6,9,.28) 56%, rgba(4,6,9,.05));
}
.scene-btn .txt {
  position: absolute; left: 10px; right: 10px; bottom: 8px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
}
.scene-btn .no {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  color: var(--brass); opacity: .9;
}
.scene-btn .nm {
  font-size: 12.5px; letter-spacing: .02em; color: #f2f6f7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0,0,0,.7);
}
.scene-btn:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.2); }
.scene-btn:hover img { opacity: .82; transform: scale(1.02); }
.scene-btn.active {
  border-color: rgba(140, 227, 199, .75);
  box-shadow: 0 10px 30px -14px rgba(140,227,199,.55), inset 0 0 0 1px rgba(140,227,199,.18);
}
.scene-btn.active img { opacity: 1; transform: scale(1); filter: none; }
.scene-btn .loading {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.28); border-top-color: var(--mint);
  animation: spin .7s linear infinite; display: none;
}
.scene-btn.busy .loading { display: block; }
.scene-btn.busy { border-color: rgba(140, 227, 199, .5); }

.nav-fade { position: absolute; top: 0; bottom: 0; width: 46px; z-index: 2; pointer-events: none; }
.nav-fade.l { left: 0; background: linear-gradient(to right, rgba(5,7,10,.9), transparent); }
.nav-fade.r { right: 0; background: linear-gradient(to left, rgba(5,7,10,.9), transparent); }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--glass-strong); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); color: var(--text);
  transition: background .2s, opacity .25s, transform .2s var(--ease);
}
.nav-arrow:hover { background: rgba(32, 42, 48, .95); }
.nav-arrow:active { transform: translateY(-50%) scale(.93); }
.nav-arrow.prev { left: -6px; }
.nav-arrow.next { right: -6px; }
.nav-arrow svg { width: 16px; height: 16px; }

.dock-side {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  padding-bottom: 2px;
}
.dock-count {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .16em;
  color: rgba(233,237,239,.5);
}
.dock-count b { color: var(--mint); font-weight: 500; }
.dock-autoplay {
  display: inline-flex; align-items: center; gap: 7px; height: 34px;
  padding: 0 12px; border-radius: 999px; font-size: 12px;
  background: var(--glass); border: 1px solid var(--line); color: var(--text-2);
  transition: color .2s, background .2s, border-color .2s;
}
.dock-autoplay svg { width: 14px; height: 14px; }
.dock-autoplay:hover { color: var(--text); background: rgba(28,36,42,.85); }
.dock-autoplay.on { color: var(--mint); border-color: rgba(140,227,199,.4); background: rgba(140,227,199,.1); }

@media (max-width: 720px) {
  #dock { padding-top: 18px; }
  .scene-btn { width: 118px; height: 64px; }
  .scene-btn .nm { font-size: 11.5px; }
  .dock-side { display: none; }
  .nav-arrow { display: none; }
  /* 手机上顶栏已有入口，悬浮按钮收起来，避免遮挡画面（见文件末尾规则） */
  #hint { bottom: calc(226px + var(--safe-b)); font-size: 12px; padding: 8px 15px 8px 12px; }
  #hint span { white-space: nowrap; }
}

/* ───────────────────────── 沉浸模式 ───────────────────────── */

body.immersive #topbar,
body.immersive #dock,
body.immersive #tools,
body.immersive #scene-cap,
body.immersive #hint,
body.immersive #wall-fab { opacity: 0; pointer-events: none; }

body.immersive #immersive-exit { opacity: 1; pointer-events: auto; }

#immersive-exit {
  position: absolute; z-index: 76;
  right: calc(16px + var(--safe-r)); bottom: calc(24px + var(--safe-b));
  opacity: 0; pointer-events: none; transition: opacity .4s var(--ease);
}

/* 鼠标静止 3.2s 后自动淡出（桌面） */
body.idle-ui:not(.immersive) #topbar,
body.idle-ui:not(.immersive) #dock,
body.idle-ui:not(.immersive) #tools,
body.idle-ui:not(.immersive) #scene-cap { opacity: .0001; pointer-events: none; }
body.idle-ui #topbar, body.idle-ui #dock, body.idle-ui #tools { }

/* ───────────────────────── 加载 / 过场 ───────────────────────── */

#veil {
  position: absolute; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: #05070a;
  transition: opacity .7s var(--ease);
}
#veil.done { opacity: 0; pointer-events: none; }
#veil .blurbg {
  position: absolute; inset: -6%;
  background-size: cover; background-position: center;
  filter: blur(26px) saturate(1.05) brightness(.42);
  transform: scale(1.04);
  opacity: .85;
}
#veil .scrim {
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 30%, rgba(7,9,12,.2), rgba(5,7,10,.92) 78%);
}
.veil-inner {
  position: relative; text-align: center; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.veil-ring { width: 54px; height: 54px; position: relative; }
.veil-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.veil-ring .track { stroke: rgba(255,255,255,.12); }
.veil-ring .prog {
  stroke: var(--mint); stroke-linecap: round;
  transition: stroke-dashoffset .45s var(--ease);
  filter: drop-shadow(0 0 6px rgba(140,227,199,.6));
}
.veil-inner h2 {
  font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: .14em;
}
.veil-inner .sub {
  font-size: 12px; color: var(--text-3); letter-spacing: .18em;
  font-family: var(--mono);
}

#scene-veil {
  position: absolute; inset: 0; z-index: 85; pointer-events: none;
  /* 用上一场景的模糊缩略图垫底 + 深色蒙版：切换瞬间不会看到硬切，
     同时把「瓦片还在上传、画面尚未干净」的那段时间整段遮住。
     这层必须是不透明合成层，不能带 backdrop-filter。 */
  background: rgba(5, 7, 10, .82);
  opacity: 0; transition: opacity .26s ease;
  display: grid; place-items: center;
  background-size: cover; background-position: center;
}
#scene-veil::after {
  content: ""; position: absolute; inset: 0;
  backdrop-filter: none;
  background: radial-gradient(120% 90% at 50% 45%, rgba(5,7,10,.25), rgba(5,7,10,.92));
}
#scene-veil.on { opacity: 1; }
#scene-veil .mini {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2); border-top-color: var(--mint);
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────────────────── 键盘帮助 ───────────────────────── */

#keys {
  position: absolute; z-index: 80; inset: 0;
  display: none; place-items: center; padding: 20px;
  background: rgba(4, 6, 9, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#keys.show { display: grid; }
.keys-card {
  width: min(520px, 100%); border-radius: var(--r-lg);
  background: var(--glass-strong); border: 1px solid var(--line);
  box-shadow: var(--shadow-2); padding: 22px 24px;
}
.keys-card h3 { font-family: var(--serif); font-size: 17px; margin-bottom: 14px; letter-spacing: .06em; }
.keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 22px; }
.keys-grid div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text);
  min-width: 24px; padding: 3px 7px; text-align: center;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-bottom-width: 2px; border-radius: 6px;
}

/* ───────────────────────── 留言墙入口 ───────────────────────── */

#wall-fab {
  position: absolute; z-index: 72;
  left: calc(18px + var(--safe-l)); bottom: calc(108px + var(--safe-b));
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 18px 0 14px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(140,227,199,.16), rgba(232,201,138,.12)), var(--glass-strong);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(140, 227, 199, .32);
  box-shadow: 0 12px 40px -16px rgba(140,227,199,.45), var(--shadow-1);
  color: var(--text); font-size: 13.5px; letter-spacing: .04em;
  transition: transform .3s var(--ease), box-shadow .3s, border-color .2s, background .2s, opacity .4s;
}
#wall-fab:hover { transform: translateY(-2px); border-color: rgba(140,227,199,.55); box-shadow: 0 18px 48px -18px rgba(140,227,199,.6); }
#wall-fab:active { transform: scale(.97); }
#wall-fab svg { width: 18px; height: 18px; color: var(--mint); }
#wall-fab .n {
  font-family: var(--mono); font-size: 11px; color: var(--mint);
  background: rgba(140,227,199,.13); border-radius: 999px; padding: 2px 7px;
}
@media (max-width: 720px) {
  #wall-fab { bottom: calc(176px + var(--safe-b)); height: 42px; font-size: 12.5px; padding: 0 14px 0 12px; }
}

/* ───────────────────────── 留言星河 ───────────────────────── */

#wall {
  position: fixed; inset: 0; z-index: 300;   /* 必须高于 #cap-layer(200) */
  display: none;
}
#wall.open { display: block; }
#wall .backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(130% 100% at 50% -18%, #131f2c 0%, #0a1020 46%, #05070c 100%);
  opacity: 0; transition: opacity .5s var(--ease);
}
#wall.open .backdrop { opacity: 1; }

/* 星空画布 */
#wall-stars {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
  opacity: 0; transition: opacity .8s var(--ease) .1s;
}
#wall.open #wall-stars { opacity: 1; }

/* 顶部标题 */
.wall-top {
  position: absolute; top: max(18px, var(--safe-t)); left: max(22px, var(--safe-l)); right: max(22px, var(--safe-r));
  display: flex; align-items: flex-start; gap: 14px;
  pointer-events: none; z-index: 5;
  opacity: 0; transform: translateY(-8px);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
#wall.open .wall-top { opacity: 1; transform: none; transition-delay: .12s; }
.wall-title { min-width: 0; }
.wall-eyebrow {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .3em;
  color: var(--mint); opacity: .85; text-transform: uppercase;
}
.wall-title h2 {
  font-family: var(--serif); font-size: clamp(26px, 3vw, 34px); font-weight: 600;
  letter-spacing: .12em; margin-top: 5px;
  text-shadow: 0 0 34px rgba(140, 227, 199, .28);
}
.wall-title p { color: var(--text-3); font-size: 13px; margin-top: 7px; letter-spacing: .05em; }
.wall-meta { margin-left: auto; display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.star-count {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  color: var(--text-3); padding: 7px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .09);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}
.star-count b { color: var(--text); font-weight: 600; }
.wall-close { flex: none; }

/* ── 下落的留言卡片 ── */
#wall-fall {
  position: absolute; inset: 0; overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 7%, #000 93%, transparent 100%);
}
.fall-note {
  position: absolute; top: 0; left: var(--x);
  width: var(--w);
  transform: translateY(-280px);
  opacity: 0;
  animation: fall-y var(--fall) cubic-bezier(.34, .3, .58, 1) forwards;
  animation-delay: var(--delay);
  will-change: transform, opacity;
}
@keyframes fall-y {
  0%   { transform: translateY(-280px); opacity: 0; }
  5%   { opacity: var(--op); }
  92%  { opacity: var(--op); }
  100% { transform: translateY(calc(100vh + 280px)); opacity: 0; }
}
.fall-note .swing {
  animation: fall-sway var(--swaydur) ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes fall-sway {
  from { transform: translateX(calc(var(--sway) * -1)) rotate(var(--rot)); }
  to   { transform: translateX(var(--sway)) rotate(calc(var(--rot) * -1)); }
}

/* 卡片本体：玻璃质感星卡 */
.note {
  border-radius: 16px; padding: 14px 16px 13px;
  background: linear-gradient(165deg, rgba(22, 32, 46, .74), rgba(10, 14, 22, .66));
  border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 18px 44px -20px rgba(0, 0, 0, .85);
}
.note .top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 12px; font-weight: 600;
  color: #071410;
  background: linear-gradient(140deg, #a8efd7, #7ec9e8);
}
.avatar.a1 { background: linear-gradient(140deg, #a8efd7, #7ec9e8); }
.avatar.a2 { background: linear-gradient(140deg, #f0d9a8, #e8b98a); }
.avatar.a3 { background: linear-gradient(140deg, #cfc2f0, #a8b8ef); }
.avatar.a4 { background: linear-gradient(140deg, #f0b9c4, #e89aae); }
.avatar.a5 { background: linear-gradient(140deg, #bde8a8, #8fd07e); }
.note .who { font-size: 12.5px; color: var(--text); letter-spacing: .02em; font-weight: 500; }
.note .when { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-3); letter-spacing: .04em; white-space: nowrap; }
.note .body {
  font-size: 13.5px; line-height: 1.72; color: rgba(233, 237, 239, .9);
  word-break: break-word; white-space: pre-wrap;
}
.note .pin {
  display: inline-flex; align-items: center; gap: 4px;
  margin-bottom: 7px; font-size: 10px; letter-spacing: .16em;
  color: var(--brass); font-family: var(--mono);
}
.note .pin svg { width: 11px; height: 11px; }

/* 刚发布的留言：一颗高亮流星 */
.fall-note.fresh .note {
  border-color: rgba(140, 227, 199, .55);
  box-shadow:
    0 0 0 1px rgba(140, 227, 199, .16) inset,
    0 0 46px -6px rgba(140, 227, 199, .42),
    0 18px 44px -20px rgba(0, 0, 0, .85);
}
.fall-note.fresh .note .who { color: #c9f7e3; }

/* 输入台状态点 */
.wall-status { font-size: 11.5px; color: var(--text-3); line-height: 1.7; }
.wall-status .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mint); margin-right: 6px; vertical-align: 1px;
  box-shadow: 0 0 8px rgba(140, 227, 199, .8);
}
.wall-status.offline .dot { background: var(--brass); box-shadow: 0 0 8px rgba(232, 201, 138, .7); }

/* ── 底部悬浮输入台 ── */
.compose {
  position: absolute; left: 50%; bottom: max(20px, var(--safe-b));
  transform: translateX(-50%) translateY(18px);
  width: min(720px, calc(100vw - 32px));
  z-index: 6;
  opacity: 0;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
#wall.open .compose { opacity: 1; transform: translateX(-50%); transition-delay: .16s; }
.composer-box {
  display: grid; gap: 10px;
  padding: 12px; border-radius: 22px;
  background: rgba(10, 14, 20, .82);
  border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(18px) saturate(1.1); -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .03) inset;
}
.compose input, .compose textarea {
  width: 100%; color: var(--text); font: inherit; font-size: 14px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 13px;
  transition: border-color .2s, background .2s;
}
.compose input { height: 40px; padding: 0 15px; }
.compose textarea {
  min-height: 46px; max-height: 130px; padding: 12px 15px;
  line-height: 1.6; resize: none;
}
.compose input::placeholder, .compose textarea::placeholder { color: var(--text-3); }
.compose input:focus, .compose textarea:focus {
  outline: none; border-color: rgba(140, 227, 199, .5);
  background: rgba(140, 227, 199, .06);
}

.btn-primary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 13px;
  background: linear-gradient(135deg, #9ff0d6, #6fd3b4);
  color: #04120d; font-size: 13.5px; font-weight: 600; letter-spacing: .06em;
  box-shadow: 0 10px 30px -12px rgba(140, 227, 199, .75), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .2s var(--ease), box-shadow .25s, filter .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 36px -14px rgba(140, 227, 199, .9); }
.btn-primary:active { transform: scale(.98); }
.btn-primary[disabled] { filter: grayscale(.5) brightness(.7); cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary svg { width: 16px; height: 16px; }

.composer-foot { display: flex; align-items: center; gap: 10px; margin-top: 9px; padding: 0 4px; }
.counter {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
  letter-spacing: .06em;
}
.counter.warn { color: var(--brass); }
.counter.full { color: var(--danger); }
.composer-foot .grow { flex: 1; }

/* 静态降级（减弱动效偏好）：星河退化为网格 */
#static-notes {
  position: absolute; inset: 0; overflow-y: auto;
  padding: 128px 28px calc(210px + var(--safe-b));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px; align-content: start;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent;
}
#static-notes::-webkit-scrollbar { width: 6px; }
#static-notes::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 99px; }
.static-empty {
  grid-column: 1 / -1; text-align: center; color: var(--text-3);
  font-size: 14px; padding: 60px 0;
}

/* 手机端：星河紧凑排布 */
@media (max-width: 720px) {
  .wall-title h2 { font-size: 22px; }
  .wall-title p { display: none; }
  .star-count { font-size: 10px; padding: 6px 10px; }
  .compose { bottom: calc(12px + var(--safe-b)); }
  .composer-box { padding: 10px; gap: 8px; }
  .compose input { height: 38px; font-size: 13.5px; }
  .compose textarea { min-height: 44px; font-size: 15px; } /* 16px 上下可避免 iOS 聚焦缩放 */
  .btn-primary { height: 42px; }
  #static-notes { padding: 96px 16px calc(200px + var(--safe-b)); grid-template-columns: 1fr; }
}
@media (max-width: 720px) and (min-width: 520px) {
  #static-notes { grid-template-columns: 1fr 1fr; }
}

/* toast */
#toasts {
  position: fixed; z-index: 999; left: 50%; bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 17px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--line);
  backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-2);
  font-size: 13px; color: var(--text);
  animation: toast-in .45s var(--ease) both;
}
.toast.out { animation: toast-out .35s var(--ease) both; }
.toast svg { width: 16px; height: 16px; color: var(--mint); flex: none; }
.toast.err svg { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Pannellum 覆盖层微调 */
.pnlm-container { font-family: var(--sans) !important; }
.pnlm-load-box { display: none !important; }
.pnlm-container .pnlm-about-msg { display: none !important; }

/* 热点（看点）——不要覆盖 Pannellum 的 position/transform，否则定位会错 */
.spot-dot {
  width: 26px; height: 26px; cursor: pointer;
}
.spot-dot::before, .spot-dot::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
}
.spot-dot::before {
  inset: 2px;
  border: 1.5px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 1px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.5);
  transition: transform .25s var(--ease), border-color .25s;
}
.spot-dot::after {
  inset: 9px; background: var(--mint);
  box-shadow: 0 0 10px rgba(140,227,199,.9);
  animation: spot-breathe 3s ease-in-out infinite;
}
.spot-dot:hover::before { transform: scale(1.18); border-color: var(--mint); }
.spot-dot .tip {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 6px 11px; border-radius: 8px; white-space: nowrap;
  background: rgba(8, 11, 14, .92); border: 1px solid rgba(255,255,255,.14);
  font-size: 12px; color: var(--text); letter-spacing: .04em;
  opacity: 0; transition: opacity .2s, transform .25s var(--ease);
  pointer-events: none;
}
.spot-dot:hover .tip { opacity: 1; transform: translateX(-50%) translateY(-2px); }
@keyframes spot-breathe { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.22); opacity: .65; } }

@media (max-width: 720px) {
  .spot-dot { width: 30px; height: 30px; }
  .spot-dot::after { inset: 10px; }
  .spot-dot .tip { display: none; }
}

/* 减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* 横屏手机压缩 UI */
@media (max-height: 460px) and (orientation: landscape) {
  #scene-cap .desc { display: none; }
  #scene-cap .name { font-size: 20px; }
  .scene-btn { width: 104px; height: 54px; }
  #dock { padding-top: 14px; }
  #wall-fab { bottom: calc(84px + var(--safe-b)); }
}

/* Pannellum 自带的浅色棋盘格背景改深色，避免加载瞬间发白 */
.pnlm-container { background: #05070a !important; background-image: none !important; }

/* 手机端隐藏悬浮入口（放在最后，确保覆盖基础样式） */
@media (max-width: 720px) {
  #wall-fab { display: none !important; }
}
