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

/* 移除顶部颜色装饰条 */
[class*="bg-[#F1CBCB]"],
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* 统一聊天框背景及基础样式 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background-color: #0c1420 !important; /* 深夜间蓝黑 */
    border-radius: 12px !important; /* 现代感圆角 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5) !important; /* 深色阴影增强深度 */
    position: relative !important;
    isolation: isolate !important; /* 建立新的层叠上下文，确保伪元素在下方 */
    overflow: hidden !important; /* 隐藏超出范围的微光效果 */
}

/* 微光渐变效果 (通过伪元素实现) — 修正：选择器改为 ::before */
.is-user > .border.border-muted::before,
.is-assistant > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    /* 调整 inset 以控制微光扩散的起始范围和大小，可根据喜好微调 */
    inset: -30% !important; 
    /* 改为均匀纯色微光，去除中心色差 */
    background: rgba(184, 134, 11, 0.08) !important; /* 柔和金色，整层均匀 */
    opacity: 0.8 !important; /* 默认微光透明度 */
    z-index: 0 !important; /* 确保在文本下方 */
    pointer-events: none !important; /* 允许点击穿透 */
    animation: micro-glow-pulse 8s infinite alternate ease-in-out !important; /* 微光动画 */
}

/* 微光动画效果定义：包含缩放、位移和旋转，模拟呼吸般的动态微光 */
@keyframes micro-glow-pulse {
    0% {
        transform: scale(1) translateX(0) translateY(0) rotate(0deg) !important;
        opacity: 0.8 !important;
    }
    25% {
        transform: scale(1.05) translateX(5%) translateY(-5%) rotate(5deg) !important;
        opacity: 0.9 !important;
    }
    50% {
        transform: scale(1.1) translateX(0) translateY(0) rotate(0deg) !important;
        opacity: 1 !important;
    }
    75% {
        transform: scale(1.05) translateX(-5%) translateY(5%) rotate(-5deg) !important;
        opacity: 0.9 !important;
    }
    100% {
        transform: scale(1) translateX(0) translateY(0) rotate(0deg) !important;
        opacity: 0.8 !important;
    }
}

/* 聊天框内的主要文本内容 */
.rili-markdown-renderer {
    color: #f0e6d9 !important; /* 暖白米色 */
    background: transparent !important; /* 确保背景微光可见 */
    z-index: 1 !important; /* 确保文本在微光上方 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
    line-height: 1.6 !important; /* 提高行高以增强可读性 */
    font-size: 15px !important;
}

/* 底部操作按钮 (普通状态) */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7 {
    color: #d4af37 !important; /* 金色亮 (标题/激活) */
    font-weight: bold !important;
    transition: color 0.3s ease, background-color 0.3s ease !important;
    padding: 4px 8px !important;
}

/* 底部操作按钮 (悬停状态) — 修正：添加 :hover */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7:hover {
    color: #b8860b !important; /* 金色 (重点) - 悬停效果 */
    background-color: rgba(184, 134, 11, 0.1) !important; /* 增加背景以示互动 */
    border-radius: 4px !important;
}

/* 模型名称文本 (例如 gemini2.5pro) */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #8a9bb5 !important; /* 灰蓝 */
    font-size: 0.8rem !important; /* 略小 */
}

/* Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #8a9bb5 !important;
    font-size: 0.8rem !important;
}
*/

/*
* 针对“微光渐变”背景动效的实现说明：
* 此处的微光动画采用 CSS `@keyframes` 实现，模拟柔和的呼吸/浮动效果。
* 即使在平台可能全局禁用 CSS 动画（animation:none/paused/!important）的情况下，
* 伪元素依然会以静态的渐变形式存在（默认 opacity: 0.8），确保“可见性”。
* 根据您的平台规范，对于“加载元素”和“离散背景动效”（如星空、流星），
* 推荐优先使用内嵌 SVG 的 SMIL 动画。但对于这种弥散的“微光渐变”背景效果，
* CSS Keyframes 在表达上更为直接且常见，且在“prefers-reduced-motion”环境下可被禁用。
* 如果平台对此类弥散背景动效有严格的 SMIL 实现要求，请告知，我们将进行更复杂的 SVG SMIL 方案设计。
*/

