/* ═══ B平台加载动画适配（自动注入）═══ */
.flex.items-center.justify-center.size-6 { opacity: 1 !important; }
.flex.items-center.justify-center.size-6 > .flex.gap-2 { display: none !important; }
.is-assistant.w-fit { width: 100% !important; }
.is-assistant > .border.border-muted:has(.flex.items-center.justify-center.size-6) {
  width: 100% !important; background: transparent !important;
  border: none !important; padding: 0 !important;
}
.is-assistant .space-y-3:has(.flex.items-center.justify-center.size-6) {
  display: flex; justify-content: center; width: 100%;
}

/* ═══ 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. 隐藏顶部颜色条 */
[class*="bg-[#F1CBCB]"], 
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* 2. 统一聊天框：纯深色背景，无透明，高对比 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #141618 !important;
    border: 1px solid rgba(180, 140, 100, 0.3) !important;
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 8px 32px rgba(0, 0, 0, 0.6) !important;
    border-radius: 12px !important;
    color: #F5F3F0 !important;         /* 高对比暖白 */
    isolation: isolate !important;      /* 层叠上下文 */
    position: relative !important;
    overflow: hidden !important;
}

/* 移除任何可能产生透明感的伪元素背景 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::before,
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::after {
    display: none !important;
}

/* 3. 输入框：更冷峻的纯黑 */
.is-user > .border.border-muted {
    background: #0F1113 !important;
    border-color: rgba(120, 130, 150, 0.35) !important;
}

/* 4. 输出框：保留极微弱暖色基底，但保证不透明 */
.is-assistant > .border.border-muted {
    background: #1A1C1E !important;
    border-color: rgba(180, 140, 100, 0.45) !important;
    box-shadow: 
        inset 0 0 15px rgba(50, 30, 20, 0.15),
        0 8px 32px rgba(0, 0, 0, 0.6) !important;
}

/* 5. 主要文本：亮暖白，清晰字重 */
.rili-markdown-renderer {
    position: relative !important;
    z-index: 1 !important;
    background: transparent !important;
    color: #F5F3F0 !important;
    font-family: 'Georgia', 'Times New Roman', ui-serif, serif !important;
    font-weight: 450 !important;       /* 适中的字重，不过粗也不过细 */
    line-height: 1.7 !important;
    text-shadow: none !important;
    text-rendering: optimizeLegibility !important;
}

/* 6. 底部附加元素：高对比，清晰可见 */
/* 操作按钮 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #F0EBE5 !important;
    font-weight: 400 !important;
    transition: color 0.2s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #FFFFFF !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* 模型名称 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #D5CEC4 !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.5px !important;
}

/* Token消耗 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #E0CBB5 !important;
    font-weight: 500 !important;
}
*/

/* ============================================== */
/*         自定义加载动画：“沉默巨像”组装片段           */
/* ============================================== */

/* 7.1 隐藏默认加载点 */
.flex.items-center.justify-center.size-6 > .flex.gap-2 {
    display: none !important;
}

/* 7.2 创建新的加载元素——基于父容器伪元素 */
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.flex.items-center.justify-center.size-6::before {
    content: '' !important;
    display: block !important;
    width: 26px !important;
    height: 26px !important;
    /* 内联SVG SMIL动画：金属齿轮旋转 */
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23a8957a' stroke-width='3'%3E%3Ccircle cx='50' cy='50' r='25' stroke-dasharray='15 10'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 50 50' to='360 50 50' dur='3s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='50' cy='50' r='15' stroke-dasharray='40 80' opacity='0.6'%3E%3CanimateTransform attributeName='transform' type='rotate' from='360 50 50' to='0 50 50' dur='4s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat !important;
    z-index: 10 !important;
    position: relative !important;
}

.flex.items-center.justify-center.size-6::after {
    content: '' !important;
    display: block !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 30px !important;
    height: 30px !important;
    transform: translate(-50%, -50%) !important;
    background: rgba(180, 140, 100, 0.08) !important;
    border-radius: 50% !important;
    z-index: 5 !important;
}

/* ============================================== */
/*           响应式与设备兼容性优化                     */
/* ============================================== */

@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        border-radius: 8px !important;
    }
    .flex.items-center.justify-center.size-6 {
        width: 32px !important;
        height: 32px !important;
    }
    .flex.items-center.justify-center.size-6::before {
        width: 20px !important;
        height: 20px !important;
    }
}

/* 尊重用户低动效偏好：降低幅度但不关闭（保持SMIL动画） */
@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        transition: none !important;
    }
    /* .loading 动画完全依靠SMIL，此处无需额外规则 */
}