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

/* ============================================
   慕容依 · 乌鸦与白玫瑰 — 纯爱聊天框美化
   设计核心：暗夜紫调 + 暖白文字，绝对可读
   ============================================ */

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

/* --- 2. 统一聊天框基底 --- */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    border-radius: 12px !important;
    box-shadow: 0 2px 16px rgba(30, 20, 36, 0.35) !important;
    transition: box-shadow 0.3s ease !important;
}

/* --- 3. 输出框（慕容依的回复）--- */
.is-assistant > .border.border-muted {
    background: linear-gradient(160deg, #1c1822 0%, #1f1a24 60%, #1a1620 100%) !important;
    border-left: 3px solid #5a3d5c !important;
    box-shadow: 0 2px 20px rgba(90, 61, 92, 0.25), 0 1px 4px rgba(0, 0, 0, 0.3) !important;
}

/* --- 4. 输入框（用户消息）--- */
.is-user > .border.border-muted {
    background: linear-gradient(160deg, #221f28 0%, #25222c 60%, #1f1c24 100%) !important;
    border-right: 3px solid #4a4448 !important;
    box-shadow: 0 2px 16px rgba(25, 22, 30, 0.4), 0 1px 3px rgba(0, 0, 0, 0.25) !important;
}

/* --- 5. 聊天框内主文本（强制高对比度暖白）--- */
.rili-markdown-renderer {
    color: #efe8e3 !important;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif !important;
    font-size: 15px !important;
    line-height: 1.7 !important;
    letter-spacing: 0.02em !important;
    background: transparent !important;
    z-index: 1 !important;
}

/* 加粗文本更亮 */
.rili-markdown-renderer strong,
.rili-markdown-renderer b {
    color: #f8f2ed !important;
    font-weight: 700 !important;
}

/* 链接颜色 */
.rili-markdown-renderer a {
    color: #c9a9d4 !important;
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
}

.rili-markdown-renderer a:hover {
    color: #e0c8e8 !important;
}

/* 引用块 */
.rili-markdown-renderer blockquote {
    border-left: 3px solid #5a3d5c !important;
    background: rgba(90, 61, 92, 0.12) !important;
    color: #d8cfc8 !important;
    padding: 8px 14px !important;
    border-radius: 0 8px 8px 0 !important;
    margin: 10px 0 !important;
}

/* 代码块 */
.rili-markdown-renderer code {
    background: rgba(30, 22, 34, 0.7) !important;
    color: #e8dcc8 !important;
    padding: 2px 7px !important;
    border-radius: 4px !important;
    font-size: 0.9em !important;
    border: 1px solid rgba(90, 61, 92, 0.3) !important;
}

.rili-markdown-renderer pre {
    background: #16131a !important;
    border: 1px solid #3d3348 !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
}

.rili-markdown-renderer pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: #e8dcc8 !important;
}

/* 列表标记 */
.rili-markdown-renderer ul,
.rili-markdown-renderer ol {
    color: #efe8e3 !important;
}

.rili-markdown-renderer li::marker {
    color: #9a7fa5 !important;
}

/* 表格 */
.rili-markdown-renderer table {
    border-color: #3d3348 !important;
}

.rili-markdown-renderer th {
    background: rgba(90, 61, 92, 0.2) !important;
    color: #f0e9e4 !important;
    border-color: #4a3a52 !important;
}

.rili-markdown-renderer td {
    border-color: #3d3348 !important;
    color: #e6ddd6 !important;
}

/* 分割线 */
.rili-markdown-renderer hr {
    border-color: #3d3348 !important;
}

/* --- 6. 底部附加元素适配深色背景 --- */

/* 底部操作按钮（复制、编辑、删除等） */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #d0c8c0 !important;
    transition: color 0.2s ease !important;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #f0e8e0 !important;
    background: rgba(90, 61, 92, 0.2) !important;
}

/* 模型名称文本 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #c8bdb3 !important;
}

/* Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #d4b896 !important;
}
*/

/* --- 7. 输入框内的文字（确保输入时文字可见）--- */
textarea,
input[type="text"] {
    color: #efe8e3 !important;
    caret-color: #c9a9d4 !important;
}

