/* ═══ 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;
}

/* ============================================ */
/* 【子柒】单人日常纯爱卡 - 聊天框美化 CSS      */
/* ============================================ */

/* 1. 顶层规则：去除顶部颜色装饰条 */
[class*="bg-[#F1CBCB]"], 
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* 2. 统一聊天框 (所有气泡的通用背景与样式) */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
    background: #1a1c1e !important; /* 深空灰底色 */
    border-radius: 18px !important;  /* 圆润边角 */
    box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important; /* 立体的投影，模拟夜晚屏幕的微光 */
    padding: 24px 20px 18px 20px !important; /* 统一内边距，让内容呼吸 */
    isolation: isolate !important; /* 为背景动效建立层叠上下文 */
    position: relative !important;
}

/* 2.1 单独的输入聊天框 (你的对话区域) */
.is-user > .border.border-muted {
    background: #25272a !important; /* 稍微亮一点的深色，与输出框区分 */
    border: 1px solid #3a3d42 !important; /* 极细的边框，增强现代感 */
    border-radius: 18px 18px 18px 18px !important; /* 保持圆角一致 */
}

/* 2.2 输出聊天框 (子柒的对话气泡) 添加专属特征 */
.is-assistant > .border.border-muted {
    background: linear-gradient(135deg, #1a1c1e 0%, #222529 100%) !important; /* 幽蓝的渐变，像深夜的电脑屏幕 */
    border-left: 4px solid #5f7a9e !important; /* 一道冷色的侧边高光，像她的耳机线 */
}

/* 3. 【核心】聊天框内的主要文本内容 - 绝对可读性 */
.rili-markdown-renderer {
    color: #FFFFFF !important;       /* 纯白文字，高对比度，清晰可见 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; /* 系统默认无衬线字体 */
    font-size: 15px !important;      /* 标准阅读字号 */
    line-height: 1.6 !important;     /* 舒适行间距 */
    text-shadow: none !important;    /* 严禁文字阴影，保证清晰 */
    background: transparent !important; /* 背景透明，继承气泡底色 */
    z-index: 1 !important;           /* 确保文字在背景动效之上 */
}

/* 4. 底部附加元素 (按钮、模型名、Token消耗) 强制浅色 */
/* 4.1 操作按钮 (复制、编辑等) */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    color: #b0b8c5 !important;       /* 柔和的银灰色，按钮图标的颜色 */
    opacity: 0.7 !important;
    transition: opacity 0.2s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7{
    opacity: 1 !important;           /* 悬停时完全显现，像她偷偷在意的表现 */
}

/* 4.2 模型名称文本 (例如 gemini2.5pro) */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    color: #9ea9b9 !important;       /* 浅灰蓝色，冷静且不抢眼 */
}

/* 4.3 Token消耗文本 */
/* [Token消耗hover逻辑转换未启用]
.text-orange-500 {
    color: #d9a066 !important;       /* 温暖的橘金色，像深夜的台灯，与深色背景形成舒服的对比 */
}
*/

/* 5. 加载动画 (用像素爱心替代默认的点) */
/* 5.1 隐藏默认的加载点 */
.flex.items-center.justify-center.size-6 > .flex.gap-2 {
    display: none !important;
}

/* 5.2 在父容器上创建自定义加载动画 */
.flex.items-center.justify-center.size-6 {
    position: relative !important;
    width: 40px !important;          /* 扩大容器以适应爱心 */
    height: 24px !important;         /* 保证高度足够 */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 4px auto !important;     /* 居中 */
}

/* 使用伪元素嵌入 SVG 像素爱心 (SMIL 动画) */
.flex.items-center.justify-center.size-6::before,
.flex.items-center.justify-center.size-6::after {
    content: '' !important;
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    position: absolute !important;
    /* 使用 data:image/svg+xml 嵌入 SMIL 动画的像素爱心 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23f7838c' d='M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z'%3E%3Canimate attributeName='opacity' values='1' dur='0s'/%3E%3C/svg%3E") !important;
    animation: none !important; /* 默认不使用CSS动画，只用SVG */
}

