/* ======================================================
   CxLLM — Enhanced Design System
   ====================================================== */

:root {
    --cx-green: #76B900;
    --cx-green-light: #8dd400;
    --cx-green-dark: #5a8f00;
    --cx-teal: #00A86B;
    --cx-blue: #0096FF;
    --cx-orange: #FF6B35;
    --cx-purple: #8B5CF6;

    --bg-primary: #09090b;
    --bg-secondary: #0f0f12;
    --bg-tertiary: #17171c;
    --bg-elevated: #1c1c23;
    --bg-hover: #24242e;
    --bg-glass: rgba(15, 15, 18, 0.85);
    --border: #27272f;
    --border-subtle: #1e1e25;
    --border-focus: rgba(118, 185, 0, 0.5);
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #fafafa;
    --bg-secondary: #f4f4f5;
    --bg-tertiary: #e4e4e7;
    --bg-elevated: #ffffff;
    --bg-hover: #e8e8ec;
    --bg-glass: rgba(250, 250, 250, 0.88);
    --border: #d4d4d8;
    --border-subtle: #e4e4e7;
    --border-focus: rgba(118, 185, 0, 0.6);
    --text-primary: #09090b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100dvh;
}

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

/* ======== Sidebar ======== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 200;
    transition: transform 0.3s ease;
}

.sidebar-header { padding: 20px 20px 16px; }

.logo { display: flex; align-items: center; gap: 12px; }

.logo-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, var(--cx-green), var(--cx-teal));
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(118,185,0,0.25);
    position: relative; overflow: hidden;
}

.logo-icon::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.15));
}

.logo-icon svg { width: 22px; height: 22px; position: relative; z-index: 1; }

.logo-text {
    font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--cx-green), var(--cx-teal));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.logo-badge {
    font-size: 0.6rem; font-weight: 600; background: var(--bg-tertiary);
    color: var(--text-muted); padding: 2px 6px; border-radius: 4px;
    letter-spacing: 0.04em; margin-left: -4px;
}

.new-chat-btn {
    margin: 4px 16px 12px; padding: 11px 16px;
    background: linear-gradient(135deg, rgba(118,185,0,0.1), rgba(0,168,107,0.08));
    border: 1px solid rgba(118,185,0,0.2); border-radius: var(--radius);
    color: var(--cx-green); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 8px;
    transition: all var(--transition);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, rgba(118,185,0,0.18), rgba(0,168,107,0.14));
    border-color: rgba(118,185,0,0.4); transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(118,185,0,0.12);
}

.sidebar-body { flex: 1; overflow-y: auto; padding: 0 12px; }
.nav-section { margin-bottom: 24px; }

.nav-label {
    padding: 8px 8px 6px; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted);
}

.nav-item {
    width: 100%; padding: 10px 12px; background: transparent; border: none;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    font-size: 0.85rem; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    transition: all 0.15s; text-align: left; position: relative;
}

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

.nav-item.active { background: var(--bg-hover); color: var(--cx-green); }

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

.nav-item-badge {
    margin-left: auto; font-size: 0.68rem; font-weight: 600;
    background: rgba(118,185,0,0.15); color: var(--cx-green);
    padding: 2px 7px; border-radius: 10px;
}

/* Agent cards */
.agent-grid { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px; }

.agent-card {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-radius: var(--radius-sm); transition: background 0.15s; cursor: default;
}

.agent-card:hover { background: var(--bg-hover); }

.agent-card.active {
    background: var(--bg-hover); border: 1px solid rgba(118,185,0,0.3);
    border-radius: var(--radius-sm);
}

.agent-card { cursor: pointer; }

.agent-dot-wrap {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.agent-dot-wrap svg { width: 14px; height: 14px; }

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.agent-desc { font-size: 0.68rem; color: var(--text-muted); line-height: 1.3; }

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 20px; border-top: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: space-between;
}

