/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS 变量定义 - 默认暗黑主题 */
:root {
    /* 背景色 */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-header: #010409;
    --bg-input: #0d1117;
    --bg-hover: #30363d;
    
    /* 文字颜色 */
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-link: #58a6ff;
    
    /* 边框颜色 */
    --border-primary: #30363d;
    --border-secondary: #21262d;
    --border-focus: #1f6feb;
    
    /* 强调色 */
    --accent-primary: #1f6feb;
    --accent-success: #3fb950;
    --accent-warning: #d29922;
    --accent-danger: #f85149;
    
    /* 其他 */
    --shadow-sm: 0 1px 0 rgba(27,31,35,0.04);
    --shadow-md: 0 3px 6px rgba(27,31,35,0.12);
    --shadow-lg: 0 8px 24px rgba(27,31,35,0.12);
    --code-bg: #161b22;
    --code-border: #30363d;
}

/* 明亮主题 */
body.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #f0f2f5;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f3f4f6;
    
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-muted: #6e7781;
    --text-link: #0969da;
    
    --border-primary: #d0d7de;
    --border-secondary: #d8dee4;
    --border-focus: #0969da;
    
    --accent-primary: #0969da;
    --accent-success: #1a7f37;
    --accent-warning: #9a6700;
    --accent-danger: #cf222e;
    
    --shadow-sm: 0 1px 0 rgba(27,31,35,0.04);
    --shadow-md: 0 3px 6px rgba(140,149,159,0.15);
    --shadow-lg: 0 8px 24px rgba(140,149,159,0.2);
    --code-bg: #f6f8fa;
    --code-border: #d0d7de;
}

/* 深海蓝主题 */
body.theme-ocean {
    --bg-primary: #0a192f;
    --bg-secondary: #112240;
    --bg-tertiary: #1d3a5f;
    --bg-header: #020c1b;
    --bg-input: #112240;
    --bg-hover: #233554;
    
    --text-primary: #ccd6f6;
    --text-secondary: #8892b0;
    --text-muted: #64ffda;
    --text-link: #64ffda;
    
    --border-primary: #233554;
    --border-secondary: #1d3a5f;
    --border-focus: #64ffda;
    
    --accent-primary: #64ffda;
    --accent-success: #64ffda;
    --accent-warning: #ffd700;
    --accent-danger: #ff6b6b;
    
    --code-bg: #112240;
    --code-border: #233554;
}

/* 森林绿主题 */
body.theme-forest {
    --bg-primary: #0b1a0b;
    --bg-secondary: #1a2f1a;
    --bg-tertiary: #2d4a2b;
    --bg-header: #051005;
    --bg-input: #1a2f1a;
    --bg-hover: #3e5c3a;
    
    --text-primary: #e8f5e9;
    --text-secondary: #a5d6a7;
    --text-muted: #81c784;
    --text-link: #66bb6a;
    
    --border-primary: #3e5c3a;
    --border-secondary: #2d4a2b;
    --border-focus: #66bb6a;
    
    --accent-primary: #66bb6a;
    --accent-success: #4caf50;
    --accent-warning: #ffb74d;
    --accent-danger: #ef5350;
    
    --code-bg: #1a2f1a;
    --code-border: #3e5c3a;
}

/* 日落橙主题 */
body.theme-sunset {
    --bg-primary: #1a0f0a;
    --bg-secondary: #2d1b11;
    --bg-tertiary: #4a2c1f;
    --bg-header: #0f0705;
    --bg-input: #2d1b11;
    --bg-hover: #5c3a2a;
    
    --text-primary: #ffe8d6;
    --text-secondary: #ffb68a;
    --text-muted: #ff8a65;
    --text-link: #ff7043;
    
    --border-primary: #5c3a2a;
    --border-secondary: #4a2c1f;
    --border-focus: #ff7043;
    
    --accent-primary: #ff7043;
    --accent-success: #66bb6a;
    --accent-warning: #ffa726;
    --accent-danger: #ef5350;
    
    --code-bg: #2d1b11;
    --code-border: #5c3a2a;
}

