/* ==========================================================================
   3D 书桌 — 版式（HUD、索引、面板、卡片）
   与 2D 版共用的只有 scarf.css（开场围巾）与 js/content.js（文案）
   ========================================================================== */

:root {
  --paper: #f7f0e2;
  --paper-2: #efe4cf;
  --paper-3: #e6d8bf;
  --ink: #2b2118;
  --ink-soft: rgba(43, 33, 24, 0.66);
  --ink-faint: rgba(43, 33, 24, 0.4);
  --rule: rgba(70, 50, 32, 0.16);
  --seal: #9c3627;
  --ice: #4a7a92;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC",
    "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
    "Hiragino Sans GB", sans-serif;
  --num: "Bodoni MT", "Didot", "Times New Roman", serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  position: fixed;
  inset: 0;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#stage.is-dragging {
  cursor: grabbing;
}

#stage.is-pointing {
  cursor: pointer;
}

/* 纸张颗粒 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: radial-gradient(
      rgba(120, 92, 60, 0.14) 0.5px,
      rgba(255, 255, 255, 0) 0.6px
    ),
    radial-gradient(rgba(90, 64, 40, 0.1) 0.5px, rgba(255, 255, 255, 0) 0.6px);
  background-size: 3px 3px, 5px 5px;
  background-position: 0 0, 1px 2px;
}

/* 四角压暗 */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
      58% 44% at 52% 64%,
      rgba(255, 176, 108, 0.07),
      rgba(255, 176, 108, 0) 72%
    ),
    radial-gradient(
      120% 100% at 50% 42%,
      rgba(38, 26, 16, 0) 40%,
      rgba(38, 26, 16, 0.2) 76%,
      rgba(24, 15, 9, 0.46) 100%
    );
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  transition: opacity 0.9s ease;
}

body.is-veiled #hud {
  opacity: 0;
  pointer-events: none;
}

body.is-veiled #hud * {
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

.hud__title {
  position: absolute;
  top: clamp(20px, 4vh, 46px);
  left: clamp(20px, 3.4vw, 56px);
  max-width: 34ch;
}

.hud__eyebrow {
  margin: 0 0 10px;
  font-family: var(--num);
  font-size: 10px;
  letter-spacing: 0.42em;
  color: var(--ink-faint);
}

.hud__name {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 3.6vw, 46px);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: 0.06em;
}

.hud__name em {
  display: block;
  font-style: normal;
  font-size: 0.62em;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.hud__sub {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.hud__actions {
  position: absolute;
  top: clamp(20px, 4vh, 46px);
  right: clamp(20px, 3.4vw, 56px);
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.hud__actions a,
.hud__actions button {
  padding: 0;
  color: var(--ink-soft);
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.3s ease;
}

.hud__actions a:hover,
.hud__actions button:hover {
  color: var(--seal);
}

.hud__actions .is-on {
  color: var(--seal);
}

/* 索引 */
#index {
  position: absolute;
  top: 50%;
  right: clamp(12px, 2.2vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateY(-50%);
}

#index button {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 5px 0;
  color: var(--ink-faint);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.3s ease;
}

#index .ix__dot {
  display: block;
  width: 6px;
  height: 6px;
  border: 1px solid currentColor;
  border-radius: 50%;
  transition: background 0.3s ease, transform 0.3s ease;
}

#index .ix__label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.4s var(--ease), opacity 0.3s ease;
}

#index button:hover,
#index button:focus-visible {
  color: var(--ink);
}

#index button:hover .ix__label,
#index button:focus-visible .ix__label {
  max-width: 8em;
  opacity: 1;
}

#index button.is-active {
  color: var(--seal);
}

#index button.is-active .ix__dot {
  background: currentColor;
  transform: scale(1.25);
}

/* 底部提示 */
.hud__hint {
  position: absolute;
  bottom: clamp(18px, 3.4vh, 38px);
  left: 50%;
  margin: 0;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 0.5s ease;
}

.hud__hint.is-hidden {
  opacity: 0;
}

