/* ============================================================
   AI-PM Bot — 生产级样式系统 v2.0
   特性：玻璃拟态、流体动画、虚拟滚动、Markdown渲染
   ============================================================ */

:root {
    /* 色彩系统 — 深邃太空 */
    --bg-primary: #030308;
    --bg-secondary: #0a0a12;
    --bg-tertiary: #12121c;
    --bg-card: rgba(20, 20, 35, 0.6);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(10, 10, 20, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --text-primary: #f0f0f8;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a8a;
    --text-ghost: #4a4a6a;

    /* 强调色 — 紫蓝极光 */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --accent-glow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 60px rgba(139, 92, 246, 0.15);

    /* 尺寸 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.6);

    /* 字体 */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;

    /* 动画 */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 背景网格动画 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(99,102,241,0.15) 1px, transparent 0);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
    pointer-events: none;
    z-index: 0;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 40px); }
}

/* 玻璃拟态基础类 */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-color);
}

/* ========== 全局加载器 ========== */
.global-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 连接状态 ========== */
.connection-status {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s var(--ease-out-expo);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.connection-status.show {
    opacity: 1;
    transform: translateY(0);
}

.connection-status.online {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.connection-status.connecting {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.connection-status.online .status-dot { background: var(--accent-success); }
.connection-status.offline .status-dot { background: var(--accent-danger); }
.connection-status.connecting .status-dot { background: var(--accent-warning); animation: pulse 1.5s ease infinite; }

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

/* ========== 页面容器 ========== */
.page { width: 100%; height: 100vh; position: relative; z-index: 1; }

/* ========== 登录页面 ========== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ambient-light {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: ambientPulse 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ambientPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

.login-container {
    display: flex;
    gap: 80px;
    align-items: center;
    z-index: 1;
    max-width: 1000px;
    width: 90%;
    animation: fadeInUp 0.8s var(--ease-out-expo);
}

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

.login-brand {
    flex: 1;
    text-align: left;
}

.brand-icon {
    margin-bottom: 28px;
    display: inline-block;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-brand h1 {
    font-size: 48px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    letter-spacing: -1.5px;
}

.login-brand p {
    font-size: 20px;
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: 24px;
}

.brand-features {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.feature-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.login-form-card {
    width: 420px;
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.8s var(--ease-out-expo) 0.1s both;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.login-form-card h2 {
    font-size: 24px;
    margin-bottom: 4px;
    font-weight: 700;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* 浮动标签输入框 */
.form-group.floating {
    position: relative;
    margin-bottom: 24px;
}

.form-group.floating input,
.form-group.floating textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 14px 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    outline: none;
    transition: all 0.2s var(--ease-in-out);
}

.form-group.floating textarea {
    padding-top: 20px;
    resize: vertical;
    min-height: 80px;
}

.form-group.floating input:focus,
.form-group.floating textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15), inset 0 1px 2px rgba(0,0,0,0.2);
}

.form-group.floating label {
    position: absolute;
    left: 14px;
    top: 14px;
    font-size: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: all 0.2s var(--ease-out-expo);
    font-weight: 400;
}

.form-group.floating input:focus + label,
.form-group.floating input:not(:placeholder-shown) + label,
.form-group.floating textarea:focus + label,
.form-group.floating textarea:not(:placeholder-shown) + label {
    top: 6px;
    font-size: 11px;
    color: var(--accent-primary);
    font-weight: 500;
}

.form-error {
    color: var(--accent-danger);
    font-size: 13px;
    margin: -8px 0 16px;
    min-height: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ========== 按钮系统 ========== */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-in-out);
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.btn:hover::after {
    transform: translateX(100%);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--accent-glow);
}

.btn-primary:active { transform: translateY(0); }

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

.btn-secondary:hover {
    background: var(--border-color);
    color: var(--text-primary);
    border-color: var(--border-light);
}

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

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

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    gap: 6px;
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
    font-size: 14px;
    gap: 6px;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled::after { display: none; }

/* ========== 主应用布局 ========== */
.main-page {
    display: flex;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    z-index: 10;
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon-mini { display: flex; }

.sidebar-brand .brand-text {
    font-size: 18px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s var(--ease-in-out);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
    color: var(--accent-primary);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 50%;
    color: var(--text-secondary);
}

.user-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* 主内容区 */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--bg-primary);
    position: relative;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.main-content::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

