/* =========================================
   二次元多元宇宙 - 精简优化版 v9
   修复：增加气泡右侧安全内边距，防止文字与悬浮复制按钮重叠干涉
   ========================================= */

:root {
  --primary: #2a5c6a;
  --primary-hover: #1e4550;
  --primary-light: rgba(42, 92, 106, 0.12);
  --secondary: #9b303c;
  --bg-deep: #eef3f5;
  --bg-card: #ffffff;
  --text: #2a2e30;
  --text-soft: #5c666b;
  --border: #d3dde2;
  --label-bp: #8250df;
}

* { box-sizing: border-box; }

/* ================= 全局基础 ================= */
body, .chat-container, #chat-wrapper,
.markdown-body, .markdown-body p, .markdown-body div {
  background-color: var(--bg-deep) !important;
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif !important;
  color: var(--text) !important;
  line-height: 1.7 !important;
}

/* ================= 折叠面板核心 ================= */
details {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  width: 96% !important;
  margin: 0.4em auto !important;
  box-shadow: 0 4px 16px rgba(28, 42, 48, 0.04) !important;
  transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}

details details {
  width: 100% !important;
  margin: 0.4em 0 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  border: 1px dashed var(--border) !important;
}

details > summary {
  background: linear-gradient(90deg, #e6eef1 0%, #f4f8fa 100%) !important;
  border-left: 4px solid var(--primary) !important;
  padding: 0.6em 14px !important;
  font-size: 1.02em !important;
  font-weight: 700 !important;
  color: var(--primary) !important;
  letter-spacing: 1px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  list-style: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

details[open] > summary {
  border-radius: 8px 8px 0 0 !important;
  border-bottom: 1px solid var(--border) !important;
}

details > summary::-webkit-details-marker { display: none !important; }

details > summary::after {
  content: "" !important;
  display: inline-block !important;
  width: 8px !important;
  height: 8px !important;
  border-right: 2px solid var(--primary) !important;
  border-bottom: 2px solid var(--primary) !important;
  transform: rotate(45deg) !important;
  transition: transform 0.3s ease !important;
  margin-right: 4px !important;
  flex-shrink: 0 !important;
}

details[open] > summary::after {
  transform: rotate(-135deg) !important;
  border-color: var(--secondary) !important;
  margin-top: 4px !important;
}

/* ================= details 内行距微调 ================= */
details p {
  display: block !important;
  margin: 0.3em 0 !important;
  line-height: 1.8 !important;
}

details br {
  display: block !important;
  content: "" !important;
  margin-bottom: 0.25em !important;
}

details[open] > *:not(summary) {
  padding: 0 14px !important;
}

details details[open] > *:not(summary) {
  padding: 0 10px !important;
}

/* ================= Markdown 原生样式增强 ================= */
.markdown-body strong,
.markdown-body b,
details strong,
details b {
  color: var(--label-bp) !important;
  font-weight: 600 !important;
}

.markdown-body em,
.markdown-body i,
details em,
details i {
  color: var(--label-bp) !important;
  font-style: italic !important;
  font-weight: 600 !important;
}

/* 潜台词引用块 */
.markdown-body blockquote,
details blockquote {
  background: #fff0f3 !important;
  border-left: 3px solid #d88c95 !important;
  color: var(--secondary) !important;
  padding: 6px 12px !important;
  margin: 4px 0 !important;
  border-radius: 4px 8px 8px 4px !important;
  font-weight: 500 !important;
  font-style: italic !important;
}

details blockquote strong,
details blockquote b {
  color: var(--secondary) !important;
}

/* ================= 代码块三色气泡 (修复留白与图标) ================= */
pre, .markdown-body pre {
  position: relative !important; 
  /* 调整：右侧增加到 44px 的内边距，给悬浮的复制按钮留出安全区，防止文字干涉 */
  padding: 14px 44px 14px 16px !important; 
  border-radius: 8px !important;
  margin: 8px 0 !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.02) !important;
  display: block !important;
  white-space: pre-wrap !important;
}

/* === 将顶部工具栏改为绝对定位，彻底消除占据的空行留白 === */
.markdown-body pre > div > div:first-child {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  height: auto !important;
  min-height: 0 !important;
  border-bottom: none !important;
  padding: 0 !important;
  background: transparent !important;
}

/* 隐藏 HTML 语言标识 */
.markdown-body pre > div > div:first-child > div:first-child {
  display: none !important;
}

/* 恢复复制按钮的原生外观，仅微调透明度 */
.markdown-body pre > div > div:first-child > div:last-child {
  opacity: 0.4 !important;
  transition: opacity 0.2s ease !important;
  padding: 4px !important;
  cursor: pointer !important;
}

.markdown-body pre > div > div:first-child > div:last-child:hover {
  opacity: 1 !important;
}
/* ================================ */

pre code, code {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif !important;
  color: var(--text) !important;
  font-size: 0.95em !important;
  line-height: 1.6 !important;
  background: transparent !important;
  padding: 0 !important;
  display: block !important;
  margin-top: 2px !important; 
}

pre:hover, .markdown-body pre:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 16px rgba(42, 92, 106, 0.08) !important;
}

