/* ═══ 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;
}

/* ===============================================
   纪未央 · 纯爱守护主题 · 完整UI美化
   视觉关键词：温暖 / 治愈 / 档案感 / 绝对清晰
   覆盖：聊天框外部容器 + 内部所有状态栏卡片
   =============================================== */

/* ----- 外部容器：聊天框整体美化 ----- */
ai {
  /* 主题色板：暖米白基底 + 茶褐/淡紫点缀 */
  --bg-warm: #fdfbf9;
  --card-bg: #ffffff;
  --border-soft: #e8e0d6;
  --border-accent: #c4b5a5;
  --text-main: #2d2822;
  --text-muted: #7a6e62;
  --accent-primary: #9b8a7a;
  --accent-glow: #d4c9bd;
  --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --radius-card: 12px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  display: block;
  max-width: 100%;
  padding: 12px 8px;
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: transparent;
}

/* ----- 卡片基类：柔和阴影，圆角，左侧装饰条 ----- */
ai details {
  display: block;
  margin: 0 0 14px 0;
  padding: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--accent-primary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

ai details[open] {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.05);
  border-left-color: #8a7a6a;
  margin-bottom: 18px;
}

/* ----- 标题栏：清晰可点击，带折叠指示器 ----- */
ai summary {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text-main);
  background: linear-gradient(135deg, #fdfbf9 0%, #f6f2ec 100%);
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.2s ease;
  letter-spacing: 0.02em;
}

/* 移除浏览器默认三角 */
ai summary::-webkit-details-marker { display: none; }
ai summary::marker { display: none; content: ""; }

/* 自定义指示器（小三角 + 旋转动画） */
ai summary::before {
  content: "▸";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-right: 10px;
  color: var(--accent-primary);
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

ai details[open] > summary::before {
  transform: rotate(90deg);
}

/* 标题栏悬停反馈 */
ai summary:hover {
  background: linear-gradient(135deg, #f8f4ef 0%, #efe9e0 100%);
}

/* 标题栏emoji图标（如果有）保持间距 */
ai summary:first-child {
  gap: 4px;
}

/* ----- 内容区域：文字舒适，间距适中 ----- */
ai details > *:not(summary) {
  padding: 0 16px 4px 16px;
}

ai details p {
  margin: 10px 0;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.7;
}

ai details ul,
ai details ol {
  margin: 8px 0;
  padding-left: 24px;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.7;
}

ai details li {
  margin: 3px 0;
}

ai details li::marker {
  color: var(--accent-primary);
}

/* 加粗标签：深色突出 */
ai details strong {
  color: #1f1a16;
  font-weight: 600;
}

/* 斜体说明文字：柔和灰色 */
ai details em {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

/* 代码块样式（通讯终端中的时间戳等） */
ai details code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 12.5px;
  background: #f4f0ea;
  color: #5e4f42;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #e8e0d6;
}

/* ----- 引用块（内心独白、提示文本） ----- */
ai details blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  background: #faf7f3;
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 6px 6px 0;
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.7;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

/* 引用块中的代码保持背景一致 */
ai details blockquote code {
  background: #ede8e1;
  border-color: #ddd5ca;
}

/* ----- 水平分割线 ----- */
ai details hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 12px 0;
}

/* ----- 表格（记忆区） ----- */
ai details table {
  width: calc(100% - 8px);
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 12.5px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-soft);
}

ai details th,
ai details td {
  border: 1px solid var(--border-soft);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

ai details th {
  background: #f6f2ec;
  font-weight: 600;
  color: #4a3f36;
  font-size: 12px;
  letter-spacing: 0.03em;
}

ai details td {
  color: var(--text-main);
  font-size: 12.5px;
}

/* 表格悬停行高亮 */
ai details tbody tr:hover {
  background: #faf7f3;
}

/* ----- 特殊板块个性化 ----- */

/* 纸月亮档案：银灰左侧装饰，神秘感 */
ai details:nth-of-type(6) {
  border-left-color: #8a8a8a;
}
ai details:nth-of-type(6) > summary {
  background: linear-gradient(135deg, #f8f8f8 0%, #efefef 100%);
  color: #3d3d3d;
}

/* 内心独白：标题栏使用虚线底边，柔和区分 */
ai details:nth-of-type(4) > summary {
  border-bottom-style: dashed;
  border-bottom-color: #d5ccc2;
}

/* 私人日记：更温暖的色调 */
ai details:nth-of-type(5) {
  border-left-color: #b8a08a;
}
ai details:nth-of-type(5) > summary {
  background: linear-gradient(135deg, #faf5ee 0%, #f0e8de 100%);
}

/* 行动推荐：有序列表编号加重 */
ai details:nth-of-type(9) ol {
  padding-left: 28px;
}
ai details:nth-of-type(9) li {
  font-weight: 500;
  padding: 2px 0;
}
ai details:nth-of-type(9) li::marker {
  color: var(--accent-primary);
  font-weight: 700;
}

/* 记忆区表格更紧凑 */
ai details:nth-of-type(10) table {
  font-size: 11.5px;
}
ai details:nth-of-type(10) th {
  font-size: 11.5px;
}
ai details:nth-of-type(10) td {
  font-size: 11.5px;
}

/* ----- 移动端优化 ----- */
@media (max-width: 500px) {
  ai {
    padding: 6px 4px;
    font-size: 14px;
  }
  ai details {
    margin-bottom: 10px;
    border-left-width: 4px;
  }
  ai details[open] {
    margin-bottom: 14px;
  }
  ai summary {
    padding: 8px 10px;
    font-size: 13.5px;
  }
  ai summary::before {
    font-size: 12px;
    width: 16px;
    height: 16px;
    margin-right: 8px;
  }
  ai details > *:not(summary) {
    padding: 0 12px 2px 12px;
  }
  ai details p,
  ai details ul,
  ai details ol {
    font-size: 13px;
    margin: 8px 0;
  }
  ai details table {
    font-size: 11px;
    margin: 6px 0;
  }
  ai details th,
  ai details td {
    padding: 4px 6px;
  }
  ai details blockquote {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* ----- 可选的淡入动画（打开卡片时） ----- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

ai details[open] > *:not(summary) {
  animation: fadeSlideIn 0.2s ease-out;
}

/* ----- 表格单元格的更细致分隔（可选增强） ----- */
ai details th:first-child,
ai details td:first-child {
  padding-left: 12px;
}
ai details th:last-child,
ai details td:last-child {
  padding-right: 12px;
}