/* ::before 和 ::after 分别独立，通过SMIL实现闪烁效果 (使用内联SVG实现) */
.flex.items-center.justify-center.size-6::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e06c75' d='M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z'%3E%3Canimate attributeName='opacity' values='0.3;1;0.3' dur='1.2s' repeatCount='indefinite'/%3E%3C/svg%3E") !important;
}

.flex.items-center.justify-center.size-6::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23f7838c' d='M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z'%3E%3Canimate attributeName='opacity' values='1;0.3;1' dur='1.2s' repeatCount='indefinite'/%3E%3C/svg%3E") !important;
    transform: scale(0.8) !important;  /* 稍微小一点，形成层次感 */
}


/* 6. 背景微动效 (使用伪元素，模拟她熬夜时屏幕的光点) */
/* 此动效仅作氛围点缀，不影响可读性 */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 0 !important;
    pointer-events: none !important;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(200, 220, 255, 0.15) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 40%, rgba(200, 220, 255, 0.1) 0%, transparent 100%),
        radial-gradient(2px 2px at 50% 80%, rgba(200, 220, 255, 0.05) 0%, transparent 100%);
    background-repeat: no-repeat;
    /* 使用SMIL实现背景光点的缓慢闪烁 (可选，这里用CSS动画增强) */
    animation: starlight 8s ease-in-out infinite !important;
}

