/* ⚠ 转换警告 ════════════════════════════════════════
   1 处游离 .bg-gray-100\/90 已按通用气泡处理
═══════════════════════════════════════════════════ */

/* ═══ 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: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%) !important;
  border: 1px solid rgba(180, 200, 220, 0.4) !important;
  border-radius: 20px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04) !important;
  padding: 16px 20px !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease !important;
}

/* 悬浮时轻微加深阴影，增加互动感 */
\.is-user > .border.border-muted,
.is-assistant > .border.border-muted:hover {
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(160, 185, 210, 0.6) !important;
}

/* ===== 输入框单独处理 ===== */
\.is-user > .border.border-muted,
.is-assistant > .border.border-muted:not(.is-assistant \.is-user > .border.border-muted,
.is-assistant > .border.border-muted) {
  background: linear-gradient(135deg, #ffffff 0%, #f7f9fc 100%) !important;
  border: 1px solid rgba(180, 200, 220, 0.5) !important;
  border-radius: 20px 20px 20px 20px !important;
}

/* ===== 主要文本内容：强制可读性 ===== */
.rili-markdown-renderer {
  color: #2c3e50 !important; /* 深灰蓝，柔和且清晰 */
  font-size: 15px !important;
  line-height: 1.7 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
  font-weight: 400 !important;
  text-shadow: none !important; /* 禁止任何光晕/阴影 */
  /* 内部链接、代码块等保持深色 */
}

.rili-markdown-renderer a {
  color: #1a73e8 !important;
  text-decoration: underline !important;
}

.rili-markdown-renderer code,
.rili-markdown-renderer pre {
  background: #f0f2f5 !important;
  color: #2c3e50 !important;
  border: 1px solid #e0e4e8 !important;
  border-radius: 6px !important;
}

.rili-markdown-renderer blockquote {
  border-left: 4px solid #b0c4de !important;
  color: #4a5a6a !important;
  background: rgba(176, 196, 222, 0.12) !important;
}

/* ===== 底部附加元素：浅色背景深色文字 ===== */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
  color: #2c3e50 !important;
  font-weight: 500 !important;
  background: transparent !important;
  border-radius: 8px !important;
  padding: 4px 12px !important;
  transition: background 0.15s !important;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
  background: rgba(44, 62, 80, 0.08) !important;
}

.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
  color: #4a5a6a !important;
  font-size: 13px !important;
  font-weight: 400 !important;
}

/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
  color: #4a5a6a !important;
  font-size: 13px !important;
}
*/

/* ===== 顶部颜色装饰条：隐藏（如果用户希望保留可删除此段） ===== */
[class="bg-[#F1CBCB]"],
[class*="bg-[#c9e1e9]"] {
  display: none !important;
}

/* ===== 加载动画：保持默认，不做额外美化 ===== */
.style-module__AtdJSq__dot-flashing.style-module__AtdJSq__text {
  /* 默认可见，不做改动 */
}

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
  \.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    border-radius: 16px !important;
    padding: 12px 16px !important;
  }
  .rili-markdown-renderer {
    font-size: 14px !important;
    line-height: 1.6 !important;
  }
}

/* ===== 低动效偏好：保留所有文字样式，仅削弱动画 ===== */
@media (prefers-reduced-motion: reduce) {
  \.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    transition: none !important;
  }
  \.is-user > .border.border-muted,
.is-assistant > .border.border-muted:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06) !important;
    border-color: rgba(180, 200, 220, 0.4) !important;
  }
}

/* ===== 核心变量与容器（完美融合自带底座） ===== */
ai {
  --p-bg: rgba(255, 255, 255, 0.6);
  --p-bg-h: rgba(255, 255, 255, 0.9);
  --bd: rgba(180, 200, 220, 0.4);
  --ac: #1a73e8; /* 科技蓝点缀 */
  --tx: #2c3e50; /* 继承自带文本色 */
  --dy-bg: #fcf9f2; /* 日记本暖色 */
  --dy-bd: #e6d5b8;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--tx);
  line-height: 1.6;
}

/* ===== 顶部状态栏（时间/地点/天气） ===== */
ai .h {
  display: flex;
  justify-content: space-between;
  background: linear-gradient(90deg, var(--p-bg), var(--p-bg-h));
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--bd);
  font-weight: 500;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

/* ===== 折叠面板核心美化 ===== */
ai details {
  background: var(--p-bg);
  border: 1px solid var(--bd);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}
