/* ═══ B平台表格修正（自动注入）═══ */
.rili-markdown-renderer table { display:table!important; table-layout:auto!important; width:100%!important; border-collapse:collapse!important; }
.rili-markdown-renderer table caption { display:table-caption!important; caption-side:top!important; text-align:center!important; padding:8px!important; }
.rili-markdown-renderer thead { display:table-header-group!important; }
.rili-markdown-renderer tbody { display:table-row-group!important; }
.rili-markdown-renderer tr { display:table-row!important; }
.rili-markdown-renderer th, .rili-markdown-renderer td { display:table-cell!important; }

/* ═══ B平台按钮组保护（自动注入 — 防止按钮消失）═══
   原理：B平台消息操作按钮结构为：
   .flex.items-center.gap-1.ml-auto (hover显隐包装)
     └── .bg-muted.rounded.flex.p-0.5 (按钮组容器)
           └── button.rounded-full.size-7 (单个按钮)
   以下规则使用高specificity + !important确保按钮
   不被任何转换后/透传的CSS规则意外隐藏
   ═══════════════════════════════════════════════ */
/* 按钮组容器保护 */
.w-full.h-full.flex.group .bg-muted.rounded.flex.p-0\.5,
.is-user .bg-muted.rounded.flex.p-0\.5,
.is-assistant .bg-muted.rounded.flex.p-0\.5 {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  overflow: visible !important;
  position: relative !important;
  width: auto !important;
  height: auto !important;
  max-height: none !important;
  pointer-events: auto !important;
  clip: auto !important;
  clip-path: none !important;
}
/* 单个按钮保护 */
.w-full.h-full.flex.group .bg-muted.rounded.flex.p-0\.5 > button,
.is-user .bg-muted.rounded.flex.p-0\.5 > button,
.is-assistant .bg-muted.rounded.flex.p-0\.5 > button {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: relative !important;
  clip: auto !important;
  clip-path: none !important;
}
/* hover显隐包装层保护 — 仅保留B平台原生的opacity过渡 */
.flex.items-center.gap-1.ml-auto.md\:opacity-0.group-hover\:opacity-100 {
  visibility: visible !important;
  display: flex !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
/* 操作行保护 */
.flex.w-full.items-center.justify-between.gap-2.px-2 {
  display: flex !important;
  visibility: visible !important;
  overflow: visible !important;
}

/* ============================================
   黄昏图书馆 · 暗夜微光 — 豪华完整版
   主题配色：象牙米白基底 × 酒红点缀 × 暗金细节
   最高原则：沉浸式叙事 | 绝对清晰 | 情感氛围
   ============================================ */

/* --- 1. 全局变量与基础框架 --- */
ai {
  --bg: #f4efe9;
  --card-bg: #fcfaf6;
  --text: #3a3531;
  --sub: #8c8072;
  --accent: #b86c7c;
  --accent2: #7a6b7a;
  --border: #e5ddd2;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
  --shadow-hover: 0 4px 16px rgba(184, 108, 124, 0.08);
  --radius: 10px;
  --font-serif: 'Georgia', 'Noto Serif SC', 'STSong', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;

  display: block;
  font-family: var(--font-sans);
  color: var(--text);
  background: transparent;
  margin: 8px 0;
  line-height: 1.7;
  font-size: 14px;
  max-width: 100%;
  box-sizing: border-box;
}

/* --- 2. 外层容器装饰（模拟图书馆灯光） --- */
details.c {
  background: var(--card-bg);
  margin: 10px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
}
details.c::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(184,108,124,0.15), transparent);
}
details.c[open] {
  box-shadow: var(--shadow-hover);
  border-color: rgba(184,108,124,0.2);
}

/* --- 3. 折叠标题（= 书签丝带） --- */
details.c summary.s {
  padding: 12px 16px;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  color: var(--text);
  background: linear-gradient(to right, var(--card-bg), var(--bg) 80%);
  border-bottom: 2px solid transparent;
  transition: all 0.3s ease;
  letter-spacing: 0.01em;
}
details.c[open] summary.s {
  border-bottom: 2px solid var(--border);
  background: linear-gradient(to right, var(--bg), var(--bg));
  color: var(--accent);
}
details.c summary.s:hover {
  background: linear-gradient(to right, var(--card-bg), rgba(184,108,124,0.04));
  color: var(--accent);
}
/* 自定义折叠图标 */
details.c summary.s::after {
  content: '▾';
  margin-left: auto;
  font-size: 12px;
  color: var(--accent2);
  opacity: 0.6;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
details.c[open] summary.s::after {
  transform: rotate(180deg);
  opacity: 1;
}

/* --- 4. 内容区域（翻页质感） --- */
details.c .b {
  padding: 14px 16px;
  background: rgba(255,255,252,0.3);
}

/* --- 5. 键值对（标签+值）--- */
ai d[l] {
  display: flex;
  margin-bottom: 8px;
  flex-wrap: wrap;
  align-items: baseline;
  line-height: 1.6;
}
ai d[l]::before {
  content: attr(l) "：";
  color: var(--sub);
  font-weight: 400;
  margin-right: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
}
ai d[l] {
  min-width: 100px;
  word-break: break-word;
}

/* --- 6. 标题系统（章节分隔） --- */
ai h4 {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--accent2);
  margin: 12px 0 6px;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
ai h5 {
  font-family: var(--font-sans);
  font-size: 14px;
  margin: 6px 0 4px;
  color: var(--text);
  font-weight: 600;
}

/* --- 7. 列表（带装饰点） --- */
ai ul, ai ol {
  margin: 6px 0 10px;
  padding-left: 20px;
  color: var(--text);
}
ai li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.5;
}
ai li em {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
  margin-right: 6px;
}

