/* ═══ B平台加载动画适配（自动注入）═══ */
.flex.items-center.justify-center.size-6 { opacity: 1 !important; }
.flex.items-center.justify-center.size-6 > .flex.gap-2 { display: none !important; }
.is-assistant.w-fit { width: 100% !important; }
.is-assistant > .border.border-muted:has(.flex.items-center.justify-center.size-6) {
  width: 100% !important; background: transparent !important;
  border: none !important; padding: 0 !important;
}
.is-assistant .space-y-3:has(.flex.items-center.justify-center.size-6) {
  display: flex; justify-content: center; width: 100%;
}

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

/* ② ★ 重构父容器：强制 Flex 列，确保正文区完全置入 ★ */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    position: relative !important;
    isolation: isolate !important;
    
    /* --- 新增：Flex 列布局，使子元素纵向排列并撑满 --- */
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;   /* 子元素宽度强制拉伸 */
    
    /* 视觉样式保持不变 */
    background: linear-gradient(150deg, #FFFCF8 0%, #FFF2EB 55%, #FFE9E2 100%) !important;
    border: 1.5px solid #F2C7BC !important;
    border-radius: 22px !important;
    box-shadow:
        0 6px 28px rgba(224, 130, 112, 0.13),
        0 2px 8px rgba(0, 0, 0, 0.04) !important;
    padding: 18px 18px 10px 18px !important;
    transition: box-shadow 0.3s ease !important;
}

/* ③ 输入聊天框（单独）：更亮白底，便于辨识 */
.is-user > .border.border-muted {
    background: linear-gradient(150deg, #FFFFFF 0%, #FFF7F2 100%) !important;
    border-color: #F5DBD1 !important;
    box-shadow:
        0 3px 14px rgba(224, 130, 112, 0.09),
        0 1px 4px rgba(0, 0, 0, 0.03) !important;
}

/* ④ ★ 重构正文区：强制 100% 宽度，永不压缩，浮于装饰层之上 ★ */
.rili-markdown-renderer {
    width: 100% !important;           /* 撑满父容器宽度 */
    flex-shrink: 0 !important;        /* 防止被压缩 */
    
    color: #2E2B28 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif !important;
    font-size: 15px !important;
    line-height: 1.9 !important;
    letter-spacing: 0.012em !important;
    font-weight: 400 !important;
    text-shadow: none !important;
    background: transparent !important;
    position: relative !important;
    z-index: 1 !important;            /* 高于背景装饰 */
    
    /* 长内容换行保护 */
    overflow-wrap: break-word !important;
    word-break: break-word !important;
}

/* Markdown 子元素：同样保证可读 */
.rili-markdown-renderer strong {
    color: #A8513F !important;
    font-weight: 700 !important;
}
.rili-markdown-renderer h1,
.rili-markdown-renderer h2,
.rili-markdown-renderer h3,
.rili-markdown-renderer h4 {
    color: #2E2B28 !important;
    font-weight: 700 !important;
}
.rili-markdown-renderer a {
    color: #A8513F !important;
    text-decoration: underline !important;
}
.rili-markdown-renderer blockquote {
    border-left: 3px solid #E8A89E !important;
    background: rgba(232, 112, 106, 0.06) !important;
    color: #4A4540 !important;
    padding: 6px 14px !important;
    border-radius: 0 8px 8px 0 !important;
}
.rili-markdown-renderer code {
    background: #F7E7E1 !important;
    color: #A8513F !important;
    padding: 2px 6px !important;
    border-radius: 6px !important;
}
.rili-markdown-renderer pre {
    background: #3A332F !important;
    color: #F7F2EE !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    overflow-x: auto !important;
}

/* ⑤ 底部附加元素：暖棕红系 + 强制浮于装饰层之上 */
/* 注意：原文件中有注释错误的 /* [Token消耗hover逻辑转换未启用] 导致后续规则被屏蔽，现已清理 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7,
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    position: relative !important;
    z-index: 1 !important;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7 {
    color: #B06455 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    padding: 4px 8px !important;
    transition: background 0.2s ease, color 0.2s ease !important;
    background: rgba(224, 130, 112, 0.12) !important;
    color: #8E4436 !important;
}

.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #A07066 !important;
    font-size: 12px !important;
}

/* ⑥ 装饰：朱砂小爱心（低透明度 · 不干扰阅读 · SMIL脉动）
   注意：此处使用伪元素，但父容器为flex列，伪元素绝对定位不影响布局 */
.is-user > .border.border-muted::before,
.is-assistant > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    top: 10px !important;
    right: 12px !important;
    width: 26px !important;
    height: 26px !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 36 36'%3E%3Cg transform='translate(18,18)'%3E%3Cg%3E%3CanimateTransform attributeName='transform' type='scale' values='1;1.08;1' keyTimes='0;0.5;1' dur='2s' repeatCount='indefinite'/%3E%3Cg transform='translate(-18,-18)'%3E%3Cpath d='M18 30 C10.5 23.25, 4.5 16.5, 4.5 10.5 C4.5 4.5, 10.5 1.5, 15 4.5 C16.875 5.85, 17.625 7.125, 18 7.875 C18.375 7.125, 19.125 5.85, 21 4.5 C25.5 1.5, 31.5 4.5, 31.5 10.5 C31.5 16.5, 25.5 23.25, 18 30 Z' fill='%23E8706A' opacity='0.13'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat !important;
    pointer-events: none !important;
    z-index: 0 !important;
}

