/* ═══ 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, #fef6f9 0%, #fdf2f8 50%, #fce7f3 100%) !important;
    border-radius: 20px !important;
    border: 2px solid #f9a8d4 !important;
    box-shadow: 
        0 4px 15px rgba(249, 168, 212, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.8) !important;
    padding: 16px 20px !important;
    max-width: 420px !important;
    position: relative !important;
    overflow: hidden !important;
}

/* 装饰性小爱心左上角 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::before {
    content: "♡" !important;
    position: absolute !important;
    top: 8px !important;
    left: 10px !important;
    font-size: 14px !important;
    color: #f472b6 !important;
    opacity: 0.6 !important;
    z-index: 2 !important;
}

/* 装饰性小爱心右上角 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::after {
    content: "♡" !important;
    position: absolute !important;
    top: 8px !important;
    right: 10px !important;
    font-size: 10px !important;
    color: #f9a8d4 !important;
    opacity: 0.5 !important;
    z-index: 2 !important;
}

/* 主要文本内容 - 清晰深色 */
.rili-markdown-renderer {
    color: #4a2545 !important;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif !important;
    font-size: 15px !important;
    line-height: 1.8 !important;
    letter-spacing: 0.3px !important;
    background: transparent !important;
    z-index: 1 !important;
    position: relative !important;
}

/* 标题/名字加粗 */
.rili-markdown-renderer strong,
.rili-markdown-renderer b {
    color: #be185d !important;
    font-weight: 700 !important;
}

/* 引用/特殊强调 */
.rili-markdown-renderer em,
.rili-markdown-renderer i {
    color: #9d174d !important;
    font-style: normal !important;
    background: linear-gradient(180deg, transparent 60%, rgba(244, 114, 182, 0.2) 60%) !important;
}

/* 链接 */
.rili-markdown-renderer a {
    color: #ec4899 !important;
    text-decoration: none !important;
    border-bottom: 1px dashed #f472b6 !important;
}

/* 底部附加元素 - 模型名称 */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #be185d !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    opacity: 0.85 !important;
    letter-spacing: 0.5px !important;
}

/* 底部附加元素 - Token消耗 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #ea580c !important;
    font-size: 11px !important;
    font-weight: 500 !important;
}
*/

/* 底部按钮 */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #db2777 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    padding: 4px 8px !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    background: rgba(236, 72, 153, 0.1) !important;
}

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

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

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        box-shadow: 
            0 2px 8px rgba(249, 168, 212, 0.2),
            0 1px 3px rgba(0, 0, 0, 0.05) !important;
    }
}
/* === 欢乐向纯爱卡·内部组件美化 === */

ai {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    color: #4a2545;
    line-height: 1.6;
}

/* 顶栏：时间地点天气 */
ai hd {
    display: block;
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
    padding: 8px;
    border-radius: 12px;
    font-weight: bold;
    color: #be185d;
    border: 1px dashed #f9a8d4;
    box-shadow: 0 2px 6px rgba(249, 168, 212, 0.15);
    letter-spacing: 0.5px;
}

/* 折叠面板容器 */
ai details {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(249, 168, 212, 0.4);
    overflow: hidden;
    transition: all 0.3s ease;
}

ai details[open] {
    box-shadow: 0 4px 12px rgba(249, 168, 212, 0.1);
    background: rgba(255, 255, 255, 0.8);
}

/* 折叠面板标题 */
ai summary {
    background: linear-gradient(90deg, rgba(252, 231, 243, 0.8), transparent);
    padding: 10px 14px;
    font-weight: bold;
    color: #be185d;
    cursor: pointer;
    list-style: none;
    user-select: none;
    border-bottom: 1px solid transparent;
}

ai details[open] summary {
    border-bottom: 1px dashed #fbcfe8;
}

ai summary::-webkit-details-marker {
    display: none;
}

/* 人物信息卡片 */
ai p[t] {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(253,242,248,0.5));
    border-radius: 10px;
    border-left: 4px solid #f472b6;
}

/* 人物名字小标题 */
ai p[t]::before {
    content: attr(t);
    font-weight: 800;
    color: #9d174d;
    font-size: 15px;
    border-bottom: 2px solid #fce7f3;
    padding-bottom: 6px;
    margin-bottom: 4px;
}

/* 键值对行 */
ai d {
    display: block;
}
ai d b {
    color: #db2777;
    margin-right: 4px;
}

/* 手机消息气泡 */
ai msg {
    display: block;
    margin: 8px 10px;
    padding: 10px 12px;
    background: #fdf2f8;
    border-radius: 0 12px 12px 12px;
    border: 1px solid #fce7f3;
    font-size: 13px;
    position: relative;
}

ai msg::before {
    content: attr(t);
    display: block;
    font-size: 11px;
    color: #f472b6;
    font-weight: bold;
    margin-bottom: 4px;
}

/* 加密备忘录 (日记风) */
ai memo {
    display: block;
    margin: 10px;
    padding: 14px;
    background: #fffbeb;
    border: 1px dashed #fcd34d;
    border-radius: 8px;
    background-image: repeating-linear-gradient(transparent, transparent 23px, rgba(252, 211, 77, 0.2) 24px);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}

ai memo q {
    display: block;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-left: 3px solid #fbbf24;
    font-style: italic;
    color: #92400e;
    border-radius: 0 8px 8px 0;
}

/* 记忆时间轴 */
ai mem {
    display: block;
    margin: 10px;
}

ai mem::before {
    content: attr(t);
    display: inline-block;
    background: #fbcfe8;
    color: #9d174d;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}

ai m {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 4px;
}

ai m i {
    color: #be185d;
    font-style: normal;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(244, 114, 182, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 行动选项按钮化 */
ai act {
    display: block;
    margin: 8px 10px;
    padding: 10px 14px;
    background: linear-gradient(to right, #fdf2f8, #fef6f9);
    border: 1px solid #fbcfe8;
    border-radius: 20px;
    color: #be185d;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(249, 168, 212, 0.1);
}

ai act:hover {
    background: #fce7f3;
    transform: translateX(6px);
    box-shadow: 0 4px 8px rgba(249, 168, 212, 0.2);
    border-color: #f9a8d4;
}