/* 移动端适配：调整圆角和阴影，字体大小，微光范围 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
    .is-assistant > .border.border-muted {
        border-radius: 8px !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4) !important;
    }
    .rili-markdown-renderer {
        font-size: 14px !important;
    }
    /* 修正：微光伪元素 */
    .is-user > .border.border-muted::before,
    .is-assistant > .border.border-muted::before {
        inset: -10% !important; /* 减少微光扩散范围，适应小屏幕 */
    }
}

/* 降低动效敏感度：针对系统设置“减少动态效果”的用户 */
@media (prefers-reduced-motion: reduce) {
    /* 修正：微光伪元素 */
    .is-user > .border.border-muted::before,
    .is-assistant > .border.border-muted::before {
        animation: none !important; /* 禁用微光动画 */
        opacity: 0.5 !important; /* 保持静态微光，降低透明度 */
        /* 静态均匀微光，不再有中心色差 */
        background: rgba(184, 134, 11, 0.06) !important;
    }
}
/* ========== 适配聊天框内的 <details> 折叠块 ========== */
.rili-markdown-renderer details {
    background: rgba(12, 20, 32, 0.6) !important;   /* 半透明深蓝底 */
    border: 1px solid rgba(184, 134, 11, 0.3) !important; /* 金色描边 */
    border-radius: 8px !important;
    padding: 0.8em 1em !important;
    margin: 0.8em 0 !important;
    transition: all 0.2s ease !important;
}

.rili-markdown-renderer summary {
    cursor: pointer !important;
    color: #d4af37 !important;          /* 亮金标题 */
    font-weight: bold !important;
    outline: none !important;
    list-style: none !important;        /* 隐藏默认三角 */
}

/* 移除 WebKit 默认的三角标记 */
.rili-markdown-renderer summary::-webkit-details-marker {
    display: none !important;
}

/* 自定义折叠箭头 */
.rili-markdown-renderer summary::before {
    content: '▸ ' !important;           /* 合起状态 */
    color: #d4af37 !important;
    display: inline-block;
    transition: transform 0.2s ease !important;
}

.rili-markdown-renderer details[open] > summary::before {
    content: '▾ ' !important;           /* 展开状态 */
}
/* 增强加粗文字可读性：亮金微光 */
.rili-markdown-renderer strong,
.rili-markdown-renderer b {
    color: #f7d44a !important;                /* 亮金，比正文更跳 */
    text-shadow: 0 0 6px rgba(184, 134, 11, 0.4) !important;  /* 淡淡光晕 */
    font-weight: 700 !important;
}
/* ========== 适配表格：深色底清晰可读 ========== */
.rili-markdown-renderer table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 1em 0 !important;
  background: rgba(12, 20, 32, 0.7) !important;   /* 和主背景同色系半透明 */
  border-radius: 8px !important;
  overflow: hidden !important;
  border: 1px solid rgba(184, 134, 11, 0.3) !important; /* 金色描边 */
}

.rili-markdown-renderer thead {
  background: rgba(184, 134, 11, 0.15) !important;  /* 金色微光表头 */
}

.rili-markdown-renderer th {
  color: #f7d44a !important;           /* 亮金，和加粗一个色 */
  font-weight: 700 !important;
  padding: 0.6em 0.8em !important;
  border-bottom: 1px solid rgba(184, 134, 11, 0.4) !important;
  text-align: left !important;
}

.rili-markdown-renderer td {
  color: #f0e6d9 !important;           /* 正文暖白 */
  padding: 0.5em 0.8em !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* 斑马纹：隔行变色，看得更清 */
.rili-markdown-renderer tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03) !important;
}

.rili-markdown-renderer tbody tr:hover {
  background: rgba(184, 134, 11, 0.08) !important; /* 悬停行微金高亮 */
}