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

/* ═══ B平台顶部栏适配说明（自动注入）═══
   A: div.sticky > div.flex.justify-between
      ├── 左侧空区
      ├── #ai-model-selector (居中)
      └── 右侧工具(设置按钮等)
   B: <header.flex.justify-between>
      ├── #nav-left (侧边栏开关)
      ├── #nav-middle (可能为空)
      └── #nav-right (通知/主题/语言)
   B平台模型按钮不在header内，选择器:
   button:has(> .flex-1.truncate.text-left)
   ═══════════════════════════════════════ */
header.flex.justify-between { position: relative; overflow: visible; }

/* ═══════════════════════════════════════════
   统一 CSS —— 聊天界面 + 状态栏折叠块
   ═══════════════════════════════════════════ */

/* ═══ 一、聊天界面 ═══ */

/* 1. 移除顶部默认颜色条，保持视觉纯净 */
[class*="bg-[#F1CBCB]"],
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}
/* 2. 统一聊天框美化：模拟幕布内侧衬里质感 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background-color: #F5EDDF !important;
    border: 1px solid rgba(44, 31, 24, 0.05) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(44, 31, 24, 0.03), 0 1px 2px rgba(44, 31, 24, 0.05) !important;
    backdrop-filter: blur(4px) !important;
    margin-bottom: 10px !important;
}
/* 3. 消息体文本 */
.rili-markdown-renderer {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
    font-size: 15px !important;
    line-height: 1.7 !important;
    color: #2C1F18 !important;
    font-weight: 400 !important;
}
.rili-markdown-renderer strong {
    color: #000000 !important;
    font-weight: 700 !important;
}
.rili-markdown-renderer code {
    background-color: rgba(44, 31, 24, 0.06) !important;
    color: #6B4F3E !important;
    font-family: 'Fira Code', monospace !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
}
/* 5. 底部附加元素美化 */
.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: #6B5E55 !important;
    opacity: 0.8 !important;
}
*/
/* 6. 移动端适配 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        max-width: 95% !important;
    }
}
/* 7. 自定义加载动画 */
.style-module__AtdJSq__dot-flashing.style-module__AtdJSq__text {
    display: none !important;
}
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Ccircle cx='4' cy='12' r='2' fill='%232C1F18'%3E%3Canimate attributeName='r' values='2;4;2' dur='1s' repeatCount='indefinite' /%3E%3C/circle%3E%3Ccircle cx='12' cy='12' r='2' fill='%232C1F18'%3E%3Canimate attributeName='r' values='2;4;2' dur='1s' begin='0.3s' repeatCount='indefinite' /%3E%3C/circle%3E%3Ccircle cx='20' cy='12' r='2' fill='%232C1F18'%3E%3Canimate attributeName='r' values='2;4;2' dur='1s' begin='0.6s' repeatCount='indefinite' /%3E%3C/circle%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* --- 顶部栏：深胡桃木剧院顶梁 --- */
header.flex.justify-between {
    background-color: #2B1A14 !important;
    border-bottom: 2px solid #B8945C !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}
#nav-middle button:has(> .flex-1.truncate.text-left) .flex-1.truncate.text-left,
#nav-right button svg,
header.flex.justify-between.w-full.top-0 svg.lucide-clock-8,
header.flex.justify-between.w-full.top-0 svg:has(use[href="#icon-icon-set"]) {
    color: #EDE0CC !important;
    fill: #EDE0CC !important;
}

/* --- 底部输入区域：暖奶油色承底 --- */
#ai-chat-bottom-input {
    background-color: #EDE0CC !important;
    border-top: 1px solid #B8945C !important;
    box-shadow: 0 -2px 10px rgba(43, 26, 20, 0.1) !important;
}
#ai-chat-input {
    background: transparent !important;
    color: #2B1A14 !important;
    font-family: "Noto Serif SC", serif !important;
}
#ai-chat-input::placeholder {
    color: #9B8D7E !important;
}

