/* ===================== 全局重置 + 全屏适配 ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html, body, #app {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* ===================== 暖色柔和极简背景 ===================== */
body {
    background: #f6f3ee;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===================== 主容器（柔和毛玻璃） ===================== */
#app {
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 0;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.06);
}

/* ===================== 顶部品牌栏（中性浅色） ===================== */
#brand-bar {
    width: 100%;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(250, 248, 244, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
#brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2f9a94 0%, #3bb7ad 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}
/* 极简品牌标记：logo 圆角块内放一个白色「C」形，替代儿童图标 */
#brand-logo::after {
    content: "C";
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}
#brand-name {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #2b2b2b;
}

/* ===================== 消息列表区域 ===================== */
#message-list {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
    scrollbar-width: none; /* 隐藏滚动条 */
}
#message-list::-webkit-scrollbar {
    display: none;
}

/* ===================== 消息气泡样式 ===================== */
.message {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.6;
    animation: slideIn 0.3s ease-out;
    word-wrap: break-word;
}
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 用户消息（暖米白） */
.user-message {
    align-self: flex-end;
    background: #efe9df;
    color: #333;
    border-bottom-right-radius: 4px;
}
.user-avatar {
    align-self: flex-end;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #2f9a94;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 3px;
}

/* AI消息（纯白/浅沙色） */
.ai-message {
    align-self: flex-start;
    background: #ffffff;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 4px;
}
.ai-avatar {
    align-self: flex-start;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #f1ece4;
    color: #2f9a94;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 3px;
}

/* ===================== 等待动画（理发器推子，极简配色） ===================== */
#loading-container {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: slideIn 0.3s ease-out;
}
#clipper-animation {
    width: 120px;
    height: 40px;
    position: relative;
    background: #f4f0e9;
    border-radius: 20px;
    padding: 5px;
    display: flex;
    align-items: center;
}
#clipper {
    width: 50px;
    height: 30px;
    background: linear-gradient(135deg, #3a3a3a 0%, #5a5a5a 100%);
    border-radius: 15px 5px 5px 15px;
    position: absolute;
    left: 10px;
    animation: clipperMove 1.2s ease-in-out infinite;
}
#clipper::after {
    content: "";
    width: 20px;
    height: 20px;
    background: #2f9a94;
    border-radius: 50%;
    position: absolute;
    right: -10px;
    top: 5px;
}
@keyframes clipperMove {
    0%, 100% { left: 10px; }
    50% { left: 60px; }
}
.hair-particle {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    position: absolute;
    animation: hairFall 1.2s ease-in-out infinite;
}
.hair-particle:nth-child(2) { background: #9aa3a6; left: 30px; top: 15px; animation-delay: 0.1s; }
.hair-particle:nth-child(3) { background: #bfc4c6; left: 50px; top: 10px; animation-delay: 0.2s; }
.hair-particle:nth-child(4) { background: #2f9a94; left: 70px; top: 18px; animation-delay: 0.3s; }
.hair-particle:nth-child(5) { background: #d9cdbd; left: 90px; top: 12px; animation-delay: 0.4s; }
@keyframes hairFall {
    0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
    50% { opacity: 1; transform: translateY(10px) scale(1); }
}

/* ===================== 底部输入区域 ===================== */
#input-area {
    width: 100%;
    padding: 15px 20px;
    display: flex;
    gap: 12px;
    background: rgba(250, 248, 244, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
#question-input {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 25px;
    font-size: 16px;
    background: #ffffff;
    color: #333;
    outline: none;
    transition: all 0.3s ease;
}
#question-input::placeholder {
    color: #9b968d;
}
#question-input:focus {
    border-color: #2f9a94;
    box-shadow: 0 0 0 3px rgba(47, 154, 148, 0.12);
}
#send-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: #2f9a94;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}
#send-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(47, 154, 148, 0.3);
}
#send-btn:active:not(:disabled) {
    transform: scale(0.95);
}
#send-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ===================== AI 回答 Markdown 排印（说明书文档感） =====================
   沿用「一类名多处生效」写法：用 :is(...) 让一组标签共用同一套样式，
   避免为每个标签单独命名类。字体与强调色统一为中性深色 + teal。 */

/* 统一样式基调：标题/列表/段落均继承气泡文字色并拉开节奏 */
.ai-message :is(h1, h2, h3, p, ul, ol, pre, blockquote, table) {
    margin: 0 0 8px;
}
.ai-message :is(h1, h2, h3, p, ul, ol, pre, blockquote, table):last-child {
    margin-bottom: 0;
}

/* 多级标题：紧凑、有层级但不喧宾夺主 */
.ai-message :is(h1, h2, h3) {
    line-height: 1.3;
    font-weight: 700;
    color: #2b2b2b;
}
.ai-message h1 {
    font-size: 1.25em;
}
.ai-message h2 {
    font-size: 1.12em;
    margin-top: 12px;
    padding-bottom: 4px;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.12);
}
.ai-message h3 {
    font-size: 1em;
}

/* 段落 */
.ai-message p {
    line-height: 1.7;
}

/* 有序 / 无序列表 */
.ai-message :is(ol, ul) {
    padding-left: 1.5em;
}
.ai-message li {
    margin-bottom: 4px;
    line-height: 1.7;
}
.ai-message li:last-child {
    margin-bottom: 0;
}

/* 表格：细边框、表头底色，窄屏可横向滚动 */
.ai-message {
    overflow-x: auto; /* 表格过宽时气泡内横向滚动，不撑破布局 */
}
.ai-message :is(table) {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    font-size: 0.95em;
}
.ai-message :is(th, td) {
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.ai-message th {
    background: rgba(0, 0, 0, 0.04);
    font-weight: 700;
    white-space: nowrap;
}

/* 行内代码 / 代码块 */
.ai-message :is(code) {
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 5px;
    border-radius: 5px;
    font-family: "SF Mono", Consolas, "Courier New", monospace;
    font-size: 0.9em;
}
.ai-message pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 12px;
    border-radius: 10px;
    overflow-x: auto;
}
.ai-message pre code {
    background: transparent;
    padding: 0;
}

/* 引用块 */
.ai-message blockquote {
    border-left: 3px solid rgba(47, 154, 148, 0.4);
    background: rgba(0, 0, 0, 0.03);
    padding: 8px 12px;
    border-radius: 0 10px 10px 0;
    color: #555;
}

/* 行内加粗 */
.ai-message strong {
    color: #2f9a94;
    font-weight: 700;
}

/* 打字机光标 */
.typing-caret {
    display: inline-block;
    width: 8px;
    height: 1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: #2f9a94;
    border-radius: 2px;
    animation: caretBlink 0.8s step-end infinite;
}
@keyframes caretBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}