/* ═══ 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: linear-gradient(145deg, #0b0c14 0%, #131726 50%, #1a1e30 100%) !important;
    border-radius: 12px !important;
    border: 1.5px solid !important;
    border-image: linear-gradient(135deg, #4CAF50 0%, #B2FF59 25%, #00E5FF 50%, #B2FF59 75%, #4CAF50 100%) 1 !important;
    border-image-slice: 1 !important;
    box-shadow:
        inset 0 0 15px rgba(0, 229, 255, 0.15),
        0 0 8px rgba(0, 229, 255, 0.2) !important;
    padding: 16px !important;
    /* 建立层叠上下文，为背景动效做准备 */
    isolation: isolate !important;
    position: relative !important;
    transition: all 0.3s ease-in-out !important;
}

/* --- 3. 单独的输入聊天框 (更深的能量感，仿佛在注入神力) --- */
.is-user > .border.border-muted {
    background: linear-gradient(145deg, #070911 0%, #0e121f 50%, #151a2c 100%) !important;
    border-image: linear-gradient(135deg, #00E5FF 0%, #FFD700 25%, #4CAF50 50%, #FFD700 75%, #00E5FF 100%) 1 !important;
    border-image-slice: 1 !important;
    box-shadow:
        inset 0 0 20px rgba(255, 215, 0, 0.1),
        0 0 15px rgba(0, 229, 255, 0.25) !important;
}

/* --- 4. 聊天框内主要的文本内容 (绝对清晰) --- */
.rili-markdown-renderer {
    /* 高对比度纯白文字 */
    color: #FFFFFF !important;
    font-size: 1rem !important;
    line-height: 1.65 !important;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif !important;
    /* 保证所有后代文本也为白色 */
    * {
        color: inherit !important;
    }
    /* 确保背景透明，让父级背景显现 */
    background: transparent !important;
    z-index: 1 !important;

    /* 神核关键词或代码高亮 */
    & code {
        color: #FFD700 !important;
        background: rgba(255, 215, 0, 0.15) !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        font-weight: bold !important;
    }

    & strong {
        color: #B2FF59 !important;
        font-weight: bold !important;
    }
}

/* --- 5. 底部附加元素 (按钮、模型名称、Token消耗) --- */
/* 操作按钮 (复制, 编辑, 删除等) */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #E0E0E0 !important;
    text-shadow: 0 0 4px rgba(0, 229, 255, 0.3) !important;
    transition: all 0.2s ease !important;
    &:hover {
        color: #00E5FF !important;
    }
}

/* 模型名称文本 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #B0BEC5 !important;
    letter-spacing: 0.5px !important;
    font-weight: 500 !important;
}

/* Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #FFB74D !important;
    font-weight: bold !important;
}
*/

/* --- 6. 输出聊天框的加载元素 (自定义) --- */

/* 禁用默认加载动画 */
.flex.items-center.justify-center.size-6 > .flex.gap-2 {
    display: none !important;
}

/* 在加载元素的父级容器中创建新的特摄风加载动画 */
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 40px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* 使用伪元素创建三个动态闪烁的能量点，模拟神核聚变 */
.flex.items-center.justify-center.size-6::before,
.flex.items-center.justify-center.size-6::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00E5FF;
    box-shadow: 0 0 8px #00E5FF, 0 0 16px #4CAF50;
    animation: pulse-dot 1.5s infinite ease-in-out;
}

.flex.items-center.justify-center.size-6::before {
    left: 4px;
    animation-delay: 0s;
}

.flex.items-center.justify-center.size-6::after {
    right: 4px;
    animation-delay: 0.3s;
}

/* 创建一个居中的稳定核心点作为基 */
.flex.items-center.justify-center.size-6 {
    &::before, &::after {
        /* 继承上面的样式 */
    }
    /* 创建一个中心发光点 */
    background: radial-gradient(circle, #4CAF50 20%, transparent 70%) !important;
    background-size: 100% 100% !important;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 0.2;
        transform: scale(0.6);
        background: #4CAF50;
        box-shadow: 0 0 4px #4CAF50;
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
        background: #00E5FF;
        box-shadow: 0 0 15px #00E5FF, 0 0 30px #B2FF59;
    }
}

/* --- 7. 移动端与低动效适配 --- */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        padding: 12px !important;
        border-radius: 8px !important;
    }
    .rili-markdown-renderer {
        font-size: 0.95rem !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        box-shadow: 0 0 5px rgba(0, 229, 255, 0.3) !important;
        border-image: linear-gradient(135deg, #4CAF50 0%, #00E5FF 50%, #4CAF50 100%) 1 !important;
    }
    .flex.items-center.justify-center.size-6::before,
    .flex.items-center.justify-center.size-6::after {
        animation: none !important;
        opacity: 0.8 !important;
        background: #00E5FF !important;
    }
}