body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e0e7eb; /* 更柔和的背景色 */
    margin: 0;
    color: #333;
}

.chat-container {
    background-color: #ffffff;
    border-radius: 12px; /* 更大的圆角 */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1); /* 更明显的阴影 */
    width: 95%;
    max-width: 720px; /* 稍微宽一点 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 600px; /* 最小高度 */
}

h1 {
    text-align: center;
    color: #2c3e50; /* 更深的标题颜色 */
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
    font-size: 1.8em;
    background-color: #f8f9fa; /* 标题背景色 */
}

.chat-box {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px); /* 动态高度 */
    background-color: #f5f7f9; /* 聊天背景色 */
    border-bottom: 1px solid #e0e0e0;
}

.message {
    margin-bottom: 18px; /* 增加间距 */
    display: flex;
    align-items: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message-content {
    padding: 12px 18px;
    border-radius: 22px; /* 更圆的聊天气泡 */
    max-width: 75%; /* 稍微宽一点 */
    word-wrap: break-word;
    line-height: 1.6; /* 更好的行高 */
    font-size: 0.95em;
    position: relative;
}

.message.user .message-content {
    background-color: #4a90e2; /* 更现代的蓝色 */
    color: white;
    border-bottom-right-radius: 6px; /* 调整气泡角 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message.ai .message-content {
    background-color: #e9ecef; /* 浅灰色 */
    color: #333;
    border-bottom-left-radius: 6px; /* 调整气泡角 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.input-area {
    display: flex;
    flex-direction: column; /* 垂直布局 */
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #ffffff;
    gap: 10px;
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px; /* 与输入框的间距 */
}

.mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.mode-selector label {
    font-size: 0.95em;
    color: #555;
    white-space: nowrap;
}

.mode-selector select {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    font-size: 0.95em;
    background-color: #f8f9fa;
    cursor: pointer;
    appearance: none; /* 移除默认的下拉箭头 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236c757d%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13.2-5.4H18.6c-5%200-9.3%201.8-13.2%205.4A17.6%2017.6%200%200%200%200%2082.6c0%204.8%201.8%209.3%205.4%2013.2l128%20128c3.9%203.9%208.4%205.4%2013.2%205.4s9.3-1.8%2013.2-5.4l128-128c3.6-3.9%205.4-8.4%205.4-13.2%200-4.8-1.8-9.3-5.4-13.2z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px; /* 为箭头留出空间 */
}

.mode-selector select:focus {
    border-color: #80bdff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.mode-selector select option {
    background-color: #ffffff;
    color: #333;
}


.icon-button {
    background-color: #f0f2f5;
    color: #555;
    border: none;
    border-radius: 50%; /* 圆形按钮 */
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.icon-button:hover {
    background-color: #e0e2e5;
    color: #333;
}

.icon-button.active {
    background-color: #28a745; /* 激活时的背景色，例如绿色 */
    color: white;
}

.file-name {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px; /* 限制文件名宽度 */
}

.message-input-row {
    display: flex;
    align-items: flex-end; /* 底部对齐 */
    gap: 10px;
    width: 100%;
}

#user-input {
    flex-grow: 1;
    padding: 12px 18px;
    border: 1px solid #ced4da;
    border-radius: 25px; /* 更圆的输入框 */
    font-size: 1em;
    resize: vertical; /* 允许垂直调整大小 */
    min-height: 45px;
    max-height: 150px; /* 增加最大高度 */
    overflow-y: auto;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#user-input:focus {
    border-color: #80bdff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

#sugar-expert-button {
    border-radius: 25px; /* 与发送按钮保持一致 */
    width: auto; /* 宽度自适应内容 */
    height: auto; /* 高度自适应内容 */
    padding: 12px 18px; /* 调整内边距 */
    font-size: 1em; /* 调整字体大小 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    align-self: flex-end; /* 靠右对齐 */
}

#send-button {
    background-color: #28a745; /* 保持绿色 */
    color: white;
    border: none;
    border-radius: 25px; /* 更圆的发送按钮 */
    padding: 12px 25px;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    align-self: flex-end; /* 靠右对齐 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#send-button:hover {
    background-color: #218838;
    transform: translateY(-1px); /* 轻微上浮效果 */
}

.message-image {
    max-width: 100%;
    height: auto;
    border-radius: 10px; /* 更圆的图片角 */
    margin-top: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    margin-top: 10px;
}

.loading-indicator span {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #4a90e2;
    border-radius: 50%;
    margin: 0 4px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}
