:root {
    --primary-color: #f16c6c;
    --background-color: #ffffff;
    --text-color: #333;
    --message-bg-user: #ffb8b8de;
    --message-bg-ai: #ffffffc8;
    --border-radius: 12px;
    --box-shadow: 0 4px 4px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}



/* --- Header 最终布局样式 --- */

/* 1. 修改 Header 容器，让它成为按钮定位的“锚点” */
.app-header {
    position: relative; /* 关键！为内部的绝对定位元素提供参考系 */
    padding: 12px 24px; /* 上下 padding 可以稍微给多一点，更好看 */
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
    flex-shrink: 0;
}

/* 这两部分的样式保持不变，确保文字垂直居中 */
.app-header h1 {
    margin: 0;
    font-size: 1.2em;
    color: var(--primary-color);
}

.app-header p {
    margin: 2px 0 0;
    font-size: 0.8em;
    color: #666;
}


/* 2. 全新设计的“清空”按钮样式 */
#clear-button {
    position: absolute;
    top: 50%;
    right: 16px;                 /* 手机上稍微往左一点，别贴边 */
    transform: translateY(-50%);
    
    /* 强制宽高相等 + 不被压缩 */
    width: 25px !important;     /* 手机上可以稍微大一点，手感更好 */
    height: 25px !important;
    min-width: 25px;             /* 防止被flex压缩 */
    min-height: 25px;
    border-radius: 50%;
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    border: 1.5px solid #cccccc;
    background: rgba(209, 209, 209, 0.156);
}



#clear-button:hover {
    background-color: #f5f5f5; /* 鼠标悬停时给一个淡淡的背景色 */
    border-color: #aaaaaa;     /* 边框颜色也加深一点 */
}

#chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message {
    padding: 12px 18px;
    border-radius: var(--border-radius);
    max-width: 80%;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user {
    background-color: var(--message-bg-user);
    color: #ff7c7c;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background-color: var(--message-bg-ai);
    color: var(--text-color);
    align-self: flex-start;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.app-footer {
    padding: 8px 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 9px;
    flex-shrink: 0;
}

#task-input {
    flex-grow: 1;
    padding: 5px 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
}

#task-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
}

#send-button {
    padding: 5px 12px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-button:hover {
    background-color: #ff8383;
}

/* 加载动画 */
#loading-indicator {
    display: flex;
    justify-content: center;
    padding: 16px;
}


@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.hidden {
    display: none !important;
}

/* 格式化AI回复 */
.message.ai ul {
    padding-left: 20px;
    margin-top: 8px;
    margin-bottom: 0;
}
.message.ai li {
    margin-bottom: 4px;
}

/* 原有变量保持不变…… */

/* ========= 1. 恢复横向布局（头像和气泡并排） ========= */
.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;                /* 头像和气泡间距 */
    margin-bottom: 16px;
    max-width: 85%;
}

.message-wrapper.user {
    flex-direction: row-reverse;
    align-self: flex-end;     /* 整体右对齐 */
}

.message-wrapper.ai {
    align-self: flex-start;   /* 整体左对齐 */
}

/* ========= 2. 头像尺寸和圆角 ========= */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ========= 3. 气泡收紧（文字更密集好看） ========= */
.message-bubble {
    padding: 9px 14px;        /* 原来12-18 → 9-14 */
    border-radius: 12px;
    max-width: 100%;
    font-size: 0.95rem;
    line-height: 1.42;        /* 关键！行距从1.6 → 1.42 超清爽 */
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.message-wrapper.user .message-bubble {
    background: var(--message-bg-user);
    border: 1.3px solid #e8e8e800;
}

.message-wrapper.ai .message-bubble {
    background: var(--message-bg-ai);
    border: 1.3px solid #e8e8e8;
}


/* ========= 4. 重roll 按钮垂直放在 AI 头像正下方 ========= */
.message-wrapper.ai {
    position: relative;       /* 为按钮定位准备 */
}

.reroll-btn {
    position: absolute;
    left: 7px;
    top: 46px;
    font-size: 0.75rem;
    padding: 3px 3px;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 30px;
    cursor: pointer;
    opacity: 0.75;
    transition: all 0.2s;
    z-index: 10;
}

.reroll-btn:hover {
    opacity: 1;
    background: rgba(0,0,0,0.14);
}

/* ========= 5. 加载动画也对齐到头像下方 ========= */
#loading-indicator {
    align-self: flex-start;
    margin-left: 50px;        /* 40px头像 + 10px gap */
    padding: 4px 0;
}

/* ─────── 最终版：唯一一段 #app-container，再也不用 !important ─────── */
#app-container {
    width: 100%;
    max-width: 600px;
    height: 90vh;
    max-height: 800px;
    background: rgba(255, 255, 255, 0.25);                 /* 极致通透 */
    backdrop-filter: blur(28px) saturate(180%);           /* 强毛玻璃 */
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.thinking-dots {
    display: inline-block;
    animation: dots 1.5s infinite;
}

.thinking-dots span {
    animation: blink 1.5s infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 100% { opacity: 0.2; }
    50%      { opacity: 1; }
}

@keyframes dots {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}



