:root {
    --primary-color: #4a90e2; /* 柔和的蓝色 */
    --secondary-color: #50e3c2; /* 柔和的青色 */
    --background-color: #1a1a2e; /* 深蓝紫背景 */
    --card-background: #2a2a4a; /* 深卡片背景 */
    --text-color: #e0e0e0; /* 浅灰文本 */
    --border-color: #3a3a5a; /* 边框颜色 */
    --input-background: #3a3a5a; /* 输入框背景 */
    --font-family-primary: 'Inter', sans-serif; /* 现代无衬线字体 */
    --font-family-mono: 'Roboto Mono', monospace; /* 等宽字体 */
}

/* 引入Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:wght@300;400;500&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-family-primary);
    color: var(--text-color);
    background-color: var(--background-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* 防止滚动条 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.chat-container {
    width: 90%;
    max-width: 900px; /* 稍微增大最大宽度 */
    height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 12px; /* 调整圆角 */
    background-color: var(--card-background);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08); /* 更深邃的阴影和细边框 */
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
    padding: 20px; /* 增加内边距 */
}

.system-prompt-container {
    margin-bottom: 20px; /* 与下方元素保持距离 */
    padding: 15px;
    background-color: var(--input-background); /* 使用输入框背景色 */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 5px rgba(0, 0, 0, 0.2); /* 增加外部阴影 */
}

.system-prompt-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95em;
    color: rgba(var(--secondary-color), 0.8); /* 标签颜色改为柔和的青色，降低透明度 */
    font-family: var(--font-family-primary);
    font-weight: 500;
}

.system-prompt-container textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-background); /* 文本框背景色与父容器一致 */
    color: var(--text-color);
    font-family: var(--font-family-mono);
    font-size: 0.9em;
    resize: vertical;
    min-height: 70px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.system-prompt-container textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3); /* 聚焦时更柔和的阴影 */
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0; /* 调整内边距 */
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px; /* 与下方聊天区域保持距离 */
}

.chat-header h1 {
    font-size: 1.8em;
    letter-spacing: 1px; /* 增加字间距 */
    color: var(--text-color);
    font-family: var(--font-family-primary);
    font-weight: 600;
}

#settings-button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5em; /* 调整图标大小 */
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease; /* 添加box-shadow过渡 */
}

#settings-button:hover {
    color: var(--primary-color);
    transform: rotate(90deg);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5); /* 悬停微光效果 */
}

.chat-messages {
    flex-grow: 1;
    padding: 0 5px; /* 调整内边距 */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--primary-color) var(--card-background);
    margin-bottom: 20px; /* 与下方输入框保持距离 */
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--card-background);
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
    border: 2px solid var(--card-background);
}

.message {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 10px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: fadeIn 0.5s ease-out;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); /* 调整阴影 */
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3); /* 用户消息阴影 */
}

.bot-message {
    align-self: flex-start;
    background-color: var(--input-background);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* 机器人消息阴影 */
}

.chat-input-form {
    display: flex;
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

.chat-input-form textarea {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-background);
    color: var(--text-color);
    font-family: var(--font-family-mono);
    font-size: 1em;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-input-form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.4); /* 聚焦时更明显的阴影 */
}

.chat-input-form button {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 12px 25px;
    font-size: 1em;
    font-family: var(--font-family-primary);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3); /* 按钮初始阴影 */
}

.chat-input-form button:hover {
    background-color: #3a7bd5; /* 按钮悬停颜色 */
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 144, 226, 0.4); /* 悬停时更明显的阴影 */
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        padding: 15px;
    }

    .chat-header {
        padding: 10px 0;
        margin-bottom: 15px;
    }

    .chat-header h1 {
        font-size: 1.5em;
    }

    #settings-button {
        font-size: 1.3em;
    }

    .system-prompt-container {
        margin-bottom: 15px;
        padding: 10px;
    }

    .system-prompt-container label {
        font-size: 0.85em;
    }

    .system-prompt-container textarea {
        min-height: 60px;
    }

    .chat-messages {
        padding: 0;
        gap: 10px;
        margin-bottom: 15px;
    }

    .message {
        max-width: 90%;
        padding: 10px 15px;
    }

    .chat-input-form {
        flex-direction: column;
        padding: 10px 0;
    }

    .chat-input-form textarea {
        margin-bottom: 10px;
    }

    .chat-input-form button {
        width: 100%;
        padding: 10px 20px;
    }
}