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

/* ===== 聊天框美化：深色高对比度清晰阅读主题 ===== */

/* --- 统一聊天框 (输入与输出) --- */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #1e1e1e !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    transition: all 0.3s ease !important;
    border: 1px solid #333333 !important;
}

/* --- 聊天框内主文本 --- */
.rili-markdown-renderer {
    color: #FFFFFF !important;
    font-weight: 500 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji" !important;
    font-size: 15px !important;
    line-height: 1.7 !important;
    letter-spacing: 0.2px !important;
    /* 严禁任何 text-shadow，确保字体无光晕 */
    text-shadow: none !important;
}

/* --- 聊天框底部操作按钮 (复制、编辑、删除等) --- */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #EAEAEA !important;
    transition: color 0.2s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #FFFFFF !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

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

/* --- Token 消耗文本 (原本为橙色，这里改为暖白以确保可读) --- */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #FFD8A8 !important;  /* 保留一丝暖调的浅橙色，但在深色背景上十分清晰 */
    font-weight: 400 !important;
}
*/

/* --- 链接文本 (深色模式下需确保可见) --- */
.rili-markdown-renderer a {
    color: #7CB9FF !important;  /* 柔和亮蓝，与白底区分 */
}

/* --- 代码块与行内代码 (深色适配) --- */
.rili-markdown-renderer code,
.rili-markdown-renderer pre {
    background-color: #2d2d2d !important;
    color: #F0F0F0 !important;
    border-radius: 4px !important;
}

/* --- 可选的微调：若聊天框内有分隔线 --- */
.rili-markdown-renderer hr {
    border-color: #444 !important;
}

/* --- 移动端适配：保持可读性 --- */
@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: 8px !important;
    }
}
/* ========== 核心变量与基础重置 ========== */
ai {
  --bg: #1a1a24;
  --surface: #252533;
  --glass: rgba(30, 26, 58, 0.75);
  --text: #e0e0f0;
  --text-dim: #a8a8c0;
  --gold: #d4a574;
  --rose: #c7788b;
  --purple: #7e6eb5;
  --blue: #5a7ea0;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.4);

  display: block;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 12px;
  box-shadow: inset 0 0 100px rgba(0,0,0,0.5);
  max-width: 100%;
  box-sizing: border-box;
}

/* ========== 通用卡片样式 ========== */
d {
  display: block;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: all 0.25s ease;
}

d:hover {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 6px 18px rgba(0,0,0,0.5), 0 0 20px rgba(212, 167, 116, 0.1);
}

/* ========== 环境信息 ========== */
.env {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(30,26,58,0.9), rgba(20,18,40,0.9));
  border: 1px solid rgba(212, 167, 116, 0.3);
  text-align: center;
  font-size: 15px;
}
.env t {
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

/* ========== 主角状态 ========== */
.pc-status {
  background: linear-gradient(135deg, rgba(37, 37, 51, 0.8), rgba(45, 45, 65, 0.8));
  border-left: 4px solid var(--gold);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  position: relative;
  overflow: hidden;
}
.pc-status::before {
  content: "📋";
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 28px;
  opacity: 0.15;
}
.pc-status f {
  font-weight: 700;
  color: #fff;
  font-size: 15px;
}
.pc-status q {
  display: block;
  color: var(--rose);
  font-style: italic;
  font-size: 13px;
  margin: 2px 0 0 4px;
  border-left: 2px solid rgba(199, 120, 139, 0.4);
  padding-left: 8px;
}
.pc-status i {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  grid-column: span 2;
}

/* ========== 角色卡片 ========== */
.char {
  position: relative;
  overflow: hidden;
}
.char t {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.char t::before {
  content: "🔹";
  margin-right: 6px;
  color: var(--gold);
}

/* 表面 */
.surface {
  color: var(--text);
  margin-bottom: 6px;
  padding-left: 8px;
  border-left: 3px solid rgba(255,255,255,0.25);
}

/* 真心 - 核心视觉设计 */
.truth {
  background: rgba(212, 167, 116, 0.05);
  border-radius: 8px;
  padding: 10px 12px 10px 16px;
  margin-left: 4px;
  position: relative;
  border: 1px dashed rgba(212, 167, 116, 0.25);
  border-left: 4px solid var(--rose);
}
.truth::before {
  content: "💭 真心";
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--rose);
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.truth q {
  display: block;
  font-style: italic;
  color: var(--gold);
  margin: 4px 0;
  padding-left: 10px;
  border-left: 2px solid rgba(212, 167, 116, 0.5);
  font-size: 14px;
}
.truth q::before {
  content: "“";
  color: var(--rose);
}
.truth q::after {
  content: "”";
  color: var(--rose);
}
.truth s {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.05);
}

/* ========== 行动推荐 ========== */
.actions {
  background: linear-gradient(135deg, rgba(37, 37, 51, 0.7), rgba(25, 25, 45, 0.7));
  border: 1px solid rgba(126, 110, 181, 0.4);
}
.actions t {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 8px;
}
.actions ol {
  margin: 0;
  padding: 0 0 0 20px;
  list-style: none;
  counter-reset: action;
}
.actions li {
  counter-increment: action;
  position: relative;
  padding: 6px 0 6px 28px;
  margin: 4px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  color: var(--text-dim);
}
.actions li:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.actions li::before {
  content: "[" counter(action) "]";
  position: absolute;
  left: 0;
  font-weight: 700;
  color: var(--purple);
  font-size: 13px;
}

/* ========== 社交动态 ========== */
.social t {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(90, 126, 160, 0.3);
}
.social f {
  display: block;
  font-weight: 700;
  color: var(--gold);
  font-size: 13px;
  margin: 8px 0 4px;
}
.social d {
  background: rgba(0,0,0,0.15);
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  padding: 8px;
  margin-bottom: 6px;
  border-left: 3px solid rgba(90, 126, 160, 0.4);
}
.social d:hover {
  background: rgba(255,255,255,0.03);
  box-shadow: none;
  border-left-color: var(--blue);
}

.group-chat, .private-chat, .school, .work {
  margin-bottom: 12px;
}

b {
  color: #fff;
  font-weight: 600;
}

/* ========== 记忆区 ========== */
.memory t {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 8px;
}
.ltm, .stm {
  margin-bottom: 8px;
}
.ltm f, .stm f {
  display: block;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 4px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  overflow: hidden;
}
th {
  background: rgba(126, 110, 181, 0.3);
  color: #fff;
  font-weight: 600;
  padding: 6px 8px;
  text-align: left;
  font-size: 12px;
}
td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-dim);
}
tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* ========== 滚动条与移动端优化 ========== */
@media (max-width: 600px) {
  ai {
    padding: 10px;
    font-size: 13px;
  }
  d {
    padding: 8px;
  }
  .pc-status {
    grid-template-columns: 1fr;
  }
  .pc-status i {
    grid-column: span 1;
  }
  .env {
    font-size: 13px;
    gap: 6px;
  }
}