/* 🆕 v1.7.3 历史注脚体验引擎 - 主样式表
 * 拆分自 web_server.py（原 INDEX_HTML 内嵌 CSS）
 * v1.6.2 起累积：移动端 + 结构化叙事 + 人物 Wiki + 反馈
 */

* { box-sizing: border-box; margin: 0; padding: 0; }
/* 🆕 v1.6.2 移动端适配：使用 dvh（dynamic viewport height）解决 iOS Safari URL 栏遮挡 */
html, body { height: 100%; }
body {
  font-family: "Songti SC", "SimSun", "Source Han Serif SC", serif;
  background: #f5f0e1;
  color: #2c2416;
  height: 100vh;
  height: 100dvh; /* 移动端动态高度（适配 iOS Safari URL 栏） */
  overflow: hidden;
  -webkit-text-size-adjust: 100%; /* 防止 iOS Safari 自动放大字体 */
}
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 1fr;
  height: 100vh;
  height: 100dvh; /* 🆕 v1.6.2 移动端 */
}
.main {
  overflow-y: auto;
  padding: 24px 32px;
  background: linear-gradient(180deg, #f5f0e1 0%, #ede4cc 100%);
  -webkit-overflow-scrolling: touch; /* 🆕 v1.6.2 iOS 弹性滚动 */
}
.sidebar {
  background: #2c2416;
  color: #d8c89c;
  padding: 20px;
  overflow-y: auto;
  border-left: 2px solid #8b6f47;
  -webkit-overflow-scrolling: touch; /* 🆕 v1.6.2 iOS 弹性滚动 */
}
.action-point-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0;
}
.ap-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c4a878;
  border: 1px solid #5a4a30;
}
.ap-dot.filled { background: #f0d8a0; box-shadow: 0 0 4px #f0d8a0; }
.ap-label { color: #c4a878; font-size: 11px; margin-left: 4px; }
.player-echo {
  color: #8b6f47;
  font-style: italic;
  border-left: 3px solid #c4a878;
  padding: 4px 10px;
  margin: 8px 0 4px;
  background: rgba(196, 168, 120, 0.1);
}
.action-tag {
  display: inline-block;
  background: #4a3820;
  color: #f0d8a0;
  padding: 3px 10px;
  margin: 6px 0;
  border-radius: 12px;
  font-size: 12px;
}
.action-tag.inquire { background: #2c4a3e; }
.month-marker {
  text-align: center;
  color: #8b6f47;
  font-weight: bold;
  margin: 16px 0;
  padding: 8px;
  background: rgba(139, 111, 71, 0.1);
  border-top: 1px dashed #8b6f47;
  border-bottom: 1px dashed #8b6f47;
}
/* 🆕 v1.5+ DE 风格：内在声音选项 */
.voice-options {
  background: linear-gradient(180deg, rgba(60,48,24,0.05) 0%, rgba(60,48,24,0.15) 100%);
  border: 2px solid #8b6f47;
  border-radius: 4px;
  padding: 16px;
  margin: 20px 0;
}

/* 🆕 v1.7.7 行动区：把 voice_options 和 input_area 整合为一个容器 */
/* 视觉上"脑海中的声音"+"输入框"是同一个行动选择区的两个部分 */
.action-area {
  background: rgba(196, 168, 120, 0.08);
  border: 1px solid #c4a878;
  border-radius: 8px;
  padding: 12px;
  margin: 20px 0;
  position: sticky;
  bottom: 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}
.action-area .voice-options {
  margin: 0 0 12px 0;
  background: rgba(255, 250, 235, 0.6);
  border-width: 1px;
}
.action-area .voice-options-collapsed {
  opacity: 0.5;
  pointer-events: none;
  margin: 0;
  padding: 8px;
}
.action-area .input-area {
  margin: 0;
  border: 1px solid #c4a878;
  background: rgba(255, 250, 235, 0.9);
}

/* 🆕 v1.7.9 输入框折叠状态：默认隐藏，点"自由输入"才展开 */
/* 节省移动端 100px 高度，强化"声音是主选" */
.action-area .input-area-collapsed {
  display: none;
}
.action-area .input-area-expanded {
  display: block;
  animation: expandInput 0.25s ease-out;
}
@keyframes expandInput {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 🆕 v1.7.9 输入框 header：显示"自由发挥"标题 + 返回按钮 */
.input-area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #c4a878;
}
.input-area-title {
  color: #5a3e1f;
  font-weight: bold;
  font-size: 14px;
}
.input-area-toggle {
  background: transparent;
  border: 1px solid #8b6f47;
  color: #5a3e1f;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
}
.input-area-toggle:hover {
  background: #8b6f47;
  color: #fff;
}

/* 🆕 v1.7.9 声音区 header 副提示 */
.voice-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: #8b6f47;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}
.voice-options-hint {
  color: #a08858;
  font-size: 12px;
  font-weight: normal;
}
.voice-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.voice-option-btn {
  background: rgba(255, 250, 235, 0.9);
  border: 1px solid #8b6f47;
  border-radius: 4px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voice-option-btn:hover {
  background: #f5e6c8;
  border-color: #c4a878;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(139, 111, 71, 0.2);
}
.voice-option-btn .voice-name {
  color: #5a3e1f;
  font-weight: bold;
  font-size: 14px;
}
.voice-option-btn .voice-intent {
  color: #6b5b3f;
  font-size: 13px;
  line-height: 1.5;
}
.voice-option-btn.free-input {
  background: rgba(139, 111, 71, 0.08);
  border-style: dashed;
}
.voice-option-btn.free-input:hover {
  background: rgba(139, 111, 71, 0.18);
}
/* 🆕 v1.6+ Tab 式 UX：其他选项按钮样式（更柔和，引导用） */
.voice-option-btn.other {
  background: rgba(60, 48, 24, 0.06);
  border-style: dashed;
  border-color: #b8a578;
  opacity: 0.85;
}
.voice-option-btn.other:hover {
  background: rgba(139, 111, 71, 0.15);
  border-color: #8b6f47;
  opacity: 1;
}
.voice-option-btn.other .voice-name {
  color: #8b6f47;
  font-style: italic;
}
/* 🆕 v1.6+ Tab 式 UX：自由发挥提示区 */
.free-input-banner {
  background: linear-gradient(180deg, rgba(139,111,71,0.12) 0%, rgba(139,111,71,0.05) 100%);
  border-left: 3px solid #8b6f47;
  border-right: 1px solid #8b6f47;
  border-top: 1px solid #8b6f47;
  border-bottom: none;
  padding: 10px 14px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  font-size: 13px;
}
.free-input-banner-text {
  color: #5a3e1f;
  font-weight: bold;
}
.free-input-cancel {
  background: transparent;
  border: 1px solid #8b6f47;
  color: #8b6f47;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s;
}
.free-input-cancel:hover {
  background: #8b6f47;
  color: #f5e6c8;
}
/* 🆕 v1.5+ 描述类提示 */
.describe-tag {
  display: inline-block;
  background: #4a3e7a;
  color: #f0e8c0;
  padding: 3px 10px;
  margin: 6px 0;
  border-radius: 12px;
  font-size: 12px;
}
.sidebar h3 {
  font-size: 14px;
  color: #c4a878;
  margin-top: 16px;
  margin-bottom: 6px;
}
.sidebar .stat-line {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}
.sidebar .stat-line .label { color: #a08858; }
.sidebar .stat-line .val { color: #f0d8a0; font-weight: bold; }
.sidebar .insight-tag {
  display: inline-block;
  background: #4a3820;
  color: #f0d8a0;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 3px;
  font-size: 12px;
}
.narrative {
  background: rgba(255, 250, 235, 0.7);
  border-left: 4px solid #8b6f47;
  padding: 16px 20px;
  margin: 16px 0;
  border-radius: 2px;
  line-height: 1.9;
  font-size: 16px;
  white-space: pre-wrap;
}
.narrative .round-tag {
  color: #8b6f47;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 8px;
}
.input-area {
  background: rgba(255, 250, 235, 0.9);
  border: 1px solid #8b6f47;
  border-radius: 4px;
  padding: 16px;
  margin: 20px 0;
  position: sticky;
  bottom: 0;
  z-index: 5;
  /* 🆕 v1.6.2：背景半透明 + backdrop-filter 让底部输入区更优雅 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.input-area textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid #c4a878;
  background: #fff;
  font-family: inherit;
  font-size: 15px;
  padding: 8px;
  border-radius: 3px;
  resize: vertical;
}
.input-area .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.input-area button {
  background: #8b6f47;
  color: #f5f0e1;
  border: none;
  padding: 8px 24px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
}
.input-area button:hover { background: #a08858; }
.input-area button:disabled { background: #c4a878; cursor: not-allowed; }
.input-area .hint { color: #8b6f47; font-size: 12px; }
.start-screen {
  text-align: center;
  padding: 40px 20px;
}
.start-screen h1 {
  font-size: 42px;
  color: #2c2416;
  margin-bottom: 12px;
  letter-spacing: 4px;
}
.start-screen .subtitle {
  color: #5a4a30;
  font-size: 18px;
  margin-bottom: 32px;
}
.start-screen .era-desc {
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.8;
  text-align: left;
  color: #3c3018;
}
.form-group {
  max-width: 500px;
  margin: 16px auto;
  text-align: left;
}
.form-group label {
  display: block;
  color: #5a4a30;
  font-size: 14px;
  margin-bottom: 4px;
}
.form-group select, .form-group input {
  width: 100%;
  padding: 8px 12px;
  font-size: 15px;
  border: 1px solid #8b6f47;
  background: #fff;
  border-radius: 3px;
  font-family: inherit;
}
.btn-primary {
  background: #8b6f47;
  color: #f5f0e1;
  border: none;
  padding: 12px 36px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  margin: 8px;
}
.btn-primary:hover { background: #a08858; }
.btn-secondary {
  background: transparent;
  color: #8b6f47;
  border: 1px solid #8b6f47;
  padding: 12px 36px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  margin: 8px;
}
.btn-secondary:hover { background: #ede4cc; }
.archive-item {
  background: #3c3018;
  padding: 10px;
  margin: 8px 0;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;           /* 🆕 v1.7.14: 让删除按钮和内容并排 */
  align-items: center;
  gap: 8px;
}
.archive-item:hover { border-color: #c4a878; }
.archive-item .ar-clickable {
  flex: 1;                 /* 🆕 v1.7.14: 内容区占满 */
  cursor: pointer;
}
.archive-item .ar-session { color: #f0d8a0; font-weight: bold; }
.archive-item .ar-meta { color: #a08858; margin-top: 3px; }
.archive-item .ar-delete-btn {  /* 🆕 v1.7.14: 删除按钮 */
  background: transparent;
  border: 1px solid #6b4020;
  color: #d4a070;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.archive-item .ar-delete-btn:hover {
  background: #a04030;
  color: #fff;
  border-color: #a04030;
}
.btn-danger {              /* 🆕 v1.7.14: 危险按钮（清空） */
  background: #6b2820;
  color: #f0d8a0;
  border: 1px solid #a04030;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.btn-danger:hover { background: #a04030; }

/* 🆕 v1.7.15: 加载弹窗（DM 渲染下一回合时） */
.loading-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
.loading-modal-fadeout { animation: fadeOut 0.2s ease-out forwards; }

.loading-modal {
  background: linear-gradient(180deg, #2a2010 0%, #1a1408 100%);
  border: 2px solid #c4a878;
  border-radius: 12px;
  padding: 32px 40px;
  min-width: 360px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  font-family: inherit;
}
.loading-title {
  color: #f0d8a0;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 16px;
}
.loading-phase {
  color: #d4a070;
  font-size: 14px;
  margin-bottom: 16px;
  min-height: 20px;
  transition: opacity 0.2s;
}
.loading-progress {
  width: 100%;
  height: 8px;
  background: #3c3018;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid #6b4020;
}
.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #c4a878 0%, #f0d8a0 100%);
  transition: width 0.3s ease-out;
  box-shadow: 0 0 8px rgba(240, 216, 160, 0.4);
}
.loading-time {
  color: #a08858;
  font-size: 12px;
  font-style: italic;
}

/* 🆕 v1.7.16: LLM 状态徽章 + 统计面板 */
.llm-status-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: #2a4a3a;
  color: #a0e0a0;
  border: 1px solid #4a7a5a;
  border-radius: 3px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.llm-status-badge:hover {
  background: #4a7a5a;
  color: #fff;
}
.llm-stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.llm-stat-card {
  background: #3c3018;
  border: 1px solid #6b4020;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}
.llm-stat-card.warn {
  border-color: #a04030;
  background: #5a2820;
}
.llm-stat-label {
  color: #a08858;
  font-size: 12px;
  margin-bottom: 4px;
}
.llm-stat-value {
  color: #f0d8a0;
  font-size: 18px;
  font-weight: bold;
}
.llm-stats-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}
.llm-stats-table th {
  background: #5a3e1f;
  color: #f0d8a0;
  padding: 6px 8px;
  text-align: left;
  border: 1px solid #6b4020;
}
.llm-stats-table td {
  background: #2a2010;
  color: #d4a070;
  padding: 4px 8px;
  border: 1px solid #6b4020;
}
.llm-stats-recent td {
  font-size: 11px;
  padding: 3px 6px;
}
.loading {
  display: inline-block;
  color: #8b6f47;
  font-size: 13px;
}
.error {
  color: #c0504d;
  background: #f0d8a0;
  padding: 8px;
  border-radius: 3px;
  margin: 8px 0;
}
.event-tag {
  display: inline-block;
  background: #6b4423;
  color: #f0d8a0;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 3px;
  font-size: 11px;
}

/* ============================================================ */
/* 🆕 v1.6.2 移动端适配（响应式断点）                              */
/* ============================================================ */

/* 平板（≤1024px）：侧边栏变窄 */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr 240px;
  }
  .sidebar { padding: 16px 12px; }
  .sidebar h3 { font-size: 14px; }
}

/* 手机横屏（≤768px）：侧边栏移到底部，主内容区独占 */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "main"
      "sidebar";
  }
  .main {
    grid-area: main;
    padding: 16px;
  }
  .sidebar {
    grid-area: sidebar;
    max-height: 35vh;        /* 侧边栏最多占屏幕 35% */
    border-left: none;
    border-top: 2px solid #8b6f47;
    padding: 12px;
  }
  /* 隐藏侧边栏内次要内容（保留：回合/日期/身份/Session/行动点）*/
  .sidebar .sidebar-secondary { display: none; }

  /* 字号适配 */
  .main { font-size: 15px; line-height: 1.7; }
  .round-tag { font-size: 14px; padding: 6px 10px; }
  .voice-options-header { font-size: 13px; letter-spacing: 1px; }
  .voice-option-btn { padding: 10px 12px; }
  .voice-option-btn .voice-name { font-size: 14px; }
  .voice-option-btn .voice-intent { font-size: 12px; }
  .input-area { padding: 12px; margin: 12px 0; }
  .input-area textarea { font-size: 16px; min-height: 60px; }  /* 16px 防 iOS 缩放 */
  .input-area button { padding: 10px 20px; font-size: 15px; min-height: 44px; min-width: 44px; }  /* 44px 触屏目标 */
  .input-area .hint { font-size: 11px; }
  .stat-line { font-size: 13px; padding: 3px 0; }
  .ap-dot { width: 12px; height: 12px; }
  .ap-label { font-size: 11px; }
  .start-screen h2 { font-size: 22px; }
  .archive-item { padding: 12px; }
  .ar-session { font-size: 14px; }
  .ar-meta { font-size: 12px; }
}

/* 手机竖屏（≤480px）：极致压缩 */
@media (max-width: 480px) {
  .layout {
    grid-template-rows: 1fr auto;
  }
  .main {
    padding: 12px;
    font-size: 14px;
  }
  .sidebar {
    max-height: 30vh;
    padding: 10px;
    font-size: 12px;
  }
  .voice-options-grid {
    grid-template-columns: 1fr;  /* 选项全部堆叠为单列 */
    gap: 8px;
  }
  .input-area { padding: 10px; }
  .input-area textarea { min-height: 50px; font-size: 16px; }
  .input-area .row { flex-wrap: wrap; gap: 6px; }
  .input-area button {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
  }
  .round-tag { font-size: 13px; padding: 4px 8px; }
}

/* 🆕 v1.6.2 iOS 键盘弹出时自适应 */
/* 当 input-area 获得焦点时，确保它在可视区域内 */
.input-area:focus-within {
  position: relative;
  z-index: 10;
}

/* ============================================================ */
/* 🆕 v1.6.3 剧情回顾（按钮 + 弹层）                             */
/* ============================================================ */
.recap-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(60, 48, 24, 0.92);
  color: #f5f0e1;
  border: 2px solid #8b6f47;
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.recap-btn:hover {
  background: rgba(90, 72, 36, 0.95);
  transform: translateY(-1px);
}
.recap-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.recap-modal {
  background: #f5f0e1;
  color: #2c2416;
  border: 2px solid #8b6f47;
  border-radius: 8px;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.recap-header {
  padding: 16px 20px;
  border-bottom: 1px solid #c4a878;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.recap-header h2 {
  margin: 0;
  color: #5a3e1f;
  font-size: 20px;
}
.recap-meta {
  flex: 1;
  color: #8b6f47;
  font-size: 12px;
}
.recap-close {
  background: none;
  border: none;
  color: #5a3e1f;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0 8px;
}
.recap-close:hover { color: #a08858; }
.recap-body-content {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.recap-body-content section { margin-bottom: 24px; }
.recap-body-content h3 {
  color: #5a3e1f;
  font-size: 15px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #c4a878;
}
.recap-entry {
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(255, 250, 235, 0.7);
  border-left: 3px solid #8b6f47;
  border-radius: 3px;
}
.recap-entry summary {
  cursor: pointer;
  color: #5a3e1f;
  font-weight: bold;
  user-select: none;
  padding: 4px 0;
}
.recap-entry summary:hover { color: #a08858; }
.recap-entry[open] {
  background: rgba(255, 250, 235, 0.95);
}
.recap-body {
  padding: 8px 0 4px;
  line-height: 1.7;
  color: #2c2416;
  font-size: 14px;
}
.recap-archive-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 12px;
  margin: 4px 0;
  background: rgba(255, 250, 235, 0.5);
  border-left: 2px solid #c4a878;
  border-radius: 3px;
  font-size: 13px;
}
.recap-round {
  color: #8b6f47;
  font-weight: bold;
  min-width: 70px;
  font-size: 12px;
}
.recap-summary {
  color: #5a4a30;
  line-height: 1.5;
}
.recap-empty {
  color: #8b6f47;
  font-style: italic;
  padding: 12px;
  text-align: center;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .recap-btn {
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0) + 90px); /* 在 input-area 上方 */
    right: 12px;
    font-size: 12px;
    padding: 6px 12px;
  }
  .recap-modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .recap-modal {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .recap-header {
    position: sticky;
    top: 0;
    background: #f5f0e1;
    z-index: 1;
  }
  .recap-entry {
    font-size: 13px;
  }
  .recap-body {
    font-size: 13px;
  }
}

/* ============================================================ */
/* 🆕 v1.6.6 侧边栏动作按钮 + 名词表 + tooltip 高亮              */
/* ============================================================ */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #5a4a30;
}
.sidebar-action-btn {
  background: rgba(196, 168, 120, 0.2);
  color: #f0d8a0;
  border: 1px solid #8b6f47;
  border-radius: 4px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar-action-btn:hover {
  background: rgba(196, 168, 120, 0.4);
  border-color: #c4a878;
}

/* 名词高亮（首次出现） */
.term-new {
  color: #a08858;
  border-bottom: 1.5px dashed #c4a878;
  cursor: help;
  position: relative;
  padding: 1px 2px;
  border-radius: 2px;
  transition: background 0.2s;
}
.term-new:hover {
  background: rgba(196, 168, 120, 0.25);
}
.term-new::after {
  content: " ?";
  font-size: 10px;
  color: #c4a878;
  font-weight: bold;
  vertical-align: super;
}

/* Tooltip 弹层 */
.term-tooltip {
  position: absolute;
  background: #2c2416;
  color: #f0d8a0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #8b6f47;
  max-width: 280px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  pointer-events: none;
}
.term-tooltip .term-name {
  color: #f0d8a0;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 4px;
}
.term-tooltip .term-cat {
  color: #c4a878;
  font-size: 11px;
  font-weight: normal;
  margin-left: 6px;
}
.term-tooltip .term-def {
  color: #d8c89c;
  font-size: 12px;
  margin-bottom: 4px;
}
.term-tooltip .term-example {
  color: #a08858;
  font-style: italic;
  font-size: 11px;
  margin-top: 4px;
}
.term-tooltip .term-related {
  color: #c4a878;
  font-size: 11px;
  margin-top: 4px;
}

/* 名词表弹层（复用 recap-modal 样式） */
.glossary-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #8b6f47;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  margin-bottom: 12px;
}
.glossary-search:focus {
  outline: none;
  border-color: #5a3e1f;
}
.glossary-list {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 600px) {
  .glossary-list {
    grid-template-columns: 1fr 1fr;
  }
}
.glossary-item {
  padding: 10px;
  background: rgba(255, 250, 235, 0.7);
  border-left: 3px solid #8b6f47;
  border-radius: 3px;
}
.glossary-item .term-name {
  color: #5a3e1f;
  font-weight: bold;
  margin-right: 6px;
}
.glossary-item .term-cat {
  color: #a08858;
  font-size: 11px;
}
.glossary-item .term-def {
  color: #2c2416;
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.5;
}
.glossary-read {
  border-left-color: #c4a878;
  opacity: 0.7;
}

/* ============================================================ */
/* 🆕 v1.6.8 版本号常驻 + 反馈弹层                              */
/* ============================================================ */
.version-badge {
  position: fixed;
  bottom: 8px;
  right: 12px;
  background: rgba(60, 48, 24, 0.75);
  color: #f0d8a0;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  z-index: 30;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(196, 168, 120, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: all 0.2s;
}
.version-badge:hover {
  background: rgba(60, 48, 24, 0.92);
  border-color: #c4a878;
  transform: translateY(-1px);
}
.version-badge .version-text {
  font-weight: bold;
  letter-spacing: 0.3px;
}
.version-badge .version-hint {
  opacity: 0.7;
  font-size: 10px;
}

/* 反馈弹层（独立于 recap/glossary，因为样式特殊） */
.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.feedback-categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (max-width: 600px) {
  .feedback-categories {
    grid-template-columns: 1fr;
  }
}
.feedback-cat-btn {
  background: rgba(196, 168, 120, 0.15);
  color: #5a3e1f;
  border: 1px solid #8b6f47;
  border-radius: 4px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.feedback-cat-btn:hover {
  background: rgba(196, 168, 120, 0.3);
}
.feedback-cat-btn.selected {
  background: #8b6f47;
  color: #f5f0e1;
  border-color: #5a3e1f;
}
.feedback-textarea {
  min-height: 120px;
  padding: 10px;
  border: 1px solid #8b6f47;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  background: #fff;
}
.feedback-textarea:focus {
  outline: none;
  border-color: #5a3e1f;
}
.feedback-context-note {
  font-size: 11px;
  color: #8b6f47;
  background: rgba(196, 168, 120, 0.1);
  padding: 8px 10px;
  border-radius: 3px;
  line-height: 1.5;
}
.feedback-submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.feedback-submit-btn {
  background: #8b6f47;
  color: #f5f0e1;
  border: none;
  border-radius: 4px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}
.feedback-submit-btn:hover {
  background: #5a3e1f;
}
.feedback-submit-btn:disabled {
  background: #c4a878;
  cursor: not-allowed;
}
.feedback-success {
  color: #2d5016;
  background: rgba(108, 152, 76, 0.15);
  padding: 12px;
  border-radius: 4px;
  text-align: center;
}

/* ============================================================ */
/* 🆕 v1.7.0 结构化叙事 blocks（视觉区分）                       */
/* ============================================================ */
.narrative-body {
  line-height: 1.8;
  margin-top: 8px;
}
.narrative-body .block-scene {
  margin: 8px 0;
  color: #2c2416;
}
.narrative-body .block-dialogue {
  margin: 6px 0 6px 8px;
  padding: 6px 12px;
  border-left: 3px solid #8b6f47;
  background: rgba(196, 168, 120, 0.08);
  border-radius: 0 4px 4px 0;
}
.narrative-body .block-dialogue .speaker {
  color: #5a3e1f;
  font-weight: bold;
  margin-right: 4px;
}
.narrative-body .block-dialogue .content {
  color: #2c2416;
  font-style: italic;
}
.narrative-body .block-monologue {
  margin: 6px 0 6px 24px;
  padding: 4px 10px;
  color: #5a4a30;
  font-style: italic;
  background: rgba(140, 111, 71, 0.06);
  border-radius: 4px;
}
.narrative-body .block-transition {
  margin: 12px 0 4px 0;
  padding: 4px 0;
  text-align: center;
  color: #8b6f47;
  font-size: 13px;
  font-style: italic;
  border-top: 1px dashed rgba(139, 111, 71, 0.3);
  border-bottom: 1px dashed rgba(139, 111, 71, 0.3);
}
/* 旧格式兼容（plain text 渲染） */
.narrative-body.plain {
  white-space: pre-wrap;
  color: #2c2416;
}

/* ============================================================ */
/* 🆕 v1.7.1 Character Wiki 弹层样式                            */
/* ============================================================ */
.wiki-character {
  background: rgba(196, 168, 120, 0.08);
  border-left: 3px solid #8b6f47;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.wiki-char-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.wiki-char-name {
  font-size: 16px;
  font-weight: bold;
  color: #5a3e1f;
}
.wiki-char-rel {
  font-size: 12px;
  padding: 2px 8px;
  background: #8b6f47;
  color: #f5f0e1;
  border-radius: 8px;
}
.wiki-char-count {
  font-size: 11px;
  color: #8b6f47;
  margin-left: auto;
}
.wiki-char-summary {
  font-size: 13px;
  color: #2c2416;
  margin: 4px 0;
}
.wiki-char-promises {
  margin-top: 6px;
  font-size: 12px;
}
.promise-player, .promise-npc {
  padding: 2px 0;
  color: #5a3e1f;
}
.promise-npc {
  color: #2c2416;
}
.wiki-char-events {
  margin: 6px 0 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: #5a4a30;
}
.wiki-char-events li {
  margin: 2px 0;
}
.wiki-decision {
  background: rgba(140, 111, 71, 0.08);
  border-left: 3px solid #c4a878;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.wiki-dec-round {
  display: inline-block;
  background: #5a3e1f;
  color: #f5f0e1;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  margin-right: 8px;
}
.wiki-dec-text {
  color: #2c2416;
}
.wiki-dec-alt {
  margin-top: 4px;
  padding-left: 8px;
  font-size: 11px;
  color: #8b6f47;
  font-style: italic;
}
