* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #2f3b43;            /* 墨 */
  --ink-dim: #5d6b70;
  --paper: #f2ecdd;          /* 宣纸 */
  --paper-edge: #e4dac2;
  --cinnabar: #a63a2e;       /* 朱砂 */
  --cinnabar-deep: #8a2c22;
  --gold: #b08d57;           /* 描金 */
  --mist-top: #dde4de;       /* 雾气 */
  --mist-bot: #aab8b2;
  --serif: "KaiTi", "STKaiti", "楷体", "TW-Kai", serif;
}

/* 祥云纹（卷云弧带），描金线条 */
:root {
  --cloud-band: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='22' viewBox='0 0 64 22'%3E%3Cg fill='none' stroke='%23b08d57' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M4 20 h56'/%3E%3Cpath d='M12 20 a8 8 0 0 1 16 0'/%3E%3Cpath d='M16 20 a4 4 0 0 0 8 0'/%3E%3Cpath d='M36 20 a6 6 0 0 1 12 0'/%3E%3Cpath d='M39.5 20 a2.5 2.5 0 0 0 5 0'/%3E%3C/g%3E%3C/svg%3E");
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(120% 90% at 50% 30%, var(--mist-top) 0%, var(--mist-bot) 100%);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
}

/* ---------- 舞台：锁定 9:16，所有 UI 都在视频画面内 ---------- */

#stage {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 100vh;
  width: min(100vw, calc(100vh * 9 / 16));
  overflow: hidden;
  box-shadow: 0 0 60px rgba(47, 59, 67, .35);
}

#char-wrap {
  position: absolute;
  inset: 0;
}

#avatar-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 70% at 50% 42%, transparent 62%, rgba(58, 72, 76, .22) 100%),
    linear-gradient(to top, rgba(58, 72, 76, .18), transparent 18%);
}

/* ---------- 通用纸面浮层 ---------- */

#status-pill, #tool-rail > button, #control-bar {
  background: linear-gradient(180deg, rgba(246, 241, 229, .94), rgba(238, 231, 212, .94));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(176, 141, 87, .55);
  box-shadow: 0 4px 18px rgba(47, 59, 67, .22), inset 0 0 0 1px rgba(255, 255, 255, .35);
  color: var(--ink);
}

button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }

/* ---------- 左上：状态 ---------- */

#left-rail {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
}

#status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--ink-dim);
  animation: rise-in .6s cubic-bezier(.2, .9, .3, 1.2) both;
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cinnabar);
  box-shadow: 0 0 8px rgba(166, 58, 46, .7);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.8); }
}

/* ---------- 历史对话框：移除 ---------- */

#chat-panel { display: none; }

/* ---------- 右上工具栏 ---------- */

#tool-rail {
  position: absolute;
  top: 14px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 10;
  animation: rise-in .6s .08s cubic-bezier(.2, .9, .3, 1.2) both;
}

.rail-btn, .rail-pill {
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 2px;
  font-family: var(--serif);
  color: var(--ink-dim);
  transition: transform .18s, box-shadow .18s, color .18s;
}

#tool-rail > button:hover {
  transform: translateY(-2px);
  color: var(--cinnabar);
  box-shadow: 0 8px 22px rgba(47, 59, 67, .3);
}

/* ---------- 动作开关弹层（3D 模式遗留，隐藏按钮时不出现） ---------- */

#anim-pop {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(246, 241, 229, .94);
  border: 1px solid rgba(176, 141, 87, .55);
  box-shadow: 0 8px 32px rgba(47, 59, 67, .25);
  color: var(--ink-dim);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

#anim-pop.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.anim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  white-space: nowrap;
}

.switch { position: relative; display: inline-block; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch i {
  position: relative;
  display: block;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(47, 59, 67, .15);
  border: 1px solid rgba(176, 141, 87, .4);
  transition: background .2s;
  cursor: pointer;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fffdf6;
  transition: transform .2s, background .2s;
}

.switch input:checked + i { background: rgba(166, 58, 46, .55); }

.switch input:checked + i::after {
  transform: translateX(16px);
  background: var(--cinnabar);
}

/* ---------- 回答框（唯一文本框，卷轴 + 祥云边） ---------- */

#subtitle {
  position: absolute;
  left: 50%;
  bottom: 13%;
  transform: translateX(-50%);
  width: 86%;
  padding: 16px 26px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(246, 241, 229, .95), rgba(236, 228, 205, .95));
  border: 1px solid rgba(176, 141, 87, .6);
  box-shadow:
    0 10px 34px rgba(47, 59, 67, .3),
    inset 0 0 24px rgba(176, 141, 87, .12);
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.65;
  letter-spacing: 1px;
  text-align: center;
  color: var(--ink);
  min-height: 1.65em;
  pointer-events: none;
  z-index: 5;
}

/* 上下各一条描金祥云带 */
#subtitle::before,
#subtitle::after {
  content: "";
  display: block;
  height: 16px;
  margin: 0 -18px;
  background: var(--cloud-band) repeat-x center / auto 100%;
  opacity: .85;
}

#subtitle::before { margin-bottom: 10px; }
#subtitle::after { margin-top: 10px; }

#subtitle:empty { opacity: 0; }

/* ---------- 底部控制条 ---------- */

#control-bar {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 999px;
  z-index: 10;
  animation: bar-in .7s .15s cubic-bezier(.2, .9, .3, 1.1) both;
}

#mic-btn {
  position: relative;
  padding: 14px 34px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--cinnabar), var(--cinnabar-deep));
  color: #f6f1e5;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--serif);
  letter-spacing: 3px;
  white-space: nowrap;
  transition: transform .12s, box-shadow .2s;
  touch-action: none;
  box-shadow: 0 4px 18px rgba(166, 58, 46, .35);
}

#mic-btn:hover { box-shadow: 0 6px 24px rgba(166, 58, 46, .5); }
#mic-btn:active { transform: scale(.96); }

#mic-btn.recording {
  background: linear-gradient(135deg, #31424c, #22323b);
  transform: scale(.97);
  box-shadow: 0 4px 18px rgba(47, 59, 67, .45);
}

#mic-btn.recording::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid rgba(166, 58, 46, .7);
  animation: pulse-ring 1.2s ease-out infinite;
}

@keyframes pulse-ring {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.25); opacity: 0; }
}

/* ---------- 进场动画 ---------- */

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bar-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 窄屏适配（stage 已锁定 9:16，这里只收字号） ---------- */

@media (max-width: 480px) {
  #subtitle { font-size: 17px; padding: 12px 18px; }
  #mic-btn { padding: 12px 22px; font-size: 14px; letter-spacing: 2px; }
}
