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

/* === 晏知遥 · 冷雾蓝主题 === */

/* 隐藏顶部颜色条，让视觉更干净 */
[class*="bg-[#F1CBCB]"],
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* —— 统一聊天框外观 —— */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #242538 !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(163, 181, 198, 0.25) !important;
    padding: 16px !important;
    margin: 8px 0 !important;
    transition: all 0.2s ease !important;
    isolation: isolate !important;
    position: relative !important;
}

/* 单独的输入框（可细微区分） */
.is-user > .border.border-muted {
    background: linear-gradient(135deg, #2a2c3e 0%, #242538 100%) !important;
    border-color: rgba(163, 181, 198, 0.4) !important;
}

/* —— 文本内容 —— */
.rili-markdown-renderer {
    color: #EAEAEA !important;          /* 柔和浅色，不刺眼 */
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    font-size: 0.95rem !important;
    line-height: 1.65 !important;
    text-shadow: none !important;       /* 绝不使用阴影破坏可读性 */
    background: transparent !important;
    position: relative !important;
    z-index: 1 !important;
}

/* 标题与强调 */
.rili-markdown-renderer strong {
    color: #ffffff !important;
    font-weight: 600 !important;
}

.rili-markdown-renderer h1, .rili-markdown-renderer h2 {
    color: #F0F0F0 !important;
    border-bottom: 1px solid rgba(163, 181, 198, 0.3) !important;
    padding-bottom: 4px !important;
}

.rili-markdown-renderer code {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #c9d1d9 !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
}

.rili-markdown-renderer pre {
    background: #1b1c2a !important;
    border: 1px solid rgba(163, 181, 198, 0.2) !important;
    border-radius: 10px !important;
}

/* —— 底部操作按钮 —— */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #BCBBC1 !important;          /* 与背景对比明显但不抢眼 */
    font-weight: 500 !important;
    text-transform: none !important;
    transition: color 0.2s !important;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #ffffff !important;
    background: rgba(255,255,255,0.08) !important;
}

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

/* Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #D1D5DB !important;        /* 淡灰色替代原橙色，更统一 */
}
*/

/* —— 加载动画占位（保留默认，也可自定义） —— */
/* 如需要可启用下方SMIL动画，此处保持简洁 */
ai {
  --c-bg: #1a1d23;
  --c-surface: #21242b;
  --c-surface-alt: #282c34;
  --c-text: #c8ccd4;
  --c-text-dim: #8a8f9a;
  --c-accent: #7b9eb3;
  --c-accent-warm: #c9a87c;
  --c-border: #363a41;
  --c-chip: #2a2d35;
  --c-shadow: rgba(0, 0, 0, 0.4);
  --font-serif: "思源宋体", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 16px;
  --gap-sm: 8px;

  display: block;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--gap) var(--gap) 40px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  box-sizing: border-box;
}

ai *,
ai *::before,
ai *::after {
  box-sizing: border-box;
}

/* ========== 卡片区块 ========== */
ai d.stat-block {
  display: block;
  margin-bottom: var(--gap);
  padding: 18px 16px;
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--c-shadow);
  border: 1px solid var(--c-border);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

ai d.stat-block:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  border-color: #4a505a;
}

/* ========== 可折叠标题 ========== */
ai d.stat-block > s {
  display: block;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-serif);
  color: var(--c-accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--c-border);
  letter-spacing: 0.6px;
  transition: color 0.2s ease, border-color 0.2s ease;
  user-select: none;
}

ai d.stat-block > s:hover {
  color: #9fc3d4;
  border-bottom-color: var(--c-accent);
}

ai d.stat-block > s::before {
  content: "▸ ";
  font-size: 12px;
  display: inline-block;
  transition: transform 0.25s ease;
}

ai d.stat-block[open] > s::before {
  transform: rotate(90deg);
}

/* ========== 键值条目 ========== */
ai t {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 13.5px;
  line-height: 1.5;
}

ai t i {
  font-style: normal;
  font-weight: 500;
  color: var(--c-text-dim);
  white-space: nowrap;
  min-width: fit-content;
}

ai t i::after {
  content: ":";
  margin-left: 2px;
}

ai t {
  color: var(--c-text);
}

/* ========== 头像名称 ========== */
ai f {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-serif);
  color: #e3e6ec;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--c-border);
  letter-spacing: 0.8px;
}

/* ========== 网格容器（紧凑排列键值对） ========== */
ai g {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 12px;
  margin-bottom: 12px;
}

ai g t {
  margin-bottom: 0;
}

