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

/* ========================================================== */
/* 【渴望都市·等价交换】—— 囚于里侧的残稿  */
/* Absolute Readability First & Forced Style Override          */
/* ========================================================== */

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

/* 2. 统一聊天框（输入与输出）背景与基础样式 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #1A1A24 !important; /* 暗灰底色，模拟里侧气氛 */
    border: 1px solid rgba(255, 255, 255, 0.05) !important; /* 极边缘微光 */
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important; /* 现代阴影 */
    border-radius: 12px !important; /* 现代圆角 */
    isolation: isolate !important; /* 为伪元素的背景动效建立层叠上下文 */
    position: relative !important;  /* 为伪元素定位 */
    overflow: hidden !important;    /* 让动效粒子不溢出圆角 */
}

/* 3. 单独的输入聊天框 */
.is-user > .border.border-muted {
    background: #0F0F15 !important; /* 更深的底色，与输出框区分 */
}

/* 4. 聊天框内主要文本内容——绝对可读性 */
.rili-markdown-renderer {
    color: #E0E0E0 !important; /* 高对比度浅灰 */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    font-weight: 400 !important;
    line-height: 1.7 !important;
    position: relative !important;
    z-index: 1 !important;
    background: transparent !important; /* 确保背景不覆盖伪元素 */
}

/* 5. 底部附加元素：按钮 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #B0B0B0 !important; /* 清晰易读且不刺眼 */
    font-family: inherit !important;
    font-size: 0.85rem !important;
    transition: color 0.2s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #FFFFFF !important;
}

/* 6. 底部附加元素：模型名称文本 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #A0A0A0 !important; /* 与按钮区分，略淡 */
    font-family: inherit !important;
    font-size: 0.8rem !important;
}

/* 7. 底部附加元素：Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #D4A855 !important; /* 暗金色，呼应“代价”的沉重 */
    font-family: inherit !important;
    font-weight: 500 !important;
}
*/

/* 8. 加载动画替换 —— 里侧微光 */
/* 8.1 隐藏默认的加载圆点 */
.flex.items-center.justify-center.size-6 > .flex.gap-2 {
    display: none !important;
}

/* 8.2 在加载容器中创建自定义动画 */
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 60px !important; /* 适当增大可视区域 */
    height: 20px !important;
}

/* 清除容器默认的子元素可能带来的干扰 */
.flex.items-center.justify-center.size-6 > * {
    display: none !important;
}

/* 使用伪元素创建悬浮微光(SMIL动画优先，CSP兼容) */
.flex.items-center.justify-center.size-6::before {
    content: '' !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 30'%3E%3Ccircle cx='20' cy='15' r='4' fill='%23D4A855' opacity='0.6'%3E%3Canimate attributeName='opacity' values='0.6;0.2;0.6' dur='2s' repeatCount='indefinite'/%3E%3Canimate attributeName='cy' values='15;10;15' dur='3s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='40' cy='15' r='3' fill='%23E0E0E0' opacity='0.4'%3E%3Canimate attributeName='opacity' values='0.4;0.1;0.4' dur='2.5s' repeatCount='indefinite' begin='0.5s'/%3E%3C/circle%3E%3Ccircle cx='60' cy='15' r='3.5' fill='%23D4A855' opacity='0.5'%3E%3Canimate attributeName='opacity' values='0.5;0.15;0.5' dur='1.8s' repeatCount='indefinite' begin='1s'/%3E%3Canimate attributeName='r' values='3.5;2;3.5' dur='2s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") no-repeat center center !important;
    background-size: contain !important;
    animation: none !important; /* 不以CSS动画为主，SMIL控制 */
}

/* 9. 背景动效 —— 用聊天框的伪元素实现里侧漂浮的碎片 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 0 !important;
    pointer-events: none !important;
    background: 
        radial-gradient(1px 1px at 10% 20%, rgba(212, 168, 85, 0.15) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 70%, rgba(255, 255, 255, 0.1) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 60% 40%, rgba(212, 168, 85, 0.2) 0%, transparent 100%),
        radial-gradient(1px 1px at 80% 90%, rgba(255, 255, 255, 0.05) 0%, transparent 100%),
        radial-gradient(2px 2px at 90% 15%, rgba(212, 168, 85, 0.1) 0%, transparent 100%);
    animation: none !important; /* 静默，不造成额外视觉干扰 */
}

/* 10. 移动端适配与低动效模式 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        border-radius: 8px !important;
    }
    .rili-markdown-renderer {
        font-size: 0.95rem !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flex.items-center.justify-center.size-6::before {
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 30'%3E%3Ccircle cx='20' cy='15' r='4' fill='%23D4A855' opacity='0.3'/%3E%3Ccircle cx='40' cy='15' r='3' fill='%23E0E0E0' opacity='0.2'/%3E%3Ccircle cx='60' cy='15' r='3.5' fill='%23D4A855' opacity='0.25'/%3E%3C/svg%3E") no-repeat center center !important;
        background-size: contain !important;
    }
    /* 背景碎片动效完全静止 */
}

