/* ========================================================= */
/* --- 1. 字体与基础设置 (时空旅客 · 诸天异客主题) --- */
/* ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600;700&family=Noto+Serif+SC:wght@600;700&family=Orbitron:wght@400;700;900&display=swap');

/* 主题色变量（源自「时空旅客」星空·金紫配色） */
:root {
    --voyager-gold: #ffd700;
    --voyager-gold-light: #ffed4a;
    --voyager-gold-deep: #d4a000;
    --voyager-violet: #8b5cf6;
    --voyager-violet-light: #a78bfa;
    --voyager-violet-deep: #6d28d9;
    --voyager-dark: #0a0a1a;
    --voyager-card: #1a0a2a;
    --voyager-cream: #f0e6f6;
    --voyager-muted: #b8a0c8;
    --voyager-border: rgba(255, 215, 0, 0.20);
    --voyager-shadow: rgba(139, 92, 246, 0.30);
}

.cinnamoroll-bubble {
    position: relative;
    margin: 28px 2px 32px 2px;
    border-radius: 12px;
    font-family: 'Noto Sans SC', 'Segoe UI', 'PingFang SC', sans-serif;
    transition: all 0.25s ease-in-out;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.50);
    line-height: 1.8;
}

.cinnamoroll-content {
    padding: 16px 4px !important;
    position: relative;
    z-index: 2;
}

.inazuma-message-text {
    font-size: 15px;
    line-height: 1.8;
    text-align: justify;
    overflow-wrap: break-word;
    word-wrap: break-word;
    font-weight: 400;
}

/* ========================================================= */
/* --- 2. AI 气泡：诸天万界空间 --- */
/* ========================================================= */
.cinnamoroll-bubble.ai-bubble {
    background: linear-gradient(145deg, #f5edf7, #ede0f5);
    border-left: 5px solid var(--voyager-violet);
    color: var(--voyager-dark);
    border-radius: 12px 12px 12px 4px;
}

.cinnamoroll-bubble.ai-bubble::before {
    content: "✦ 诸天万界空间...";
    position: absolute;
    top: -26px;
    left: 0px;
    font-size: 13px;
    font-weight: 700;
    color: var(--voyager-dark);
    background: #ede0f5;
    padding: 2px 12px 2px 10px;
    border-radius: 6px 6px 0 0;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-bottom: none;
    letter-spacing: 0.5px;
    font-family: 'Orbitron', 'Noto Serif SC', monospace;
}

.cinnamoroll-bubble.ai-bubble::after {
    content: '✦';
    position: absolute;
    bottom: 6px;
    right: 10px;
    font-size: 22px;
    color: var(--voyager-violet);
    opacity: 0.25;
    z-index: 1;
    filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.20));
}

/* AI 气泡内文字颜色（浅色背景 → 深色文字） */
.cinnamoroll-bubble.ai-bubble .inazuma-message-text {
    color: var(--voyager-dark);
}

/* ========================================================= */
/* --- 3. User 气泡：诸天万界空间 (玩家) --- */
/* ========================================================= */
.cinnamoroll-bubble.user-bubble {
    background: linear-gradient(145deg, #0a0a1a, #1a0a2a);
    border-right: 5px solid var(--voyager-gold);
    color: var(--voyager-cream);
    border-radius: 12px 12px 4px 12px;
}

.cinnamoroll-bubble.user-bubble::before {
    content: "⚡ 诸天万界空间...";
    position: absolute;
    top: -26px;
    right: 0px;
    font-size: 13px;
    font-weight: 700;
    color: var(--voyager-gold-light);
    background: #0a0a1a;
    padding: 2px 10px 2px 12px;
    border-radius: 6px 6px 0 0;
    border: 1px solid rgba(255, 215, 0, 0.25);
    border-bottom: none;
    letter-spacing: 0.5px;
    font-family: 'Orbitron', 'Noto Serif SC', monospace;
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.20);
}

.cinnamoroll-bubble.user-bubble::after {
    content: '旅';
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 18px;
    font-family: 'Noto Serif SC', serif;
    font-weight: 700;
    color: var(--voyager-gold);
    border: 2px solid var(--voyager-gold);
    padding: 0px 5px;
    opacity: 0.45;
    z-index: 1;
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.06);
    line-height: 1.4;
}