/* 梦幻紫主题 */
body.theme-purple {
    --bg-primary: #0f0a1a;
    --bg-secondary: #1a0f2e;
    --bg-tertiary: #2d1b4e;
    --bg-header: #0a0510;
    --bg-input: #1a0f2e;
    --bg-hover: #3d2a5a;
    
    --text-primary: #e8def8;
    --text-secondary: #c39eff;
    --text-muted: #b388ff;
    --text-link: #9c27b0;
    
    --border-primary: #3d2a5a;
    --border-secondary: #2d1b4e;
    --border-focus: #9c27b0;
    
    --accent-primary: #9c27b0;
    --accent-success: #66bb6a;
    --accent-warning: #ffc107;
    --accent-danger: #f44336;
    
    --code-bg: #1a0f2e;
    --code-border: #3d2a5a;
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 聊天应用容器 */
.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* 顶部导航栏 */
.app-header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(var(--bg-header), 0.9);
}

.header-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-center {
    flex: 1;
    text-align: center;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background-color: var(--bg-hover);
}

.session-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.new-session-btn {
    background: none;
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
    margin-right: 1rem;
}

.new-session-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--accent-primary);
}

/* 协作模式退出按钮 */
.collaboration-exit-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: 1px solid #e74c3c;
    color: white;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
    margin-right: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collaboration-exit-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    border-color: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.collaboration-exit-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-selector {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.theme-selector:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
}

.theme-selector:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1.5rem 1rem 1rem;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.new-project-btn,
.new-role-btn {
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 4px;
    transition: opacity 0.2s;
}

