
/* --- LOGS SPECIFIC STYLES --- */

.group\/tree-item:hover summary {
    color: var(--color-primary);
}

.group\/leaf:hover {
    background-color: var(--color-surface-highlight);
    border-radius: 4px;
}

/* Checkered background for image previews if any */
.bg-checkered {
    background-image: linear-gradient(45deg, var(--color-surface) 25%, transparent 25%), 
                      linear-gradient(-45deg, var(--color-surface) 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, var(--color-surface) 75%), 
                      linear-gradient(-45deg, transparent 75%, var(--color-surface) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: var(--color-background);
}

/* Better Scrollbars for Logs */
#log-container::-webkit-scrollbar {
    width: 8px;
}
#log-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
#log-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}
#log-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Animations for Log Items */
@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInSlideUp 0.2s ease-out forwards;
}

/* --- THEME ROOT UPDATES --- */

/* ============================================================
   LSAI THEME SYSTEM - 10 Themes (5 Dark, 5 Light)
   ============================================================ */

/* ---------- SHARED SEMANTIC COLORS (all themes) ---------- */
:root {
  --color-primary: #818cf8;
  --color-secondary: #34d399;
  --color-accent: #fbbf24;
  --color-highlight: #f472b6;
  --color-webhook: #a78bfa;
  --color-int-tool: #fb923c;
  --color-int-resource: #2dd4bf;
  --color-io-input: #22d3ee;
  --color-io-output: #a78bfa;
  --color-primary-text: #ffffff;
  --color-red-400: #f87171;
  /* Node-specific distinct colors */
  --color-connector: #38bdf8;      /* Sky blue — LLM/STT/TTS models */
  --color-vector-db: #a78bfa;      /* Violet — vector databases */
  --color-guardrail: #fb7185;      /* Rose — guardrail filters */
  --color-mcp: #c084fc;            /* Purple — MCP servers */
  --color-embed-connector: #facc15; /* Yellow — embedding connectors */
}

/* ── DARK 1: Midnight Indigo (Default) ── */
[data-theme="dark"],
:root {
  --theme-label: "Midnight Indigo";
  --color-background: #0f172a;
  --color-surface: #1e293b;
  --color-surface-highlight: #334155;
  --color-border: #1f2937;
  --color-text: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-primary: #818cf8;
  --color-secondary: #34d399;
  --color-accent: #fbbf24;
  --color-highlight: #f472b6;
  --color-primary-text: #ffffff;
}

/* ── DARK 2: Obsidian Green (Cyberpunk Terminal) ── */
[data-theme="dark-obsidian"] {
  --color-background: #010b06;
  --color-surface: #0a1a0f;
  --color-surface-highlight: #102a18;
  --color-border: #1a3a22;
  --color-text: #c8fad6;
  --color-text-muted: #5a9a6a;
  --color-primary: #00e676;
  --color-secondary: #69f0ae;
  --color-accent: #ffee58;
  --color-highlight: #40c4ff;
  --color-webhook: #18ffb2;
  --color-int-tool: #ff6d00;
  --color-int-resource: #00bcd4;
  --color-primary-text: #000000;
}

/* ── DARK 3: Crimson Night (Deep Red Luxury) ── */
[data-theme="dark-crimson"] {
  --color-background: #0d0203;
  --color-surface: #1a0509;
  --color-surface-highlight: #2d0a12;
  --color-border: #3d0f18;
  --color-text: #fff0f2;
  --color-text-muted: #9e7780;
  --color-primary: #ff5370;
  --color-secondary: #ff8a65;
  --color-accent: #ffcb6b;
  --color-highlight: #c792ea;
  --color-webhook: #e040fb;
  --color-int-tool: #ff9800;
  --color-int-resource: #80cbc4;
  --color-primary-text: #ffffff;
}

/* ── DARK 4: Deep Space (Sci-Fi Futuristic) ── */
[data-theme="dark-space"] {
  --color-background: #060614;
  --color-surface: #0e0e2a;
  --color-surface-highlight: #16163d;
  --color-border: #242452;
  --color-text: #e8eaff;
  --color-text-muted: #7878a8;
  --color-primary: #7c83fe;
  --color-secondary: #00e5ff;
  --color-accent: #ffe500;
  --color-highlight: #fe5196;
  --color-webhook: #b45aff;
  --color-int-tool: #ff7043;
  --color-int-resource: #26c6da;
  --color-primary-text: #ffffff;
}