/* 用户气泡内文字颜色（深色背景 → 浅色文字） */
.cinnamoroll-bubble.user-bubble .inazuma-message-text {
    color: var(--voyager-cream);
}

/* ========================================================= */
/* --- 4. 文本特殊颜色转换 (Markdown 增强) --- */
/* ========================================================= */

/* 加粗 (Strong) -> 星辰红 · 因果烙印 */
.inazuma-message-text strong {
    color: #f472b6 !important;
    font-weight: 700;
}

/* 斜体 (Em) -> 辉光紫 · 时空韵律 */
.inazuma-message-text em {
    color: var(--voyager-violet) !important;
    font-style: italic;
}

/* 加粗斜体 -> 耀金 · 传奇之力 */
.inazuma-message-text strong em,
.inazuma-message-text em strong {
    color: var(--voyager-gold-light) !important;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.50), 0 0 32px rgba(255, 215, 0, 0.10);
    font-weight: 700;
}

/* 标题 (Header) -> 轨道书法 · 诸天标题 */
.inazuma-message-text h1,
.inazuma-message-text h2,
.inazuma-message-text h3 {
    color: var(--voyager-dark) !important;
    border-bottom: 2px solid var(--voyager-gold);
    padding-bottom: 4px;
    margin: 14px 0 8px 0;
    font-family: 'Orbitron', 'Noto Serif SC', serif;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* 标题在用户气泡（深色背景）中的适配 */
.user-bubble .inazuma-message-text h1,
.user-bubble .inazuma-message-text h2,
.user-bubble .inazuma-message-text h3 {
    color: var(--voyager-cream) !important;
    border-bottom-color: var(--voyager-gold-light);
}

/* 删除线 -> 因果湮灭 · 轨迹消散 */
.inazuma-message-text del {
    color: #888888;
    text-decoration: line-through;
    opacity: 0.55;
}

/* ========================================================= */
/* --- 5. 代码块：轮回者 --- */
/* ========================================================= */
pre {
    margin: 12px 0px !important;
    padding: 32px 4px 10px 4px !important;
    background: #f0e6f5 !important;
    border-radius: 8px;
    border: 1px solid var(--voyager-gold);
    position: relative;
    overflow-x: hidden;
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.06);
}

pre::before {
    content: "📜 轮回者...";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 26px;
    background: var(--voyager-violet-deep);
    color: var(--voyager-cream);
    font-size: 12px;
    line-height: 26px;
    padding-left: 10px;
    border-bottom: 1px solid var(--voyager-gold);
    font-weight: 600;
    letter-spacing: 0.5px;
    font-family: 'Orbitron', 'Noto Sans SC', sans-serif;
    border-radius: 8px 8px 0 0;
}

pre code {
    font-family: 'Consolas', 'Courier New', monospace !important;
    font-size: 13px !important;
    color: var(--voyager-dark) !important;
    font-weight: 600 !important;
    line-height: 1.7 !important;
    white-space: pre-wrap;
    word-break: break-all;
}

pre code strong {
    color: #f472b6 !important;
}
pre code em {
    color: var(--voyager-violet) !important;
    font-style: italic;
}

/* ========================================================= */
/* --- 6. 其它细节修饰 --- */
/* ========================================================= */

/* 引用块：诗号/箴言/旁白 */
blockquote {
    margin: 10px 4px;
    padding: 10px 16px;
    background: rgba(139, 92, 246, 0.06);
    border-left: 4px solid var(--voyager-violet);
    color: var(--voyager-dark) !important;
    font-weight: 600 !important;
    font-size: 14px;
    font-style: italic;
    border-radius: 2px 8px 8px 2px;
    line-height: 1.7;
}

blockquote strong {
    color: #f472b6 !important;
}

blockquote em {
    color: var(--voyager-violet) !important;
}