.status-pill {
    display: flex; align-items: center; gap: 6px; font-size: 0.75rem;
    color: var(--text-secondary); background: var(--bg-tertiary);
    padding: 5px 10px; border-radius: 20px;
}

.status-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--cx-green);
    box-shadow: 0 0 6px rgba(118,185,0,0.5);
}

.status-dot.busy {
    background: var(--cx-orange); box-shadow: 0 0 6px rgba(255,107,53,0.5);
    animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.model-tag {
    font-size: 0.65rem; color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-tertiary); padding: 3px 8px; border-radius: 4px;
}

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

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 150; backdrop-filter: blur(4px);
}
.sidebar-overlay.active { display: block; }

.main-header {
    height: 56px; padding: 0 20px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
    background: var(--bg-glass); backdrop-filter: blur(12px); z-index: 10;
}

.menu-toggle {
    display: none; background: none; border: none; color: var(--text-secondary);
    cursor: pointer; padding: 6px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.menu-toggle:hover { background: var(--bg-hover); }

.header-title {
    flex: 1; font-size: 0.9rem; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}

.mode-indicator {
    font-size: 0.65rem; font-weight: 600; color: var(--cx-green);
    background: rgba(118,185,0,0.1); padding: 3px 8px; border-radius: 6px;
    text-transform: uppercase; letter-spacing: 0.04em;
}

.header-actions { display: flex; gap: 4px; }

.icon-btn {
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-secondary); cursor: pointer;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }

/* ======== Chat ======== */
.messages { flex: 1; overflow-y: auto; padding: 0; scroll-behavior: smooth; }
.messages-inner { max-width: 780px; margin: 0 auto; padding: 24px 24px 16px; }

/* Welcome */
.welcome {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 70vh; text-align: center; gap: 20px; padding: 40px 20px 80px;
}

.welcome-logo {
    width: 80px; height: 80px; border-radius: 22px;
    background: linear-gradient(135deg, var(--cx-green), var(--cx-teal));
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 32px rgba(118,185,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
    animation: float 4s ease-in-out infinite;
}

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

.welcome-logo svg { width: 42px; height: 42px; }

.welcome h2 {
    font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--cx-green), var(--cx-teal), var(--cx-blue));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.welcome p { color: var(--text-secondary); font-size: 0.95rem; max-width: 400px; }

.welcome-cards {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    margin-top: 8px; max-width: 600px; width: 100%;
}

.welcome-card {
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; cursor: pointer;
    transition: all var(--transition); text-align: left;
}

.welcome-card:hover {
    border-color: var(--cx-green); background: var(--bg-hover);
    transform: translateY(-2px); box-shadow: var(--shadow), 0 0 0 1px rgba(118,185,0,0.1);
}

.welcome-card-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px; font-size: 1.1rem;
}

.welcome-card h4 { font-size: 0.82rem; font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.welcome-card p { font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; }

/* Messages */
.message {
    display: flex; gap: 14px; padding: 20px 0;
    animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.message + .message { border-top: 1px solid var(--border-subtle); }

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

.message-avatar {
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 0.7rem; font-weight: 700;
}

.message.user .message-avatar {
    background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--cx-green), var(--cx-teal));
    color: white; box-shadow: 0 2px 8px rgba(118,185,0,0.2);
}

.message-body { flex: 1; min-width: 0; padding-top: 2px; }

.message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.message-sender { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); }
.message-time { font-size: 0.68rem; color: var(--text-muted); }

.message-content {
    font-size: 0.9rem; line-height: 1.75; color: var(--text-primary);
    word-wrap: break-word; overflow-wrap: break-word;
}

.message-content pre {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px; margin: 10px 0;
    overflow-x: auto; font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem; line-height: 1.6;
}

.message-content code {
    font-family: 'JetBrains Mono', monospace; font-size: 0.84em;
    background: var(--bg-tertiary); padding: 2px 7px; border-radius: 5px;
    border: 1px solid var(--border-subtle);
}

