/* ═══ 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. 统一聊天气泡背景 ---------- */
.group > div:first-child,
.group.is-user > div:first-child,
.group.is-assistant > div:first-child {
    background: linear-gradient(145deg, #2a2a38, #1e1e2a) !important;
    background-color: #252530 !important;
    border: 1px solid #4a4a5a !important;
    border-radius: 18px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05) !important;
    padding: 18px 20px !important;
    isolation: isolate !important;
    position: relative !important;
    transition: all 0.3s ease !important;
    color: #e8e0e8 !important; /* 基准色 */
}

.group.is-user > div:first-child {
    background: linear-gradient(145deg, #333345, #252538) !important;
    border-color: #5a5a6a !important;
}
.group.is-assistant > div:first-child {
    background: linear-gradient(145deg, #2f2f40, #1b1b28) !important;
    border-color: #6a5a6a !important;
}

/* ---------- 2. 文字区域：强制高对比 + 消除所有划线 ---------- */
.rili-markdown-renderer,
.rili-markdown-renderer *,
[class*="markdown"] *,
[class*="content"] * {
    color: #e8e0e8 !important;
    background: transparent !important;
    background-color: transparent !important;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif !important;
    font-weight: 400 !important;
    font-size: 15px !important;
    line-height: 1.7 !important;
    text-shadow: none !important;
    text-decoration: none !important;
    text-decoration-line: none !important;
    -webkit-text-decoration: none !important;
    border: none !important;
}

.rili-markdown-renderer strong,
.rili-markdown-renderer b { color: #f0e6a0 !important; font-weight: 600 !important; }
.rili-markdown-renderer em,
.rili-markdown-renderer i { color: #c8b8d8 !important; }
.rili-markdown-renderer a { color: #80b0ff !important; text-decoration: underline !important; }
.rili-markdown-renderer code,
.rili-markdown-renderer pre {
    background: rgba(255,255,255,0.08) !important;
    color: #e8e0e8 !important;
    border: 1px solid #4a4a5a !important;
    border-radius: 6px !important;
    padding: 2px 6px !important;
}

/* ---------- 3. 底部附加信息 ---------- */
.text-xs.font-mono.text-muted-foreground,
[class*="text-muted-foreground"] {
    color: rgba(204, 192, 208, 0.9) !important;
    font-size: 12px !important;
    font-weight: 300 !important;
}

/* ---------- 4. 底部操作按钮 ---------- */
.bg-muted.rounded.flex button {
    color: rgba(204, 192, 208, 0.85) !important;
    opacity: 1 !important;
}
.bg-muted.rounded.flex button svg.lucide {
    stroke: rgba(204, 192, 208, 0.85) !important;
    color: transparent !important;
}
.group .md\:opacity-0 { opacity: 1 !important; }

/* ---------- 5. 加载动画 ---------- */
.flex.gap-2.w-full.h-full.items-center.justify-center > span { display: none !important; }
.flex.gap-2.w-full.h-full.items-center.justify-center {
    position: relative !important;
    width: 40px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.flex.gap-2.w-full.h-full.items-center.justify-center::before {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 24px;
    height: 8px;
    background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='9' viewBox='0 0 24 9'%3E%3Cstyle%3Ecircle:nth-child(1)%7Banimation:dotAnim 1.4s infinite ease-in-out;animation-delay:-0.32s;%7Dcircle:nth-child(2)%7Banimation:dotAnim 1.4s infinite ease-in-out;animation-delay:-0.16s;%7Dcircle:nth-child(3)%7Banimation:dotAnim 1.4s infinite ease-in-out;%7D@keyframes dotAnim%7B0%25%7Bopacity:0.35;r:2.5%7D20%25%7Bopacity:1;r:3.5%7D40%25%7Bopacity:0.35;r:2.5%7D100%25%7Bopacity:0.35;r:2.5%7D%7D%3C/style%3E%3Ccircle cx='4' cy='4.5' r='2.5' fill='%23e8d8f0'/%3E%3Ccircle cx='12' cy='4.5' r='2.5' fill='%23e8d8f0'/%3E%3Ccircle cx='20' cy='4.5' r='2.5' fill='%23e8d8f0'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat;
    background-position: center;
}

/* ================================================================ */
/* 第二部分：状态栏独立增强美化（暖绒私语 · 特色版）               */
/* 专为 <ai> 容器设计，具有毛玻璃、渐变辉光、装饰元素               */
/* ================================================================ */

/* 状态栏整体容器 */
ai {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  padding: 12px;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #4a4a4a;
  background: radial-gradient(ellipse at 30% 20%, #f4eeff 0%, #ffe3e3 100%);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(72, 50, 80, 0.08), 0 0 0 1px rgba(255, 200, 220, 0.3) inset;
  overflow: hidden;
  text-decoration: none !important;
  /* 毛玻璃效果 - 覆盖整个状态栏 */
  backdrop-filter: blur(2px);
}

/* 顶部栏（时间/地点/天气） - 发光边框 */
ai hd {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  font-size: 13px;
  color: #6a5a7a;
  border: 1px solid rgba(255, 150, 180, 0.4);
  box-shadow: 0 1px 6px rgba(255, 121, 121, 0.10);
}
ai hd time,
ai hd loc,
ai hd weather {
  white-space: nowrap;
}
ai hd::before {
  content: "✦";
  font-size: 12px;
  color: #ff7979;
  animation: pulse-dot 2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

/* 每个模块卡片 <s> */
ai s {
  display: block;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(255, 200, 220, 0.3) inset;
  border: none;
  transition: box-shadow 0.3s, transform 0.2s;
}
ai s:hover {
  box-shadow: 0 4px 16px rgba(255, 121, 121, 0.15), 0 0 0 1px rgba(255, 150, 180, 0.6) inset;
  transform: translateY(-1px);
}

/* 模块标题 h4 - 带装饰 */
ai s h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #5a3d5e;
  display: flex;
  align-items: center;
  gap: 6px;
}
ai s h4::before {
  content: "★";
  font-size: 14px;
  color: #ff7979;
  text-shadow: 0 0 4px rgba(255, 121, 121, 0.4);
}

/* 数据行 d */
ai d {
  display: block;
  padding: 3px 0;
  font-size: 13px;
  line-height: 1.55;
  border-bottom: 1px dashed rgba(216, 195, 213, 0.25);
  color: #4a4a4a;
}
ai d:last-child { border-bottom: none; }
ai d i,
ai d em {
  font-style: normal;
  color: #8a6d8f;
  font-weight: 500;
  margin-right: 2px;
}

/* 内心独白引用 q - 有光晕 */
ai q {
  display: block;
  margin: 8px 0 0 0;
  padding: 8px 12px;
  font-style: italic;
  color: #6a5a7a;
  background: rgba(255, 121, 121, 0.08);
  border-left: 3px solid #ff7979;
  border-radius: 0 6px 6px 0;
  font-size: 13.5px;
  line-height: 1.6;
  quotes: "“" "”" "‘" "’";
  box-shadow: 0 0 8px rgba(255, 121, 121, 0.06) inset;
}
ai q::before { content: open-quote; color: #ff7979; font-size: 1.2em; margin-right: 2px; }
ai q::after { content: close-quote; color: #ff7979; font-size: 1.2em; margin-left: 2px; }

/* 折叠面板 details/summary */
ai details {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
}
ai summary {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #5a3d5e;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
  border: 1px solid transparent;
}
ai summary::-webkit-details-marker { display: none; }
ai summary::before {
  content: "▶";
  font-size: 10px;
  color: #ff7979;
  transition: transform 0.2s, filter 0.2s;
  display: inline-block;
  margin-right: 4px;
}
ai details[open] > summary::before { transform: rotate(90deg); }
ai summary:hover {
  background: rgba(255, 121, 121, 0.12);
  color: #4a2a4a;
  border-color: rgba(255, 121, 121, 0.3);
}
ai details > p {
  margin: 6px 0 0 0;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.65;
  color: #5a4a5a;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 0 0 10px 10px;
}

/* 表格（记忆区） - 斑马纹 */
ai table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
}
ai th, ai td {
  padding: 4px 6px;
  text-align: left;
  border-bottom: 1px solid #e6dce6;
  vertical-align: top;
  color: #4a4a4a;
}
ai th {
  background: #f5ebf5;
  color: #4a3a4a;
  font-weight: 600;
  white-space: nowrap;
}
ai tr:nth-child(even) td {
  background: rgba(245, 235, 245, 0.4);
}

/* 有序列表（行动推荐） */
ai ol {
  margin: 4px 0 0 0;
  padding-left: 24px;
  font-size: 13px;
  line-height: 1.7;
}
ai ol li {
  padding: 2px 0;
  color: #4a4a4a;
}
ai ol li::marker {
  color: #ff7979;
  font-weight: 600;
}

/* 游戏世界内的在线状态 - 带光晕 */
ai s[n="game_world"] .status {
  display: inline-block;
  padding: 1px 8px;
  background: linear-gradient(135deg, #c2f0c2, #b0e0b0);
  color: #1d6b1d;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 0 8px rgba(100, 200, 100, 0.3) inset;
}
ai s[n="game_world"] .status::before {
  content: "●";
  margin-right: 3px;
  font-size: 9px;
  animation: pulse-dot 2s infinite;
}

/* 高亮标记 mark（日常节点中的备注） */
ai mark {
  background: linear-gradient(120deg, #ffd9d9 0%, #ffb3b3 100%);
  color: #4a2a2a;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 500;
  font-style: normal;
}

/* 响应式：窄屏适配 */
@media (max-width: 419px) {
  ai {
    padding: 8px;
    font-size: 14px;
  }
  ai hd {
    font-size: 12px;
    padding: 6px 10px;
  }
  ai s {
    padding: 10px;
  }
  ai d {
    font-size: 12.5px;
  }
  ai table th,
  ai table td {
    font-size: 11px;
    padding: 3px 4px;
  }
  ai ol {
    font-size: 12px;
  }
}