/* --- 8. 引用块（日记/内心独白） --- */
ai blockquote {
  display: block;
  background: rgba(184,108,124,0.04);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  margin: 10px 0;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-serif);
  color: #5a4a4a;
  font-size: 13.5px;
  line-height: 1.7;
  position: relative;
}
ai blockquote::before {
  content: '"';
  position: absolute;
  top: -4px; left: 2px;
  font-size: 28px;
  color: var(--accent);
  opacity: 0.2;
  font-family: serif;
}
ai blockquote p {
  margin: 6px 0;
}

/* --- 9. 表格（记忆区卡片） --- */
ai table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
  background: var(--card-bg);
  border-radius: 6px;
  overflow: hidden;
}
ai table thead {
  background: var(--bg);
}
ai table th {
  color: var(--sub);
  font-weight: 500;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-size: 13px;
}
ai table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
}
ai table tr:last-child td {
  border-bottom: none;
}
ai table tbody tr:hover {
  background: rgba(122,107,122,0.04);
}

/* --- 10. 特殊区域微调 --- */
.ai .appearance d[l]::before {
  font-weight: 600;
  color: var(--accent2);
}
.ai .thoughts p {
  font-style: italic;
  color: #5a4040;
  margin: 6px 0;
  padding-left: 12px;
  border-left: 2px dotted var(--accent2);
  position: relative;
}
.ai .bond {
  font-family: var(--font-serif);
  font-size: 16px;
  font-style: italic;
  color: var(--accent);
  background: linear-gradient(to right, rgba(184,108,124,0.06), transparent 80%);
  padding: 8px 14px;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* --- 11. 正负因素分栏（带渐变背景） --- */
ai .factors {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0;
}
ai .pos, ai .neg {
  flex: 1 1 160px;
  background: linear-gradient(135deg, rgba(255,255,255,0.6), rgba(255,255,255,0.9));
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
ai .pos {
  border-color: rgba(128, 160, 128, 0.2);
}
ai .neg {
  border-color: rgba(160, 128, 128, 0.15);
}
ai .pos h5 {
  color: #5a7a5a;
}
ai .neg h5 {
  color: #7a5a5a;
}
ai .pos h5::before {
  content: '☀ '; /* 使用纯文本符号替代emoji，更稳定 */
  font-size: 14px;
}
ai .neg h5::before {
  content: '☂ ';
  font-size: 14px;
}
ai .pos ul, ai .neg ul {
  list-style: none;
  padding-left: 0;
}
ai .pos li::before {
  content: '· ';
  color: #7a9a7a;
  font-weight: bold;
}
ai .neg li::before {
  content: '· ';
  color: #9a7a7a;
  font-weight: bold;
}

/* --- 12. “对她而言的意义”特殊标签样式 --- */
ai .desc t {
  display: inline-block;
  font-style: italic;
  font-weight: 600;
  color: var(--accent2);
  margin-bottom: 4px;
  border-bottom: 1px dotted var(--border);
}

/* --- 13. 移动端适配（书籍口袋版） --- */
@media (max-width: 480px) {
  ai {
    margin: 6px 0;
    font-size: 13px;
  }
  details.c summary.s {
    padding: 10px 12px;
    font-size: 14px;
  }
  details.c .b {
    padding: 10px 12px;
  }
  ai d[l] {
    flex-direction: column;
    align-items: flex-start;
  }
  ai d[l]::before {
    margin-right: 0;
    margin-bottom: 2px;
    display: block;
  }
  ai .factors {
    flex-direction: column;
    gap: 8px;
  }
  ai table {
    font-size: 12px;
  }
  ai table th, ai table td {
    padding: 6px 8px;
  }
}

/* --- 14. 减少动画偏好适配 --- */
@media (prefers-reduced-motion: reduce) {
  details.c,
  details.c summary.s,
  details.c summary.s::after {
    transition: none !important;
  }
}