.message-content pre code { background: none; padding: 0; border: none; border-radius: 0; }
.message-content ul, .message-content ol { padding-left: 20px; margin: 8px 0; }
.message-content li { margin-bottom: 4px; }

.message-actions {
    display: flex; gap: 4px; margin-top: 10px; opacity: 0; transition: opacity 0.15s;
}
.message:hover .message-actions { opacity: 1; }

.msg-action-btn {
    padding: 4px 10px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-muted); font-size: 0.7rem; cursor: pointer;
    display: flex; align-items: center; gap: 4px; transition: all 0.15s;
}
.msg-action-btn:hover { border-color: var(--cx-green); color: var(--cx-green); }

/* Thinking dots */
.thinking-dots { display: flex; align-items: center; gap: 5px; padding: 6px 0; }

.thinking-dots span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--cx-green);
    animation: dotBounce 1.4s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.32s; }

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

/* ======== Input ======== */
.input-area { padding: 0 24px 24px; }
.input-wrapper { max-width: 780px; margin: 0 auto; width: 100%; }

.image-preview-bar { margin-bottom: 8px; display: flex; gap: 8px; }
.img-thumb { position: relative; display: inline-flex; }
.img-thumb img { height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--border); object-fit: cover; }

.img-thumb-remove {
    position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
    border-radius: 50%; background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.img-thumb-remove:hover { background: #ef4444; color: white; border-color: #ef4444; }

.input-box {
    display: flex; align-items: flex-end; gap: 6px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 6px 6px 6px 16px;
    transition: all var(--transition); box-shadow: var(--shadow-sm);
}

.input-box:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(118,185,0,0.08), var(--shadow-sm);
}

.input-tools { display: flex; align-items: center; gap: 2px; padding-bottom: 6px; }

.tool-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.tool-btn:hover { color: var(--cx-green); background: var(--bg-hover); }

.input-box textarea {
    flex: 1; background: none; border: none; outline: none; color: var(--text-primary);
    font-family: inherit; font-size: 0.9rem; line-height: 1.5; resize: none;
    max-height: 180px; padding: 8px 0; min-height: 24px;
}
.input-box textarea::placeholder { color: var(--text-muted); }

.send-btn {
    width: 38px; height: 38px; border-radius: var(--radius); border: none;
    background: var(--cx-green); color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: all var(--transition); box-shadow: 0 2px 8px rgba(118,185,0,0.2);
}

.send-btn:disabled { background: var(--bg-hover); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }

.send-btn:not(:disabled):hover {
    background: var(--cx-green-dark); transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(118,185,0,0.3);
}

.input-hint { text-align: center; padding: 8px 0 0; font-size: 0.68rem; color: var(--text-muted); }

/* ======== Run View ======== */
.run-container { flex: 1; overflow-y: auto; padding: 40px 24px; }
.run-inner { max-width: 680px; margin: 0 auto; width: 100%; }

.run-hero { text-align: center; margin-bottom: 36px; }

.run-hero-icon {
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, rgba(118,185,0,0.15), rgba(0,168,107,0.1));
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px; color: var(--cx-green);
}

.run-hero h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.run-hero p { color: var(--text-secondary); font-size: 0.9rem; max-width: 440px; margin: 0 auto; }

.pipeline-steps {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    margin: 20px 0 32px; flex-wrap: wrap;
}

.pipeline-step {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: 20px; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary);
}

.pipeline-step .step-num {
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.6rem; font-weight: 700; color: white;
}

.pipeline-arrow { color: var(--text-muted); font-size: 0.7rem; }

.run-form { display: flex; flex-direction: column; gap: 20px; }

.form-group label {
    display: flex; align-items: center; gap: 6px; font-size: 0.8rem;
    font-weight: 600; margin-bottom: 8px; color: var(--text-secondary);
}

.form-group textarea {
    width: 100%; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px; color: var(--text-primary);
    font-family: inherit; font-size: 0.9rem; line-height: 1.6; resize: vertical;
    outline: none; transition: all var(--transition); min-height: 120px;
}

