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

/* ============================================================
   书页风格 · details/summary 折叠块适配
   颜色体系：#4A3B32(深棕) #8B7355(中棕) #C4A97D(浅金)
             #FCF5E8(书页左) #FBF7EF(书页右) #F0E8D5(固定值底)
   字体体系：Georgia(标题) / Times New Roman(正文) / Patrick Hand(手写)
   ============================================================ */

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

/* ---- 2. details 容器 ---- */
details {
    background: #FCF5E8 !important;
    border: 1px solid #D4C4A8 !important;
    border-radius: 4px !important;
    margin: 12px 0 !important;
    padding: 0 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    font-family: 'Times New Roman', serif !important;
    overflow: hidden !important;
    transition: all 0.25s ease !important;
}
details[open] {
    border-color: #C4A97D !important;
    box-shadow: 0 2px 12px rgba(74,59,50,0.12) !important;
}

/* ---- 3. summary 点击条 ---- */
details > summary {
    display: flex !important;
    align-items: center !important;
    padding: 10px 16px !important;
    background: linear-gradient(to right, #FBF7EF, #FCF5E8) !important;
    border-bottom: 1px dashed #E0D0B8 !important;
    cursor: pointer !important;
    font-family: 'Georgia', serif !important;
    font-size: 15px !important;
    color: #4A3B32 !important;
    letter-spacing: 1px !important;
    list-style: none !important;           /* 隐藏默认三角 */
    user-select: none !important;
    transition: background 0.2s ease !important;
}
details > summary::-webkit-details-marker {
    display: none !important;              /* Chrome 隐藏默认三角 */
}
details > summary::marker {
    content: none !important;              /* Firefox 隐藏默认三角 */
}

/* ---- 4. summary 手写体标记（替换默认三角） ---- */
details > summary::before {
    content: '❧';
    display: inline-block;
    margin-right: 10px;
    font-size: 14px;
    color: #C4A97D;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
details[open] > summary::before {
    transform: rotate(90deg);
    color: #8B7355;
}

/* ---- 5. summary hover ---- */
details > summary:hover {
    background: linear-gradient(to right, #F0E3CC, #FCF5E8) !important;
    color: #2C1F16 !important;
}
details > summary:hover::before {
    color: #8B7355 !important;
}

/* ---- 6. details 展开内容区 ---- */
details > .rili-markdown-renderer,
details > *:not(summary) {
    padding: 16px 20px !important;
    background: #FCF5E8 !important;
}

/* ---- 7. details 内部 markdown 文本 ---- */
details .rili-markdown-renderer,
details > div {
    color: #4A3B32 !important;
    font-family: 'Georgia', serif !important;
    line-height: 1.6 !important;
    font-size: 15px !important;
    text-shadow: none !important;
    background: transparent !important;
}

/* ---- 8. details 内部表格 ---- */
details table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 10px 0 !important;
    font-size: 14px !important;
}
details table th {
    background: #F0E8D5 !important;
    color: #4A3B32 !important;
    font-family: 'Georgia', serif !important;
    padding: 8px 12px !important;
    border-bottom: 2px solid #C4A97D !important;
    text-align: left !important;
}
details table td {
    padding: 6px 12px !important;
    border-bottom: 1px solid #E0D0B8 !important;
    color: #5A4A3A !important;
}

/* ---- 9. details 内部加粗 ---- */
details strong,
details b {
    color: #2C1F16 !important;
    font-weight: bold !important;
}

/* ---- 10. details 内部代码/行内标记 ---- */
details code {
    background: #F0E8D5 !important;
    color: #8B7355 !important;
    font-family: 'Patrick Hand', cursive !important;
    font-size: 13px !important;
    padding: 1px 6px !important;
    border-radius: 3px !important;
}

/* ---- 11. details 内部水平线 ---- */
details hr {
    border: none !important;
    border-top: 1px dashed #D4C4A8 !important;
    margin: 12px 0 !important;
}

/* ---- 12. 嵌套 details ---- */
details details {
    margin: 8px 0 !important;
    border-color: #E0D0B8 !important;
    box-shadow: none !important;
}
details details > summary {
    font-size: 14px !important;
    padding: 8px 14px !important;
    background: #FBF7EF !important;
}

/* ---- 13. 原有聊天框适配 ---- */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #FCF5E8 !important;
    border: 1px solid #D4C4A8 !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    font-family: 'Times New Roman', serif !important;
}
.is-user > .border.border-muted {
    background: #FBF7EF !important;
    border: 1px solid #D4C4A8 !important;
}

/* ---- 14. markdown 正文 ---- */
.rili-markdown-renderer {
    color: #4A3B32 !important;
    font-family: 'Georgia', serif !important;
    line-height: 1.6 !important;
    font-size: 15px !important;
    text-shadow: none !important;
    background: transparent !important;
    z-index: 1 !important;
}

/* ---- 15. 输入区 ---- */
textarea::placeholder,
input::placeholder,
[contenteditable="true"]:empty:before {
    color: #C4A97D !important;
    font-family: 'Patrick Hand', cursive !important;
    font-size: 14px !important;
    opacity: 0.8 !important;
}
textarea,
input,
[contenteditable="true"] {
    color: #2C1F16 !important;
    font-family: 'Patrick Hand', cursive !important;
    font-size: 16px !important;
    caret-color: #8B7355 !important;
}

/* ---- 16. 按钮 ---- */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #8B7355 !important;
    font-family: 'Georgia', serif !important;
    font-size: 12px !important;
    text-transform: none !important;
    letter-spacing: 0.5px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    padding: 2px 8px !important;
    border-radius: 3px !important;
    transition: all 0.2s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    background: #F0E3CC !important;
    border-color: #C4A97D !important;
    color: #4A3B32 !important;
}