@keyframes starlight {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* 7. 移动端与低动效适配 */
@media (max-width: 480px) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted {
        padding: 18px 14px 14px 14px !important; /* 移动端紧凑一点 */
    }
    .rili-markdown-renderer {
        font-size: 14px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .is-user > .border.border-muted,
.is-assistant > .border.border-muted::before {
        animation: none !important; /* 关闭背景闪烁 */
        opacity: 0.4 !important;
    }
    .flex.items-center.justify-center.size-6::before,
    .flex.items-center.justify-center.size-6::after {
        /* SMIL动画依然保留，但降低透明度变化幅度 */
    }
}
/* ============================================
   「贪恋时光」- 与子柒的日常 UI 样式表
   专为 <ai> 容器设计，移动端优先
   配色：墨蓝黑 + 樱花粉 + 暖米白
   ============================================ */

/* ---- 容器基础 ---- */
ai {
  display: block;
  background: linear-gradient(135deg, #F9F7F4 0%, #F0ECE6 100%);
  border-radius: 20px;
  padding: 16px 18px 20px;
  margin: 8px 0;
  box-shadow: 0 2px 12px rgba(26, 27, 47, 0.06), 0 1px 4px rgba(0,0,0,0.04);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #2D2D3A;
  max-width: 100%;
  box-sizing: border-box;
  --pink: #FF9A9E;
  --pink-light: #FECFEF;
  --dark: #1A1B2F;
  --warm-gray: #C4B8A8;
  --blue: #6BA3D6;
  --red: #FF6B6B;
  --green: #51CF66;
  --purple: #845EF7;
  --gold: #FFD43B;
  --text-muted: #9E9488;
  --border-light: rgba(0,0,0,0.06);
  --tag-bg: #E8E4DE;
}

/* ---- 顶部状态栏 (hd) ---- */
hd {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 12px;
  position: relative;
  animation: hdFadeIn 0.6s ease both;
}

hd::after {
  content: '';
  position: absolute;
  bottom: -3px;
  right: 0;
  width: 30px;
  height: 3px;
  background: linear-gradient(90deg, var(--pink), var(--pink-light));
  border-radius: 3px;
}

@keyframes hdFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 主文本 (text) ---- */
text {
  display: block;
  margin-bottom: 12px;
}

text p {
  margin: 0.5em 0;
  text-indent: 2em;
  color: #3A3A4A;
}

/* ---- 可折叠面板 (details) ---- */
details {
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(2px);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

details[open] {
  box-shadow: 0 1px 6px rgba(26, 27, 47, 0.06);
}

/* ---- 折叠标题 (summary) ---- */
summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
  cursor: pointer;
  user-select: none;
  position: relative;
  z-index: 1;
  transition: background 0.2s ease, color 0.2s ease;
  list-style: none;  /* 移除默认三角 */
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: '';  /* 保留伪元素占位，实际图标用emoji */
}

summary:hover {
  background: rgba(255, 154, 158, 0.06);
  color: var(--pink);
}

/* 每个模块左侧色条 - 根据顺序分配不同颜色 */
ai > details:nth-of-type(1) > :not(summary) { border-left: 3px solid var(--warm-gray); }
ai > details:nth-of-type(2) > :not(summary) { border-left: 3px solid var(--blue); }
ai > details:nth-of-type(3) > :not(summary) { border-left: 3px solid var(--pink); }
ai > details:nth-of-type(4) > :not(summary) { border-left: 3px solid var(--warm-gray); }
ai > details:nth-of-type(5) > :not(summary) { border-left: 3px solid var(--red); }
ai > details:nth-of-type(6) > :not(summary) { border-left: 3px solid var(--green); }
ai > details:nth-of-type(7) > :not(summary) { border-left: 3px solid var(--purple); }
ai > details:nth-of-type(8) > :not(summary) { border-left: 3px solid var(--gold); }

/* 内容区统一内边距和左边距（为色条留空间） */
details > :not(summary) {
  padding: 4px 12px 12px calc(12px + 6px); /* 左内边距留出色条和间隔 */
  margin-left: 12px;    /* 与summary的图标对齐（摘要本身已有padding-left:12px，所以margin-left:0，但为了色条在左侧，我们用padding-left预留） */
  margin-top: -4px;     /* 减少与summary的间隙 */
  border-left: 3px solid transparent; /* 占位，实际颜色由上面覆盖 */
  transition: max-height 0.5s ease;
  max-height: 0;
  overflow: hidden;
}

details[open] > :not(summary) {
  max-height: 2000px;  /* 足够大 */
}

/* ---- 信息行/字段 ---- */
d, dd {
  display: block;
  font-size: 13px;
  line-height: 1.7;
  padding: 2px 0;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

d:last-of-type, dd:last-of-type {
  border-bottom: none;
}

/* dl 容器 */
dl {
  margin: 0;
  padding: 0;
}

dl dt {
  font-weight: 600;
  font-size: 14px;
  padding: 4px 0 2px;
  color: var(--dark);
}

dl dd {
  padding-left: 4px;
}

/* 小标题（带 t 属性的 p） */
p[t] {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 8px 0 4px 0;
  padding: 0;
}

p[t="ltm"] { color: var(--warm-gray); }
p[t="stm"] { color: var(--blue); }

/* ---- 好进度条 (meter) ---- */
meter {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  height: 8px;
  width: 120px;
  border-radius: 4px;
  background: #E5E0D8;
  vertical-align: middle;
  margin: 0 4px;
}

meter::-webkit-meter-bar {
  background: #E5E0D8;
  border-radius: 4px;
}

meter::-webkit-meter-optimum-value {
  background: linear-gradient(90deg, var(--pink), var(--pink-light));
  border-radius: 4px;
}

/* Firefox 兼容 */
meter::-moz-meter-bar {
  background: linear-gradient(90deg, var(--pink), var(--pink-light));
  border-radius: 4px;
}

/* ---- 标签 (tag) ---- */
tag {
  display: inline-block;
  padding: 0 8px;
  height: 20px;
  line-height: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tag-bg);
  border-radius: 10px;
  color: var(--dark);
  margin: 0 2px;
}

/* 带 v 属性的 meter 配套显示文字（已包含在HTML中，无需额外样式） */

/* ---- 其他实用类 ---- */
b, strong {
  color: var(--dark);
}

em {
  color: var(--pink);
  font-style: normal;
}

/* 引用或特殊文本 */
blockquote {
  margin: 6px 0;
  padding: 4px 8px;
  border-left: 3px solid var(--pink-light);
  background: rgba(255, 154, 158, 0.04);
  font-style: italic;
  color: #5A5A6A;
}

/* 分隔线在前面的 details 中已经使用 border，这里不再重复 */

/* ---- 响应式微调 ---- */
@media (max-width: 480px) {
  ai {
    padding: 12px 14px 16px;
    font-size: 13px;
  }
  summary {
    font-size: 13px;
    padding: 8px 10px;
  }
  d, dd {
    font-size: 12px;
  }
  meter {
    width: 80px;
  }
}