/* --- 底部按钮：酒红与金色 --- */
#ai-mod-button2 button.MuiButton-root {
    background-color: #722F37 !important;
    color: #EDE0CC !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
}
#ai-mod-button2 button.MuiButton-root:not(:first-child) {
    background-color: #B8945C !important;
    color: #2B1A14 !important;
}
#ai-mod-button2 button.MuiButton-root:active,
#ai-mod-button2 button.MuiButton-root:focus,
#ai-mod-button2 button.MuiButton-root[class*="Mui-selected"] {
    box-shadow: 0 0 15px #FFBF00 !important;
    filter: brightness(1.1) !important;
}

/* --- 分页栏 --- */
.MuiPaginationItem-root {
    color: #9B8D7E !important;
    border: 1px solid transparent !important;
}
.MuiPaginationItem-root.Mui-selected {
    background-color: #B8945C !important;
    color: #2B1A14 !important;
    font-weight: bold !important;
}
.MuiPaginationItem-root:hover {
    background-color: #722F37 !important;
    color: #FFFFFF !important;
}

/* --- 评论区 --- */
div[class*="w-full"][class*="bg-white"][class*="bottom-0"] {
    background-color: #FBF7F0 !important;
    border-left: 4px solid #B8945C !important;
}
div.group.ml-0 {
    background-color: #EDE4D6 !important;
    border-radius: 12px !important;
    padding: 12px !important;
    margin-bottom: 10px !important;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.05) !important;
    border: 1px solid rgba(184, 148, 92, 0.2) !important;
}
div.group.ml-0:has(span.text-\[10px\]) {
    background-color: #722F37 !important;
    color: #FFFFFF !important;
}
div.group.ml-0:has(span.text-\[10px\]) div.break-all,
div.group.ml-0:has(span.text-\[10px\]) div.text-sm,
div.group.ml-0:has(span.text-\[10px\]) div.text-xs {
    color: #EDE0CC !important;
}
div[data-state="closed"] svg[data-icon="Send03"] {
    fill: #722F37 !important;
}
button.MuiButton-containedPrimary {
    background-color: #722F37 !important;
}
button.MuiButton-outlinedPrimary {
    border-color: #B8945C !important;
    color: #B8945C !important;
}


/* ═══ 二、状态栏折叠块 ═══ */

/* --- 根容器：卡片纸质感 --- */
div:has(> details:first-child) {
    background: #FBF7F0;
    border: 1px solid rgba(184, 148, 92, 0.15);
    border-radius: 10px;
    padding: 6px 8px;
    box-shadow: 0 2px 12px rgba(62, 39, 35, 0.05);
    margin-bottom: 12px;
}

/* --- 一级折叠块 --- */
details {
    background: transparent;
    border: none;
    margin-bottom: 3px;
    overflow: hidden;
    color: #2C1F18;
    transition: margin 0.2s ease;
}
details[open] {
    margin-bottom: 6px;
}

/* --- 一级标题栏：奶油纸卡 + 金色左线 --- */
details > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 12px;
    background: linear-gradient(90deg, rgba(251, 247, 240, 0.95), #F5EDDF);
    color: #3E2723;
    font-family: 'Noto Serif SC', serif;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    border-left: 3px solid #B8945C;
    border-radius: 6px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 1px 2px rgba(62, 39, 35, 0.04);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { display: none; content: none; }

/* emoji 图标保持原样 */
details > summary > :first-child {
    font-size: 15px;
    flex-shrink: 0;
}

/* 箭头：小号金色 V */
details > summary::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: auto;
    border-right: 1.5px solid #B8945C;
    border-bottom: 1.5px solid #B8945C;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    opacity: 0.7;
}
details[open] > summary::after {
    transform: rotate(-135deg);
}