/* 回到桌面 */
.hud__back {
  position: absolute;
  bottom: clamp(18px, 3.4vh, 38px);
  left: clamp(20px, 3.4vw, 56px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.16em;
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s var(--ease), color 0.3s ease;
  pointer-events: none;
}

.hud__back.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.hud__back:hover {
  color: var(--seal);
}

/* 通知条 */
#toast {
  position: absolute;
  bottom: clamp(56px, 9vh, 92px);
  left: 50%;
  max-width: min(88vw, 46ch);
  padding: 12px 24px;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: 0.08em;
  color: #2b2118;
  text-align: center;
  background: rgba(247, 240, 226, 0.95);
  border: 1px solid rgba(64, 44, 26, 0.16);
  border-radius: 2px;
  box-shadow: 0 14px 40px rgba(40, 26, 14, 0.18);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.45s ease, transform 0.45s var(--ease);
  pointer-events: none;
}

#toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 面板（右侧抽出的纸） ---------- */
#panel {
  position: fixed;
  z-index: 5;
  top: clamp(84px, 12vh, 118px);
  right: clamp(16px, 3vw, 54px);
  bottom: clamp(84px, 12vh, 118px);
  display: flex;
  flex-direction: column;
  width: min(430px, 40vw);
  color: var(--ink);
  background: linear-gradient(
    180deg,
    rgba(251, 246, 236, 0.97),
    rgba(243, 234, 217, 0.97)
  );
  border: 1px solid rgba(70, 50, 32, 0.14);
  box-shadow: 0 26px 70px rgba(40, 26, 14, 0.24),
    0 2px 0 rgba(255, 255, 255, 0.7) inset;
  opacity: 0;
  transform: translateX(28px);
  transition: opacity 0.5s ease, transform 0.5s var(--ease);
  pointer-events: none;
}

#panel.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

#panel[hidden] {
  display: none;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 26px 0;
}

.panel__no {
  font-family: var(--num);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
}

.panel__close {
  padding: 6px;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
}

.panel__close:hover {
  color: var(--seal);
  transform: rotate(90deg);
}

.panel__body {
  flex: 1;
  padding: 10px 26px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.panel__body::-webkit-scrollbar {
  width: 6px;
}

.panel__body::-webkit-scrollbar-thumb {
  background: rgba(70, 50, 32, 0.2);
  border-radius: 3px;
}

.panel__title {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: clamp(19px, 1.9vw, 24px);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.04em;
  white-space: pre-line;
}

.panel__intro {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 2;
  color: var(--ink-soft);
}

.panel__foot {
  margin: 20px 0 0;
  padding-top: 14px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.14em;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(70, 50, 32, 0.26);
  border-radius: 1px;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease,
    transform 0.3s var(--ease);
}

.btn:hover {
  color: var(--seal);
  border-color: rgba(156, 54, 39, 0.42);
  background: rgba(255, 255, 255, 0.8);
}

.btn:active {
  transform: translateY(1px);
}

.btn--solid {
  color: #fdf8ee;
  background: var(--seal);
  border-color: var(--seal);
}

.btn--solid:hover {
  color: #fff;
  background: #b03e2c;
  border-color: #b03e2c;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- 聊天 ---------- */
.chat {
  padding: 8px 0 4px;
}

.chat__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
}

.chat__row {
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s var(--ease);
}

.chat__row.is-in {
  opacity: 1;
  transform: none;
}

.chat__row--who {
  flex-direction: row-reverse;
}

.chat__ava {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  font-family: var(--serif);
  font-size: 11px;
  line-height: 24px;
  color: var(--ink-soft);
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--rule);
  border-radius: 50%;
}

.chat__bubble {
  max-width: 74%;
  padding: 9px 13px;
  font-size: 12.5px;
  line-height: 1.75;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(70, 50, 32, 0.12);
  border-radius: 12px 12px 12px 3px;
}

.chat__row--who .chat__bubble {
  color: #fdf8ee;
  background: #7d9aa7;
  border-color: transparent;
  border-radius: 12px 12px 3px 12px;
}

.chat__chip {
  align-self: center;
  padding: 3px 10px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 10px;
}

.chat__row--system {
  justify-content: center;
}

.chat__system {
  padding: 4px 10px;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--ink-faint);
  text-align: center;
}

.chat__typing {
  display: inline-flex;
  gap: 4px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(70, 50, 32, 0.1);
  border-radius: 12px 12px 3px 12px;
}