.view { display: none; animation: viewFadeIn 0.3s var(--ease-out-expo); }
.view.active { display: block; }

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

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

.view-header h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.view-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
}

/* ========== 骨架屏 ========== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: skeletonShine 1.5s infinite;
}

@keyframes skeletonShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* ========== 项目网格 ========== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s var(--ease-out-expo);
    position: relative;
    overflow: hidden;
    animation: cardEnter 0.5s var(--ease-out-expo) both;
}

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

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--accent-glow);
    border-color: var(--border-light);
}

.project-card:hover::before { opacity: 1; }

.project-card.empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
    cursor: default;
    animation: none;
}

.project-card.empty:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
}

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

.project-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.project-code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.project-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

.status-tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-tag.digging { background: rgba(99,102,241,0.15); color: var(--accent-primary); border: 1px solid rgba(99,102,241,0.2); }
.status-tag.frozen { background: rgba(34,197,94,0.15); color: var(--accent-success); border: 1px solid rgba(34,197,94,0.2); }
.status-tag.arch { background: rgba(245,158,11,0.15); color: var(--accent-warning); border: 1px solid rgba(245,158,11,0.2); }
.status-tag.done { background: rgba(99,102,241,0.15); color: var(--accent-primary); border: 1px solid rgba(99,102,241,0.2); }

.project-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ========== 对话布局 ========== */
.chat-layout {
    display: flex;
    height: calc(100vh - 64px);
    margin: -32px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-header-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 5;
}

.chat-project-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-name {
    font-size: 16px;
    font-weight: 600;
}

.node-badge {
    font-size: 11px;
    padding: 4px 12px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.node-badge.pulse {
    animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(99,102,241,0); }
}

.chat-actions {
    display: flex;
    gap: 8px;
}

/* 消息区域包装器 */
.chat-messages-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}

.chat-messages-wrapper::-webkit-scrollbar { width: 6px; }
.chat-messages-wrapper::-webkit-scrollbar-track { background: transparent; }
.chat-messages-wrapper::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.chat-load-more {
    text-align: center;
    padding: 12px;
    cursor: pointer;
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.chat-load-more:hover {
    background: var(--bg-hover);
}

.load-more-text::before {
    content: '↑ ';
}

.chat-messages-area {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100%;
}

/* 欢迎界面 */
.chat-welcome {
    text-align: center;
    padding: 80px 20px;
    max-width: 640px;
    margin: auto;
    animation: welcomeIn 0.6s var(--ease-out-expo);
}

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

.welcome-icon-large {
    margin-bottom: 28px;
    display: inline-block;
    animation: float 5s ease-in-out infinite;
}

.chat-welcome h3 {
    font-size: 24px;
    margin-bottom: 12px;
    font-weight: 700;
}

.chat-welcome p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.example-chips {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s var(--ease-out-expo);
    max-width: 520px;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(99,102,241,0.15);
}

.chip-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.chip-text {
    line-height: 1.5;
}

/* 消息气泡系统 */
.message-row {
    display: flex;
    gap: 12px;
    max-width: 88%;
    animation: msgEnter 0.4s var(--ease-out-expo);
    position: relative;
}

@keyframes msgEnter {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-row.user { align-self: flex-end; flex-direction: row-reverse; margin-left: auto; }
.message-row.assistant { align-self: flex-start; }
.message-row.system { align-self: center; max-width: 70%; }

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.msg-avatar.user {
    background: var(--accent-gradient);
    border: none;
    color: white;
    box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}

.msg-body {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.75;
    word-break: break-word;
    position: relative;
}

.msg-body.user {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(99,102,241,0.25);
}

.msg-body.assistant {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.msg-body.system {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
}

/* 消息折叠 */
.msg-body.assistant .msg-collapsed {
    max-height: 200px;
    overflow: hidden;
    position: relative;
}

.msg-body.assistant .msg-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--bg-card));
}

.msg-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--accent-primary);
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.msg-expand-btn:hover {
    background: rgba(99,102,241,0.2);
}

/* Markdown 内容样式 */
.msg-body.assistant .markdown-content h1,
.msg-body.assistant .markdown-content h2,
.msg-body.assistant .markdown-content h3 {
    margin: 16px 0 10px;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
}