/* --- 8. 移动端适配 --- */
@media (max-width: 480px) {
    .rili-markdown-renderer {
        font-size: 14px !important;
        line-height: 1.65 !important;
    }

    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        border-radius: 10px !important;
        box-shadow: 0 1px 10px rgba(30, 20, 36, 0.3) !important;
    }

    .is-assistant > .border.border-muted {
        border-left-width: 2px !important;
    }

    .is-user > .border.border-muted {
        border-right-width: 2px !important;
    }
}

/* --- 9. 减少动效偏好 --- */
@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        transition: none !important;
    }
}
/* === 慕容依·情感追踪档案 — 完整CSS === */
/* 使用说明：将此代码粘贴至平台的“内置CSS”区域 */
/* 基于容器<ai>隔离，不污染全局 */

/* ---------- 变量与基础 ---------- */
ai {
  display: block;
  position: relative;
  padding: 0;
  margin: 0;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #3a3a3a;
  background: #faf8f5;
  border-radius: 0;
  --gold: #c9a96e;
  --rose: #8b3a3a;
  --deeprose: #5c1e1e;
  --sage: #7a8b7a;
  --ivory: #f5f0e8;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
}

/* ---------- 呼吸光晕背景 (SMIL) ---------- */
ai::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(201,169,110,0.04) 0%, transparent 70%);
  opacity: 0;
  animation: breathe 7s ease-in-out infinite;
}
@keyframes breathe {
  0%,100% { opacity: 0; }
  50% { opacity: 0.6; }
}

/* ---------- 通用细节/摘要 ---------- */
ai details {
  margin: 6px 0;
  border: none;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
ai details:hover {
  box-shadow: var(--shadow-hover);
}
ai details[open] {
  background: #fff;
  border-left: 3px solid var(--rose);
}
ai summary {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 14px;
  color: #444;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(to right, #fdfbf7, #fff);
  border-bottom: 1px solid transparent;
}
ai details[open] summary {
  border-bottom: 1px solid #f0ece5;
  color: var(--rose);
}
ai summary::marker { display: none; content: ""; }
ai summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.2s;
  font-size: 12px;
  color: var(--sage);
}
ai details[open] summary::before {
  transform: rotate(90deg);
  color: var(--rose);
}