.chat__typing i {
  width: 4px;
  height: 4px;
  background: var(--ink-faint);
  border-radius: 50%;
  animation: typing 1.1s ease-in-out infinite;
}

.chat__typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.chat__typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ---------- 星图 ---------- */
.star-detail {
  margin-top: 16px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--ice);
}

.star-detail__label {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.1em;
}

.star-detail__text {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 2;
  color: var(--ink-soft);
  white-space: pre-line;
}

.star-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.star-list button {
  padding: 6px 12px;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(70, 50, 32, 0.16);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.star-list button:hover,
.star-list button.is-on {
  color: #fdf8ee;
  background: var(--ice);
  border-color: var(--ice);
}

/* ---------- 雾窗 ---------- */
.fog__meter {
  position: relative;
  height: 2px;
  margin: 18px 0 6px;
  overflow: hidden;
  background: rgba(70, 50, 32, 0.14);
}

.fog__meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--ice);
  transition: width 0.3s linear;
}

.fog__hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.fog__reveal {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease);
}

.fog__reveal.is-on {
  opacity: 1;
  transform: none;
}

.fog__reveal h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.12em;
}

.fog__reveal p {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 2.1;
  color: var(--ink-soft);
  white-space: pre-line;
}

/* ---------- 唱片 ---------- */
.vinyl__hint {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--seal);
}

/* ---------- 唱片 · 正在播放 ---------- */
.player {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 16px;
  align-items: center;
  margin: 18px 0 0;
  padding: 12px;
  border: 1px solid rgba(120, 96, 64, 0.2);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(255, 252, 244, 0.72), rgba(240, 230, 210, 0.42));
}

.player__cover {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(120, 96, 64, 0.32);
  background: #2a2320;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 14px rgba(60, 40, 20, 0.16);
}

.player__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player__cover::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #f6efdf;
  box-shadow: 0 0 0 2px rgba(43, 33, 24, 0.5);
}

.player.is-playing .player__cover img {
  animation: playerSpin 18s linear infinite;
}

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

.player__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.player__by {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.player__bar {
  position: relative;
  height: 2px;
  margin: 11px 0 0;
  background: rgba(120, 96, 64, 0.2);
  cursor: pointer;
}

.player__bar i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--seal);
  transition: width 0.25s linear;
}

.player__time {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 460px) {
  .player {
    grid-template-columns: 66px 1fr;
    gap: 12px;
  }
  .player__cover {
    width: 66px;
    height: 66px;
  }
}

.lyrics {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.lyrics li {
  padding: 6px 0;
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.9;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s var(--ease), color 0.6s ease;
}

.lyrics li.is-in {
  opacity: 1;
  transform: none;
}

.lyrics li.is-on {
  color: var(--ink);
}

.vinyl__note {
  margin: 18px 0 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

/* ---------- 草稿 ---------- */
.draft {
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--rule);
}

.draft__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 16px;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  background: none;
  border: 0;
  cursor: pointer;
}

.draft__date {
  font-family: var(--num);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

.draft__tag {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--seal);
}

.draft__text {
  max-height: 0;
  padding: 0 16px;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 2;
  color: var(--ink-soft);
  transition: max-height 0.55s var(--ease), padding 0.55s var(--ease);
}

.draft.is-open .draft__text {
  max-height: 260px;
  padding: 0 16px 16px;
}