.msg-body.assistant .markdown-content h1 { font-size: 18px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.msg-body.assistant .markdown-content h2 { font-size: 16px; }
.msg-body.assistant .markdown-content h3 { font-size: 14px; }

.msg-body.assistant .markdown-content p { margin-bottom: 10px; }
.msg-body.assistant .markdown-content p:last-child { margin-bottom: 0; }

.msg-body.assistant .markdown-content ul,
.msg-body.assistant .markdown-content ol {
    margin: 8px 0 8px 20px;
}

.msg-body.assistant .markdown-content li {
    margin: 4px 0;
}

.msg-body.assistant .markdown-content code {
    background: rgba(99,102,241,0.12);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-cyan);
    border: 1px solid rgba(99,102,241,0.15);
}

.msg-body.assistant .markdown-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
    position: relative;
}

.msg-body.assistant .markdown-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.6;
}

.msg-body.assistant .markdown-content pre .code-lang {
    position: absolute;
    top: 6px;
    right: 10px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.msg-body.assistant .markdown-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 12px;
    margin: 10px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.msg-body.assistant .markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.msg-body.assistant .markdown-content th,
.msg-body.assistant .markdown-content td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.msg-body.assistant .markdown-content th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-primary);
}

.msg-body.assistant .markdown-content tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

/* Mermaid 图表容器 */
.mermaid-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 12px 0;
    text-align: center;
    overflow: auto;
}

.mermaid {
    display: inline-block;
}

/* 选项交互组件 */
.options-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 8px;
    animation: optionsIn 0.4s var(--ease-out-expo);
}

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

.options-question {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.6;
    color: var(--text-primary);
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s var(--ease-in-out);
    position: relative;
}

.option-row:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.option-row.selected {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.05));
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.option-row input[type="radio"],
.option-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.option-row label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.option-row.selected label {
    color: var(--text-primary);
    font-weight: 500;
}

/* 布尔选项特殊样式 */
.boolean-options {
    display: flex;
    gap: 12px;
}

.boolean-options .option-row {
    flex: 1;
    justify-content: center;
    padding: 14px;
}

.boolean-options .option-row label {
    flex: 0;
    font-weight: 600;
}

.options-custom {
    margin-top: 12px;
}

.options-custom input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.options-custom input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.options-btns {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* 输入锁定遮罩 */
.input-lock-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to top, var(--bg-secondary) 60%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    animation: lockFadeIn 0.3s var(--ease-out-expo);
}

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

.lock-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}

.lock-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-warning);
    animation: pulse 1.5s ease infinite;
}

/* 输入栏 */
.chat-input-bar {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 5;
    transition: opacity 0.3s;
}

.chat-input-bar.locked {
    opacity: 0.5;
    pointer-events: none;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.file-upload-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.textarea-wrapper {
    flex: 1;
    position: relative;
}

#chatInput {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    font-family: var(--font-sans);
    outline: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    transition: all 0.2s;
}

#chatInput:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

#chatInput::placeholder {
    color: var(--text-ghost);
}

.input-hint {
    position: absolute;
    bottom: -18px;
    right: 0;
    font-size: 11px;
    color: var(--text-ghost);
    opacity: 0;
    transition: opacity 0.2s;
}

#chatInput:focus + .input-hint {
    opacity: 1;
}

.send-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.uploaded-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent-primary);
    padding: 6px 10px;
    background: rgba(99,102,241,0.08);
    border-radius: var(--radius-sm);
    width: fit-content;
}

.remove-file {
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    transition: color 0.2s;
}

.remove-file:hover { color: var(--accent-danger); }

/* 加载动画 */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-right: 8px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: dotBounce 1.4s ease-in-out infinite both;
}

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

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

/* 右侧面板 */
.chat-side-panel {
    width: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
}

.chat-side-panel::-webkit-scrollbar { width: 4px; }
.chat-side-panel::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

.panel-section h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-list-compact { display: flex; flex-direction: column; gap: 6px; }
.status-item-compact {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.status-item-compact:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.status-item-compact .k { color: var(--text-muted); }
.status-item-compact .v { color: var(--text-primary); font-weight: 500; }
.status-empty, .doc-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 16px; }

