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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --accent: #e94560;
    --approved: #53d769;
    --review: #ffd700;
    --text: #e0e0e0;
    --text-muted: #8892a4;
    --border: #2a3a5e;
    --role-lead: #e94560;
    --role-architect: #ffd700;
    --role-reviewer: #53d769;
    --role-dev: #00b4d8;
    --status-draft: #6b7280;
    --status-designing: #3b82f6;
    --status-review: #ffd700;
    --status-revision: #f97316;
    --status-approved: #53d769;
    --status-development: #00b4d8;
    --status-code_review: #a855f7;
    --status-done: #22c55e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-header h2 { font-size: 14px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }

.agent-list { padding: 8px; overflow-y: auto; flex: 1; }

.agent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.agent-item:hover { background: var(--bg-card); }

.agent-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-role { font-size: 11px; color: var(--text-muted); }

.status-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.online { background: var(--approved); box-shadow: 0 0 6px var(--approved); }
.status-dot.offline { background: var(--status-draft); }

/* Topbar */
.topbar {
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}
.topbar h1 { font-size: 18px; flex: 1; }
.topbar-controls { display: flex; gap: 12px; align-items: center; }
.topbar-controls select {
    background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 6px; font-size: 13px;
}

/* Buttons */
.btn {
    padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 13px;
    transition: all 0.2s;
}
.btn:hover { border-color: var(--text-muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-transition { padding: 4px 10px; font-size: 11px; border-radius: 4px; }

/* Main content */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.panels { flex: 1; display: flex; overflow: hidden; }

.panel-left {
    width: 320px; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; flex-shrink: 0;
    overflow-y: auto;
}
.panel-header { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-header h3 { font-size: 13px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }

.panel-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Project list */
.project-list { overflow-y: auto; flex: 1; padding: 8px; }

.project-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.project-card:hover { border-color: var(--accent); transform: translateX(2px); }
.project-card.active { border-color: var(--accent); background: #1a2a50; }

.project-card-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.project-card-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card-meta { display: flex; align-items: center; gap: 8px; }

.badge {
    padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-draft { background: var(--status-draft); color: #fff; }
.badge-designing { background: var(--status-designing); color: #fff; }
.badge-review { background: var(--status-review); color: #000; }
.badge-revision { background: var(--status-revision); color: #fff; }
.badge-approved { background: var(--status-approved); color: #000; }
.badge-development { background: var(--status-development); color: #000; }
.badge-code_review { background: var(--status-code_review); color: #fff; }
.badge-done { background: var(--status-done); color: #000; }

.role-badge {
    padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
    text-transform: uppercase;
}

/* Thread */
.thread-header {
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.thread-title { font-weight: 600; font-size: 15px; }

.status-flow {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    flex-shrink: 0;
}
.flow-node {
    padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
    white-space: nowrap; background: var(--bg-card); color: var(--text-muted);
    transition: all 0.3s;
}
.flow-node.active { color: #fff; transform: scale(1.1); box-shadow: 0 0 12px rgba(255,255,255,0.2); }
.flow-arrow { color: var(--text-muted); font-size: 12px; }

.messages {
    flex: 1; overflow-y: auto; padding: 16px 20px;
    display: flex; flex-direction: column; gap: 12px;
}

.message {
    display: flex; gap: 10px; animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.msg-body { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-name { font-weight: 600; font-size: 13px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-content { font-size: 14px; line-height: 1.6; word-wrap: break-word; }
.msg-content code { background: var(--bg-secondary); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg-content pre { background: var(--bg-secondary); padding: 10px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.msg-content strong { color: #fff; }

.message.system {
    justify-content: center; gap: 0;
}
.message.system .msg-content {
    text-align: center; color: var(--text-muted); font-size: 12px; font-style: italic;
}

/* Message input */
.message-input {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 10px;
}
.message-input input {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); padding: 10px 14px; border-radius: 8px; font-size: 14px;
}
.message-input input:focus { outline: none; border-color: var(--accent); }

/* Transition buttons */
.transition-bar {
    padding: 8px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; flex-wrap: wrap;
}

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; width: 400px; max-width: 90vw;
}
.modal h3 { margin-bottom: 16px; }
.modal input, .modal textarea {
    width: 100%; background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); padding: 10px; border-radius: 6px; font-size: 14px; margin-bottom: 12px;
}
.modal textarea { height: 80px; resize: vertical; font-family: inherit; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Login screen */
#login-screen {
    position: fixed; inset: 0; background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 16px; padding: 40px; width: 360px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-box h2 { font-size: 22px; margin-bottom: 8px; }
.login-box input {
    width: 100%; background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); padding: 12px 16px; border-radius: 8px; font-size: 15px;
    margin-bottom: 16px; text-align: center;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.login-box button {
    width: 100%; padding: 12px; border-radius: 8px; border: none;
    background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: opacity 0.2s;
}
.login-box button:hover { opacity: 0.85; }

.btn-ms-login {
    width: 100%; padding: 12px; border-radius: 8px; border: 1px solid #555;
    background: #2f2f2f; color: #fff; font-size: 15px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-ms-login:hover { background: #404040; border-color: #888; }

.login-divider {
    display: flex; align-items: center; margin: 16px 0; gap: 12px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.login-divider span { color: var(--text-muted); font-size: 12px; }
