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

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

/* ===== 全局字体 ===== */
* {
    font-family: Georgia, 'Noto Serif SC', '宋体', serif !important;
}
strong, b, h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Serif SC', '宋体', serif !important;
    font-weight: 600 !important;
    color: #c9a84c !important;
}
code, pre {
    font-family: 'SF Mono', 'Consolas', monospace !important;
}

/* ===== 顶部栏 ===== */
header.flex.justify-between {
    background-color: #1a1410 !important;
    border-bottom: 1px solid #5a4a3a !important;
}
#nav-middle button:has(> .flex-1.truncate.text-left) .flex-1.truncate.text-left {
    color: #c9a84c !important;
    letter-spacing: 0.06em !important;
}
#nav-right button { color: #b0a090 !important; transition: color 0.3s ease !important; }
#nav-right button:hover { color: #e8c84c !important; }
header.flex.justify-between.w-full.top-0 svg { color: #b0a090 !important; transition: color 0.3s ease !important; }
header.flex.justify-between.w-full.top-0 svg:hover { color: #e8c84c !important; }

/* ===== 玩家气泡 ===== */
.is-user > .border.border-muted {
    background: rgba(58, 42, 24, 0.9) !important;
    border-radius: 8px !important;
    color: #f0e6d0 !important;
    font-size: 0.95rem !important;
    line-height: 1.75 !important;
    padding: 14px 18px !important;
}
.is-user > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 10% !important;
    height: 80% !important;
    width: 3px !important;
    background: #c9a84c !important;
    border-radius: 2px !important;
}

/* ===== AI气泡 ===== */
.is-assistant > .border.border-muted {
    background: rgba(28, 26, 38, 0.9) !important;
    border-radius: 8px !important;
    color: #e8e4f0 !important;
    font-size: 0.95rem !important;
    line-height: 1.75 !important;
    padding: 14px 18px !important;
}
.is-assistant > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    left: 0 !important;
    top: 10% !important;
    height: 80% !important;
    width: 3px !important;
    background: #6a7a8a !important;
    border-radius: 2px !important;
}

/* ===== 正文 ===== */
.rili-markdown-renderer {
    color: #d8cfb8 !important;
    font-weight: 400 !important;
    line-height: 1.75 !important;
}

/* ===== 系统消息 ===== */
.text-gray-500, .text-gray-400 {
    color: #8a7a6a !important;
    font-style: italic !important;
}

/* ===== details 折叠块 ===== */
details {
    background: rgba(40, 32, 24, 0.65) !important;
    border: 1px solid #5a4a3a !important;
    border-radius: 8px !important;
    margin: 6px 0 !important;
    padding: 10px 14px !important;
    transition: border-color 0.25s ease !important;
}
details:hover { border-color: #c9a84c !important; }
details[open] { border-color: #c9a84c !important; }
details summary {
    color: #c9a84c !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    user-select: none !important;
    list-style: none !important;
    letter-spacing: 0.04em !important;
}
details summary::-webkit-details-marker { display: none !important; }
details summary::before {
    content: '▶' !important;
    display: inline-block !important;
    margin-right: 6px !important;
    font-size: 0.65rem !important;
    color: #c9a84c !important;
    transition: transform 0.25s ease !important;
}
details[open] summary::before { transform: rotate(90deg) !important; }
details .rili-markdown-renderer,
details p, details li, details div {
    color: #b0a090 !important;
    font-size: 0.85rem !important;
    line-height: 1.7 !important;
    padding-top: 6px !important;
}

/* ===== 底部输入栏 ===== */
#ai-chat-bottom-input {
    background-color: #1e1812 !important;
    border: 1px solid #5a4a3a !important;
    border-radius: 8px !important;
    padding: 2px !important;
}
#ai-chat-input {
    color: #d9c8a0 !important;
    caret-color: #c9a84c !important;
}
#ai-chat-input::placeholder { color: #7a6b55 !important; }
#ai-chat-input:focus {
    border-color: #c9a84c !important;
    box-shadow: 0 0 0 1px rgba(201,168,76,0.3) !important;
}