/* ---------- 头部信息 ---------- */
ai header {
  padding: 6px 12px;
  margin: 0 0 10px 0;
  background: linear-gradient(135deg, #f9f6f0, #f3efe7);
  border-radius: 6px;
  font-size: 13px;
  color: #6b6b6b;
}
ai header t {
  display: block;
  font-size: 13px;
}

/* ---------- 正文段落 ---------- */
ai article p {
  margin: 0 0 8px 0;
  text-indent: 0;
}

/* ---------- 信息条目（通用键值对） ---------- */
ai d {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 5px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f5f2ed;
}
ai d:last-child {
  border-bottom: none;
}
ai d l {
  display: inline-block;
  min-width: 80px;
  font-weight: 600;
  color: #5a5a5a;
  margin-right: 8px;
  font-size: 13px;
}
ai d l::after {
  content: "：";
}

/* ---------- 数值条（病娇面板） ---------- */
ai [c="gauge"] {
  padding: 8px 12px;
  background: #fdfbf8;
  border-bottom: 1px solid #f0ece5;
}
ai [c="gauge"] row {
  display: flex;
  align-items: center;
  margin: 6px 0;
  font-size: 13px;
}
ai [c="gauge"] label {
  width: 80px;
  flex-shrink: 0;
  font-weight: 600;
  color: #5a5a5a;
  font-size: 12px;
}
ai [c="gauge"] bar {
  flex: 1;
  height: 6px;
  background: #e9e4db;
  border-radius: 6px;
  margin: 0 10px;
  overflow: hidden;
  position: relative;
}
ai [c="gauge"] bar f {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--gold), #e6d5a8);
  transition: width 1.2s ease-out;
}
ai [c="gauge"] bar f[t="yd"] {
  background: linear-gradient(90deg, var(--rose), #a14d4d);
}
ai [c="gauge"] bar f[t="pr"] {
  background: linear-gradient(90deg, #9b8e7e, var(--rose));
}
ai [c="gauge"] v {
  width: 60px;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
  color: var(--rose);
  text-align: right;
}
ai [c="gauge"] row:first-child v {
  color: var(--gold);
}

/* ---------- 情绪网格 ---------- */
ai [c="emotion"] {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 12px;
  background: #f9f7f3;
  border-bottom: 1px solid #f0ece5;
}
ai [c="emotion"] item {
  background: #fff;
  border-radius: 6px;
  padding: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
ai [c="emotion"] icon {
  font-size: 14px;
  margin-right: 2px;
}
ai [c="emotion"] l {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #777;
  margin-bottom: 2px;
}
ai [c="emotion"] v {
  font-size: 12px;
  color: #4a4a4a;
}

/* ---------- 行为日志 ---------- */
ai [c="log"] {
  padding: 8px 12px;
  background: #fff;
}
ai [c="log"] t {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--rose);
  margin-bottom: 4px;
  border-left: 3px solid var(--rose);
  padding-left: 8px;
}
ai [c="log"] row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed #f0ece5;
}
ai [c="log"] row:last-child { border-bottom: none; }
ai [c="log"] d { border: none; padding: 0; flex: 1; }
ai [c="log"] v { font-weight: 600; color: #5a5a5a; }

/* ---------- 警告/偏差 ---------- */
ai d[c="warn"] {
  margin: 6px 12px;
  padding: 6px 10px;
  background: #fdf3f3;
  border-left: 3px solid var(--rose);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #7a3a3a;
}
ai d[c="deviation"] {
  margin: 6px 12px;
  font-size: 12px;
  color: var(--sage);
}

/* ---------- 里程碑表格 ---------- */
ai [c="milestone"] {
  padding: 8px 10px;
}
ai [c="milestone"] t {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--rose);
}
ai [c="milestone"] table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
ai [c="milestone"] th {
  background: #f5f0e8;
  padding: 6px 4px;
  text-align: left;
  font-weight: 600;
  color: #5a5a5a;
}
ai [c="milestone"] td {
  padding: 6px 4px;
  border-bottom: 1px solid #f5f2ed;
  vertical-align: top;
}

/* 时间线垂直装饰（里程碑内部可选用） */
ai [c="milestone"] line {
  display: flex;
  margin: 8px 0;
  border-left: 2px dashed var(--sage);
  padding-left: 14px;
  position: relative;
}
ai [c="milestone"] dot {
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  background: var(--rose);
  transform: rotate(45deg);
}
ai [c="milestone"] note {
  display: block;
  font-size: 12px;
}
ai [c="milestone"] date {
  font-weight: 600;
  color: var(--sage);
  display: block;
}
ai [c="milestone"] ev {
  color: #3a3a3a;
  font-weight: 600;
}
ai [c="milestone"] q {
  display: block;
  font-style: italic;
  color: #6b6b6b;
  margin-top: 2px;
}

/* ---------- 本月互动、秘密记录 ---------- */
ai [c="monthly"], ai [c="secret"] {
  padding: 8px 12px;
  border-top: 1px solid #f0ece5;
}
ai [c="monthly"] t, ai [c="secret"] t {
  font-weight: 700;
  font-size: 13px;
  color: var(--sage);
  display: block;
  margin-bottom: 4px;
}

/* ---------- 任务板 ---------- */
ai [c="mainquest"] {
  padding: 10px 12px;
  background: linear-gradient(135deg, #fefcf9, #fcf7f1);
  border-bottom: 1px solid #f0ece5;
}
ai [c="mainquest"] t {
  font-weight: 700;
  font-size: 14px;
  color: var(--rose);
}
ai [c="sidequest"] {
  padding: 8px 12px;
}
ai [c="sidequest"] t {
  font-weight: 700;
  font-size: 14px;
  color: #5a5a5a;
  margin-bottom: 8px;
  display: block;
}
ai qst {
  display: block;
  margin: 10px 0;
  padding: 8px 10px;
  background: #fdfbf8;
  border-radius: 6px;
  border-left: 2px solid var(--gold);
}
ai qst t {
  font-size: 13px;
  font-weight: 700;
  color: #4a4a4a;
  display: block;
  margin-bottom: 2px;
}
ai qst p {
  font-size: 12px;
  color: #5a5a5a;
  margin: 4px 0;
}
ai qst d {
  font-size: 11px;
  color: var(--sage);
  border: none;
  padding: 0;
}

/* 每日循环 */
ai [c="daily"] {
  padding: 8px 12px;
  background: #f5f2ed;
  border-radius: 0 0 8px 8px;
}
ai [c="daily"] t {
  font-weight: 700;
  font-size: 13px;
  color: #5a5a5a;
  display: block;
  margin-bottom: 4px;
}
ai [c="daily"] d {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  font-size: 11px;
  border: none;
  color: #5a5a5a;
}

/* ---------- 日记/内心独白 ---------- */
ai [c="diary"] {
  padding: 8px 12px;
}
ai [c="diary"] t {
  display: block;
  font-weight: 700;
  color: var(--rose);
  margin-bottom: 4px;
}
ai blockquote {
  background: #fdfbf8;
  border-left: 3px solid var(--gold);
  margin: 8px 0;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 0 4px 4px 0;
}
ai blockquote p {
  margin: 4px 0;
  color: #4a4a4a;
}
ai blockquote cite {
  display: block;
  text-align: right;
  font-style: italic;
  color: var(--sage);
  margin-top: 4px;
}
ai d[c="replay"], ai d[c="unsaid"], ai d[c="imagery"] {
  margin: 4px 12px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  background: #f9f7f3;
  border: none;
}
ai d[c="unsaid"] { color: var(--rose); }
ai d[c="imagery"] { color: var(--sage); }

/* ---------- 手机通讯 ---------- */
ai [c="chat"], ai [c="secretaccount"], ai [c="album"] {
  padding: 8px 12px;
  border-top: 1px solid #f0ece5;
}
ai [c="chat"] t, ai [c="secretaccount"] t, ai [c="album"] t {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: var(--sage);
  margin-bottom: 4px;
}

/* ---------- 装备与物品 ---------- */
ai [c="eq"], ai [c="eqspecial"], ai [c="relic"] {
  padding: 8px 12px;
}
ai [c="eq"] t, ai [c="eqspecial"] t, ai [c="relic"] t {
  display: block;
  font-weight: 700;
  font-size: 13px;
  color: #5a5a5a;
  margin-bottom: 4px;
}
ai [c="eqspecial"] {
  background: #fefdfa;
  border-left: 2px solid #e6d5a8;
}
ai [c="relic"] d {
  align-items: flex-start;
}

/* ---------- 记忆区表格 ---------- */
ai [c="ltm"], ai [c="stm"] {
  padding: 8px 10px;
  overflow-x: auto;
}
ai [c="ltm"] t, ai [c="stm"] t {
  font-weight: 700;
  font-size: 13px;
  color: var(--sage);
  display: block;
  margin-bottom: 4px;
}
ai [c="ltm"] table, ai [c="stm"] table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
ai [c="ltm"] th, ai [c="stm"] th {
  background: #f5f0e8;
  padding: 4px 6px;
  text-align: left;
  font-weight: 600;
  color: #5a5a5a;
}
ai [c="ltm"] td, ai [c="stm"] td {
  padding: 4px 6px;
  border-bottom: 1px solid #f5f2ed;
}

/* ---------- 行动推荐 ---------- */
ai details:last-of-type d[n] {
  padding: 6px 12px;
  font-size: 13px;
  position: relative;
  border-bottom: 1px solid #f5f2ed;
  transition: background 0.2s, padding-left 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
ai details:last-of-type d[n]::before {
  content: attr(n);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e9e4db;
  color: #777;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
ai details:last-of-type d[n]:hover {
  background: #fdfbf8;
  padding-left: 16px;
}
ai details:last-of-type d[n]:hover::before {
  background: var(--gold);
  color: #fff;
}

/* ---------- 小剧场 ---------- */
ai [c="theatre"] {
  padding: 8px 12px;
  background: linear-gradient(135deg, #fcf9f5, #f8f4ec);
  border-radius: 6px;
  margin: 4px 0;
}

/* ---------- 响应式微调 ---------- */
@media (max-width: 600px) {
  ai { font-size: 13px; }
  ai d { flex-direction: column; }
  ai d l { margin-bottom: 2px; }
  ai [c="emotion"] {
    grid-template-columns: 1fr;
  }
  ai [c="gauge"] label {
    width: 65px;
  }
}