.is-user > .border.border-muted::after,
.is-assistant > .border.border-muted::after {
    content: '' !important;
    position: absolute !important;
    bottom: 8px !important;
    left: 12px !important;
    width: 18px !important;
    height: 18px !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 36 36'%3E%3Cpath d='M18 30 C10.5 23.25, 4.5 16.5, 4.5 10.5 C4.5 4.5, 10.5 1.5, 15 4.5 C16.875 5.85, 17.625 7.125, 18 7.875 C18.375 7.125, 19.125 5.85, 21 4.5 C25.5 1.5, 31.5 4.5, 31.5 10.5 C31.5 16.5, 25.5 23.25, 18 30 Z' fill='%23C96A5E' opacity='0.10'/%3E%3C/svg%3E") center / contain no-repeat !important;
    pointer-events: none !important;
    z-index: 0 !important;
}

/* ⑦ 自定义加载动画：隐藏默认三点 · SVG SMIL 心跳 */
.style-module__AtdJSq__dot-flashing.style-module__AtdJSq__text {
    display: none !important;
}
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
}
.flex.items-center.justify-center.size-6::before {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cg transform='translate(18,18)'%3E%3Cg%3E%3CanimateTransform attributeName='transform' type='scale' values='1;1.22;1;1.12;1' keyTimes='0;0.22;0.44;0.66;1' dur='1.4s' repeatCount='indefinite'/%3E%3Cg transform='translate(-18,-18)'%3E%3Cpath d='M18 30 C10.5 23.25, 4.5 16.5, 4.5 10.5 C4.5 4.5, 10.5 1.5, 15 4.5 C16.875 5.85, 17.625 7.125, 18 7.875 C18.375 7.125, 19.125 5.85, 21 4.5 C25.5 1.5, 31.5 4.5, 31.5 10.5 C31.5 16.5, 25.5 23.25, 18 30 Z' fill='%23E8706A'/%3E%3Ccircle cx='13' cy='12' r='3' fill='%23FFE0DA' opacity='0.65'%3E%3Canimate attributeName='r' values='3;2.2;3' keyTimes='0;0.5;1' dur='1.4s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
    display: block !important;
    line-height: 0 !important;
}
.flex.items-center.justify-center.size-6::after {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='16' fill='none' stroke='%23E8706A' stroke-width='1.5' opacity='0'%3E%3Canimate attributeName='r' values='12;22' dur='1.6s' repeatCount='indefinite'/%3E%3Canimate attributeName='opacity' values='0.35;0' dur='1.6s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") !important;
    display: block !important;
    line-height: 0 !important;
}

/* ⑧ 移动端适配 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
    .is-assistant > .border.border-muted {
        border-radius: 16px !important;
        padding: 14px 12px 8px 12px !important;
    }
    .rili-markdown-renderer {
        font-size: 14px !important;
        line-height: 1.75 !important;
    }
    .flex.items-center.justify-center.size-6 {
        width: 32px !important;
        height: 32px !important;
    }
    .flex.items-center.justify-center.size-6::before {
        transform: scale(0.8) !important;
    }
    .flex.items-center.justify-center.size-6::after {
        transform: scale(0.8) !important;
    }
}

/* ⑨ 低动效：降低幅度与频率，不关闭 */
@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted::before,
    .is-assistant > .border.border-muted::before {
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 36 36'%3E%3Cpath d='M18 30 C10.5 23.25, 4.5 16.5, 4.5 10.5 C4.5 4.5, 10.5 1.5, 15 4.5 C16.875 5.85, 17.625 7.125, 18 7.875 C18.375 7.125, 19.125 5.85, 21 4.5 C25.5 1.5, 31.5 4.5, 31.5 10.5 C31.5 16.5, 25.5 23.25, 18 30 Z' fill='%23E8706A' opacity='0.13'/%3E%3C/svg%3E") center / contain no-repeat !important;
    }
    .flex.items-center.justify-center.size-6::before {
        content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cg transform='translate(18,18)'%3E%3Cg%3E%3CanimateTransform attributeName='transform' type='scale' values='1;1.05;1' keyTimes='0;0.5;1' dur='2.8s' repeatCount='indefinite'/%3E%3Cg transform='translate(-18,-18)'%3E%3Cpath d='M18 30 C10.5 23.25, 4.5 16.5, 4.5 10.5 C4.5 4.5, 10.5 1.5, 15 4.5 C16.875 5.85, 17.625 7.125, 18 7.875 C18.375 7.125, 19.125 5.85, 21 4.5 C25.5 1.5, 31.5 4.5, 31.5 10.5 C31.5 16.5, 25.5 23.25, 18 30 Z' fill='%23E8706A'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E") !important;
    }
    .flex.items-center.justify-center.size-6::after {
        display: none !important;
    }
}