.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-track {
    flex: 1;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.6s var(--ease-out-expo);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-label { font-size: 12px; color: var(--text-secondary); font-weight: 700; min-width: 40px; }

.doc-list-compact { display: flex; flex-direction: column; gap: 6px; }
.doc-item-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.doc-item-compact:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateX(2px);
}

.doc-item-compact .doc-icon { font-size: 14px; }
.doc-item-compact .doc-name { flex: 1; color: var(--text-primary); font-weight: 500; }
.doc-item-compact .doc-ver {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--accent-success);
    color: white;
    border-radius: 10px;
    font-weight: 600;
}

/* ========== 模板列表 ========== */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.3s var(--ease-out-expo);
    display: flex;
    align-items: center;
    gap: 16px;
    animation: cardEnter 0.4s var(--ease-out-expo) both;
}

.template-item:hover {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(99,102,241,0.05), transparent);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(99,102,241,0.1);
}

.template-item.loading {
    text-align: center;
    color: var(--text-muted);
    cursor: default;
    animation: none;
}

.template-item.loading:hover {
    transform: none;
    border-color: var(--border-color);
    box-shadow: none;
}

.template-num {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    min-width: 60px;
    text-align: center;
}

.template-info { flex: 1; }
.template-info h4 { font-size: 15px; margin-bottom: 6px; font-weight: 600; }
.template-info p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

.template-arrow {
    color: var(--text-muted);
    transition: all 0.2s;
}

.template-item:hover .template-arrow {
    color: var(--accent-primary);
    transform: translateX(4px);
}

/* ========== 模态框 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: modalOverlayIn 0.3s ease;
}

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

.modal-box {
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalBoxIn 0.4s var(--ease-out-expo);
}

.modal-large { max-width: 860px; }

@keyframes modalBoxIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-actions { display: flex; gap: 8px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

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

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.modal-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 10px 14px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-warning);
}

.required { color: var(--accent-danger); }

/* 文档内容 */
.doc-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    max-height: 60vh;
    overflow-y: auto;
}

.doc-content::-webkit-scrollbar { width: 6px; }
.doc-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

/* Markdown 文档体 */
.markdown-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 24px 0 12px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.markdown-body h1 { font-size: 22px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 15px; }

.markdown-body p { margin-bottom: 12px; }
.markdown-body ul, .markdown-body ol { margin: 8px 0 8px 24px; }
.markdown-body li { margin: 4px 0; }

.markdown-body pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 12px;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
}

.markdown-body blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-hover);
    font-weight: 600;
}

/* Prompt详情 */
.prompt-detail-content .detail-section { margin-bottom: 28px; }
.prompt-detail-content .detail-section h4 {
    font-size: 13px;
    color: var(--accent-primary);
    margin-bottom: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.prompt-detail-content .detail-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}
.prompt-detail-content pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* 下载列表 */
.docs-download-list { display: flex; flex-direction: column; gap: 10px; }
.download-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.download-row:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.download-row .doc-icon { font-size: 22px; }
.download-row .doc-info { flex: 1; }
.download-row .doc-info .name { font-size: 14px; font-weight: 600; }
.download-row .doc-info .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* 修改需求 */
.modify-slot-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.modify-slot-row:hover {
    border-color: var(--border-light);
}

.modify-slot-row .slot-key {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-primary);
    min-width: 120px;
    font-weight: 500;
}

.modify-slot-row .slot-value {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.modify-slot-row input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.modify-slot-row input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.loading-text { text-align: center; color: var(--text-muted); padding: 24px; font-size: 14px; }

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .chat-side-panel { display: none; }
    .login-container { flex-direction: column; gap: 40px; }
    .login-brand { text-align: center; }
    .brand-features { justify-content: center; }
}

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar .brand-text, .sidebar .nav-text, .sidebar .user-meta { display: none; }
    .sidebar-brand { justify-content: center; padding: 20px 0; }
    .sidebar-footer { padding: 12px 8px; }
    .sidebar-footer .btn { padding: 8px; }
    .sidebar-footer .btn svg { margin: 0; }
    .main-content { padding: 20px; }
    .projects-grid { grid-template-columns: 1fr; }
    .chat-layout { margin: -20px; }
    .message-row { max-width: 95%; }
}

/* ========== 工具类 ========== */
.hidden { display: none !important; }
.visually-hidden { opacity: 0; pointer-events: none; }