.new-project-btn:hover,
.new-role-btn:hover {
    opacity: 0.9;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.section-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.projects-list,
.roles-list,
.sessions-list {
    padding: 0 0.5rem;
}

.project-item,
.role-item,
.session-item {
    padding: 0.75rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    position: relative;
}

.project-item:hover,
.role-item:hover,
.session-item:hover {
    background-color: var(--bg-hover);
}

.project-item.active,
.role-item.active,
.session-item.active {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.project-item.active .project-description,
.role-item.active .role-description,
.session-item.active .session-meta {
    color: rgba(255, 255, 255, 0.8);
}

.project-name,
.role-name,
.session-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.project-description,
.role-description,
.session-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.session-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-count {
    font-size: 0.7rem;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
}

/* 项目和角色编辑按钮 */
.item-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: 0.5rem;
}

.project-item:hover .item-actions,
.role-item:hover .item-actions {
    opacity: 1;
}

.project-item.active .item-actions,
.role-item.active .item-actions {
    opacity: 1;
}

.edit-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.edit-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.project-item.active .edit-btn,
.role-item.active .edit-btn {
    color: rgba(255, 255, 255, 0.8);
}

.project-item.active .edit-btn:hover,
.role-item.active .edit-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.chat-container.sidebar-open {
    margin-left: 300px;
}

.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.messages-list {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* 欢迎区域 */
.welcome-section {
    text-align: center;
    padding: 3rem 1rem;
    animation: fadeIn 0.5s ease;
}

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

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.welcome-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.feature-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.feature-card:hover {
    background-color: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 1.5rem;
}

.feature-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 消息样式 */
.message {
    padding: 1.5rem 0;
    animation: slideIn 0.3s ease;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-content {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: var(--accent-primary);
    color: white;
}

.message.assistant .message-avatar {
    background-color: var(--accent-success);
    color: white;
}

.message-body {
    flex: 1;
    min-width: 0;
    position: relative;
}

.message-text {
    color: var(--text-primary);
    word-wrap: break-word;
}

/* 消息复制按钮 */
.message-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 0.375rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    z-index: 10;
}

.message:hover .message-copy-btn {
    opacity: 1;
}

.message-copy-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.message-copy-btn:active {
    transform: scale(0.95);
}

.message-copy-btn.copied {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.message-copy-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.message-copy-btn:hover svg {
    color: var(--text-primary);
}

.message-copy-btn.copied svg {
    color: white;
}

/* Markdown 样式 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: var(--text-primary);
}

.message-text h1 { font-size: 1.75em; }
.message-text h2 { font-size: 1.5em; }
.message-text h3 { font-size: 1.25em; }

.message-text p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.message-text ul,
.message-text ol {
    margin: 0 0 1em 2em;
}

.message-text li {
    margin-bottom: 0.5em;
}

.message-text blockquote {
    border-left: 4px solid var(--border-primary);
    padding-left: 1rem;
    margin: 1em 0;
    color: var(--text-secondary);
}

.message-text code {
    background-color: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.875em;
    font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

.message-text pre {
    margin: 1em 0;
    background-color: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    overflow: hidden;
}

.message-text pre code {
    display: block;
    padding: 1rem;
    overflow-x: auto;
    background: none;
    border: none;
    font-size: 0.875em;
}

/* 代码块头部 */
.code-block {
    position: relative;
    margin: 1em 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--code-border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.code-lang {
    font-weight: 500;
}

.copy-button {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.copy-button.copied {
    background-color: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.code-block pre {
    margin: 0;
    border-radius: 0 0 6px 6px;
}

/* 表格样式 */
.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border-primary);
}

.message-text th,
.message-text td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.message-text th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.message-text tr:last-child td {
    border-bottom: none;
}

.message-text tr:hover {
    background-color: var(--bg-hover);
}

/* 链接样式 */
.message-text a {
    color: var(--text-link);
    text-decoration: none;
    transition: all 0.2s ease;
}

.message-text a:hover {
    text-decoration: underline;
}

/* 数学公式样式 */
.katex {
    font-size: 1em !important;
}

.katex-display {
    margin: 1em 0 !important;
    text-align: center;
}

.katex-display > .katex {
    text-align: center;
}

.message-text .katex-error {
    color: var(--accent-danger);
    background-color: var(--bg-secondary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.875em;
}

/* 加载动画 */
.loading-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

/* 输入区域 */
.input-section {
    border-top: 1px solid var(--border-primary);
    background-color: var(--bg-primary);
    padding: 1rem 0;
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.input-section.sidebar-open {
    margin-left: 300px;
}

.input-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 0.75rem;
    transition: all 0.2s ease;
    width: 100%;
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.user-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.user-input::placeholder {
    color: var(--text-muted);
}

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

.send-button:hover {
    background-color: var(--accent-primary);
    opacity: 0.9;
}

.send-button:active {
    transform: scale(0.95);
}

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

.send-button.generating {
    background-color: var(--accent-danger);
    animation: pulse-red 1.5s infinite;
}

.send-button.generating:hover {
    background-color: var(--accent-danger);
    opacity: 0.9;
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.send-icon {
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.input-tips {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.tip {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-secondary);
}

/* 模态对话框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-danger {
    background-color: var(--accent-danger);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* 右键上下文菜单 */
.context-menu {
    position: fixed;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    min-width: 150px;
    display: none;
    padding: 0.25rem 0;
    pointer-events: auto;
}

.context-menu.show {
    display: block;
    animation: contextMenuFadeIn 0.15s ease;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: background-color 0.2s;
    pointer-events: auto;
    user-select: none;
}

.context-menu-item:hover {
    background-color: var(--bg-hover);
}

.context-menu-item:last-child:hover {
    background-color: var(--accent-danger);
    color: white;
}

.context-menu-item svg {
    flex-shrink: 0;
}

/* 删除选项样式 */
#projectSessionOptions {
    border: 1px solid var(--border-primary);
}

#projectSessionOptions label {
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#projectSessionOptions label:hover {
    background-color: var(--bg-hover);
}

#projectSessionOptions input[type="radio"] {
    accent-color: var(--accent-primary);
}

#projectSessionOptions input[type="radio"]:checked + span {
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 在小屏幕上，侧边栏使用覆盖模式，不推挤主内容 */
    .chat-container.sidebar-open {
        margin-left: 0;
    }

    .input-section.sidebar-open {
        margin-left: 0;
    }

    .header-content {
        padding: 0.75rem 1rem;
    }
    
    /* 移动设备上的复制按钮 */
    .message-copy-btn {
        opacity: 1;
        width: 28px;
        height: 28px;
        top: 0.25rem;
        right: 0.25rem;
    }
    
    .message-copy-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .app-title {
        font-size: 1.125rem;
    }
    
    .theme-selector {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }
    
    .welcome-title {
        font-size: 1.5rem;
    }
    
    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .messages-list {
        padding: 1rem 0.5rem;
    }
    
    .message {
        padding: 1rem 0;
    }
    
    .input-container {
        padding: 0 1rem;
    }
    
    .input-wrapper {
        padding: 0.75rem 1rem;
        max-width: 100%;
        margin: 0 0.5rem;
    }
    
    .input-tips {
        flex-direction: column;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .welcome-features {
        grid-template-columns: 1fr;
    }
    
    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    .message-content {
        gap: 0.75rem;
    }
    
    .input-container {
        padding: 0 0.75rem;
    }
    
    .input-wrapper {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
}

/* 打印样式 */
@media print {
    .app-header,
    .input-section {
        display: none;
    }
    
    .chat-container {
        height: auto;
    }
    
    .messages-wrapper {
        overflow: visible;
    }
}

/* 导入数据功能样式 */
.header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.import-data-btn {
    background: none;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.import-data-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.import-preview {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
}

.import-result {
    background: #d1f2eb;
    color: #155724;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid #3fb950;
}

body.theme-dark .import-result {
    background: #1a3328;
    color: #3fb950;
}

.import-error {
    margin: 1rem 0;
}

/* ===== Enhanced Markdown Styles ===== */

/* 改进的代码块复制按钮 */
.copy-button {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.copy-button svg {
    width: 14px;
    height: 14px;
}

.copy-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.copy-button.copied {
    background-color: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

/* 表格包装器 */
.table-wrapper {
    margin: 1em 0;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9em;
}

.markdown-table th,
.markdown-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
    vertical-align: top;
}

.markdown-table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-primary);
}

.markdown-table tr:last-child td {
    border-bottom: none;
}

.markdown-table tr:hover {
    background-color: var(--bg-hover);
}

/* 引用块样式 */
.markdown-quote {
    margin: 1em 0;
    padding: 16px 20px;
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-secondary);
    border-radius: 0 6px 6px 0;
    position: relative;
}

.markdown-quote::before {
    content: '"';
    position: absolute;
    left: -2px;
    top: -10px;
    font-size: 3em;
    color: var(--accent-primary);
    opacity: 0.3;
    line-height: 1;
}

.markdown-quote p {
    margin: 0;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.6;
}

.markdown-quote p:first-child {
    margin-top: 0;
}

.markdown-quote p:last-child {
    margin-bottom: 0;
}

/* 列表样式 */
.markdown-list {
    margin: 1em 0;
    padding-left: 2em;
    line-height: 1.6;
}

.markdown-list li {
    margin: 0.5em 0;
    color: var(--text-primary);
}

.markdown-list li::marker {
    color: var(--accent-primary);
}

.markdown-list-ordered {
    list-style-type: decimal;
}

.markdown-list-ordered li::marker {
    font-weight: 600;
}

/* 嵌套列表 */
.markdown-list .markdown-list {
    margin: 0.25em 0;
    padding-left: 1.5em;
}

/* 外部链接样式 */
.external-link {
    color: var(--text-link);
    text-decoration: none;
    position: relative;
    transition: all 0.2s ease;
}

.external-link::after {
    content: '↗';
    display: inline-block;
    margin-left: 2px;
    font-size: 0.8em;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.external-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.external-link:hover::after {
    opacity: 1;
    transform: translateY(-1px);
}

/* 增强的标题样式 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    color: var(--text-primary);
    margin: 1.5em 0 0.75em 0;
    line-height: 1.3;
    font-weight: 600;
}

.message-text h1 {
    font-size: 2em;
    border-bottom: 2px solid var(--border-primary);
    padding-bottom: 0.3em;
}

.message-text h2 {
    font-size: 1.6em;
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 0.2em;
}

.message-text h3 {
    font-size: 1.3em;
}

.message-text h4 {
    font-size: 1.1em;
}

.message-text h5,
.message-text h6 {
    font-size: 1em;
}

/* 水平分隔线 */
.message-text hr {
    border: none;
    height: 2px;
    background: linear-gradient(
        to right,
        transparent,
        var(--border-primary),
        transparent
    );
    margin: 2em 0;
}

/* 强调文本 */
.message-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-text em {
    color: var(--text-secondary);
    font-style: italic;
}

/* 行内代码 */
.message-text code:not([class]) {
    background: var(--bg-secondary);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85em;
    border: 1px solid var(--border-primary);
}

/* 删除线 */
.message-text del {
    color: var(--text-muted);
    text-decoration-color: var(--accent-danger);
}

/* 键盘按键样式 */
.message-text kbd {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-bottom: 2px solid var(--border-primary);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8em;
    font-family: monospace;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 段落间距 */
.message-text p {
    margin: 1em 0;
    line-height: 1.6;
}

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

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

/* 响应式改进 */
@media (max-width: 768px) {
    .table-wrapper {
        font-size: 0.8em;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 8px 12px;
    }
    
    .markdown-quote {
        padding: 12px 16px;
        margin: 0.75em 0;
    }
    
    .markdown-list {
        padding-left: 1.5em;
    }
}