/* ── DARK 5: Noir Carbon (Minimal Black) ── */
[data-theme="dark-noir"] {
  --color-background: #0a0a0a;
  --color-surface: #141414;
  --color-surface-highlight: #1e1e1e;
  --color-border: #2a2a2a;
  --color-text: #f5f5f5;
  --color-text-muted: #737373;
  --color-primary: #e0e0e0;
  --color-secondary: #bdbdbd;
  --color-accent: #ffd54f;
  --color-highlight: #ef9a9a;
  --color-webhook: #ce93d8;
  --color-int-tool: #ffcc80;
  --color-int-resource: #80cbc4;
  --color-primary-text: #0a0a0a;
}

/* ── LIGHT 1: Polar Frost (Clean Modern) ── */
[data-theme="light"] {
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-highlight: #e2e8f0;
  --color-border: #cbd5e1;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-primary: #6366f1;
  --color-secondary: #10b981;
  --color-accent: #f59e0b;
  --color-highlight: #ec4899;
  --color-webhook: #00b4ff;
  --color-int-tool: #f97316;
  --color-int-resource: #14b8a6;
  --color-primary-text: #ffffff;
}

/* ── LIGHT 2: Warm Ivory (Classic Paper) ── */
[data-theme="light-ivory"] {
  --color-background: #fdf6e3;
  --color-surface: #fff8e7;
  --color-surface-highlight: #ede8d8;
  --color-border: #d4c9b0;
  --color-text: #3c3022;
  --color-text-muted: #8a7660;
  --color-primary: #8b5e3c;
  --color-secondary: #5c8a46;
  --color-accent: #c0882a;
  --color-highlight: #b55a8a;
  --color-webhook: #7a5cb5;
  --color-int-tool: #c46a2e;
  --color-int-resource: #3a8a7e;
  --color-primary-text: #ffffff;
}

/* ── LIGHT 3: Sky Blue (Airy Corporate) ── */
[data-theme="light-sky"] {
  --color-background: #eff6ff;
  --color-surface: #ffffff;
  --color-surface-highlight: #dbeafe;
  --color-border: #bfdbfe;
  --color-text: #1e3a5f;
  --color-text-muted: #6b8db5;
  --color-primary: #2563eb;
  --color-secondary: #0891b2;
  --color-accent: #d97706;
  --color-highlight: #db2777;
  --color-webhook: #0099e6;
  --color-int-tool: #ea580c;
  --color-int-resource: #0d9488;
  --color-primary-text: #ffffff;
}

/* ── LIGHT 4: Rose Garden (Soft Elegant) ── */
[data-theme="light-rose"] {
  --color-background: #fff1f2;
  --color-surface: #ffffff;
  --color-surface-highlight: #ffe4e6;
  --color-border: #fecdd3;
  --color-text: #4a0013;
  --color-text-muted: #9f6672;
  --color-primary: #e11d48;
  --color-secondary: #be185d;
  --color-accent: #b45309;
  --color-highlight: #0099e6;
  --color-webhook: #9333ea;
  --color-int-tool: #c2410c;
  --color-int-resource: #0f766e;
  --color-primary-text: #ffffff;
}

/* ── LIGHT 5: Forest Sage (Natural Calm) ── */
[data-theme="light-forest"] {
  --color-background: #f0fdf4;
  --color-surface: #ffffff;
  --color-surface-highlight: #dcfce7;
  --color-border: #bbf7d0;
  --color-text: #14532d;
  --color-text-muted: #5a8570;
  --color-primary: #16a34a;
  --color-secondary: #0d9488;
  --color-accent: #ca8a04;
  --color-highlight: #9333ea;
  --color-webhook: #0099e6;
  --color-int-tool: #ea580c;
  --color-int-resource: #0891b2;
  --color-primary-text: #ffffff;
}

/* ── AUTO-CONTRAST: Primary buttons always have readable text ── */
.bg-primary {
  color: var(--color-primary-text) !important;
}
.bg-primary .text-white,
.bg-primary.text-white {
  color: var(--color-primary-text) !important;
}


