* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;  /* 主题蓝色 */
    --primary-light: #60a5fa;  /* 浅蓝色 */
    --primary-dark: #1d4ed8;   /* 深蓝色 */
    --bg-color: #f8fafc;       /* 背景色 */
    --text-color: #1e293b;     /* 文字颜色 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
}

.chat-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    display: none;  /* 默认隐藏 */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-bottom: 20px;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.icon-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

#messageArea {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.message {
    max-width: 85%;
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow: hidden;
}

.user-message {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    border-radius: 12px 12px 2px 12px;
    padding: 16px 20px;
}

.ai-message {
    background: white;
    border: 1px solid #e2e8f0;
    margin-right: auto;
    border-radius: 12px 12px 12px 2px;
    padding: 16px 20px;
}

.thinking-content {
    color: #64748b;
    font-size: 0.95em;
    padding: 12px 16px;
    border-left: 3px solid #e2e8f0;
    margin-bottom: 12px;
    background: #f8fafc;
    border-radius: 6px;
}

.final-answer {
    color: #333;
}

.input-area {
    display: flex;
    gap: 10px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

#userInput {
    flex: 1;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    resize: none;
    transition: all 0.2s ease;
    line-height: 1.6;
}

#userInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

#sendBtn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.icon-btn:hover, #sendBtn:hover {
    background: var(--primary-dark);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border: 1px solid #e2e8f0;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 15px;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.button-group {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.button-group button {
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#saveSettings {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

#saveSettings:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

#closeSettings {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#closeSettings:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

.button-group button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Markdown 样式 */
.markdown-content {
    font-size: 15px;
    line-height: 1.6;
}

.message p {
    margin: 0 0 12px 0;
}

.message p:last-child {
    margin-bottom: 0;
}

.message pre,
.message .katex-display {
    margin: 12px -4px;
    padding: 16px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}

/* 适配手机端 */
@media (max-width: 768px) {
    .chat-container {
        padding: 10px;
    }

    .message {
        max-width: 90%;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* 修改滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 确保 Markdown 内容不会溢出 */
.markdown-content img {
    max-width: 100%;
    height: auto;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    overflow-x: auto;
    display: block;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #e2e8f0;
    padding: 8px;
    text-align: left;
}

.markdown-content th {
    background: #f8fafc;
}

/* LaTeX 公式样式 */
.katex-display {
    margin: 1em -2px !important;  /* 修正边距 */
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.katex {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Mermaid 图表样式 */
.mermaid-rendered {
    background: white;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mermaid-rendered svg {
    max-width: 100%;
    height: auto;
}

/* 深色主题下的 Mermaid 图表 */
.user-message .mermaid-rendered {
    background: rgba(255,255,255,0.1);
}

/* 登录界面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-color);
}

.login-box {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-color);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-form button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-form button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.login-form button:active {
    transform: translateY(0);
}

.login-error {
    color: #ef4444;
    text-align: center;
    font-size: 14px;
    margin: 0;
    min-height: 20px;
}

/* 确保聊天容器在登录后显示正确 */
.chat-container {
    display: none;  /* 默认隐藏 */
} 