/* ═══ 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平台按钮组保护（自动注入）═══ */
.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;
}
.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;
}

/* ═══════════════════════════════════════════
   伪人城市生存终端 · 全页面暗色优化
   ═══════════════════════════════════════════ */

/* —— 页面基底 —— */
html, body, #root, .app-root, .h-screen {
  background: #111318 !important;
  color: #e0e0e6 !important;
}

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

/* 选择 + 占位 */
::selection { background: rgba(74,144,226,0.25) !important; color: #fff !important; }
::placeholder { color: #5c5f6e !important; opacity: 0.6; }

/* 滚动条 */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent !important; }
::-webkit-scrollbar-thumb { background: rgba(74,144,226,0.25) !important; border-radius: 3px; }

/* —— 顶部导航 —— */
.sticky.w-full.top-0.flex.items-center,
header.sticky,
nav.sticky {
  background: rgba(17,19,24,0.88) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}

/* 导航内文字 */
.sticky.w-full.top-0.flex.items-center *,
header.sticky * {
  color: #e0e0e6 !important;
}

/* —— 侧边栏 —— */
.border-r {
  background: #161820 !important;
  border-color: rgba(255,255,255,0.06) !important;
}
.border-r * { color: #e0e0e6 !important; }
.border-r .text-muted-foreground,
.border-r .text-gray-500,
.border-r [class*="text-muted"] { color: #8a8d9a !important; }

/* —— 聊天消息行 —— */
.w-full.h-full.flex.group,
.flex.w-full.items-center.justify-between.gap-2.px-2 {
  background: transparent !important;
}

/* —— 聊天气泡 —— */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: rgba(20, 22, 28, 0.94) !important;
    border: 1px solid rgba(80, 85, 100, 0.2) !important;
    border-radius: 16px !important;
    padding: 16px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
    margin-bottom: 8px !important;
}

/* —— Markdown 正文 —— */
.rili-markdown-renderer {
    color: #e0e0e6 !important;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto, sans-serif !important;
    font-weight: 400 !important;
    line-height: 1.75 !important;
    background: transparent !important;
}
.rili-markdown-renderer h1,
.rili-markdown-renderer h2,
.rili-markdown-renderer h3 { color: #fff !important; }
.rili-markdown-renderer h4 { color: #8a8d9a !important; }
.rili-markdown-renderer strong { color: #fff !important; }
.rili-markdown-renderer em { color: #8a8d9a !important; }
.rili-markdown-renderer a { color: #4A90E2 !important; }
.rili-markdown-renderer a:hover { opacity: 0.8; }
.rili-markdown-renderer li::marker { color: #4A90E2; }
.rili-markdown-renderer p, .rili-markdown-renderer li,
.rili-markdown-renderer span, .rili-markdown-renderer div { color: #e0e0e6 !important; }

.rili-markdown-renderer blockquote {
    border-left: 3px solid #4A90E2 !important;
    background: rgba(74,144,226,0.05) !important;
    color: #8a8d9a !important;
    padding: 10px 16px !important;
    margin: 12px 0 !important;
    border-radius: 0 6px 6px 0 !important;
}
.rili-markdown-renderer hr {
    height: 1px !important; border: none !important;
    background: rgba(74,144,226,0.12) !important;
    margin: 20px 0 !important;
}
.rili-markdown-renderer :not(pre) > code {
    background: rgba(74,144,226,0.12) !important;
    color: #4A90E2 !important;
    padding: 0.15em 0.5em; border-radius: 3px;
}
.rili-markdown-renderer pre {
    background: #14161b !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    border-left: 3px solid #4A90E2 !important;
    border-radius: 6px !important;
    padding: 1em 1.2em !important;
}
.rili-markdown-renderer pre code {
    background: transparent !important;
    color: #cdd1da !important;
    font-size: 0.87em;
}
.rili-markdown-renderer table {
    border-collapse: separate; border-spacing: 0;
    border-radius: 6px; overflow: hidden; width: 100%; margin: 12px 0;
}
.rili-markdown-renderer th, .rili-markdown-renderer td {
    border: 1px solid rgba(255,255,255,0.06) !important;
    padding: 8px 14px;
}
.rili-markdown-renderer th {
    background: rgba(74,144,226,0.08) !important;
    color: #4A90E2 !important; font-weight: 600;
}
.rili-markdown-renderer td { color: #e0e0e6 !important; }
.rili-markdown-renderer tr:nth-child(even) td { background: rgba(255,255,255,0.012); }
.rili-markdown-renderer tr:hover td { background: rgba(74,144,226,0.04); }

/* —— 底部输入区 —— */
#ai-chat-input,
textarea.rc-textarea,
[class*="chat-input"],
input[type="text"][class*="input"],
div:has(> textarea) textarea {
  background: #1b1d24 !important;
  color: #e0e0e6 !important;
  caret-color: #4A90E2 !important;
  border: 1px solid rgba(255,255,255,0.07) !important;
  border-radius: 10px !important;
  padding: 12px 16px !important;
  font-size: 0.94em;
}
#ai-chat-input:focus,
textarea:focus {
  border-color: rgba(74,144,226,0.35) !important;
  outline: none !important;
}

/* 发送按钮 */
#ai-send-button,
button:has(svg[data-icon="Send"]),
button[aria-label*="发送"],
button[aria-label*="send"] {
  background: #4A90E2 !important;
  color: #fff !important;
  border-radius: 8px !important;
}

/* 底部区域背景 */
.bg-gradient-to-t,
[class*="bg-gradient-to-t"] {
  background: linear-gradient(to top, #111318, transparent 85%) !important;
}

/* —— 积分/Token —— */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7 {
    color: #e0e0e6 !important;
    background: rgba(255,255,255,0.04) !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.08) !important;
}
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #8a8d9a !important;
    font-weight: 500 !important;
}
.text-orange-500 {
    color: #f59e0b !important;
    font-weight: 600 !important;
}
.flex.items-center.gap-1:has(.text-orange-500),
.flex.items-center.gap-2:has(.text-xs.font-mono) {
    display: flex !important; visibility: visible !important; opacity: 1 !important;
}

/* —— 头像 —— */
.rounded-full {
  border-color: rgba(74,144,226,0.3) !important;
}

/* —— 对话框/抽屉 —— */
[role="dialog"],
[role="drawer"],
.MuiDialog-paper,
.MuiDrawer-paper {
  background: #161820 !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
  color: #e0e0e6 !important;
}
[role="dialog"] *,
[role="drawer"] * { color: #e0e0e6 !important; }
.MuiBackdrop-root { background: rgba(0,0,0,0.55) !important; }

/* —— 全局按钮 —— */
button[class*="primary"],
.MuiButton-containedPrimary {
  background: #4A90E2 !important;
  color: #fff !important;
  border-radius: 8px !important;
}

/* —— 加载动画 —— */
.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;
}
.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="%234A90E2"><animate attributeName="opacity" values="1;0.3;1" dur="1s" repeatCount="indefinite"/></circle><circle cx="20" cy="5" r="3" fill="%234A90E2"><animate attributeName="opacity" values="1;0.3;1" dur="1s" begin="0.2s" repeatCount="indefinite"/></circle><circle cx="35" cy="5" r="3" fill="%234A90E2"><animate attributeName="opacity" values="1;0.3;1" dur="1s" begin="0.4s" repeatCount="indefinite"/></circle></svg>') !important;
}

/* —— 折叠块 —— */
details {
    background: rgba(22, 25, 32, 0.92) !important;
    border: 1px solid rgba(90, 96, 115, 0.2) !important;
    border-radius: 14px !important;
    margin: 14px 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
}
details[open] {
    border-color: rgba(74,144,226,0.35) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}
summary {
    list-style: none !important;
    cursor: pointer !important;
    padding: 12px 16px !important;
    font-size: 0.93rem !important;
    font-weight: 600 !important;
    color: #8a8d9a !important;
    background: #1b1d24 !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    user-select: none !important;
}
summary:hover { color: #fff !important; background: #1f2129 !important; }
summary::-webkit-details-marker { display: none !important; }
summary::marker { content: none !important; }
summary::before {
    content: "▶" !important;
    display: inline-block !important;
    font-size: 0.55rem !important;
    color: #5c5f6e !important;
}
details[open] > summary { color: #4A90E2 !important; border-bottom-color: rgba(255,255,255,0.08) !important; }
details[open] > summary::before { transform: rotate(90deg) !important; color: #4A90E2 !important; }
details > *:not(summary) {
    padding: 14px 16px !important;
    color: #e0e0e6 !important;
    line-height: 1.7 !important;
}
details details {
    margin: 8px 0 0 0 !important;
    border-radius: 10px !important;
    background: rgba(18,20,26,0.5) !important;
    border-color: rgba(255,255,255,0.04) !important;
}
details details summary {
    font-size: 0.88rem !important;
    padding: 10px 14px !important;
    color: #8a8d9a !important;
    background: rgba(18,20,26,0.6) !important;
}
details details[open] > summary { color: #4A90E2 !important; }

/* —— 响应式 —— */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
    .is-assistant > .border.border-muted {
        border-radius: 12px !important; padding: 12px !important;
    }
    summary { padding: 10px 14px !important; font-size: 0.9rem !important; }
    details > *:not(summary) { padding: 12px 14px !important; }
}