* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background: #f7f9fc;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px 0;
}

.header h1 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 5px;
}

.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    position: relative;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background: #3498db;
    color: white;
    border-bottom-right-radius: 5px;
}

.assistant-message {
    align-self: flex-start;
    background: #f1f2f6;
    color: #2d3436;
    border-bottom-left-radius: 5px;
}

.message-content {
    min-height: 20px;
    font-size: 16px;
    line-height: 1.6;
}

/* 思考内容样式 - 更明显的视觉区分 */
.thinking-container {
    background: #e1f0fa;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.thinking-header {
    padding: 10px 15px;
    background: #3498db;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-header .toggle-thinking {
    background: none;
    border: none;
    color: white;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thinking-content {
    padding: 15px;
    font-style: italic;
    color: #2c3e50;
    display: block;
}

.thinking-content.collapsed {
    display: none;
}

/* Markdown样式 */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: #f1f2f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #e74c3c;
}

.message-content pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 15px 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.message-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.message-content ul,
.message-content ol {
    padding-left: 25px;
    margin: 12px 0;
}

.message-content li {
    margin-bottom: 8px;
}

.message-content blockquote {
    border-left: 4px solid #3498db;
    padding-left: 15px;
    margin: 15px 0;
    color: #7f8c8d;
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 0 8px 8px 0;
}

/* 数学公式容器 */
.katex-container {
    overflow-x: auto;
    padding: 10px 0;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
}

.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    margin: 15px 0;
}

.assistant-thinking {
    align-self: flex-start;
    background: #f1f2f6;
    border: 1px dashed #dfe6e9;
    color: #636e72;
    padding: 12px 18px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 180px;
}

.typing-indicator {
    display: flex;
    gap: 5px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #636e72;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

.input-area {
    border-top: 1px solid #ecf0f1;
    padding: 15px;
    background: white;
}

.input-group {
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #ecf0f1;
    border-radius: 25px;
    font-size: 16px;
    transition: all 0.3s;
    background: #f8f9fa;
}

#messageInput:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#sendButton {
    padding: 14px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
}

#sendButton:hover {
    background: #2980b9;
}

#sendButton:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.config-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.config-toggle:hover {
    transform: rotate(30deg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.config-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.config-box {
    background: white;
    padding: 25px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.config-box h2 {
    margin-top: 0;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.5rem;
}

.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

.config-group input,
.config-group select,
.config-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.config-group input:focus,
.config-group select:focus,
.config-group textarea:focus {
    border-color: #3498db;
    outline: none;
}

.config-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.config-actions button {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s;
}

.save-btn {
    background: #3498db;
    color: white;
    border: none;
}

.save-btn:hover {
    background: #2980b9;
}

.close-btn {
    background: #ecf0f1;
    border: 2px solid #bdc3c7;
    color: #34495e;
}

.close-btn:hover {
    background: #dfe6e9;
}

.error-message {
    background: #ff6b6b;
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    margin-top: 10px;
    display: none;
    font-size: 14px;
}

.formula-error {
    color: #e74c3c;
    font-size: 0.9em;
    margin-top: 5px;
    padding: 5px;
    border-radius: 4px;
    background-color: #fff1f0;
    border: 1px solid #ffccc7;
}

.preset-selection {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 8px 15px;
    background: #f1f2f6;
    border: 1px solid #dfe6e9;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.preset-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .input-group {
        flex-direction: column;
    }

    #sendButton {
        padding: 12px;
    }

    .message {
        max-width: 90%;
    }

    .config-toggle {
        top: 10px;
        right: 10px;
    }

    .config-box {
        padding: 15px;
    }
}