/* Base styles */
body {
    font-family: 'Inter', sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--color-surface); 
}
::-webkit-scrollbar-thumb {
    background: var(--color-surface-highlight); 
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748b; 
}

/* Canvas Styles */
#workflow-canvas {
    background-color: var(--color-background);
    cursor: grab;
    transition: background-color 0.3s;
}
#workflow-canvas:active {
    cursor: grabbing;
}

/* Utils */
.view-section {
    transition: opacity 0.2s ease-in-out;
}

.modal-open {
    display: flex !important;
    opacity: 1 !important;
}

.modal-content-open {
    display: flex !important;
    transform: scale(100%) !important;
}

/* Toast Styles */
.toast-success {
    background-color: rgba(52, 211, 153, 0.2); 
    border: 1px solid rgba(52, 211, 153, 0.5);
    color: var(--color-text);
}
.toast-error {
    background-color: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.5);
    color: #fca5a5;
}
.toast-info {
    background-color: var(--color-surface-highlight);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}


/* Markdown Editor Wrapper */
.markdown-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.markdown-preview h1 { font-size: 1.5em; font-weight: bold; margin-bottom: 0.5em; color: var(--color-text); }
.markdown-preview h2 { font-size: 1.3em; font-weight: bold; margin-bottom: 0.5em; color: var(--color-text); }
.markdown-preview h3 { font-size: 1.1em; font-weight: bold; margin-bottom: 0.5em; color: var(--color-text); }
.markdown-preview ul, .markdown-preview ol { padding-left: 1.5em; margin-bottom: 0.5em; list-style-position: outside; }
.markdown-preview ul { list-style-type: disc; }
.markdown-preview ol { list-style-type: decimal; }
.markdown-preview blockquote { border-left: 3px solid var(--color-surface-highlight); padding-left: 1em; color: var(--color-text-muted); font-style: italic; }
.markdown-preview code { background: var(--color-surface-highlight); padding: 0.1em 0.3em; rounded: 3px; font-family: monospace; font-size: 0.9em; }
.markdown-preview pre { background: var(--color-surface-highlight); padding: 0.5em; border-radius: 4px; overflow-x: auto; margin-bottom: 0.5em; }
.markdown-preview pre code { background: transparent; padding: 0; }
.markdown-preview hr { border: 0; border-top: 1px solid var(--color-border); margin: 1em 0; }
.markdown-preview table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.markdown-preview th, .markdown-preview td { border: 1px solid var(--color-border); padding: 0.5em; text-align: left; }
.markdown-preview th { background-color: var(--color-surface); font-weight: bold; }

/* Code Editor Component Styles (Chat/Preview) */
.code-editor {
    margin: 1rem 0;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    background-color: #0d1117; /* GitHub Dark Dimmed */
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.code-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: #161b22;
    border-bottom: 1px solid var(--color-border);
    user-select: none;
}

