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

/* ===== 状态栏 & 记忆区 · 专用美化样式 ===== */
/* 仅美化折叠块、状态栏、记忆区，不改变其他任何区域 */

/* 折叠块整体样式 */
details {
    background: linear-gradient(135deg, #f8f0e8, #f5ede5);
    border: 1px solid #d8ccc0;
    border-radius: 20px;
    margin: 14px 0;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}
details[open] {
    padding-bottom: 12px;
    background: linear-gradient(135deg, #fefaf5, #fcf5ed);
    box-shadow: 0 4px 12px rgba(168, 152, 136, 0.12);
}

/* 折叠块标题栏 - 点击区域 */
summary {
    cursor: pointer;
    padding: 12px 18px;
    font-size: 0.88rem;
    color: #5a4a3a;
    user-select: none;
    list-style: none;
    font-weight: 600;
    background: linear-gradient(135deg, #e8e0d8, #e0d8d0);
    border-radius: 20px;
    word-break: break-word;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
    border: 1px solid #d8ccc0;
}
summary:hover {
    background: linear-gradient(135deg, #ddd4cc, #d8d0c8);
    color: #4a3a2a;
    transform: translateX(2px);
}
summary::-webkit-details-marker { display: none; }

/* 折叠块展开箭头 */
summary::before {
    content: "▶ ";
    font-size: 0.7rem;
    color: #a89888;
    transition: transform 0.2s ease;
    display: inline-block;
}
details[open] summary::before {
    content: "▼ ";
    transform: rotate(0deg);
}

/* 折叠块内部内容 */
details div, details .panel, details .stats-panel {
    color: #7a6a5a;
    padding: 14px 16px;
    line-height: 1.7;
    font-size: 0.85rem;
    background: rgba(255, 252, 248, 0.6);
    border-radius: 16px;
    margin: 8px 6px 0 6px;
}

/* 状态栏内行样式 */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px dashed #e0d4c8;
}
.stat-row:last-child {
    border-bottom: none;
}
.stat-row span:first-child {
    min-width: 90px;
    color: #8a7a6a;
    font-weight: 500;
}
.stat-row span:last-child {
    min-width: 45px;
    text-align: right;
    color: #a08060;
    font-weight: 500;
}

/* 进度条美化 */
.progress-bar {
    background: #e0d4c8;
    border-radius: 20px;
    height: 10px;
    width: 55%;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}
.progress-fill {
    background: linear-gradient(90deg, #b8a898, #a89888);
    height: 100%;
    border-radius: 20px;
    transition: width 0.4s ease;
    box-shadow: 0 0 4px rgba(168, 152, 136, 0.3);
}

/* 记忆区 · 短记忆表格美化 */
.memory-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 8px;
}
.memory-table th {
    background: #e8e0d8;
    color: #5a4a3a;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}
.memory-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e0d4c8;
    color: #7a6a5a;
}
.memory-table tr:last-child td {
    border-bottom: none;
}
.memory-table tr:hover td {
    background: #f5ede5;
}

/* 记忆区 · 长记忆摘要卡片 */
.long-memory {
    background: linear-gradient(135deg, #f5ede5, #efe5dd);
    border-left: 4px solid #a89888;
    padding: 12px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #7a6a5a;
    line-height: 1.6;
}

/* 数值变化标识 */
.value-up {
    color: #7a9a6a;
    font-weight: bold;
}
.value-down {
    color: #c08868;
    font-weight: bold;
}

/* 分割线装饰 */
.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #d8ccc0, transparent);
    margin: 12px 0;
}

/* 状态栏内部头像/图标 */
.stat-icon {
    font-size: 1rem;
    margin-right: 6px;
    vertical-align: middle;
}