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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f7f7f8;
    color: #333;
    line-height: 1.6;
}

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

/* ========== 左侧边栏 ========== */
.sidebar {
    width: 300px;
    background: #fff;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #111;
}

.new-project-btn {
    width: 100%;
    padding: 10px 15px;
    background: #10a37f;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.new-project-btn:hover {
    background: #0d8c6d;
}

/* 项目列表 */
.project-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.project-list h3 {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding: 0 10px;
}

.project-item {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.project-item:hover {
    background: #f7f7f8;
}

.project-item.active {
    background: #f0f0f0;
    border-color: #10a37f;
}

.project-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #111;
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #666;
}

.stage-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.stage-badge.stage-1 {
    background: #e3f2fd;
    color: #1976d2;
}

.stage-badge.stage-2 {
    background: #fff3e0;
    color: #f57c00;
}

.stage-badge.stage-3 {
    background: #e8f5e9;
    color: #388e3c;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.project-date {
    color: #999;
    font-size: 11px;
}

.stage-select-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.stage-select-btn {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    text-decoration: none;
    color: #666;
    background: #f5f5f5;
    transition: all 0.2s;
}

.stage-select-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.stage-select-btn.current {
    background: #e3f2fd;
    color: #1976d2;
    font-weight: 500;
}

.stage-select-btn.completed {
    background: #f5f5f5;
    color: #999;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* 阶段指示器 */
.stage-indicator {
    padding: 15px;
    border-top: 1px solid #e5e5e5;
    background: #fafafa;
}

.stage-indicator h3 {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.stage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.stage-item.active {
    color: #10a37f;
    font-weight: 500;
}

.stage-item.completed {
    color: #999;
}

.stage-icon {
    font-size: 16px;
}

/* ========== 主聊天区域 ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h1 {
    font-size: 20px;
    color: #111;
}

.stage-badge-large {
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 6px;
    font-size: 14px;
    color: #666;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 消息列表 */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-bubble {
    max-width: 75%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.ai .message-bubble {
    background: #f7f7f8;
    color: #111;
    border-bottom-left-radius: 4px;
}

/* Markdown渲染样式 */
.message-bubble.markdown-body h1,
.message-bubble.markdown-body h2,
.message-bubble.markdown-body h3 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble.markdown-body h1 { font-size: 1.3em; }
.message-bubble.markdown-body h2 { font-size: 1.15em; }
.message-bubble.markdown-body h3 { font-size: 1.05em; }

.message-bubble.markdown-body p {
    margin: 8px 0;
}

.message-bubble.markdown-body ul,
.message-bubble.markdown-body ol {
    margin: 8px 0;
    padding-left: 1.5em;
}

.message-bubble.markdown-body li {
    margin: 4px 0;
}

.message-bubble.markdown-body strong {
    font-weight: 600;
}

.message-bubble.markdown-body em {
    font-style: italic;
}

.message-bubble.markdown-body code {
    background: #e8e8e8;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
}

.message-bubble.markdown-body pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-bubble.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-bubble.markdown-body hr {
    border: none;
    border-top: 1px solid #d1d5db;
    margin: 12px 0;
}

.message-bubble.markdown-body blockquote {
    border-left: 3px solid #10a37f;
    padding-left: 12px;
    margin: 8px 0;
    color: #666;
}

.message.user .message-bubble {
    background: #10a37f;
    color: white;
    border-bottom-right-radius: 4px;
}

/* 阶段分隔符 */
.stage-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
    animation: fadeIn 0.3s ease;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #d1d5db, transparent);
}

.divider-text {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    padding: 4px 12px;
    background: #f0f0f0;
    border-radius: 12px;
    white-space: nowrap;
}

/* 加载动画 */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
}

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

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

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

.loading-text {
    color: #999;
    font-size: 14px;
}

/* 按钮区域 */
.button-container {
    padding: 20px 30px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #fff;
}

.chat-button {
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: all 0.2s;
    font-family: inherit;
}

.chat-button:hover {
    background: #f9fafb;
    border-color: #10a37f;
    color: #10a37f;
}

.chat-button:active {
    transform: scale(0.98);
}

.chat-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 文件上传区域 */
.upload-area {
    padding: 20px 30px;
    border-top: 1px solid #e5e5e5;
}

.upload-btn {
    padding: 10px 20px;
    background: #10a37f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.upload-btn:hover {
    background: #0d8c6d;
}

#uploadStatus {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

#uploadStatus.success {
    color: #10a37f;
}

#uploadStatus.error {
    color: #ef4444;
}

/* 欢迎页面 */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 800px;
}

.welcome-content h1 {
    font-size: 36px;
    margin-bottom: 15px;
    color: #111;
}

.welcome-content > p {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
}

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

.feature {
    padding: 30px;
    background: #f7f7f8;
    border-radius: 12px;
    transition: transform 0.2s;
}

.feature:hover {
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.feature h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #111;
}

.feature p {
    font-size: 14px;
    color: #666;
}

.start-btn {
    padding: 12px 32px;
    background: #10a37f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s;
}

.start-btn:hover {
    background: #0d8c6d;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #111;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: #10a37f;
}

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

.btn-cancel, .btn-submit {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-cancel {
    background: #f0f0f0;
    color: #666;
}

.btn-cancel:hover {
    background: #e5e5e5;
}

.btn-submit {
    background: #10a37f;
    color: white;
}

.btn-submit:hover {
    background: #0d8c6d;
}

/* 滚动条样式 */
.message-list::-webkit-scrollbar,
.project-list::-webkit-scrollbar {
    width: 6px;
}

.message-list::-webkit-scrollbar-track,
.project-list::-webkit-scrollbar-track {
    background: transparent;
}

.message-list::-webkit-scrollbar-thumb,
.project-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.message-list::-webkit-scrollbar-thumb:hover,
.project-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .message-bubble {
        max-width: 85%;
    }
}
