/* =========================================================
   魔法手账剪报风 - 聊天框美化方案 (适配高对比度与移动端)
   ========================================================= */

/* 1. 隐藏平台默认的顶部颜色装饰条 */
[class*="bg-[#F1CBCB]"], 
[class*="bg-[#c9e1e9]"] {
    display: none !important;
}

/* 2. 统一聊天框基础样式 (手账波点纸背景 + 剪报硬阴影) */
.bg-gray-100\/90.relative.inline-block {
    background-color: #fdfbf7 !important; /* 浅色手账纸底色 */
    background-image: radial-gradient(#ffeaa7 3px, transparent 3px) !important; /* 亮黄色波点 */
    background-size: 24px 24px !important;
    border: 3px dashed #fd79a8 !important; /* 魔法少女粉虚线边框 */
    border-radius: 16px !important;
    box-shadow: 6px 6px 0px #a29bfe !important; /* 错位硬阴影，增强剪报感 */
    padding: 18px !important;
    margin-bottom: 10px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* 悬浮时轻微交互，增加活泼感 */
.bg-gray-100\/90.relative.inline-block:hover {
    transform: translate(-2px, -2px) !important;
    box-shadow: 8px 8px 0px #a29bfe !important;
}

/* 3. 单独区分用户输入框 (横格笔记本风格) */
.bg-gray-100\/90.relative.inline-block:not(.chat-answer-container .bg-gray-100\/90) {
    background-color: #ffffff !important;
    border: 3px solid #74b9ff !important; /* 活泼的天蓝色实线 */
    box-shadow: 6px 6px 0px #00b894 !important; /* 绿色硬阴影 */
    /* 笔记本横格线背景 */
    background-image: repeating-linear-gradient(transparent, transparent 27px, #dfe6e9 27px, #dfe6e9 28px) !important;
    background-size: 100% 28px !important;
}

/* 4. 【最高优先级】主文本高对比度可读性控制 */
.markdown-body {
    color: #2d3436 !important; /* 深灰色，确保在浅色底上绝对清晰 */
    font-weight: 800 !important; /* 加粗文字提升阅读体验 */
    font-family: "Comic Sans MS", "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif !important; /* 活泼圆润的字体栈 */
    text-shadow: none !important; /* 绝对禁止文字发光影响可读性 */
    line-height: 1.7 !important;
    z-index: 1 !important;
    position: relative !important;
}

/* 5. 底部附加元素 (按钮、Token、模型名称) 高对比度亮色调 */
.MuiButtonBase-root.MuiButton-root.MuiButton-text.MuiButton-textPrimary,
.MuiTypography-root.MuiTypography-body2.css-6c0gf2,
.text-orange-500 {
    color: #6c5ce7 !important; /* 活泼的紫色 */
    font-weight: 800 !important;
    background: rgba(255, 255, 255, 0.7) !important; /* 垫一层半透明白底防止波点干扰 */
    padding: 2px 6px !important;
    border-radius: 4px !important;
}

/* =========================================================
   6. 巨大的 SVG 魔法阵加载动画 (SMIL驱动)
   ========================================================= */

/* a. 隐藏默认无聊的加载点 */
.style_dot-flashing__8L91Q.style_text__zGhNq {
    display: none !important;
}

/* b. 扩大加载容器，准备召唤魔法阵 */
.flex.items-center.justify-center.w-6.h-5 {
    position: relative !important;
    width: 100% !important; /* 占满宽度以便居中 */
    height: 160px !important; /* 留出巨大的高度空间 */
    margin: 10px 0 !important;
    overflow: visible !important;
}

/* c. 注入内联 SVG 魔法阵 (使用SMIL动画确保无视CSS禁动效) */
.flex.items-center.justify-center.w-6.h-5::before {
    content: "" !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 150px !important; /* 巨大的魔法阵尺寸 */
    height: 150px !important;
    z-index: 10 !important;
    pointer-events: none !important;
    /* 
       SVG解析：
       - 外圈粉色虚线圆（顺时针缓转）
       - 中圈紫色实线圆（逆时针快转）
       - 内嵌绿色双三角构成六芒星（顺时针旋转）
       - 中心粉色心形（跳动缩放）
    */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3C!-- Outer Dashed Circle --%3E%3Ccircle cx='100' cy='100' r='90' fill='none' stroke='%23fd79a8' stroke-width='4' stroke-dasharray='15 10'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 100 100' to='360 100 100' dur='12s' repeatCount='indefinite'/%3E%3C/circle%3E%3C!-- Inner Solid Circle --%3E%3Ccircle cx='100' cy='100' r='75' fill='none' stroke='%23a29bfe' stroke-width='2'%3E%3CanimateTransform attributeName='transform' type='rotate' from='360 100 100' to='0 100 100' dur='8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C!-- Hexagram Triangle 1 --%3E%3Cpolygon points='100,35 156,132 44,132' fill='none' stroke='%2300b894' stroke-width='3'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 100 100' to='360 100 100' dur='15s' repeatCount='indefinite'/%3E%3C/polygon%3E%3C!-- Hexagram Triangle 2 --%3E%3Cpolygon points='100,165 156,68 44,68' fill='none' stroke='%2300b894' stroke-width='3'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 100 100' to='360 100 100' dur='15s' repeatCount='indefinite'/%3E%3C/polygon%3E%3C!-- Center Beating Heart --%3E%3Cpath d='M100,85 C100,85 90,70 75,70 C55,70 55,95 55,95 C55,115 100,145 100,145 C100,145 145,115 145,95 C145,95 145,70 125,70 C110,70 100,85 100,85 Z' fill='%23fd79a8'%3E%3CanimateTransform attributeName='transform' type='scale' values='1; 1.15; 1' calcMode='spline' keySplines='0.4 0 0.2 1; 0.4 0 0.2 1' dur='1.2s' repeatCount='indefinite' additive='sum'/%3E%3C/path%3E%3C/svg%3E") !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* d. 魔法阵中心的动态文字 */
.flex.items-center.justify-center.w-6.h-5::after {
    content: "少女祈祷中..." !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    color: #d63031 !important; /* 醒目的深红色 */
    font-weight: 900 !important;
    font-size: 14px !important;
    letter-spacing: 2px !important;
    white-space: nowrap !important;
    /* 纯白描边，确保文字在复杂的魔法阵线条上清晰可读 */
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff !important;
    z-index: 11 !important;
    animation: pulseText 1.2s ease-in-out infinite alternate !important;
}

@keyframes pulseText {
    from { opacity: 0.8; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

/* =========================================================
   7. 移动端适配 (窄屏幕微调)
   ========================================================= */
@media (max-width: 480px) {
    .bg-gray-100\/90.relative.inline-block {
        padding: 12px !important;
        box-shadow: 4px 4px 0px #a29bfe !important; /* 缩小阴影 */
    }
    .flex.items-center.justify-center.w-6.h-5::before {
        width: 120px !important; /* 移动端魔法阵稍微缩放以免溢出 */
        height: 120px !important;
    }
    .flex.items-center.justify-center.w-6.h-5::after {
        font-size: 12px !important;
    }
}

ai {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #fdfbf7;
  padding: 12px;
  border-radius: 16px;
  color: #2d3436;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: inset 0 0 40px rgba(255, 234, 167, 0.2);
  background-image: radial-gradient(#dfe6e9 1px, transparent 1px);
  background-size: 20px 20px;
}

ai details {
  background: #fff;
  border: 2px dashed #b2bec3;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 15px;
  position: relative;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.03);
  transition: all 0.3s ease;
}

ai details::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 50px;
  height: 16px;
  background: rgba(255, 234, 167, 0.8);
  box-shadow: 1px 1px 2px rgba(0,0,0,0.1);
  z-index: 1;
}

ai summary {
  font-weight: 800;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 10px;
  font-size: 15px;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
  letter-spacing: 0.5px;
  list-style: none;
}
ai summary::-webkit-details-marker { display: none; }

/* 基础条目与字段 */
ai d { display: block; margin-bottom: 6px; border-bottom: 1px dotted #ecf0f1; padding-bottom: 4px; }
ai f { 
  font-weight: 700; 
  padding: 2px 6px; 
  border-radius: 4px; 
  margin-right: 6px; 
  font-size: 0.9em;
  display: inline-block;
}

ai ul { margin: 5px 0 10px 0; padding-left: 20px; }
ai li { margin-bottom: 4px; color: #444; }

/* 正文小说区 */
ai txt {
  display: block;
  padding: 16px;
  background: rgba(255, 255, 255, 0.9);
  border-left: 5px solid #74b9ff;
  border-radius: 0 12px 12px 0;
  margin: 20px 0;
  font-size: 15.5px;
  line-height: 1.8;
  color: #2c3e50;
  box-shadow: 0 2px 8px rgba(116, 185, 255, 0.15);
}

/* 顶部便签 (.t) */
ai .t { border-color: #ffeaa7; background: #fffcf3; }
ai .t summary { background: #ffeaa7; color: #d35400; transform: rotate(-1deg); }
ai .t f { background: #ffeaa7; color: #d35400; }

/* 新闻报纸 (.n) */
ai .n { border-color: #636e72; border-style: solid; background: #fdfdfd; }
ai .n summary { background: #2d3436; color: #fff; transform: rotate(1deg); }
ai .n f { background: #2d3436; color: #fff; }

/* 主角-暗紫打工人 (.p) */
ai .p { border-color: #a29bfe; }
ai .p summary { background: #a29bfe; color: #fff; transform: rotate(-1deg); }
ai .p f { background: #dfe6e9; color: #6c5ce7; }

/* 妹妹-魔法少女粉 (.e) */
ai .e { border-color: #fd79a8; border-style: solid; box-shadow: inset 0 0 15px rgba(253, 121, 168, 0.1); }
ai .e summary { background: #fd79a8; color: #fff; border-radius: 20px; }
ai .e f { background: #fab1a0; color: #d63031; }
ai q {
  display: block;
  margin-top: 10px;
  padding: 10px;
  background: #ffeaa7;
  border-radius: 12px;
  border-bottom-right-radius: 0;
  font-style: italic;
  color: #d35400;
  position: relative;
}

/* 记忆手账 (.m) */
ai .m { border-color: #74b9ff; }
ai .m summary { background: #74b9ff; color: #fff; }
ai mr { display: block; font-size: 0.85em; color: #636e72; background: #f1f2f6; padding: 6px; border-radius: 4px; margin-bottom: 8px; }
ai .sm { border: none; box-shadow: none; padding: 0; margin-bottom: 5px; background: transparent; }
ai .sm::before { display: none; }
ai .sm summary { background: #dfe6e9; color: #2d3436; font-size: 13px; margin-bottom: 5px; box-shadow: none; }
ai .sm p { margin: 0; padding-left: 10px; font-size: 13px; border-left: 2px solid #74b9ff; }

/* 行动Galgame按钮 (.a) */
ai .a { border: none; background: transparent; box-shadow: none; padding: 0; }
ai .a::before { display: none; }
ai .a summary { background: #00b894; color: #fff; display: block; text-align: center; margin-bottom: 15px; }
ai btn {
  display: block;
  background: linear-gradient(135deg, #fff, #f1f2f6);
  border: 2px solid #a29bfe;
  color: #6c5ce7;
  font-weight: bold;
  padding: 10px 15px;
  border-radius: 25px;
  margin-bottom: 10px;
  text-align: center;
  box-shadow: 0 4px 0 #a29bfe;
  cursor: pointer;
  transition: all 0.2s;
}
ai btn:active { transform: translateY(4px); box-shadow: 0 0 0 #a29bfe; }