/* 用户气泡内的引用块适配（深色背景） */
.user-bubble blockquote {
    background: rgba(255, 255, 255, 0.04);
    border-left-color: var(--voyager-gold-light);
    color: var(--voyager-cream) !important;
}
.user-bubble blockquote strong {
    color: var(--voyager-gold-light) !important;
}
.user-bubble blockquote em {
    color: var(--voyager-violet-light) !important;
}

/* 分割线：星轨笔触 / 场景变换 */
hr {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--voyager-gold), transparent);
    margin: 22px 0;
    opacity: 0.30;
    border-radius: 2px;
}

/* 列表样式 */
.inazuma-message-text ul,
.inazuma-message-text ol {
    padding-left: 22px;
    margin: 6px 0;
}

.inazuma-message-text li {
    line-height: 1.8;
    margin: 2px 0;
}

/* 链接 */
.inazuma-message-text a {
    color: var(--voyager-violet);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}
.inazuma-message-text a:hover {
    color: var(--voyager-gold);
}

.user-bubble .inazuma-message-text a {
    color: var(--voyager-gold-light);
}
.user-bubble .inazuma-message-text a:hover {
    color: var(--voyager-cream);
}

/* ========================================================= */
/* --- 7. 移动端优化 --- */
/* ========================================================= */
@media (max-width: 600px) {
    .cinnamoroll-bubble {
        margin: 20px 1px 26px 1px;
        border-radius: 8px;
    }
    .cinnamoroll-content {
        padding: 12px 3px !important;
    }
    .cinnamoroll-bubble::before {
        top: -22px;
        font-size: 11px;
        padding: 1px 10px;
    }
    .cinnamoroll-bubble::after {
        font-size: 18px;
        bottom: 4px;
        right: 6px;
    }
    .cinnamoroll-bubble.user-bubble::after {
        font-size: 15px;
        top: 8px;
        left: 8px;
        padding: 0px 4px;
    }
    .inazuma-message-text {
        font-size: 14px;
        line-height: 1.7;
    }
    pre {
        padding: 28px 3px 8px 3px !important;
    }
    pre::before {
        font-size: 11px;
        height: 24px;
        line-height: 24px;
    }
    pre code {
        font-size: 12px !important;
    }
    blockquote {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* ========================================================= */
/* --- 8. 深色/浅色背景通用文字清晰保障 --- */
/* ========================================================= */

/* 确保所有文字在各自背景上都有足够对比度 */
.cinnamoroll-bubble.ai-bubble .inazuma-message-text {
    color: #0a0a1a;
}
.cinnamoroll-bubble.user-bubble .inazuma-message-text {
    color: #f0e6f6;
}

/* 特殊强调色在浅色背景上保持清晰 */
.ai-bubble .inazuma-message-text strong {
    color: #f472b6 !important;
}
.ai-bubble .inazuma-message-text em {
    color: #8b5cf6 !important;
}
.ai-bubble .inazuma-message-text strong em,
.ai-bubble .inazuma-message-text em strong {
    color: #d4a000 !important;
    text-shadow: 0 0 8px rgba(212, 160, 0, 0.35);
}

/* 特殊强调色在深色背景上保持清晰 */
.user-bubble .inazuma-message-text strong {
    color: #f9a8d4 !important;
}
.user-bubble .inazuma-message-text em {
    color: #c4b5fd !important;
}
.user-bubble .inazuma-message-text strong em,
.user-bubble .inazuma-message-text em strong {
    color: #ffed4a !important;
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.40), 0 0 40px rgba(255, 215, 0, 0.10);
}

/* 滚动条美化（适用于包含气泡的容器） */
.message-container::-webkit-scrollbar {
    width: 4px;
}
.message-container::-webkit-scrollbar-track {
    background: transparent;
}
.message-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.30);
    border-radius: 10px;
}

/* ========================================================= */
/* --- 9. 气泡入场微动效 --- */
/* ========================================================= */
.cinnamoroll-bubble {
    animation: bubbleFadeIn 0.35s ease forwards;
    opacity: 0;
    transform: translateY(6px);
}

@keyframes bubbleFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 连续气泡消除重复动画 */
.cinnamoroll-bubble + .cinnamoroll-bubble {
    animation: none;
    opacity: 1;
    transform: none;
}