/* ═══ 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. 背景与前景联动：统一设置浅色温馨背景，确保文字为高对比度深色 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFF6F0 100%) !important; /* 柔和的暖白到奶茶色渐变 */
    border: 1px solid rgba(255, 214, 186, 0.50) !important; /* 浅橘色极细边框，增加精致感 */
    border-radius: 18px !important; /* 更大的圆角，更可爱 */
    box-shadow: 0 4px 15px rgba(255, 183, 140, 0.15) !important; /* 暖色系的柔和阴影 */
    transition: box-shadow 0.2s ease !important; /* 悬停效果增加互动感 */
}
.is-user > .border.border-muted,
.is-assistant > .border.border-muted:hover {
    box-shadow: 0 6px 20px rgba(255, 183, 140, 0.25) !important; /* 悬停时阴影略加深 */
}
/* 2. 文本内容：高对比度深色字体，确保阅读舒适 */
.rili-markdown-renderer {
    color: #4A3728 !important; /* 温暖、醇厚的深咖啡色，比纯黑色更柔和 */
    font-size: 15px !important;
    line-height: 1.7 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif !important;
    background: transparent !important; /* 继承父级背景 */
}
/* 3. 移除顶部颜色装饰条 */
[class*="bg-[#F1CBCB]"], 
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}
/* 4. 底部操作按钮 - 统一设置为温暖柔和的深色，与背景呼应 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #A67C6B !important; /* 柔和的奶茶棕 */
    font-weight: 500 !important;
    font-size: 13px !important;
    letter-spacing: 0.3px !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #7A584A !important; /* 悬停时颜色加深，增加反馈感 */
    background-color: rgba(125, 90, 70, 0.08) !important; /* 非常淡的悬停背景色 */
}
/* 5. 模型名称文本 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #A67C6B !important; /* 与按钮颜色统一，保持整体感 */
    font-size: 12px !important;
    opacity: 0.9 !important;
}
/* 6. Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #D28B6E !important; /* 温暖的珊瑚橙，与整体暖色调融合，同时保持一定辨识度 */
    font-weight: 600 !important;
    font-size: 12px !important;
}
*/
/* 7. 针对输入框的特别调整：使其与输出框风格更统一 */
.is-user > .border.border-muted {
    background: #FFFAF7 !important; /* 输入框背景比输出框略微更亮白一点，以作区分 */
    border-style: dashed !important; /* 虚线边框，视觉上与输出框的实线边框区分 */
}
/* 8. 移动端适配：保证小屏幕下的可读性 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        border-radius: 14px !important;
    }
    .rili-markdown-renderer {
        font-size: 14px !important; /* 字体微调以适应小屏 */
    }
}
/* 移动端优先，主题暖色渐变，舒适阅读 */
ai {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  background: #fffaf5;
  color: #3a2e2a;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  font-size: 15px;
  box-sizing: border-box;
}
/* 标题栏 */
ai hd {
  display: block;
  padding: 6px 0 4px;
  font-size: 13px;
  color: #9b7b6b;
  letter-spacing: 0.5px;
  border-bottom: 1px dashed #e6d3c8;
  margin-bottom: 6px;
}
/* 正文文本 */
ai text p {
  margin: 0 0 6px;
  font-size: 15px;
  color: #3a2e2a;
}
/* 所有 details 信息卡片 */
ai details.info,
ai details.action {
  display: block;
  margin: 8px 0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(200, 160, 140, 0.15);
  overflow: hidden;
  transition: box-shadow 0.3s;
}
ai details.info:hover,
ai details.action:hover {
  box-shadow: 0 2px 8px rgba(200, 160, 140, 0.25);
}
/* summary 标题栏 – 渐变色下划线 */
ai details summary {
  display: block;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  color: #5e3f35;
  cursor: pointer;
  list-style: none;
  position: relative;
  background: linear-gradient(to right, #ffeae0, #fff4ed);
  transition: background 0.3s;
}
ai details summary::-webkit-details-marker {
  display: none;
}
ai details summary::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: 0;
  width: calc(100% - 28px);
  height: 2px;
  background: linear-gradient(90deg, #ffa5b0, #c471ed);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
ai details[open] summary::after {
  transform: scaleX(1);
}
ai details summary:hover {
  background: linear-gradient(to right, #ffddd0, #ffe8dc);
}
/* 内容区展开动画 */
ai details .info > *:not(summary),
ai details.action > *:not(summary) {
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 1000px; }
}
/* 内容区内边距 */
ai details[open] p,
ai details[open] ul,
ai details[open] ol,
ai details[open] table {
  margin: 4px 14px 10px;
}
/* 段落与列表 */
ai details p {
  margin: 4px 14px 6px;
  font-size: 14px;
  color: #3a2e2a;
}
ai details ul,
ai details ol {
  margin: 2px 14px 8px;
  padding-left: 20px;
}
ai details li {
  margin: 2px 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #3c302c;
}
/* 内联标签 f (字段名) 和 d (描述) */
ai f {
  font-weight: 600;
  color: #b55a3a;
  background: linear-gradient(135deg, #ffa5b0 0%, #c471ed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
ai d {
  font-weight: 500;
  color: #7a5a4a;
}
ai strong {
  color: #4a3228;
  font-weight: 700;
}
/* 表格 – 记忆区 */
ai table {
  width: calc(100% - 28px);
  margin: 6px auto 10px;
  border-collapse: collapse;
  font-size: 12px;
  background: #fcf6f0;
  border-radius: 6px;
  overflow: hidden;
}
ai th {
  background: #e6d3c8;
  color: #3a2e2a;
  padding: 4px 6px;
  font-weight: 600;
  text-align: left;
}
ai td {
  padding: 4px 6px;
  border-bottom: 1px solid #edd9cc;
}
ai tr:last-child td {
  border-bottom: none;
}
/* 行动推荐 – 列表美化 */
ai details.action ol {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}
ai details.action ol li {
  counter-increment: step;
  position: relative;
  padding: 5px 10px 5px 30px;
  margin: 2px 0;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
ai details.action ol li::before {
  content: counter(step);
  position: absolute;
  left: 8px;
  top: 6px;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffa5b0, #c471ed);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
}
ai details.action ol li:hover {
  border-left-color: #c471ed;
  background: #fdf0e8;
  cursor: pointer;
}
/* 手机优化 – 更紧凑 */
@media (max-width: 480px) {
  ai {
    padding: 6px;
    font-size: 14px;
  }
  ai details summary {
    padding: 8px 10px;
    font-size: 13px;
  }
  ai details p,
  ai details ul,
  ai details ol {
    margin: 3px 10px 6px;
  }
  ai details[open] p,
  ai details[open] ul,
  ai details[open] ol,
  ai details[open] table {
    margin: 3px 10px 6px;
  }
  ai table {
    font-size: 11px;
    width: calc(100% - 20px);
  }
  ai details.action ol li {
    padding: 4px 6px 4px 26px;
    font-size: 13px;
  }
  ai details.action ol li::before {
    width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 10px;
    left: 4px;
  }
}
/* 预留hover心形装饰（可选） */
ai details.action ol li:hover::after {
  content: "💕";
  position: absolute;
  right: 8px;
  top: 6px;
  font-size: 12px;
  animation: heartBeat 0.6s;
}
@keyframes heartBeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
/* 仅对已确认的html生效，无副作用 */
ai .placeholder {
  display: none;
}