* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #f1f1f3;
    --text-primary: #0d0d0d;
    --text-secondary: #676767;
    --text-tertiary: #8e8ea0;
    --border-light: #e5e5e5;
    --border-medium: #d1d5db;
    --accent-primary: #10a37f;
    --accent-hover: #0d8f6f;
    --accent-light: #f0fdf4;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.logo svg {
    color: var(--accent-primary);
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

.chat-history {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.history-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.history-item:hover {
    background: var(--bg-secondary);
}

.history-item.active {
    background: var(--accent-light);
    color: var(--accent-primary);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* 欢迎消息 */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 600px;
    margin: auto;
    padding: 40px 20px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--accent-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.welcome-icon svg {
    color: var(--accent-primary);
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* AI消息内容格式化样式 */
.ai-paragraph {
    margin: 8px 0;
    line-height: 1.6;
}

.ai-list {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.ai-list li {
    margin: 6px 0;
    padding: 8px 12px;
    background: rgba(16, 163, 127, 0.05);
    border-left: 3px solid #10a37f;
    border-radius: 4px;
    line-height: 1.5;
}

.ai-question-list {
    margin: 12px 0;
}

.ai-question {
    margin: 8px 0;
    padding: 10px 15px;
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    font-weight: 500;
    color: #1e40af;
}

.ai-text {
    margin: 6px 0;
    line-height: 1.6;
}

/* Markdown样式支持 */
.ai-heading {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: #1f2937;
}

.ai-heading:first-child {
    margin-top: 0;
}

h1.ai-heading {
    font-size: 1.5em;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 4px;
}

h2.ai-heading {
    font-size: 1.3em;
    color: #374151;
}

h3.ai-heading {
    font-size: 1.1em;
    color: #4b5563;
}

.ai-inline-code {
    background: #f3f4f6;
    color: #dc2626;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.ai-code-block {
    background: #1f2937;
    color: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.ai-code-block code {
    background: none;
    color: inherit;
    padding: 0;
}

.ai-link {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.ai-link:hover {
    border-bottom-color: #2563eb;
}

/* 改进消息内容的整体样式 */
.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.bot-message .message-content {
    color: #374151;
    line-height: 1.6;
}

.bot-message .message-content p:first-child {
    margin-top: 0;
}

.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

/* 有序列表样式 */
.ai-list.ordered {
    counter-reset: list-counter;
}

.ai-list.ordered li {
    counter-increment: list-counter;
    position: relative;
    padding-left: 40px;
}

.ai-list.ordered li::before {
    content: counter(list-counter) ".";
    position: absolute;
    left: 12px;
    font-weight: 600;
    color: #10a37f;
}
.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    animation: fadeIn 0.3s ease;
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.bot-message {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 15px;
    position: relative;
}

.user-message .message-content {
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
    max-width: 80%;
}

.bot-message .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    max-width: 100%;
}

.bot-message .message-content p {
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

/* 简化的列表样式 */
.bot-message .message-content .ai-list {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.bot-message .message-content .ai-list li {
    margin: 6px 0;
    padding: 8px 12px;
    background: rgba(16, 163, 127, 0.05);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
    line-height: 1.5;
}

.bot-message .message-content .ai-list li:before {
    content: '•';
    color: var(--accent-primary);
    font-weight: bold;
    margin-right: 8px;
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
    padding: 0 4px;
}

/* 输入区域 */
.input-container {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.input-form {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
}

.send-button {
    width: 36px;
    height: 36px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.send-button:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
}

/* 加载状态 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    max-width: 100px;
    margin-bottom: 24px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

/* 错误消息 */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    max-width: 800px;
}

/* 流式响应样式 */
.streaming-content {
    position: relative;
}

.streaming-content::after {
    content: '▋';
    color: var(--accent-primary);
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .input-container {
        padding: 16px;
    }
    
    .welcome-message {
        padding: 20px;
    }
    
    .welcome-message h2 {
        font-size: 24px;
    }
    
    .message-content {
        padding: 12px 16px;
    }
}

/* 滚动条样式 */
.chat-container::-webkit-scrollbar,
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track,
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.chat-history::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.chat-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}