/* ═══ 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: rgba(255, 252, 249, 0.92) !important;
    backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(200, 180, 190, 0.25) !important;
    border-radius: 18px !important;
    padding: 16px !important;
    box-shadow: 0 4px 24px rgba(180, 160, 170, 0.15),
                0 1px 4px rgba(160, 140, 150, 0.1) !important;
    margin-bottom: 12px !important;
    transition: all 0.3s ease !important;
}

/* 3. 聊天框内文本 */
.rili-markdown-renderer {
    color: #4a3b44 !important;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif !important;
    font-weight: 500 !important;
    line-height: 1.7 !important;
    background: transparent !important;
}

/* 4. 底部附加元素（按钮、模型名、Token）高亮 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7,
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground,
/* [Token消耗hover逻辑转换未启用]
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7,
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground,
.text-orange-500 {
    color: #e898a8 !important;
    font-weight: 600 !important;
}
*/

/* 5. 移除原加载动画并启用自定义加载逻辑 */
.style-module__AtdJSq__dot-flashing.style-module__AtdJSq__text {
    display: none !important;
}

.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 60px !important;
    height: 20px !important;
}

/* 自定义SVG加载动画 — 飘落的樱花花瓣 */
.flex.items-center.justify-center.size-6::before {
    content: url('data:image/svg+xml;utf8,<svg width="40" height="10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="3" fill="%23e898a8"><animate attributeName="opacity" values="1;0.3;1" dur="1s" repeatCount="indefinite"/></circle><circle cx="20" cy="5" r="3" fill="%23e898a8"><animate attributeName="opacity" values="1;0.3;1" dur="1s" begin="0.2s" repeatCount="indefinite"/></circle><circle cx="35" cy="5" r="3" fill="%23e898a8"><animate attributeName="opacity" values="1;0.3;1" dur="1s" begin="0.4s" repeatCount="indefinite"/></circle></svg>') !important;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        border-radius: 12px !important;
        padding: 12px !important;
    }
}

/* ========== 折叠块卡片化 ========== */
details {
    background: rgba(255, 250, 252, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(232, 180, 200, 0.28);
    border-radius: 16px;
    margin: 14px 0;
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 3px 16px rgba(200, 180, 190, 0.12);
}

details[open] {
    background: rgba(255, 248, 250, 0.95);
    border-color: rgba(232, 152, 168, 0.4);
    box-shadow: 0 6px 24px rgba(200, 170, 180, 0.2);
}

/* 标题栏 */
summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #c87088;
    background: linear-gradient(135deg, rgba(255, 235, 242, 0.7), rgba(255, 248, 250, 0.3));
    border-bottom: 1px solid rgba(232, 180, 200, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: background 0.25s;
}

summary:hover {
    background: linear-gradient(135deg, rgba(255, 220, 232, 0.8), rgba(255, 240, 246, 0.5));
}

/* 隐藏默认三角 */
summary::-webkit-details-marker { display: none; }
summary::marker { content: none; }

/* 左侧展开指示器 — 樱花花苞 */
summary::before {
    content: "✿";
    display: inline-block;
    font-size: 0.85rem;
    transition: transform 0.3s ease;
    color: #e898a8;
    opacity: 0.9;
}

details[open] > summary::before {
    transform: rotate(180deg) scale(1.15);
    color: #d06080;
}

/* 展开内容区域 */
details > .details-content,
details > *:not(summary) {
    padding: 14px 18px;
    color: #4a3b44;
    line-height: 1.7;
    animation: petalIn 0.3s ease;
}

/* 嵌套 details 微调 */
details details {
    margin: 10px 0 0 0;
    border-radius: 14px;
    background: rgba(255, 245, 248, 0.6);
    border-color: rgba(232, 200, 210, 0.3);
}

details details summary {
    font-size: 0.9rem;
    padding: 10px 14px;
    color: #d08090;
    background: linear-gradient(135deg, rgba(255, 240, 245, 0.6), transparent);
}

/* 入场动画 — 花瓣飘落 */
@keyframes petalIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 移动端 */
@media (max-width: 480px) {
    summary {
        padding: 12px 14px;
        font-size: 0.9rem;
    }
    details > .details-content,
    details > *:not(summary) {
        padding: 12px 14px;
    }
}