/* ===== 底部按钮 ===== */
#ai-mod-button2 button.MuiButton-root {
    background-color: rgba(40, 32, 24, 0.7) !important;
    border: 1px solid #5a4a3a !important;
    color: #b0a090 !important;
    font-family: 'Noto Sans SC', sans-serif !important;
    border-radius: 6px !important;
    transition: all 0.25s ease !important;
}
#ai-mod-button2 button.MuiButton-root:hover {
    border-color: #c9a84c !important;
    color: #c9a84c !important;
    background-color: rgba(50, 40, 30, 0.8) !important;
}
#ai-mod-button2 button.MuiButton-root.Mui-selected,
#ai-mod-button2 button.MuiButton-containedPrimary {
    background-color: #c9a84c !important;
    border-color: #c9a84c !important;
    color: #1a1410 !important;
}
#ai-mod-button2 button.MuiButton-root:disabled {
    opacity: 0.35 !important;
    color: #7a6b55 !important;
}

/* ===== 分页栏 ===== */
.MuiPaginationItem-root {
    color: #7a6b55 !important;
    font-family: 'Noto Sans SC', sans-serif !important;
    border-radius: 4px !important;
    transition: all 0.25s ease !important;
}
.MuiPaginationItem-root.Mui-selected {
    background-color: #c9a84c !important;
    color: #1a1410 !important;
}
.MuiPaginationItem-root:hover:not(.Mui-selected) { color: #e8c84c !important; }

/* ===== 评论区 ===== */
div[class*="w-full"][class*="bg-white"][class*="bottom-0"] {
    background-color: rgba(30, 24, 18, 0.95) !important;
}
div.group.ml-0 {
    background: rgba(30, 24, 18, 0.6) !important;
    border-left: 3px solid #c9a84c !important;
    border-radius: 6px !important;
    padding: 10px 14px !important;
    margin-bottom: 6px !important;
    transition: border-color 0.25s ease !important;
}
div.group.ml-0:hover { border-left-color: #e8c84c !important; }
div.text-sm.text-grey-600 span.font-bold {
    color: #c9a84c !important;
    font-size: 0.85rem !important;
    letter-spacing: 0.04em !important;
}
div.text-xs.text-grey-600 {
    color: #7a6b55 !important;
    font-size: 0.72rem !important;
}
div.break-all {
    color: #b0a090 !important;
    line-height: 1.6 !important;
}
span.cursor-pointer {
    color: #7a6b55 !important;
    transition: color 0.25s ease !important;
}
span.cursor-pointer:hover { color: #c9a84c !important; }
div.style_divider__mW0YX { background-color: #3a2a1a !important; }
textarea.rc-textarea {
    background-color: #1e1812 !important;
    color: #d9c8a0 !important;
    border: 1px solid #5a4a3a !important;
    border-radius: 6px !important;
    caret-color: #c9a84c !important;
}
textarea.rc-textarea::placeholder { color: #7a6b55 !important; }
textarea.rc-textarea:focus {
    border-color: #c9a84c !important;
    box-shadow: 0 0 0 1px rgba(201,168,76,0.3) !important;
}

/* ===== MUI 兜底 ===== */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{ color: #c9a84c !important; }
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground { color: #d4c8b0 !important; opacity: 0.7 !important; }
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 { color: #c9a84c !important; opacity: 0.8 !important; }
*/

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px !important; }
::-webkit-scrollbar-track { background: transparent !important; }
::-webkit-scrollbar-thumb { background: #5a4a3a !important; border-radius: 3px !important; }
::-webkit-scrollbar-thumb:hover { background: #c9a84c !important; }

/* ===== 选中文字 ===== */
::selection { background: rgba(201,168,76,0.25) !important; color: #f0e6d0 !important; }