/* 此间 · T24.4 交流面板（固定头 / 唯一滚动区 / 固定尾；无全屏遮罩，场景照常可点）
   —— 替代旧的单句对话框：面板承载「本段转录 + 接话选项 + 自由输入」，收起即退出。
   字号取整数倍缩放防糊（Herein Pixel 12px 网格）为既有规则：V0.7.56 起本表内正文/按钮/输入一律
   12 或 24px（2×），不再用 14/15/16px——非整数倍会被插值，真页上明显发虚。
   输入框必须 ≥16px，否则 iOS 聚焦时整页自动放大；24px 同时满足这一条与整数倍。 */
#npc-dialog, #npc-dialog button, #npc-dialog input {
  font-family: "Herein Pixel", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#npc-dialog {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom) + var(--kb, 0px));
  transform: translate(-50%, 160%);
  width: min(94vw, 560px);
  max-height: min(calc(100vh - 44px), 520px);                /* 旧浏览器回退 */
  max-height: min(calc(100dvh - var(--kb, 0px) - 44px), 520px); /* 上限而非固定高：内容短时面板自己缩；
                                                                  24px 正文 + 三条选项必须留得下转录区（400 只剩 36px） */
                                                               /* 键盘弹出时用「键盘上方剩余空间」，不再 dvh 硬减导致塌成 0 */
  display: flex;
  flex-direction: column;
  background: #3f2d1b;
  border: 2px solid #b99e86;
  border-radius: 12px;
  padding: 10px 14px 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(240, 224, 192, .08);
  transition: transform .35s ease;
  z-index: 95;
  text-align: left;
  pointer-events: auto;
  touch-action: manipulation;
}
#npc-dialog.show { transform: translate(-50%, 0); }

/* 固定头：参与人 + 收起 */
#npc-dialog .chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(185, 158, 134, .35);
  padding-bottom: 6px;
}
#npc-dialog .who {
  font-size: 24px;
  color: #e0b870;
  letter-spacing: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#npc-dialog .who::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  background: #e0b870;
  margin-right: 8px;
  box-shadow: 2px 2px 0 #b99e86; /* 像素风斜角点缀 */
}
#npc-dialog .chat-close {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 12px;
  background: #2b1f12;
  border: 1px solid #b99e86;
  border-radius: 8px;
  color: #d0be9c;
  font-size: 24px;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#npc-dialog .chat-close:active { transform: translateY(1px); opacity: .85; }

/* 唯一滚动区：本段转录 */
#npc-dialog .chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 2px;
}
#npc-dialog .chat-row {
  font-size: 24px;                                            /* 12px 网格 ×2，像素字体不被插值 */
  line-height: 1.4;
  color: #d0be9c;
  margin-bottom: 6px;
  word-break: break-word;
}
#npc-dialog .chat-name {
  color: #ca8854;
  font-size: 12px;
  margin-right: 6px;
  letter-spacing: 1px;
}
#npc-dialog .chat-row.me .chat-name { color: #e0b870; }
#npc-dialog .chat-row.me .chat-text { color: #f0e0c0; }

/* 固定尾：接话选项 + 自由输入 */
#npc-dialog .chat-foot {
  flex: 0 0 auto;
  border-top: 1px solid rgba(185, 158, 134, .35);
  padding-top: 8px;
}
#npc-dialog .chat-status {
  font-size: 12px;
  color: #9c786b;
  margin-bottom: 6px;
}
#npc-dialog .chat-suggests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
#npc-dialog .chat-suggests:empty { display: none; }
#npc-dialog .chat-suggest {
  min-height: 44px;
  padding: 6px 14px;
  background: #2b1f12;
  border: 1px solid #b99e86;
  border-radius: 8px;
  color: #d0be9c;
  font-size: 24px;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#npc-dialog .chat-suggest.retry { color: #e0b870; border-color: #e0b870; }
#npc-dialog .chat-suggest:disabled { opacity: .5; }
#npc-dialog .chat-suggest:active { transform: translateY(1px); opacity: .85; }

#npc-dialog form.chat-ask {
  display: flex;
  gap: 8px;
}
#npc-dialog form.chat-ask input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  background: #2b2013;
  border: 2px solid #b99e86;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 24px;
  color: #d0be9c;
  outline: none;
  font-family: inherit;
}
#npc-dialog form.chat-ask input:focus { border-color: #e0b870; }
#npc-dialog form.chat-ask input::placeholder { color: #8a755a; }
#npc-dialog form.chat-ask button {
  min-height: 44px;
  min-width: 44px;
  background: #e0b870;
  border: 2px solid #b99e86;
  border-radius: 6px;
  color: #4a3620;
  font-size: 24px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  touch-action: manipulation;
}
#npc-dialog form.chat-ask button:active { transform: translateY(1px); }
/* 生成中：禁用重复提交（关闭 / 切人 / 回看仍然可用） */
#npc-dialog.busy form.chat-ask { opacity: .6; pointer-events: none; }
#npc-dialog.is-ended .chat-foot { opacity: .6; }

/* M10-a 确认模式（虚拟点单）：与聊天互斥，复用同一面板 */
#npc-dialog .confirm-line {
  font-size: 24px;
  line-height: 1.4;
  color: #d0be9c;
  display: none;
}
#npc-dialog.is-confirm .confirm-line { display: block; }
#npc-dialog .confirm {
  display: none;
  gap: 10px;
}
#npc-dialog .confirm button {
  min-height: 44px;
  padding: 8px 18px;
  background: #2b1f12;
  border: 1px solid #b99e86;
  border-radius: 8px;
  color: #d0be9c;
  font-size: 24px;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#npc-dialog .confirm button:first-child { color: #e0b870; border-color: #e0b870; }
#npc-dialog .confirm button:active { transform: translateY(1px); opacity: .85; }
#npc-dialog.is-confirm .chat-suggests,
#npc-dialog.is-confirm .chat-status,
#npc-dialog.is-confirm form.chat-ask { display: none; }

/* M2.8 静音按钮：右下角像素小圆钮（安全区适配）
   T24.4：交流面板出现时移到面板上缘外侧，避免挡住唯一静音入口 */
#sound-btn {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid #b99e86;
  background: rgba(255, 244, 224, 0.92);
  color: #6b503a;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
  image-rendering: pixelated;
}
#sound-btn:active { transform: translateY(1px); }
body.chat-open #sound-btn {
  bottom: calc(var(--chat-h, 520px) + 28px + env(safe-area-inset-bottom));
}
/* 无点击提示条同步让位（仍有 pointer-events:none，不吞点击） */
body.chat-open #prop-tip {
  bottom: calc(var(--chat-h, 520px) + 28px + env(safe-area-inset-bottom));
}