details > summary:hover {
    border-left-color: #C9A054;
    background: linear-gradient(90deg, #FBF7F0, #F5EDDF);
    box-shadow: 0 2px 8px rgba(184, 148, 92, 0.12);
}

details[open] > summary {
    border-radius: 6px 6px 0 0;
    border-left-color: #C9A054;
    box-shadow: 0 2px 6px rgba(184, 148, 92, 0.1);
}

/* --- 一级折叠内部内容区 --- */
details > *:not(summary) {
    padding: 12px 14px 14px 18px;
    background: linear-gradient(180deg, #FCFAF5 0%, #FBF7F0 100%);
    border-left: 3px solid rgba(184, 148, 92, 0.15);
    border-radius: 0 0 6px 6px;
}

/* --- 二级折叠块（NPC内嵌） --- */
details details {
    border: 1px solid rgba(184, 148, 92, 0.12);
    border-radius: 5px;
    margin: 6px 0;
    background: rgba(251, 247, 240, 0.6);
}
details details[open] {
    background: rgba(251, 247, 240, 0.8);
    border-color: rgba(184, 148, 92, 0.2);
}

details details > summary {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    background: transparent;
    color: #5C3328;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    border-radius: 5px;
    border-left: none;
    box-shadow: none;
}
details details > summary::after {
    width: 5px;
    height: 5px;
    border-color: #9B8D7E;
    opacity: 0.6;
}
details details > summary:hover {
    background: rgba(184, 148, 92, 0.06);
    box-shadow: none;
    border-left: none;
}
details details[open] > summary {
    border-radius: 5px 5px 0 0;
    color: #3E2723;
}
details details > *:not(summary) {
    padding: 8px 12px 10px;
    background: transparent;
    border-left: none;
    border-radius: 0 0 5px 5px;
}

/* --- 粗体标题 --- */
details strong {
    color: #3E2723;
    font-weight: 600;
    font-family: 'Noto Serif SC', serif;
}

/* --- 表格（记忆区 LTM/STM） --- */
details table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 12px;
    line-height: 1.6;
    margin: 6px 0;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(184, 148, 92, 0.15);
}
details table thead {
    background: #F5EDDF;
    color: #3E2723;
}
details table thead th {
    padding: 7px 9px;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-align: left;
    border-bottom: 1px solid rgba(184, 148, 92, 0.2);
}
details table tbody td {
    padding: 6px 9px;
    border-bottom: 1px solid rgba(184, 148, 92, 0.08);
    color: #2C1F18;
    background: #FBF7F0;
    font-size: 11.5px;
}
details table tbody tr:nth-child(even) td {
    background: rgba(245, 237, 223, 0.5);
}
details table tbody tr:hover td {
    background: rgba(232, 197, 109, 0.08);
}

/* --- 无序列表 --- */
details ul {
    list-style: none;
    padding-left: 0;
    margin: 5px 0;
}
details ul li {
    position: relative;
    padding-left: 14px;
    margin-bottom: 3px;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 13px;
    line-height: 1.65;
    color: #2C1F18;
}
details ul li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 8px;
    width: 4px;
    height: 4px;
    background: #B8945C;
    border-radius: 50%;
    opacity: 0.7;
}

/* --- 水平分割线 --- */
details hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(184, 148, 92, 0.15), transparent);
    margin: 9px 0;
}

/* --- 行内代码 --- */
details code {
    background: rgba(44, 31, 24, 0.05);
    color: #6B4F3E;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 11.5px;
    padding: 1px 4px;
    border-radius: 3px;
}

details > *:not(summary) > p:first-of-type {
    margin-top: 0;
}

/* --- 窄屏适配 --- */
@media (max-width: 480px) {
    details > summary {
        font-size: 12.5px;
        padding: 9px 10px 9px 10px;
    }
    details > *:not(summary) {
        padding: 10px 10px 12px 14px;
    }
    details table {
        font-size: 11px;
    }
    details table thead th,
    details table tbody td {
        padding: 5px 6px;
    }
    details details > summary {
        font-size: 12px;
        padding: 6px 10px;
    }
}