/* ---- 17. 模型标签 ---- */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #A0845A !important;
    font-family: 'Georgia', serif !important;
    font-size: 11px !important;
    font-style: italic !important;
    opacity: 0.8 !important;
}

/* ---- 18. Token 消耗 ---- */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #8B7355 !important;
    font-family: 'Patrick Hand', cursive !important;
    font-size: 12px !important;
    background: #F0E8D5 !important;
    padding: 1px 6px !important;
    border-radius: 3px !important;
    margin-left: 4px !important;
}
*/

/* ---- 19. 自定义加载动画 ---- */
.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: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.flex.items-center.justify-center.size-6::after {
    content: '';
    display: block;
    width: 50px;
    height: 24px;
    background: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='24' viewBox='0 0 60 24'%3E%3Crect x='2' y='4' width='16' height='16' rx='1' fill='%23c4a97d'%3E%3Canimate attributeName='opacity' values='1;0;1' dur='1.2s' begin='0s' repeatCount='indefinite' /%3E%3C/rect%3E%3Crect x='22' y='4' width='16' height='16' rx='1' fill='%238B7355'%3E%3Canimate attributeName='opacity' values='1;0;1' dur='1.2s' begin='0.3s' repeatCount='indefinite' /%3E%3C/rect%3E%3Crect x='42' y='4' width='16' height='16' rx='1' fill='%234A3B32'%3E%3Canimate attributeName='opacity' values='1;0;1' dur='1.2s' begin='0.6s' repeatCount='indefinite' /%3E%3C/rect%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    opacity: 0.85;
}

/* ---- 20. 移动端 ---- */
@media (max-width: 480px) {
    .rili-markdown-renderer { font-size: 14px !important; }
    details > summary { font-size: 14px !important; padding: 8px 12px !important; }
    details > *:not(summary) { padding: 12px 14px !important; }
    .bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
        font-size: 11px !important;
        padding: 1px 5px !important;
    }
    .flex.items-center.justify-center.size-6 {
        width: 50px !important;
        height: 26px !important;
    }
    .flex.items-center.justify-center.size-6::after {
        width: 40px;
        height: 20px;
    }
}

/* ---- 21. 低动效 ---- */
@media (prefers-reduced-motion: reduce) {
    .flex.items-center.justify-center.size-6::after {
        opacity: 0.5 !important;
        transition: none !important;
    }
    details > summary::before {
        transition: none !important;
    }
}