/* ═══ 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平台按钮组保护（自动注入）═══ */
.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;
}

.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;
}

/* ============ 全局背景 ============ */
body, html, #__next, [class*="bg-gray"] {
  background-color: #f4f1ea !important;
}

/* ============ 聊天框卡片 ============ */
.is-user > .border.border-muted,
.is-assistant > .border.border-muted {
  background: #faf8f4 !important;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 16px 18px;
  border: 1px solid #d9d3c9 !important;
  max-width: 600px;
}

/* 左侧竖线标记 */
.is-assistant > .border.border-muted {
  position: relative;
}
.is-assistant > .border.border-muted::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: #d1ccbf;
  border-radius: 3px 0 0 3px;
}

/* ============ 文本区域 ============ */
.rili-markdown-renderer {
  color: #2c2a27 !important;
  font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Georgia', 'Times New Roman', serif;
  line-height: 1.8;
  font-size: 0.95em;
  background: transparent !important;
}

.rili-markdown-renderer p {
  padding-bottom: 6px;
  margin-bottom: 6px;
}

/* ============ 折叠面板 ============ */
.rili-markdown-renderer details {
  margin: 12px 0;
  border: 1px solid #d9d3c9;
  border-radius: 3px;
  background: #fcfaf6;
}

.rili-markdown-renderer details summary {
  cursor: pointer;
  padding: 8px 14px;
  font-family: 'Noto Serif SC', 'Source Han Serif SC', serif;
  font-size: 0.92em;
  color: #2c2a27;
  background: #f5f0e6;
  border-bottom: 1px solid #d9d3c9;
  border-radius: 2px 2px 0 0;
  user-select: none;
  transition: background .15s;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rili-markdown-renderer details summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #a89f91;
  border: 1px solid #a89f91;
  border-radius: 2px;
  line-height: 1;
  flex-shrink: 0;
}

.rili-markdown-renderer details[open] summary::before {
  content: '−';
}

.rili-markdown-renderer details summary:hover {
  background: #ede7db;
}

.rili-markdown-renderer details[open] {
  padding-bottom: 8px;
}

.rili-markdown-renderer details[open] > :not(summary) {
  padding: 8px 14px 4px;
  font-size: 0.9em;
  color: #3a3a3a;
}

.rili-markdown-renderer details[open] p {
  border-bottom: 1px dashed #ebe4d8;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

/* ============ 操作按钮 ============ */
.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7 {
  color: #a89f91 !important;
  font-weight: normal;
  text-transform: none;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 0.85em;
  transition: color .15s, background-color .15s;
}

.bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7:hover {
  background-color: rgba(44, 42, 39, 0.06);
  color: #2c2a27 !important;
}

/* ============ 模型名称 / Token ============ */
.flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
  color: #a89f91;
  font-size: 0.8em;
  font-family: 'Courier New', monospace;
}

/* ============ 加载动画 ============ */
.flex.items-center.justify-center.size-6 > .flex.gap-2 {
  display: none !important;
}

.flex.items-center.justify-center.size-6 {
  position: relative;
  width: 24px;
  height: 24px;
}

.flex.items-center.justify-center.size-6::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='6' cy='12' r='3' fill='%23a89f91'%3E%3Canimate attributeName='r' values='3;5;3' dur='1.2s' repeatCount='indefinite' begin='0s'/%3E%3Canimate attributeName='opacity' values='1;0.4;1' dur='1.2s' repeatCount='indefinite' begin='0s'/%3E%3C/circle%3E%3Ccircle cx='12' cy='12' r='3' fill='%23a89f91'%3E%3Canimate attributeName='r' values='3;5;3' dur='1.2s' repeatCount='indefinite' begin='0.4s'/%3E%3Canimate attributeName='opacity' values='1;0.4;1' dur='1.2s' repeatCount='indefinite' begin='0.4s'/%3E%3C/circle%3E%3Ccircle cx='18' cy='12' r='3' fill='%23a89f91'%3E%3Canimate attributeName='r' values='3;5;3' dur='1.2s' repeatCount='indefinite' begin='0.8s'/%3E%3Canimate attributeName='opacity' values='1;0.4;1' dur='1.2s' repeatCount='indefinite' begin='0.8s'/%3E%3C/circle%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
}

/* ============ 移动端 ============ */
@media (max-width: 768px) {
  .is-user > .border.border-muted,
  .is-assistant > .border.border-muted {
    padding: 12px 14px;
  }
  .rili-markdown-renderer {
    font-size: 0.9em;
    line-height: 1.65;
  }
  .rili-markdown-renderer details summary {
    padding: 6px 10px;
    font-size: 0.88em;
  }
  .bg-muted.rounded.flex.p-0\.5 > button.rounded-full.size-7 {
    padding: 3px 6px;
    font-size: 0.8em;
  }
  .flex.items-center.gap-2.text-xs.font-mono.text-muted-foreground {
    font-size: 0.76em;
  }
}

/* ============ 低动效 ============ */
@media (prefers-reduced-motion: reduce) {
  .flex.items-center.justify-center.size-6::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='6' cy='12' r='3' fill='%23a89f91'/%3E%3Ccircle cx='12' cy='12' r='3' fill='%23a89f91'/%3E%3Ccircle cx='18' cy='12' r='3' fill='%23a89f91'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
  }
}