/* 针对一些代码块或高亮的额外优化(确保可读性) */
.rili-markdown-renderer pre,
.rili-markdown-renderer code {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px !important;
    color: #E0E0E0 !important;
}
<ai> {
  /* --- 主题变量 --- */
  --bg-deep: #0a0a0a;
  --bg-card: #111111;
  --bg-card-alt: #1a1a1a;
  --border-green: #1e3a2e;
  --border-red: #3a1a1a;
  --text-pale: #c8c8c8;
  --text-dim: #6a6a6a;
  --text-accent: #8b2500;
  --text-green: #4a8c5c;
  --glow-red: rgba(139, 37, 0, 0.15);
  --glow-green: rgba(74, 140, 92, 0.1);
  --radius: 6px;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* 容器 */
ai {
  display: block;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-pale);
  background: var(--bg-deep);
  padding: 12px;
  max-width: 640px;
  margin: 0 auto;
}

/* 头部 */
hd {
  display: block;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
  border-left: 3px solid var(--border-green);
  border-radius: var(--radius);
  box-shadow: 0 0 12px var(--glow-green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* details 通用 */
details {
  margin: 8px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-green);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}
details:hover {
  border-color: #2a5a3a;
  box-shadow: 0 0 16px var(--glow-green);
}

/* summary 风格 */
summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-pale);
  background: linear-gradient(135deg, #141414, #1a1a1a);
  border-bottom: 1px solid transparent;
  transition: background 0.2s, color 0.2s;
  user-select: none;
  list-style: none;
  position: relative;
}
summary::-webkit-details-marker {
  display: none;
}
summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 8px;
  font-size: 10px;
  color: var(--text-green);
  transition: transform 0.3s ease;
}
details[open] summary::before {
  transform: rotate(90deg);
}
details[open] summary {
  background: linear-gradient(135deg, #1a1a1a, #222);
  border-bottom-color: var(--border-green);
}

/* details 内部内容区 */
details > *:not(summary) {
  padding: 10px 14px;
}

/* 嵌套 details */
details details {
  margin: 6px 0;
  border: 1px solid var(--border-red);
  background: var(--bg-card-alt);
}
details details summary {
  font-size: 12px;
  padding: 6px 10px;
  background: #1a0f0f;
  color: var(--text-accent);
}
details details summary::before {
  color: var(--text-accent);
}

/* 文本块 <p> */
p {
  margin: 4px 0;
  padding: 2px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
}

/* 字段名 <f> */
f {
  display: inline;
  font-weight: 400;
  color: var(--text-dim);
  min-width: 80px;
  flex-shrink: 0;
}

/* 字段值 <d> */
d {
  display: inline;
  font-weight: 300;
}

/* 带标记的段落左边框区分 */
p[t="identity"] { border-left: 3px solid #3a6a6a; padding-left: 6px; }
p[t="power"] { border-left: 3px solid var(--border-red); padding-left: 6px; }
p[t="appearance"] { border-left: 3px solid #2a3a3a; padding-left: 6px; }
p[t="possession"] { border-left: 3px solid #5a4a3a; padding-left: 6px; }
p[t="npc"] { border-left: 3px solid #6a3a6a; padding-left: 6px; }
p[t="npc-personality"] { border-left: 3px solid #4a4a6a; padding-left: 6px; }
p[t="goal"] { border-left: 3px solid var(--text-green); padding-left: 6px; }
p[t="desire"] { border-left: 3px solid var(--text-accent); padding-left: 6px; }
p[t="transaction-done"] { border-left: 3px solid #8a5a00; padding-left: 6px; }
p[t="transaction-offer"] { border-left: 3px solid #aa4400; padding-left: 6px; }
p[t="your-record"] { border-left: 3px solid #4a2a2a; padding-left: 6px; }

/* 物品列表 item */
item {
  display: block;
  padding: 1px 0 1px 12px;
  position: relative;
  font-size: 13px;
  color: var(--text-dim);
}
item::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-accent);
}

/* 行动推荐 <q> */
q {
  display: block;
  padding: 6px 10px;
  margin: 2px 0;
  background: rgba(0,0,0,0.3);
  border-left: 2px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  cursor: default;
  transition: background 0.2s, border-left-color 0.2s, transform 0.2s;
}
q:hover {
  background: rgba(255,255,255,0.04);
  border-left-color: var(--text-green);
  transform: translateX(4px);
}

/* 表格美化 */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
th {
  background: #1a2a1a;
  color: var(--text-dim);
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-green);
}
td {
  padding: 4px 6px;
  border-bottom: 1px solid #1a1a1a;
  vertical-align: top;
}
tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* 装饰性分隔线 */
details[open] > summary + * {
  animation: slideDown 0.25s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 移动端适配 */
@media (max-width: 480px) {
  ai { padding: 8px; font-size: 13px; }
  summary { font-size: 12px; padding: 8px 10px; }
  details > *:not(summary) { padding: 6px 10px; }
  f { min-width: 60px; }
  table { font-size: 11px; }
}

/* 高亮关键字 */
d:contains("代价"),
d:contains("警告"),
d:contains("已支付") {
  color: var(--text-accent);
  font-weight: 500;
}