pre:nth-of-type(3n+1) {
  border: 1px solid #d88c95 !important;
  background: #fff7f8 !important;
}

pre:nth-of-type(3n+2) {
  border: 1px solid #94b4be !important;
  background: #f2f7f9 !important;
}

pre:nth-of-type(3n) {
  border: 1px solid #d8c8b0 !important;
  background: #fdfbf6 !important;
}

/* ================= 行动建议分隔线 ================= */
.markdown-body h3 {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  color: var(--primary) !important;
  margin: 1.2em 0 0.6em !important;
  font-size: 0.95em !important;
  letter-spacing: 1px !important;
}

.markdown-body h3::before,
.markdown-body h3::after {
  content: "" !important;
  flex: 1 !important;
  border-bottom: 1px dashed var(--border) !important;
  margin: 0 15px !important;
}

/* ================= Loading 动画 ================= */
.flex.items-center.justify-center.w-6.h-5 {
  color: transparent !important;
  width: 100% !important;
  height: auto !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin: 20px 0 !important;
}

.flex.items-center.justify-center.w-6.h-5 > * { display: none !important; }

.flex.items-center.justify-center.w-6.h-5::after {
  content: '💠 跃迁演算进行中...' !important;
  display: block !important;
  font-family: 'Noto Sans SC', sans-serif !important;
  font-size: 16px !important;
  letter-spacing: 4px !important;
  font-weight: 900 !important;
  text-align: center !important;
  background: linear-gradient(90deg, #2a5c6a 0%, #7b42f6 50%, #2a5c6a 100%) !important;
  background-size: 200% auto !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  animation: hologram-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
}

@keyframes hologram-pulse {
  0%   { background-position: 0% center; opacity: 0.8; transform: scale(0.98); }
  50%  { opacity: 1; transform: scale(1.02); }
  100% { background-position: 200% center; opacity: 0.8; transform: scale(0.98); }
}

/* ================= 输入框优化 ================= */
#ai-chat-bottom-input {
  background: transparent !important;
  backdrop-filter: blur(4px) !important;
}

#ai-chat-input {
  background-color: #ffffff !important;
  border: 1px solid #b8cdd6 !important;
  border-radius: 8px !important;
  color: #2a2e30 !important;
  transition: all 0.3s ease !important;
  box-shadow: inset 0 2px 6px rgba(42, 92, 106, 0.05) !important;
}

#ai-chat-input:focus {
  border-color: var(--primary) !important;
  box-shadow: inset 0 2px 6px rgba(42, 92, 106, 0.05), 0 0 0 2px rgba(42, 92, 106, 0.1) !important;
  outline: none !important;
}

button:has(> img), .rounded-full > img, .MuiAvatar-root > img {
  border-radius: 50% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
}