.form-group textarea:focus {
    border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(118,185,0,0.08);
}

.file-drop {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px;
    text-align: center; cursor: pointer; transition: all var(--transition);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    color: var(--text-muted);
}

.file-drop:hover { border-color: var(--cx-green); color: var(--cx-green); background: rgba(118,185,0,0.03); }
.file-drop.has-file { border-color: var(--cx-green); border-style: solid; color: var(--cx-green); background: rgba(118,185,0,0.03); }
.file-drop-text { font-size: 0.82rem; font-weight: 500; }

.run-submit-btn {
    padding: 14px 28px; background: linear-gradient(135deg, var(--cx-green), var(--cx-teal));
    border: none; border-radius: var(--radius); color: white; font-size: 0.95rem;
    font-weight: 700; cursor: pointer; display: flex; align-items: center;
    justify-content: center; gap: 10px; transition: all var(--transition);
    position: relative; overflow: hidden;
}

.run-submit-btn::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.1)); pointer-events: none;
}

.run-submit-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(118,185,0,0.25); }
.run-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.run-result {
    margin-top: 32px; background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.result-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border-subtle);
}

.result-header h3 {
    font-size: 0.88rem; font-weight: 700; display: flex; align-items: center; gap: 8px;
}

.result-header .check-icon { color: var(--cx-green); }

.result-content {
    padding: 18px; font-size: 0.9rem; line-height: 1.75;
    white-space: pre-wrap; word-wrap: break-word; max-height: 500px; overflow-y: auto;
}

/* Toasts */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 1000;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    padding: 12px 18px; background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary); font-size: 0.82rem;
    font-weight: 500; box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; align-items: center; gap: 8px;
}

.toast.success { border-left: 3px solid var(--cx-green); }
.toast.error { border-left: 3px solid #ef4444; }

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

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

/* Session History */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.session-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.session-item.active { background: var(--bg-elevated); color: var(--text-primary); border-left: 2px solid var(--cx-green); }

.session-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-item-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.session-item-delete {
    opacity: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: opacity 0.15s, color 0.15s;
    display: flex;
    align-items: center;
}

.session-item:hover .session-item-delete { opacity: 1; }
.session-item-delete:hover { color: #ef4444; }

.session-empty {
    padding: 12px 10px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

/* System Prompt Panel */
.system-prompt-panel {
    padding: 0 24px;
    margin-bottom: 8px;
}

.system-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.system-prompt-panel textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.system-prompt-panel textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

/* Conversation context indicator */
.context-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 0.7rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    margin: 0 24px;
}

.context-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cx-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Message timestamp & agent badge */
.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.message-agent-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(118, 185, 0, 0.12);
    color: var(--cx-green);
}

.message-agent-badge.vision { background: rgba(0,150,255,0.12); color: var(--cx-blue); }
.message-agent-badge.researcher { background: rgba(139,92,246,0.12); color: var(--cx-purple); }
.message-agent-badge.executor { background: rgba(255,107,53,0.12); color: var(--cx-orange); }

.message-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Enhanced code blocks */
.code-block {
    position: relative;
    margin: 8px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}

.code-block pre {
    margin: 0;
    padding: 12px 14px;
    overflow-x: auto;
}

.code-block code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.code-lang {
    padding: 4px 12px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.inline-code {
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'JetBrains Mono', monospace;
}

.message-content h2, .message-content h3, .message-content h4 {
    margin: 12px 0 6px;
    color: var(--text-primary);
}

.message-content ul, .message-content ol {
    padding-left: 20px;
    margin: 6px 0;
}

.message-content li {
    margin: 3px 0;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.message-content a {
    color: var(--cx-green);
    text-decoration: none;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: flex; }
    .welcome-cards { grid-template-columns: 1fr; }
    .input-area { padding: 0 12px 16px; }
    .messages-inner { padding: 16px; }
    .pipeline-steps { flex-direction: column; }
}