.code-editor-dots {
    display: flex;
    gap: 0.375rem;
}
.code-dot { width: 0.625rem; height: 0.625rem; border-radius: 9999px; }
.code-dot.red { background-color: #ff5f56; }
.code-dot.yellow { background-color: #ffbd2e; }
.code-dot.green { background-color: #27c93f; }

.code-editor-lang {
    font-family: monospace;
    font-size: 0.7rem;
    color: #8b949e;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.code-editor-copy {
    color: #8b949e;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(240, 246, 252, 0.1);
    background-color: rgba(240, 246, 252, 0.05);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.code-editor-copy:hover {
    background-color: rgba(240, 246, 252, 0.1);
    color: #f0f6fc;
}

.code-editor-body {
    position: relative;
    padding: 1rem;
    overflow-x: auto;
}

.code-editor-body pre {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #e6edf3;
}

/* Syntax Highlighting Tokens (Static Preview) */
.token-comment { color: #8b949e; font-style: italic; }
.token-string { color: #a5d6ff; }
.token-number { color: #79c0ff; }
.token-keyword { color: #ff7b72; }
.token-function { color: #d2a8ff; }
.token-operator { color: #79c0ff; }
.token-tag { color: #7ee787; }
.token-attr { color: #79c0ff; }
.token-punctuation { color: #c9d1d9; }

/* EasyMDE Container overrides */
.EasyMDEContainer {
    display: flex;
    flex-direction: column;
    height: 100%; 
    min-height: 0;
}
.EasyMDEContainer .CodeMirror {
    background-color: var(--color-surfaceHighlight);
    color: var(--color-text);
    border-color: var(--color-border);
    border-radius: 0 0 0.5rem 0.5rem;
    flex: 1; 
    height: auto;
    border: 1px solid #1e293b !important;
    border-top: none !important;
    border-radius: 0px 0px 5px 5px !important;
    font-family: 'Inter', sans-serif;
}

/* Scoped Fix for Files Editor to ensure scrolling */
#file-editor-body .EasyMDEContainer .CodeMirror {
    height: 100% !important;
    min-height: 0;
}

/* --- CHAT INPUT STYLING (MODERN/SEAMLESS) --- */
.chat-editor-wrapper .EasyMDEContainer {
    height: auto !important; /* Allow growing */
    border: none !important;
}

.chat-editor-wrapper .EasyMDEContainer .CodeMirror {
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    font-size: 0.95rem; /* Larger font for chat */
}

.chat-editor-wrapper .EasyMDEContainer .editor-toolbar {
    background-color: transparent !important;
    border: none !important;
    padding: 0 0 4px 0 !important;
    opacity: 0.6;
    transition: opacity 0.2s;
    border-radius: 0 !important;
}

.chat-editor-wrapper:focus-within .EasyMDEContainer .editor-toolbar,
.chat-editor-wrapper:hover .EasyMDEContainer .editor-toolbar {
    opacity: 1;
}

.chat-editor-wrapper .EasyMDEContainer .editor-toolbar button {
    background: transparent !important;
    border: none !important;
    color: var(--color-text-muted) !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 4px !important;
}

.chat-editor-wrapper .EasyMDEContainer .editor-toolbar button:hover {
    background-color: var(--color-surfaceHighlight) !important;
    color: var(--color-text) !important;
}

.chat-editor-wrapper .EasyMDEContainer .editor-toolbar button.active {
    background-color: var(--color-primary) !important;
    color: white !important;
}

.chat-editor-wrapper .EasyMDEContainer .editor-toolbar i.separator {
    border-left: 1px solid var(--color-border);
    margin: 0 4px;
}

.chat-editor-wrapper .CodeMirror-scroll {
    min-height: 40px !important; /* Match JS config */
    max-height: 200px !important;
}

.chat-editor-wrapper .CodeMirror-cursor {
    border-left: 2px solid var(--color-primary) !important;
}

.chat-editor-wrapper .CodeMirror-placeholder {
    color: var(--color-text-muted) !important;
    opacity: 0.5;
}

/* EasyMDE Preview Styling for Dark Theme */
.editor-preview, .editor-preview-side {
    background-color: var(--color-background) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
    padding: 2rem !important;
}
.editor-preview pre, .editor-preview-side pre {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
}
.editor-preview a, .editor-preview-side a {
    color: var(--color-primary) !important;
}
.editor-preview h1, .editor-preview-side h1,
.editor-preview h2, .editor-preview-side h2,
.editor-preview h3, .editor-preview-side h3 {
    border-bottom-color: var(--color-border) !important;
    color: var(--color-text) !important;
}

/* 
 * Custom CodeMirror Theme: 'lsai' 
 * Applied to Standalone CodeMirror instances for code files
 */
.cm-s-lsai.CodeMirror {
    height: 100% !important; /* Force fill */
    font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
    font-size: 14px;
    background-color: #0f172a !important; /* Dark Slate background */
    color: #e2e8f0 !important;
    border: none !important;
}

.cm-s-lsai .CodeMirror-gutters {
    background-color: #0d1425 !important;
    border-right: 1px solid #1e293b !important;
}

.cm-s-lsai .CodeMirror-linenumber {
    color: #475569 !important;
}

.cm-s-lsai .CodeMirror-cursor {
    border-left: 2px solid #818cf8 !important; /* Primary color cursor */
}

.cm-s-lsai .CodeMirror-selected {
    background: rgba(129, 140, 248, 0.2) !important;
}
.cm-s-lsai .CodeMirror-line::selection, 
.cm-s-lsai .CodeMirror-line > span::selection, 
.cm-s-lsai .CodeMirror-line > span > span::selection {
    background: rgba(129, 140, 248, 0.2) !important;
}

/* Syntax Highlighting for 'lsai' theme */
.cm-s-lsai .cm-comment { color: #64748b !important; font-style: italic; }
.cm-s-lsai .cm-string { color: #a5d6ff !important; }
.cm-s-lsai .cm-string-2 { color: #7dd3fc !important; }
.cm-s-lsai .cm-number { color: #fb923c !important; }
.cm-s-lsai .cm-keyword { color: #f472b6 !important; font-weight: bold; }
.cm-s-lsai .cm-atom { color: #c084fc !important; }
.cm-s-lsai .cm-def { color: #e879f9 !important; } 
.cm-s-lsai .cm-variable { color: #e2e8f0 !important; }
.cm-s-lsai .cm-variable-2 { color: #22d3ee !important; }
.cm-s-lsai .cm-variable-3 { color: #34d399 !important; }
.cm-s-lsai .cm-property { color: #bae6fd !important; }
.cm-s-lsai .cm-operator { color: #fbbf24 !important; }
.cm-s-lsai .cm-meta { color: #a78bfa !important; }
.cm-s-lsai .cm-tag { color: #f87171 !important; }
.cm-s-lsai .cm-attribute { color: #fbbf24 !important; }
.cm-s-lsai .cm-bracket { color: #94a3b8 !important; }
.cm-s-lsai .cm-qualifier { color: #818cf8 !important; }
.cm-s-lsai .cm-builtin { color: #2dd4bf !important; }
.cm-s-lsai .cm-link { color: #38bdf8 !important; text-decoration: underline; }

.EasyMDEContainer .editor-toolbar {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    border-radius: 0.5rem 0.5rem 0 0;
    opacity: 1;
}
.EasyMDEContainer .editor-toolbar i {
    color: var(--color-text-muted);
}
.EasyMDEContainer .editor-toolbar button:hover {
    background-color: var(--color-surfaceHighlight);
    border-color: var(--color-border);
}
.EasyMDEContainer .editor-toolbar button.active {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}
.EasyMDEContainer .editor-toolbar button.active i {
    color: white;
}
.EasyMDEContainer .editor-statusbar {
    display: none; /* Hide status bar for cleaner look */
}

/* Draggable Items */
[draggable="true"] {
    cursor: grab;
}
[draggable="true"]:active {
    cursor: grabbing;
}

/* Drag Over State for Files */
.drag-over {
    border-color: var(--color-primary) !important; 
    background-color: rgba(99, 102, 241, 0.1);
    border-style: dashed;
}

/* Message Animation */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.message-animate {
    animation: slideIn 0.3s ease-out forwards;
}

/* Workflow Assistant Chat Panel */
@keyframes waSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.wa-panel-inner {
    animation: waSlideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Chat Bubbles */
.chat-bubble-user {
    /* Vibrant Gradient for User */
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-highlight) 100%);
    color: white;
    border-radius: 18px 18px 2px 18px; /* Sharper bottom-right */
    max-height: 600px;
    overflow-y: auto;
    /* User Glow */
    box-shadow: 0 4px 15px -3px rgba(99, 102, 241, 0.4); 
    border: 1px solid rgba(255,255,255,0.1);
}

.chat-bubble-model {
    /* Sleek Dark Surface for Model */
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: 18px 18px 18px 2px; /* Sharper bottom-left */
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    /* Dynamic border/shadow applied via inline style in JS */
}

/* Tool Execution Details Styles */
.tool-execution[open] summary {
    background-color: var(--color-surfaceHighlight);
}
.tool-execution summary::-webkit-details-marker {
    display: none;
}

.chat-bubble-error {
    /* Danger/Error Styling */
    background: linear-gradient(135deg, rgba(127, 29, 29, 0.95) 0%, rgba(185, 28, 28, 0.95) 100%);
    color: #fee2e2;
    border: 1px solid #ef4444;
    border-radius: 18px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 0 20px -5px rgba(239, 68, 68, 0.5); /* Red Glow */
}

/* Think Block */
.think-block[open] {
    margin-bottom: 1rem;
}
.think-block summary {
    list-style: none; /* Hide default triangle */
}
.think-block summary::-webkit-details-marker {
    display: none; /* Hide default triangle in Chrome */
}

/* Loading Dots */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
}
.loading-dots .dot {
    width: 8px;
    height: 8px;
    background-color: var(--color-text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.loading-dots .dot:nth-child(1) { animation-delay: -0.32s; background-color: var(--color-primary); }
.loading-dots .dot:nth-child(2) { animation-delay: -0.16s; background-color: var(--color-highlight); }
.loading-dots .dot:nth-child(3) { background-color: var(--color-secondary); }

/* Options Builder Styles */
.opt-children {
    border-left: 2px solid var(--color-surface-highlight);
    padding-left: 8px;
    margin-top: 4px;
}
/* Hierarchy Lines */
.hierarchy-item {
    position: relative;
}
.hierarchy-item .hierarchy-line {
    position: absolute;
    left: -12px;
    top: -12px;
    bottom: 50%;
    width: 12px;
    border-left: 2px solid var(--color-surface-highlight);
    border-bottom: 2px solid var(--color-surface-highlight);
    border-bottom-left-radius: 8px;
    pointer-events: none;
    z-index: 0;
}
/* Hide root line */
.space-y-2 > .hierarchy-item .hierarchy-line {
    display: none;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

/* Sidebar Collapse Helpers */
.w-20 .sidebar-text {
    display: none;
}
.w-20 .nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.w-20 .sidebar-logo {
    justify-content: center;
}

/* Sidebar icon-only action buttons */
.sidebar-icon-btn { display:flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:6px; background:none; border:none; color:var(--color-text-muted); cursor:pointer; transition:background 0.15s,color 0.15s; flex-shrink:0; font-size:12px; }
.sidebar-icon-btn:hover { background:var(--color-surface-highlight); color:var(--color-text); }

/* Sidebar collapsed popover menu */
.sidebar-popover-btn { display:flex; align-items:center; gap:8px; width:100%; padding:6px 10px; border:none; background:none; color:var(--color-text-muted); font-size:12px; font-weight:500; border-radius:6px; cursor:pointer; transition:background 0.12s,color 0.12s; white-space:nowrap; }
.sidebar-popover-btn:hover { background:var(--color-surface-highlight); color:var(--color-text); }
.sidebar-popover-btn i { width:14px; text-align:center; flex-shrink:0; }

/* Collapsed-only elements: hidden by default, shown via JS when sidebar is w-20 */
.sidebar-collapsed-only { display: none; }
.w-20 .sidebar-collapsed-only { display: block; }

/* Nav tooltip - shown only when sidebar collapsed (w-20) */
.nav-tooltip { display:none; position:absolute; left:calc(100% + 10px); top:50%; transform:translateY(-50%); background:var(--color-surface); border:1px solid var(--color-border); color:var(--color-text); font-size:11px; font-weight:600; padding:4px 10px; border-radius:7px; white-space:nowrap; pointer-events:none; z-index:9999; box-shadow:0 4px 16px rgba(0,0,0,0.35); }
.nav-tooltip::before { content:''; position:absolute; right:100%; top:50%; transform:translateY(-50%); border:5px solid transparent; border-right-color:var(--color-border); }
.w-20 .nav-item:hover .nav-tooltip { display:block; }

/* Toolbox Collapse Helpers */
#toolbox.w-8 {
    width: 2rem;
}
#toolbox.w-8 .toolbox-content-wrapper {
    opacity: 0;
    pointer-events: none;
}
#toolbox.w-8 #toolbox-toggle-icon {
    transform: rotate(180deg);
}

/* Category Headers */
.category-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.category-header:hover {
    color: var(--color-text);
}
.category-content.collapsed {
    display: none;
}

/* Search Card */
.search-result-card {
    transition: all 0.2s ease;
}
.search-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px var(--color-surface-highlight);
}

/* Wizard */
.wizard-step.active {
    display: flex;
}
.step-indicator {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    background-color: var(--color-surface-highlight);
    color: var(--color-text-muted);
}
.step-indicator.active {
    background-color: var(--color-primary);
    color: white;
}
.step-indicator.completed {
    background-color: var(--color-secondary);
    color: white;
}
.step-line {
    flex: 1;
    height: 2px;
    background-color: var(--color-surface-highlight);
    margin: 0 4px;
}
.step-line.completed {
    background-color: var(--color-secondary);
}

/* Unsaved Changes Indicator */
.unsaved-indicator {
    position: relative;
}
.unsaved-indicator::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    border: 1px solid var(--color-surface);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- MENTION MENU STYLES --- */
#chat-mention-menu {
    max-height: 240px;
    overflow-y: auto;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    scrollbar-width: thin;
}

.group\/tree-item:hover summary {
    color: var(--color-primary);
}

.group\/leaf:hover {
    background-color: var(--color-surface-highlight);
    border-radius: 4px;
}

/* Caret rotation for trees and collapsible sections */
details.group\/args[open] i.fa-caret-right,
details.group\/tree-item[open] i.fa-caret-right {
    transform: rotate(90deg);
}

.tool-execution[open] i.fa-chevron-down {
    transform: rotate(180deg);
}

.tool-execution summary i.fa-chevron-down {
    transition: transform 0.2s ease-in-out;
}

/* ============================
   AUTH PAGE STYLES — NOIR CARBON
   ============================ */

.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #050508;
    position: relative;
    overflow: hidden;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

#auth-bg-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.auth-glow-orb {
    position: fixed;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 180, 255, 0.12) 0%, rgba(0, 180, 255, 0.03) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    transition: left 0.08s ease-out, top 0.08s ease-out;
    mix-blend-mode: screen;
}

.auth-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: rgba(12, 12, 18, 0.65);
    border: 1px solid rgba(0, 180, 255, 0.12);
    border-radius: 1.5rem;
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.03) inset,
        0 30px 60px -15px rgba(0, 0, 0, 0.7),
        0 0 80px -20px rgba(0, 180, 255, 0.15);
    animation: authPanelIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
    overflow: hidden;
}

.auth-scanlines {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 180, 255, 0.015) 2px,
            rgba(0, 180, 255, 0.015) 4px
        );
    pointer-events: none;
    z-index: 0;
    border-radius: 1.5rem;
}

@keyframes authPanelIn {
    0% { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.auth-logo-bolt {
    width: 280px;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    mix-blend-mode: screen;           /* makes white bg transparent on dark panels */
    filter: drop-shadow(0 0 16px rgba(0, 100, 220, 0.45)) brightness(1.15);
    animation: logoBreathe 3s ease-in-out infinite;
}

@keyframes logoBreathe {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(0, 180, 255, 0.3)); transform: scale(1); }
    50% { filter: drop-shadow(0 0 20px rgba(0, 180, 255, 0.6)); transform: scale(1.05); }
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    z-index: 1;
}

.auth-logo-hex {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #00b4ff 0%, #0084cc 50%, #005799 100%);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    animation: hexPulse 3s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(0, 180, 255, 0.4);
}

@keyframes hexPulse {
    0%, 100% { filter: brightness(1); transform: scale(1); }
    50% { filter: brightness(1.3); transform: scale(1.05); }
}

.auth-logo-text {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, #e2e8f0, #00b4ff, #e2e8f0);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textShimmer 4s ease-in-out infinite;
    position: relative;
    margin: 0;
}

@keyframes textShimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.auth-subtitle {
    color: rgba(0, 180, 255, 0.6);
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

.auth-tagline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    color: rgba(148, 163, 184, 0.5);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.auth-tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: dotBlink 2s ease-in-out infinite;
}

@keyframes dotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.auth-setup-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.15);
    border-radius: 0.5rem;
    color: #fbbf24;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.auth-setup-desc {
    color: rgba(148, 163, 184, 0.6);
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.auth-field {
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.auth-field label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(0, 180, 255, 0.7);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'JetBrains Mono', monospace;
}

.auth-field label i {
    margin-right: 0.25rem;
    font-size: 0.6rem;
}

.auth-field input {
    width: 100%;
    background: rgba(10, 10, 16, 0.6);
    border: 1px solid rgba(0, 180, 255, 0.12);
    border-radius: 0.75rem;
    padding: 0.8rem 1rem;
    color: #e2e8f0;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
    font-family: 'Inter', sans-serif;
}

.auth-field input:hover {
    border-color: rgba(0, 180, 255, 0.25);
    background: rgba(15, 15, 24, 0.7);
}

.auth-field input:focus {
    border-color: rgba(0, 180, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 180, 255, 0.1), 0 0 20px -5px rgba(0, 180, 255, 0.2);
    background: rgba(15, 15, 24, 0.8);
}

.auth-field input::placeholder {
    color: rgba(100, 100, 130, 0.5);
    font-size: 0.85rem;
}

.auth-btn {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    position: relative;
    overflow: hidden;
    z-index: 1;
    letter-spacing: 0.04em;
}

.auth-btn-primary {
    background: linear-gradient(135deg, #0099e6, #0084cc, #006db3);
    color: white;
    border: 1px solid rgba(0, 180, 255, 0.3);
    box-shadow: 0 4px 20px -5px rgba(0, 180, 255, 0.4);
}

.auth-btn-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px -5px rgba(0, 180, 255, 0.5), 0 0 0 1px rgba(0, 180, 255, 0.3);
    background: linear-gradient(135deg, #00b4ff, #0099e6, #0084cc);
}

.auth-btn-primary:hover .auth-btn-glow {
    opacity: 1;
}

.auth-btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px -3px rgba(0, 180, 255, 0.4);
}

.auth-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.75rem;
    color: #fca5a5;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: authShake 0.4s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.auth-success {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 0.75rem;
    color: #6ee7b7;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeInSlideUp 0.3s ease-out;
    position: relative;
    z-index: 1;
}

.auth-footer {
    text-align: center;
    margin-top: 1.75rem;
    color: rgba(100, 100, 130, 0.4);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    position: relative;
    z-index: 1;
}

.auth-footer-version { color: rgba(0, 180, 255, 0.4); }
.auth-footer-sep { margin: 0 0.5rem; font-size: 0.4rem; vertical-align: middle; }

.auth-spinner {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(0, 180, 255, 0.15);
    border-top: 2px solid #00b4ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.auth-loading {
    text-align: center;
    color: rgba(148, 163, 184, 0.5);
    position: relative;
    z-index: 10;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================
   SESSION WARNING BANNER
   ============================ */

.session-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    animation: slideDown 0.3s ease-out;
}

.session-warning.hidden {
    display: none;
}

.session-warning-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(245, 158, 11, 0.15));
    border-bottom: 1px solid rgba(251, 191, 36, 0.3);
    backdrop-filter: blur(10px);
    color: #fbbf24;
    font-size: 0.8rem;
    font-weight: 600;
}

.session-warning-btn {
    background: rgba(251, 191, 36, 0.2);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.session-warning-btn:hover {
    background: rgba(251, 191, 36, 0.3);
}

.session-warning-dismiss {
    background: none;
    border: none;
    color: rgba(251, 191, 36, 0.5);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.session-warning-dismiss:hover {
    color: #fbbf24;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ============================
   PROJECT CARDS
   ============================ */

.project-card {
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Changeset row hover */
.changeset-row {
    transition: border-color 0.2s, background-color 0.2s;
}

.changeset-row:hover {
    background: rgba(129, 140, 248, 0.03);
}

/* ============================
   AUTH HIDDEN STATE
   ============================ */
.hidden {
    display: none !important;
}

/* ============================
   CONTEXT GATHERING PANEL
   ============================ */
.animate-spin {
    animation: spin 0.75s linear infinite;
    display: inline-block;
}

.context-source-row + .context-source-row {
    border-top: 1px solid rgba(255,255,255,0.04);
}

.context-sources-panel {
    min-height: 0;
}

/* Token Usage Pill (chat message header) */
.token-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--color-text-muted);
    background: var(--color-surface-highlight);
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    padding: 1px 7px 1px 5px;
    opacity: 0.65;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    cursor: default;
    user-select: none;
}
.token-pill:hover { opacity: 1; }