/* ======================================================
   张一觉 × 用户 · 纯爱欢乐卡 状态栏美化
   暖杏底色 · 朱砂爱心 · 墨色文字 · 容器隔离
   全部规则挂在 <ai> 容器下，零全局污染
   ====================================================== */

ai {
  display: block;
  --ink: #2E2B28;
  --brown: #8E4436;
  --red: #A8513F;
  --pink: #E8706A;
  --paper: linear-gradient(160deg, #FFF9F4 0%, #FFF0E8 55%, #FFE7DE 100%);
  --line: #F0CFC3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.85;
  letter-spacing: 0.012em;
}

ai details {
  position: relative;
  overflow: hidden;
  margin: 10px 0;
  padding: 10px 14px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pink);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(232, 112, 106, 0.08);
  transition: border-color 0.3s, box-shadow 0.3s;
}
ai details[open] {
  border-left-color: var(--red);
  box-shadow: 0 5px 20px rgba(232, 112, 106, 0.13);
}
ai details > * {
  position: relative;
  z-index: 1;
}

ai summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 15px;
  color: var(--red);
  padding: 4px 0 7px;
  margin: 0 0 6px;
  border-bottom: 1px dashed rgba(232, 112, 106, 0.4);
  user-select: none;
  transition: color 0.2s, padding-left 0.2s;
}
ai summary:hover {
  color: var(--brown);
  padding-left: 4px;
}
ai summary::-webkit-details-marker { display: none; }
ai summary::after {
  content: '▾';
  float: right;
  opacity: 0.5;
  font-size: 12px;
  transition: transform 0.3s;
}
ai details[open] summary::after {
  transform: rotate(180deg);
}

ai f {
  display: inline-block;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--brown);
  background: rgba(232, 112, 106, 0.12);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 4px;
  line-height: 1.7;
}

ai d {
  display: block;
  margin: 3px 0;
  font-size: 13.5px;
  word-break: break-word;
}

ai p[t] {
  margin: 8px 0 3px;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--red);
}
ai p[t="sub"] {
  padding-left: 8px;
  border-left: 3px solid var(--pink);
  margin: 10px 0 5px;
}

ai ul, ai ol {
  margin: 4px 0 6px;
  padding-left: 20px;
}
ai li {
  margin: 2px 0;
  font-size: 13.5px;
  line-height: 1.75;
}
ai ul li::marker {
  content: "✦ ";
  color: var(--pink);
  font-size: 11px;
}
ai ol li::marker {
  font-weight: 700;
  color: var(--red);
}

ai blockquote {
  margin: 6px 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.55);
  border-left: 3px solid var(--pink);
  border-radius: 0 8px 8px 0;
  color: #4A4540;
  font-size: 13px;
  line-height: 1.8;
  overflow-x: auto;
}

ai table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
}
ai th {
  background: rgba(232, 112, 106, 0.16);
  color: var(--brown);
  font-weight: 700;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
ai td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(240, 207, 195, 0.5);
  vertical-align: top;
  line-height: 1.6;
  word-break: break-word;
}
ai td:first-child {
  text-align: center;
  color: var(--red);
  font-weight: 700;
}
ai tr:last-child td { border-bottom: none; }

ai .qq {
  margin: 6px 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
}
ai p[t="msg"] {
  margin: 4px 0 2px;
  font-size: 13px;
  color: var(--brown);
}
ai p[t="msg"] b {
  color: var(--red);
  font-weight: 700;
}

ai details::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 44px;
  height: 44px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Cpath d='M18 30 C10.5 23.25,4.5 16.5,4.5 10.5 C4.5 4.5,10.5 1.5,15 4.5 C16.875 5.85,17.625 7.125,18 7.875 C18.375 7.125,19.125 5.85,21 4.5 C25.5 1.5,31.5 4.5,31.5 10.5 C31.5 16.5,25.5 23.25,18 30 Z' fill='%23E8706A'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
}

@media (max-width: 480px) {
  ai { font-size: 13px; }
  ai details { padding: 8px 10px 12px; border-radius: 12px; }
  ai summary { font-size: 14px; }
  ai d, ai li { font-size: 12.5px; }
  ai blockquote { font-size: 12.5px; }
  ai th, ai td { padding: 4px 6px; font-size: 11px; }
}