.composer {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.composer__label {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 64px;
  max-height: 140px;
  padding: 12px 14px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.9;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(70, 50, 32, 0.2);
  border-radius: 1px;
  outline: none;
  resize: none;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.composer textarea:focus {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(156, 54, 39, 0.4);
}

.composer__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.composer__note {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--seal);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.composer__note.is-on {
  opacity: 1;
}

/* ---------- 十七件小事 ---------- */
.number__meta {
  margin: 0 0 14px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.number__now {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 4px 0 0;
}

.number__idx {
  font-family: var(--num);
  font-size: 34px;
  line-height: 1;
  color: var(--ice);
}

.number__text {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 2;
  letter-spacing: 0.04em;
  transition: opacity 0.18s ease;
}

.number__text.is-fading {
  opacity: 0;
}

.number__nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.number__nav button {
  width: 34px;
  height: 34px;
  color: var(--ink-soft);
  font: inherit;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.number__nav button:hover {
  color: var(--seal);
  border-color: rgba(156, 54, 39, 0.4);
}

.number__count {
  font-family: var(--num);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

/* ---------- 信 ---------- */
.letter-open {
  margin-top: 16px;
}

.seal-press {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin: 8px 0 18px;
  color: #fdf8ee;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-align: center;
  background: var(--seal);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(120, 30, 20, 0.28);
  transition: transform 0.4s var(--ease), box-shadow 0.4s ease;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.seal-press::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(156, 54, 39, 0.4);
  border-radius: 50%;
  clip-path: inset(0 0 calc(100% - var(--p, 0%)) 0);
  transition: clip-path 0.1s linear;
}

.seal-press:active {
  transform: scale(0.97);
}

.seal-press.is-done {
  box-shadow: 0 0 0 8px rgba(156, 54, 39, 0.12);
}

/* 全屏信纸 */
#letterLayer {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vh, 40px);
  background: rgba(30, 20, 12, 0.5);
  opacity: 0;
  transition: opacity 0.7s ease;
  pointer-events: none;
}

#letterLayer.is-on {
  opacity: 1;
  pointer-events: auto;
}

.letterSheet {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  padding: clamp(28px, 5vh, 52px) clamp(24px, 4vw, 52px);
  overflow-y: auto;
  color: #3a2c1f;
  background: linear-gradient(180deg, #fdf8ec, #f4e9d3);
  border: 1px solid rgba(70, 50, 32, 0.16);
  box-shadow: 0 30px 80px rgba(20, 12, 6, 0.4);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.7s var(--ease);
  scrollbar-width: thin;
}

#letterLayer.is-on .letterSheet {
  transform: none;
}

.letterSheet__to {
  margin: 0;
  font-family: var(--num);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: rgba(58, 44, 31, 0.5);
}

.letterSheet h3 {
  margin: 18px 0 22px;
  font-family: var(--serif);
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 400;
  letter-spacing: 0.1em;
}

.letterSheet p {
  margin: 0 0 1.05em;
  font-family: var(--serif);
  font-size: clamp(13px, 1.5vw, 15px);
  line-height: 2.15;
  letter-spacing: 0.03em;
  text-indent: 1.5em;
}

.letterSheet__sign {
  margin: 26px 0 0;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-align: right;
  text-indent: 0;
}

.letterSheet__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid rgba(70, 50, 32, 0.16);
}

.letterSheet__stamp {
  display: inline-grid;
  place-items: center;
  width: 62px;
  height: 62px;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.1em;
  color: var(--seal);
  text-align: center;
  border: 2px solid rgba(156, 54, 39, 0.6);
  border-radius: 50%;
  transform: rotate(-8deg);
}

/* ---------- 加载 ---------- */
#boot {
  position: fixed;
  inset: 0;
  /* 盖在围巾（z-index:100）之上：先看进度，贴图解码完再掀开，避免开场露白 */
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: rgba(120, 92, 52, 0.62);
  --ink-faint: rgba(120, 92, 52, 0.62);
  --ink-soft: rgba(120, 92, 52, 0.7);
  background: radial-gradient(120% 90% at 50% 30%, #efe4cd 0%, #e3d6bd 52%, #d3c2a4 100%);
  transition: opacity 0.8s ease;
}

#boot .boot__text {
  margin: 0;
  font-size: 13px;
  text-indent: 0.3em;
}

#boot .boot__bar {
  position: relative;
  display: block;
  width: 168px;
  height: 2px;
  overflow: hidden;
  background: rgba(120, 92, 52, 0.22);
}

#boot .boot__bar b {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(170, 92, 70, 0.5), #a8563c);
  box-shadow: 0 0 10px rgba(168, 86, 60, 0.45);
  transition: width 0.45s cubic-bezier(0.22, 0.9, 0.3, 1);
}

#boot .boot__pct {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.24em;
  color: rgba(120, 92, 52, 0.5);
  font-variant-numeric: tabular-nums;
}

#boot.is-gone {
  opacity: 0;
  pointer-events: none;
}

