/* ================================================================
   全局基础样式（书面常用色背景 · 暧昧粉主调）
   ================================================================ */

/* ---------- 全局背景 ---------- */
body {
    background: #f7f3ee;          /* 米白暖灰，书面常用色 */
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: #2c2a2a;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

/* ---------- 对话容器（用于分区左右） ---------- */
.chat-container {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ---------- 基础气泡 ---------- */
.chat-bubble {
    max-width: 78%;
    padding: 14px 20px;
    border-radius: 18px;
    position: relative;
    box-shadow: 0 2px 12px rgba(160, 80, 80, 0.08);
    transition: box-shadow 0.2s ease;
    word-break: break-word;
}

.chat-bubble:hover {
    box-shadow: 0 4px 20px rgba(180, 80, 80, 0.12);
}

/* ---------- 用户气泡（靠右，暧昧粉主色） ---------- */
.user-bubble {
    align-self: flex-end;
    background: linear-gradient(145deg, #fce4e4, #f8d0d0);
    border: 1px solid #ecc0c0;
    border-bottom-right-radius: 4px;
    color: #2c1e1e;
}

.user-bubble::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 10px;
    width: 14px;
    height: 14px;
    background: #f8d0d0;
    border-right: 1px solid #ecc0c0;
    border-bottom: 1px solid #ecc0c0;
    transform: rotate(-45deg);
    border-radius: 0 0 4px 0;
}

/* ---------- AI气泡（靠左，柔白粉底） ---------- */
.ai-bubble {
    align-self: flex-start;
    background: linear-gradient(145deg, #fcf6f6, #f8eeee);
    border: 1px solid #e8d4d4;
    border-bottom-left-radius: 4px;
    color: #2a2222;
}

.ai-bubble::after {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 10px;
    width: 14px;
    height: 14px;
    background: #f8eeee;
    border-left: 1px solid #e8d4d4;
    border-bottom: 1px solid #e8d4d4;
    transform: rotate(45deg);
    border-radius: 0 0 0 4px;
}

/* ---------- 气泡内边距 ---------- */
.bubble-content {
    padding: 2px 0;
}

/* ================================================================
   消息文本样式（清晰锐利，所有变色均高对比）
   ================================================================ */

.message-text {
    font-size: 16px;
    line-height: 1.8;
    color: #2c2222;
    font-weight: 400;
}

/* ----- 加粗（深粉红，清晰） ----- */
.message-text strong {
    color: #b34b6b !important;        /* 深粉红，高对比 */
    font-weight: 700;
}

/* ----- 斜体（玫瑰紫，明显） ----- */
.message-text em {
    color: #8e5a7a !important;        /* 玫瑰紫，与背景反差足够 */
    font-style: italic;
    font-weight: 500;
}

/* ----- 加粗斜体（亮粉红+光晕，确保突出） ----- */
.message-text strong em,
.message-text em strong {
    color: #d45a7a !important;
    font-weight: 900;
    font-style: italic;
    text-shadow: 0 0 8px rgba(212, 90, 122, 0.25);
}

/* ----- 标题（深褐，典雅） ----- */
.message-text h1,
.message-text h2,
.message-text h3 {
    color: #4d3a3a !important;
    font-weight: 700;
    border-bottom: 2px solid #ecc0c0;
    padding-bottom: 4px;
    margin: 18px 0 12px 0;
    font-family: 'Georgia', 'Times New Roman', serif;
}
.message-text h1 { font-size: 1.7rem; }
.message-text h2 { font-size: 1.4rem; }
.message-text h3 { font-size: 1.2rem; }

/* ----- 删除线（灰，低调） ----- */
.message-text del {
    color: #998888;
    text-decoration: line-through;
}

/* ================================================================
   代码块（商用干净风格）
   ================================================================ */
.message-text pre {
    margin: 14px 0 !important;
    padding: 28px 6px 10px 6px !important;
    background: #f4f0ec !important;
    border-radius: 12px;
    border: 1px solid #e8d4d4;
    position: relative;
    overflow-x: auto;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.03);
}

.message-text pre::before {
    content: "⌨️ 代码片段";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 26px;
    background: #e8d4d4;
    color: #4d3a3a;
    font-size: 12px;
    font-weight: 600;
    line-height: 26px;
    padding-left: 14px;
    border-radius: 12px 12px 0 0;
    letter-spacing: 0.03em;
}

.message-text pre code {
    font-family: 'JetBrains Mono', 'Consolas', monospace !important;
    font-size: 14px !important;
    color: #2c2222 !important;
    font-weight: 500 !important;
    line-height: 1.7 !important;
    white-space: pre-wrap;
    word-break: break-all;
}

.message-text pre code strong {
    color: #b34b6b !important;
    font-weight: 700;
}
.message-text pre code em {
    color: #8e5a7a !important;
    font-style: italic;
}
.message-text pre code strong em,
.message-text pre code em strong {
    color: #d45a7a !important;
    text-shadow: 0 0 8px rgba(212, 90, 122, 0.2);
}

/* ================================================================
   引用块（柔粉边框）
   ================================================================ */
.message-text blockquote {
    margin: 14px 0;
    padding: 12px 20px;
    background: #faf4f0;
    border-left: 5px solid #f0b8b8;
    color: #3a2e2e !important;
    font-weight: 500;
    font-size: 15px;
    font-style: italic;
    border-radius: 4px 12px 12px 4px;
}

.message-text blockquote strong {
    color: #b34b6b !important;
    font-weight: 700;
}
.message-text blockquote em {
    color: #8e5a7a !important;
    font-style: italic;
}
.message-text blockquote strong em,
.message-text blockquote em strong {
    color: #d45a7a !important;
    text-shadow: 0 0 8px rgba(212, 90, 122, 0.2);
}

/* ================================================================
   分割线（暧昧粉渐隐）
   ================================================================ */
.message-text hr {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #f0b8b8, #ecc0c0, #f0b8b8, transparent);
    margin: 24px 0;
    opacity: 0.6;
}

/* ================================================================
   列表与链接
   ================================================================ */
.message-text ul,
.message-text ol {
    padding-left: 24px;
    margin: 10px 0;
    color: #2c2222;
}
.message-text li {
    margin-bottom: 4px;
}
.message-text a {
    color: #b34b6b;
    text-decoration: underline wavy #ecc0c0 1px;
    text-underline-offset: 3px;
    transition: color 0.2s;
}
.message-text a:hover {
    color: #8e3a5a;
}

/* ================================================================
   移动端优化
   ================================================================ */
@media (max-width: 600px) {
    .chat-bubble {
        max-width: 90%;
        padding: 12px 16px;
        border-radius: 14px;
    }
    .message-text {
        font-size: 15px;
    }
    .user-bubble::after,
    .ai-bubble::after {
        display: none;   /* 小屏简化三角 */
    }
    .chat-container {
        gap: 14px;
    }
}

/* ================================================================
   辅助类（可选用）
   ================================================================ */
/* 若要整体居中容器，可在外层包裹 .chat-container */
.chat-container .user-bubble {
    align-self: flex-end;
}
.chat-container .ai-bubble {
    align-self: flex-start;
}