/* ========== 段落描述 ========== */
ai p.desc {
  margin: 6px 0 12px;
  padding-left: 8px;
  border-left: 3px solid var(--c-accent);
  color: var(--c-text-dim);
  font-size: 13.5px;
  line-height: 1.65;
}

/* ========== 区块内子标题 ========== */
ai q {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--c-accent-warm);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px dotted var(--c-border);
}

/* ========== 无序列表 ========== */
ai ul {
  margin: 4px 0 10px;
  padding-left: 18px;
  list-style: none;
}

ai ul li {
  position: relative;
  margin-bottom: 5px;
  font-size: 13.5px;
  color: var(--c-text);
  line-height: 1.55;
}

ai ul li::before {
  content: "•";
  position: absolute;
  left: -16px;
  color: var(--c-accent);
  font-weight: bold;
}

ai ul.dense li {
  margin-bottom: 2px;
}

ai ul li b {
  color: #d0d4db;
  font-weight: 600;
}

/* ========== 有序列表（行动推荐） ========== */
ai ol {
  margin: 4px 0 10px;
  padding-left: 22px;
  counter-reset: action-counter;
  list-style: none;
}

ai ol li {
  position: relative;
  margin-bottom: 6px;
  font-size: 13.5px;
  counter-increment: action-counter;
  padding: 6px 8px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
  cursor: pointer;
}

ai ol li:hover {
  background: #30343c;
}

ai ol li::before {
  content: counter(action-counter);
  position: absolute;
  left: -20px;
  top: 6px;
  width: 18px;
  height: 18px;
  background: var(--c-accent);
  color: #1a1d23;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  text-align: center;
  line-height: 18px;
}

/* ========== 消息分组 ========== */
ai .msg-group {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--c-accent);
  transition: border-color 0.2s ease;
}

ai .msg-group:hover {
  border-left-color: var(--c-accent-warm);
}

ai .msg-group h4 {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: #d0d4db;
  display: flex;
  align-items: center;
  gap: 8px;
}

ai .msg-group h4 span {
  font-size: 11px;
  font-weight: 400;
  color: var(--c-accent);
  background: #2a2d35;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

ai .msg-group ul {
  margin: 0;
  padding-left: 0;
}

ai .msg-group ul li {
  font-size: 13px;
  color: var(--c-text-dim);
  margin-bottom: 3px;
  padding-left: 14px;
}

ai .msg-group ul li::before {
  left: 0;
  color: var(--c-border);
}

/* ========== 任务卡片 ========== */
ai .mission {
  margin-bottom: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #262a30 0%, #21242b 100%);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--c-accent-warm);
}

ai .mission b {
  display: block;
  font-size: 15px;
  font-family: var(--font-serif);
  color: #e3c78c;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

ai .mission p {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--c-text-dim);
  line-height: 1.6;
}

ai .mission t {
  font-size: 13px;
  margin-bottom: 2px;
}

ai .mission t i {
  color: var(--c-accent-warm);
}

ai .mission-item {
  margin-bottom: 10px !important;
  padding: 10px 12px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--c-accent);
}

ai .mission-item b {
  color: #d0d4db;
}

ai .mission-item b:last-of-type {
  color: var(--c-accent-warm);
}

/* ========== NPC卡片 ========== */
ai .npc-card {
  padding: 12px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}

ai .npc-card f {
  border-bottom-color: var(--c-accent-warm);
  color: #e3c78c;
}

/* ========== 记忆表格 ========== */
ai .mem-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}

ai .mem-table table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 12.5px;
  font-family: var(--font-mono, monospace);
  background: var(--c-surface-alt);
}

ai .mem-table th {
  background: #1e2127;
  color: var(--c-accent);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--c-border);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

ai .mem-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-dim);
  vertical-align: top;
}

ai .mem-table tr:last-child td {
  border-bottom: none;
}

ai .mem-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

ai .mem-table tr:hover td {
  background: rgba(255, 255, 255, 0.04);
  color: var(--c-text);
}

/* ========== 响应式微调 ========== */
@media (max-width: 600px) {
  ai {
    padding: 10px 8px 32px;
    font-size: 13.5px;
  }

  ai d.stat-block {
    padding: 14px 10px;
    margin-bottom: 10px;
    border-radius: 8px;
  }

  ai d.stat-block > s {
    font-size: 14px;
  }

  ai f {
    font-size: 16px;
  }

  ai g {
    grid-template-columns: 1fr;
  }

  ai .msg-group {
    padding: 8px 10px;
  }

  ai .mission {
    padding: 10px 12px;
  }

  ai ol li {
    padding: 8px 6px;
  }
}