/* ---------- 深色房间里的 HUD：改用浅墨 ---------- */
#hud,
#toast,
#boot {
  --ink: #f4e9d8;
  --ink-soft: rgba(244, 233, 216, 0.72);
  --ink-faint: rgba(244, 233, 216, 0.46);
  --rule: rgba(255, 240, 220, 0.16);
}

#hud {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42), 0 1px 20px rgba(0, 0, 0, 0.55);
}

/* HUD 的上下暗角：浅墨字在暗墙上本来就看得很清，但镜头切到亮桌面时
   会糊进木纹里。这里在上下边缘压一层很淡的暗渐变——暗处几乎看不出
   区别，亮处把字托起来，于是同一行字在任何镜头下都成立。 */
#hud::before,
#hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

#hud::before {
  top: 0;
  height: clamp(170px, 24vh, 250px);
  background: linear-gradient(
    180deg,
    rgba(20, 14, 9, 0.68) 0%,
    rgba(20, 14, 9, 0.44) 38%,
    rgba(20, 14, 9, 0.14) 70%,
    rgba(20, 14, 9, 0) 100%
  );
}

#hud::after {
  bottom: 0;
  height: clamp(90px, 14vh, 140px);
  background: linear-gradient(
    0deg,
    rgba(22, 16, 11, 0.5) 0%,
    rgba(22, 16, 11, 0) 100%
  );
}

#hud .hud__title,
#hud .hud__name {
  color: #f6ecdb;
}

.hud__actions a,
.hud__actions button,
#index button {
  border-color: rgba(246, 236, 219, 0.22);
}

/* 动作行只有 11px 小字，比标题更容易被木纹吃掉，单独把墨提亮一档 */
.hud__actions {
  color: rgba(250, 243, 230, 0.92);
}

#index button:hover,
#index button:focus-visible,
.hud__actions a:hover,
.hud__actions button:hover,
.hud__back:hover {
  color: #f0b9a3;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  .hud__eyebrow {
    display: none;
  }

  .hud__actions {
    top: clamp(16px, 3vh, 24px);
    right: clamp(14px, 4vw, 22px);
    gap: 12px;
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  .hud__title {
    max-width: 60vw;
  }

  .hud__name {
    font-size: 26px;
  }

  #index {
    top: auto;
    right: auto;
    bottom: clamp(48px, 8vh, 76px);
    left: 50%;
    flex-direction: row;
    gap: 10px;
    transform: translateX(-50%);
  }

  #index .ix__label {
    display: none;
  }

  #panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: min(78vh, 640px);
    transform: translateY(30px);
    border-right: 0;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 54px rgba(28, 18, 10, 0.32);
  }

  #panel.is-on {
    transform: none;
  }

  #panel .panel__head {
    padding: 16px 22px 0;
  }

  /* 内容多的页（雾窗 / 草稿 / 十七件）在面板内滚动，内容少的页只占实际高度，
     不再把 3D 桌面整个盖住 */
  #panel .panel__body {
    flex: 0 1 auto;
    min-height: 0;
    padding: 8px 22px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* 未擦开时那块隐藏文字不该占高度，否则手机上会撑出一大片空白 */
  .fog__reveal {
    display: none;
  }

  .fog__reveal.is-on {
    display: block;
  }

  .hud__hint {
    bottom: clamp(20px, 4vh, 30px);
    font-size: 11px;
    letter-spacing: 0.12em;
  }

  .hud__back {
    bottom: clamp(18px, 3.4vh, 26px);
    top: auto;
    left: clamp(14px, 4vw, 22px);
    transform: none;
    font-size: 11px;
  }

  .hud__back.is-on {
    transform: none;
  }

  .hud__hint {
    left: auto;
    right: clamp(14px, 4vw, 22px);
    transform: none;
    text-align: right;
  }

  #toast {
    bottom: auto;
    top: 74px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #panel,
  #toast,
  .letterSheet {
    transition-duration: 0.2s;
  }
  .chat__typing i {
    animation: none;
  }
}


/* ---------- 围巾开场：两翼分开时直接透出房间（画布） ---------- */
.veil,
.veil__shade {
  background: transparent;
}