ai details[open] {
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  padding-bottom: 10px;
}
ai summary {
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  transition: background 0.2s;
}
ai summary::-webkit-details-marker { display: none; }
ai summary:hover { background: var(--p-bg-h); }
ai summary::before {
  content: "✦";
  color: var(--ac);
  margin-right: 8px;
  font-size: 12px;
  transition: transform 0.3s;
}
ai details[open] summary::before { transform: rotate(90deg); }
ai details[open] summary { border-bottom: 1px dashed var(--bd); margin-bottom: 10px; }

/* ===== 网格与信息条目 ===== */
ai .g {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 0 10px;
}
ai v {
  display: flex;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.5);
}
ai v.f { grid-column: 1 / -1; margin: 6px 10px 0; }
ai v b {
  color: var(--ac);
  min-width: 60px;
  margin-right: 8px;
  position: relative;
}
ai v b::after {
  content: "";
  position: absolute;
  right: 0; top: 20%; height: 60%; width: 1px;
  background: var(--bd);
}

/* ===== NPC卡片 ===== */
ai .nc {
  margin: 0 10px 10px;
  background: linear-gradient(135deg, rgba(255,255,255,0.8), rgba(245,247,250,0.6));
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding-bottom: 6px;
  overflow: hidden;
}
ai .nh {
  background: rgba(26, 115, 232, 0.05);
  padding: 6px 12px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
ai .nh n { font-weight: bold; color: #2c3e50; font-size: 15px; }
ai .nh span { font-size: 12px; color: #666; background: #fff; padding: 2px 6px; border-radius: 10px; border: 1px solid var(--bd); }

/* ===== 标题与列表 (记忆/动态/行动) ===== */
ai t {
  display: block;
  font-size: 12px;
  color: #666;
  margin: 10px 10px 4px;
  padding-left: 8px;
  border-left: 3px solid var(--ac);
  font-weight: 600;
}
ai ul.m, ai ul.a {
  margin: 0 10px;
  padding: 0;
  list-style: none;
}
ai ul.m li, ai ul.a li {
  position: relative;
  padding: 6px 10px 6px 20px;
  background: rgba(255,255,255,0.6);
  margin-bottom: 4px;
  border-radius: 6px;
  font-size: 13px;
}
ai ul.m li::before {
  content: "•"; color: var(--ac); position: absolute; left: 8px; font-weight: bold;
}
ai ul.a li { cursor: pointer; transition: transform 0.2s, background 0.2s; border: 1px solid transparent; }
ai ul.a li:hover { background: #fff; border-color: var(--ac); transform: translateX(4px); }
ai ul.a li::before {
  content: "▶"; color: var(--ac); position: absolute; left: 8px; font-size: 10px; top: 9px;
}

/* ===== 社交聊天气泡 (QQ/论坛) ===== */
ai .c {
  margin: 0 10px;
  background: rgba(240, 244, 248, 0.6);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  border: 1px solid var(--bd);
}

/* ===== 私密日记本 (特殊视觉) ===== */
ai .dy {
  margin: 0 10px;
  background: var(--dy-bg);
  border: 1px solid var(--dy-bd);
  border-radius: 4px 12px 12px 4px;
  padding: 12px;
  position: relative;
  box-shadow: inset 20px 0 20px -20px rgba(0,0,0,0.1);
  border-left: 4px solid #d4a373;
}
ai .dy::before { /* 模拟笔记本线圈打孔 */
  content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 4px;
  background: repeating-linear-gradient(to bottom, transparent, transparent 15px, rgba(0,0,0,0.1) 15px, rgba(0,0,0,0.1) 20px);
}
ai .dh {
  display: flex; gap: 10px; border-bottom: 1px solid var(--dy-bd);
  padding-bottom: 6px; margin-bottom: 8px; font-family: serif; color: #8a6a4b; font-size: 12px;
}
ai .dy p { margin: 0 0 6px 0; font-family: "KaiTi", serif; color: #3e3222; }

/* ===== 好感度面板 ===== */
ai .fv { margin: 0 10px 10px; background: rgba(255,255,255,0.8); border-radius: 8px; padding: 10px; border: 1px solid var(--bd); }
ai .fb { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-weight: bold; }
ai .hr { color: #e74c3c; letter-spacing: 2px; text-shadow: 0 0 2px rgba(231,76,60,0.3); }
ai .ob { font-size: 12px; color: #555; background: rgba(240,244,248,0.8); padding: 6px; border-radius: 4px; }

/* 移动端适配强化 */
@media (max-width: 480px) {
  ai .g { grid-template-columns: 1fr; }
  ai v.f { margin: 6px 0 0 0; }
  ai .nc, ai .dy, ai .fv, ai t, ai ul.m, ai ul.a, ai .c { margin-left: 0; margin-right: 0; }
}