/* =============================================================
   Fynal Studio â€” Design System
   Theme: Dark | Accent: #5b13ec | Font: Inter | Radius: 12px
   Derived from Stitch project "Fynal Studio IDE"
   ============================================================= */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Colors â€” Backgrounds */
    --bg-primary: #09090b;
    --bg-secondary: #0d0d0e;
    --bg-tertiary: #111113;
    --bg-elevated: #18181b;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-active: rgba(255, 255, 255, 0.06);

    /* Colors â€” Accent */
    --accent: #5b13ec;
    --accent-hover: #6d28d9;
    --accent-glow: rgba(91, 19, 236, 0.4);
    --accent-subtle: rgba(91, 19, 236, 0.1);
    --accent-gradient: linear-gradient(135deg, #5b13ec, #a855f7);

    /* Colors â€” Text */
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-faint: #52525b;
    --text-disabled: #3f3f46;

    /* Colors â€” Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-accent: rgba(91, 19, 236, 0.3);

    /* Colors â€” Semantic */
    --success: #22c55e;
    --warning: #eab308;
    --error: #ef4444;
    --info: #3b82f6;

    /* Colors â€” File Types */
    --file-html: #f97316;
    --file-css: #3b82f6;
    --file-js: #eab308;
    --file-json: #22c55e;
    --file-asset: #10b981;
    --file-folder: #71717a;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Sizing */
    --navbar-height: 56px;
    --statusbar-height: 28px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 48px;
    --tab-height: 40px;
    --preview-toolbar-height: 48px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}


/* --- Reset & Base --- */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

::selection {
    background: rgba(91, 19, 236, 0.3);
}

/* --- Global Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 10px;
    /* Thicker for better visibility */
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #0d0d0e;
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Specific targeting for Monaco */
.monaco-editor .scrollbar .slider {
    background: #5b13ec !important;
    border-radius: var(--radius-full) !important;
}

/* Specific targeting for Monaco Editor's custom scrollbar divs */
.monaco-editor .scrollbar .slider {
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-full) !important;
    opacity: 1;
}

.monaco-editor .scrollbar .slider:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Visually separate minimap */
.monaco-editor .minimap {
    border-left: 1px solid var(--border);
    background-color: var(--bg-secondary) !important;
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

a {
    color: inherit;
    text-decoration: none;
}


/* --- App Layout --- */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#workspace {
    flex: 1;
    display: flex;
    min-width: 0;
    overflow: hidden;
    --editor-width: 50%;
}

#editor-panel {
    width: var(--editor-width);
    flex: none;
    display: flex;
    flex-direction: column;
    min-width: 100px;
    overflow: hidden;
}

#editor-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.editor-wrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    overflow: hidden;
}

.resizer {
    width: 2px;
    background: transparent;
    cursor: col-resize;
    position: relative;
    z-index: 10;
    flex: none;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    right: -4px;
    cursor: col-resize;
}

.resizer:hover,
.resizer--dragging {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

#preview-panel {
    flex: 1;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
}

#preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Visual Editor Panel */
#visual-editor-panel {
    display: none;
    grid-template-columns: 260px 1fr 280px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}

/* --- View Modes --- */

.view-mode--code #preview-panel,
.view-mode--code #resizer,
.view-mode--code #agent-panel,
.view-mode--code #visual-editor-panel {
    display: none !important;
}

.view-mode--code #editor-panel {
    width: 100% !important;
    flex: 1 !important;
}

.view-mode--preview #editor-panel,
.view-mode--preview #resizer,
.view-mode--preview #visual-editor-panel {
    display: none !important;
}

.view-mode--preview #preview-panel {
    width: 100% !important;
    flex: 1 !important;
    border-left: none;
}

.view-mode--split #preview-panel,
.view-mode--split #resizer,
.view-mode--split #visual-editor-panel {
    display: none !important;
}

.view-mode--split #agent-panel {
    display: flex !important;
    /* Removed fixed width here to let #agent-panel rules handle it */
}

.view-mode--split #editor-panel {
    flex: 1 !important;
    width: auto !important;
}

/* ===== Visual Editor Mode ===== */
#main-layout.view-mode--visual #editor-panel,
#main-layout.view-mode--visual #resizer,
#main-layout.view-mode--visual #preview-panel,
#main-layout.view-mode--visual #agent-panel {
    display: none !important;
}

/* --- Preview Mode --- */
#main-layout.view-mode--preview #agent-panel {
    display: none !important;
}

#main-layout.view-mode--visual #workspace {
    position: relative;
}

/* --- View Selector (Segmented Control) --- */

.view-selector {
    display: flex;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px;
    position: relative;
    gap: 4px;
    width: fit-content;
}

.view-option {
    width: 80px;
    height: 28px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
}

.view-option:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.view-option--active {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.view-selector-highlight {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 80px;
    height: 28px;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    box-shadow: 0 2px 10px var(--accent-glow), inset 0 1px 1px rgba(255, 255, 255, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    pointer-events: none;
}

/* Highlight Positions using Transform (Performance + Smoothness) */
.view-selector-highlight.pos-code {
    transform: translateX(0);
}

.view-selector-highlight.pos-split {
    transform: translateX(84px);
    /* 80px width + 4px gap */
}

.view-selector-highlight.pos-visual {
    transform: translateX(168px);
    /* 2 * (80px + 4px) */
}

.view-selector-highlight.pos-preview {
    transform: translateX(252px);
    /* 3 * (80px + 4px) */
}



/* --- Navigation Bar --- */

.navbar {
    height: var(--navbar-height);
    background: rgba(13, 13, 14, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Agent Panel ===== */
#agent-panel {
    flex: none;
    width: 240px;
    min-width: 0;
    max-width: 240px;
    height: 100%;
    display: none;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    overflow: hidden;
    min-height: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 50;
}

#agent-panel.is-wide,
#main-layout.view-mode--split #agent-panel.is-wide {
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
}

#agent-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Header */
#agent-header {
    height: 48px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

#agent-header-right { display: flex; align-items: center; gap: 4px; }

/* Model Selector */
#agent-model-select {
    display: flex;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-right: 4px;
}

.agent-model-btn {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-faint);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 150ms ease;
}

.agent-model-btn.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.agent-model-btn:hover:not(.active) {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

#agent-expand-btn,
#agent-clear-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms ease;
}

#agent-expand-btn:hover { color: var(--accent); background: var(--accent-subtle); }
#agent-clear-btn:hover  { color: var(--error);  background: rgba(239,68,68,0.1); }

#agent-header-left { display: flex; align-items: center; gap: 10px; }

#agent-avatar {
    width: 30px;
    height: 30px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
    flex-shrink: 0;
}

#agent-name   { font-size: 12px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
#agent-status { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-faint); }

.agent-status-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px rgba(34,197,94,0.7);
    animation: agent-pulse 2s ease-in-out infinite;
}

@keyframes agent-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(34,197,94,0.5); }
    50%       { box-shadow: 0 0 10px rgba(34,197,94,0.9); }
}

/* Messages container */
#agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    scroll-behavior: smooth;
    position: relative;
}

/* Scroll-to-bottom button */
#agent-scroll-btn {
    position: sticky;
    bottom: 0;
    align-self: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: all 150ms ease;
    z-index: 10;
    margin-top: auto;
    flex-shrink: 0;
}

#agent-scroll-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
}

/* Welcome */
#agent-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 12px;
    gap: 12px;
    margin: auto 0;
    animation: agent-welcome-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes agent-welcome-in {
    from { opacity: 0; transform: translateY(16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#agent-welcome-icon {
    width: 52px; height: 52px;
    background: var(--accent-subtle);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xl);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    margin-bottom: 4px;
    box-shadow: 0 0 20px var(--accent-glow);
}

#agent-welcome-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
#agent-welcome-sub   { font-size: 11px; color: var(--text-faint); line-height: 1.6; }

/* Messages */
.agent-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
    animation: agent-msg-in 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes agent-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.agent-msg--user { align-items: flex-end; }

.agent-msg--user .agent-msg-text {
    background: var(--accent-gradient);
    color: white;
    border-radius: 14px 14px 2px 14px;
    padding: 9px 13px;
    font-size: 12px;
    line-height: 1.55;
    min-width: 0;
    max-width: 92%;
    word-break: break-word;
    overflow-wrap: break-word;
    box-shadow: 0 2px 8px var(--accent-glow);
    max-height: 200px;
    overflow-y: auto;
}

.agent-msg--ai .agent-msg-text {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 2px 14px 14px 14px;
    padding: 9px 13px;
    font-size: 12px;
    line-height: 1.55;
    min-width: 0;
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

.agent-msg-time {
    font-size: 9px;
    color: var(--text-faint);
    padding: 0 4px;
    opacity: 0;
    transition: opacity 200ms ease;
}

.agent-msg:hover .agent-msg-time { opacity: 1; }
.agent-msg--user .agent-msg-time  { text-align: right; }

/* Code block */
.agent-code-block {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-primary);
    transition: border-color 150ms ease;
}

.agent-code-block:hover { border-color: var(--border-hover); }

.agent-code-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    min-width: 0;
    overflow: hidden;
}

.agent-code-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
}

.agent-code-actions { display: flex; gap: 4px; margin-left: auto; }

.agent-code-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.agent-code-btn:hover { background: var(--bg-active); color: var(--text-primary); }

.agent-apply-btn {
    background: var(--accent-subtle) !important;
    color: var(--accent) !important;
    border-color: var(--border-accent) !important;
}

.agent-apply-btn:hover {
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* Diff toggle */
.agent-diff-toggle {
    padding: 4px 8px;
    border-bottom: 1px solid transparent;
    transition: border-color 150ms ease;
}

.agent-diff-toggle[data-open="true"] { border-bottom-color: var(--border); }

.agent-diff-toggle-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 4px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: var(--text-faint);
    cursor: pointer;
    transition: all 150ms ease;
    width: 100%;
}

.agent-diff-toggle-btn:hover { color: var(--text-secondary); background: var(--bg-hover); }

.diff-chevron { transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1); flex-shrink: 0; }

.diff-stat {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
}

.diff-stat--add    { color: #4ade80; background: rgba(34,197,94,0.1); }
.diff-stat--remove { color: #f87171; background: rgba(239,68,68,0.1); }

.diff-toggle-label { font-size: 10px; color: var(--text-faint); margin-left: 2px; }

.agent-diff-body { animation: diff-reveal 0.2s ease; }

@keyframes diff-reveal {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Diff view */
.agent-diff {
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.7;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 300px;
    max-width: 100%;
    padding: 6px 0;
}

.diff-line { display: flex; min-width: 0; }

.diff-gutter {
    width: 32px;
    flex-shrink: 0;
    padding: 0 6px;
    color: var(--text-faint);
    user-select: none;
    text-align: right;
    font-size: 9px;
}

.diff-content {
    flex: 1;
    padding: 0 8px;
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.diff-add    { background: rgba(34,197,94,0.08); color: #86efac; }
.diff-remove { background: rgba(239,68,68,0.08); color: #fca5a5; text-decoration: line-through; opacity: 0.7; }
.diff-meta   { color: var(--text-faint); font-style: italic; }
.diff-add .diff-gutter    { color: #4ade80; }
.diff-remove .diff-gutter { color: #f87171; }

/* Fallback code preview */
.agent-code-pre {
    padding: 8px 10px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    overflow-x: auto;
    max-height: 220px;
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
    background: rgba(0,0,0,0.2);
}

/* Chips */
#agent-chips {
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    min-width: 0;
    overflow: hidden;
}

.agent-chip {
    padding: 3px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.agent-chip:hover {
    background: var(--accent-subtle);
    border-color: var(--border-accent);
    color: var(--accent);
    transform: translateY(-1px);
}

/* Input area */
#agent-input-wrap {
    padding: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: flex-end;
    flex-shrink: 0;
    min-width: 0;
    background: var(--bg-secondary);
    transition: background 150ms ease;
}

#agent-input-wrap:focus-within { background: var(--bg-tertiary); }

#agent-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 7px 9px;
    font-size: 11px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    resize: none;
    line-height: 1.5;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    max-height: 120px;
    min-height: 34px;
    overflow-y: auto;
}

#agent-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

#agent-input::placeholder { color: var(--text-faint); }

#agent-send-btn {
    width: 34px;
    height: 34px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 150ms ease;
    box-shadow: 0 2px 8px var(--accent-glow);
}

#agent-send-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px var(--accent-glow);
}

#agent-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Status pill */
.agent-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-bottom: 4px;
    align-self: flex-start;
}

.agent-status-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: agent-spin 0.8s linear infinite;
}

.agent-status-label { font-size: 10px; font-weight: 600; color: var(--text-muted); }

/* Tool steps */
.agent-tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    animation: agent-msg-in 0.2s ease;
}

.agent-tool-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-faint);
    transition: all 300ms ease;
    min-width: 0;
    overflow: hidden;
}

.agent-tool-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.agent-tool-item--active { color: var(--accent); }
.agent-tool-item--done   { color: var(--success); opacity: 0.7; }

.agent-tool-spinner {
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.agent-tool-item--active .agent-tool-spinner {
    border: 1.5px solid var(--accent-subtle);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: agent-spin 0.7s linear infinite;
}

@keyframes agent-spin { to { transform: rotate(360deg); } }

/* Inline styles */
.agent-inline-code {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent);
}

.agent-p { margin: 0 0 6px 0; line-height: 1.6; font-size: 12px; }
.agent-p:last-child { margin-bottom: 0; }

.agent-ol, .agent-ul {
    margin: 6px 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.agent-ol { list-style: decimal; }
.agent-ul { list-style: disc; }
.agent-li { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.agent-msg strong { color: var(--text-primary); font-weight: 700; }
.agent-msg em     { color: var(--text-muted); font-style: italic; }

/* File badge */
.agent-file-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
}

.agent-file-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-line-count {
    font-size: 9px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    margin-left: 4px;
    margin-right: auto;
    white-space: nowrap;
}

/* Streaming cursor */
.agent-cursor {
    display: inline-block;
    color: var(--accent);
    animation: agent-blink 0.7s step-end infinite;
    margin-left: 1px;
    font-weight: 300;
}

@keyframes agent-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* Plan checklist */
.agent-plan {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 6px;
    animation: agent-msg-in 0.25s ease;
}

.agent-plan-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-faint);
}

.agent-plan-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    transition: background 150ms ease;
}

.agent-plan-step:last-child { border-bottom: none; }

.agent-plan-check {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--border-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: transparent;
    transition: all 200ms ease;
}

.agent-plan-step--done .agent-plan-check {
    background: var(--success);
    border-color: var(--success);
    color: white;
    box-shadow: 0 0 8px rgba(34,197,94,0.4);
}

.agent-plan-label {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    transition: color 150ms ease;
}

.agent-plan-step--done .agent-plan-label {
    color: var(--text-faint);
    text-decoration: line-through;
}

/* Ask options */
.agent-ask {
    background: var(--bg-primary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: agent-msg-in 0.25s ease;
}

.agent-ask-question {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.agent-ask-options {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.agent-ask-option {
    padding: 5px 11px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
}

.agent-ask-option:hover:not(:disabled) {
    background: var(--accent-subtle);
    border-color: var(--border-accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.agent-ask-option--selected {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: white !important;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.agent-ask-option:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Antigravity-Style Proposals --- */
.agent-response-card {
    background: var(--bg-hover);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    margin: 10px 0;
    overflow: hidden;
    animation: agent-msg-in 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.agent-card-header {
    background: rgba(168, 85, 247, 0.1);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* File Proposals */
.agent-proposal-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.agent-file-row {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-file-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

.agent-file-checkbox {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-hover);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.agent-file-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.agent-file-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 7px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

/* Database & Terminal Proposals */
.agent-db-proposal, .agent-cmd-proposal {
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    padding: 10px;
    border-left: 3px solid var(--accent);
}

.agent-cmd-proposal { border-left-color: #10b981; } /* Emerald for terminal */

.agent-proposal-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.7;
}

.agent-db-sql, .agent-cmd-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}



/* Terminal Emulator */
#agent-terminal-container {
    border-top: 1px solid var(--border);
    background: #000;
}

.agent-terminal {
    height: 180px;
    padding: 12px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #aeaeae;
    line-height: 1.5;
}

.terminal-line {
    margin-bottom: 4px;
    word-break: break-all;
}

.terminal-prompt {
    color: var(--accent);
    font-weight: 700;
    margin-right: 8px;
}

.terminal-input-wrap {
    display: flex;
    align-items: center;
}

.terminal-input {
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: inherit;
    flex: 1;
    outline: none;
    padding: 0;
}

.terminal-error { color: var(--error); }

/* --- Proceed Gate & Diffs --- */
.agent-proceed-gate {
    padding: 12px;
    background: rgba(0,0,0,0.1);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-proceed-actions {
    display: flex;
    gap: 2px;
}

.agent-proceed-btn {
    flex: 1;
    height: 34px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.agent-proceed-dropdown-toggle {
    width: 34px;
    height: 34px;
    background: var(--accent);
    color: white;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.2);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.agent-proceed-dropdown-toggle:hover { background: var(--accent-hover); }

.agent-proceed-menu {
    background: var(--bg-hover);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.agent-proceed-menu-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-radius: 4px;
    cursor: pointer;
}

.agent-proceed-menu-item:hover {
    background: var(--accent-subtle);
    color: var(--accent);
}

.agent-diff-badge {
    font-size: 9px;
    font-weight: 700;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 1px 4px;
    border-radius: 4px;
}

.agent-diff-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}

.agent-diff-toggle-btn.is-open { transform: rotate(180deg); color: var(--accent); }

.agent-diff-view {
    margin: 4px 12px 12px 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    animation: agent-msg-in 0.2s ease;
}

.agent-proceed-status {
    font-size: 10px;
    color: var(--text-faint);
    text-align: center;
    min-height: 14px;
}

/* Typing dots */
.agent-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 2px 12px 12px 12px;
    width: fit-content;
}

.agent-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: agent-bounce 1.2s infinite ease-in-out;
}

.agent-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.agent-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes agent-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* Placeholder (empty panel state) */
.agent-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 24px 16px;
}

.agent-placeholder-icon {
    width: 56px; height: 56px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.agent-placeholder-label {
    font-size: 13px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.agent-placeholder-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

/* View selector highlight â€” 4th position for Visual */
.view-selector-highlight.pos-visual {
    transform: translateX(168px);
    /* 2 * (80px + 4px) */
}


.brand-logo {
    width: 34px;
    height: 34px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: box-shadow var(--transition-base);
}

.brand-logo:hover {
    box-shadow: 0 6px 20px var(--accent-glow);
}

.brand-logo span {
    color: white;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
}

.brand-logo-img {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.brand-text {
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(91, 19, 236, 0.2);
    font-size: 14px;
    letter-spacing: -0.3px;
}

.navbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
}

.project-name-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.project-name-input {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    width: 180px;
    padding: 4px 28px 4px 10px;
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    background: var(--bg-hover);
    border: 1px solid var(--border);
}

.project-name-input:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.project-name-input:focus {
    color: var(--text-primary);
    background: var(--bg-active);
    box-shadow: 0 0 0 1px var(--border-accent);
}

.project-rename-btn {
    position: absolute;
    right: 6px;
    opacity: 0.5;
    /* Brighter initial state */
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-name-wrapper:hover .project-rename-btn {
    opacity: 1;
    color: var(--accent);
}

.project-rename-btn svg {
    stroke-width: 2.5;
    /* Bolder icon */
}

.project-rename-btn:hover {
    transform: scale(1.1);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.nav-btn.saved-flash {
    color: var(--success) !important;
}

.nav-btn svg {
    flex-shrink: 0;
}

.nav-btn-label {
    white-space: nowrap;
}

.publish-btn {
    padding: 6px 16px;
    font-weight: 600;
    font-size: 12px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: all var(--transition-fast);
}

.publish-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-glow);
}

.btn--republish {
    background: linear-gradient(135deg, #059669, #10b981);
    /* Emerald gradient for updates */
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn--republish:hover {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.copy-url-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-full);
}

.copy-url-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-accent);
}

.btn--loading {
    opacity: 0.8;
    cursor: wait;
    pointer-events: none;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Publish Success Modal --- */
.publish-success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease;
}

.publish-success-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent-glow);
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    border: 2px solid rgba(34, 197, 94, 0.2);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

.publish-success-card h3 {
    font-size: 24px;
    color: white;
    margin-bottom: 12px;
}

.publish-success-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.publish-url-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    padding: 4px;
    margin-bottom: 32px;
}

.publish-url-box input {
    flex: 1;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    background: transparent;
}

.publish-url-box button {
    padding: 8px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.publish-url-box button:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.publish-success-actions {
    display: flex;
    gap: 12px;
}

.btn-visit-site {
    flex: 1;
    background: var(--accent-gradient);
    color: white;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-visit-site:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-close-success {
    flex: 1;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-close-success:hover {
    background: var(--bg-active);
}

/* --- Version Manager Modal --- */
.version-manager-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.version-manager-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl), 0 0 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

.version-manager-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.version-manager-header .header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.version-manager-header .close-btn {
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.version-manager-header .close-btn:hover {
    color: var(--text-primary);
}

.version-manager-actions {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.version-manager-actions input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.2s;
}

.version-manager-actions input:focus {
    border-color: var(--accent);
    outline: none;
}

.version-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.version-item {
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.version-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
    transform: translateX(4px);
}

.version-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.version-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.version-date {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-restore {
    padding: 6px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-restore:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.version-loading,
.version-empty,
.version-error {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #27272a, #3f3f46);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color var(--transition-base);
    margin-left: 8px;
}

.user-avatar:hover {
    border-color: var(--border-hover);
}

.user-avatar svg {
    color: var(--text-secondary);
}

/* User Profile Actions & Login Button */
.user-profile-actions {
    display: flex;
    align-items: center;
    margin-left: 6px;
}

.auth-login-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-login-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* --- Auth Prompt Modal --- */
.auth-prompt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.auth-prompt-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.auth-prompt-logo {
    width: 64px;
    display: block;
    margin: 0 auto 20px auto;
}

.auth-prompt-card h3 {
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.auth-prompt-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.auth-prompt-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px;
    font-size: 12px;
    cursor: pointer;
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--accent-glow);
}

.auth-btn-secondary:hover {
    background: var(--bg-active);
}

.auth-btn-ghost:hover {
    color: var(--text-secondary);
}


/* --- File Explorer --- */

#sidebar-container {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.file-explorer {
    width: var(--sidebar-width);
    background: rgba(13, 13, 14, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width var(--transition-smooth);
    overflow: hidden;
}

.file-explorer.collapsed {
    width: var(--sidebar-collapsed);
}

.explorer-header {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.explorer-search-wrap {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
}

.explorer-search {
    width: 100%;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px 7px 32px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.explorer-search:focus {
    border-color: var(--border-hover);
    background: var(--bg-active);
}

.explorer-search::placeholder {
    color: var(--text-faint);
}

.explorer-toggle {
    padding: 6px;
    color: var(--text-faint);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.explorer-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.explorer-body {
    flex: 1;
    overflow-y: scroll !important;
    /* Force visibility of the scrollbar track */
    overflow-x: hidden;
    padding: 4px 0 60px;
    /* 60px bottom padding for extra breathing room */
    min-height: 0;
    position: relative;
    z-index: 5;
    scrollbar-gutter: stable;
    /* Prevent layout shifts when items load */
}

#file-tree {
    display: block;
    width: 100%;
}

.explorer-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px 8px;
}

.explorer-label span {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-faint);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.add-file-icon {
    color: var(--text-faint);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.add-file-icon:hover {
    color: var(--text-primary);
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}

.file-item:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.file-item--root {
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
    background: rgba(91, 19, 236, 0.05);
}

.file-item--root:hover {
    background: rgba(91, 19, 236, 0.08);
}

.file-item--active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.file-item--selected {
    background: rgba(91, 19, 236, 0.08);
}

.file-item--dragging {
    opacity: 0.4;
    background: var(--bg-hover);
}

.file-item--drag-over {
    background: rgba(91, 19, 236, 0.15) !important;
    box-shadow: inset 0 0 0 1px var(--accent);
    color: var(--text-primary) !important;
}

.file-item svg {
    flex-shrink: 0;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-action-btns {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-base), transform var(--transition-base);
    margin-left: auto;
    padding-right: 4px;
    transform: translateX(4px);
}

.file-item:hover .folder-action-btns,
.file-item-wrap:hover>.file-item .folder-action-btns {
    opacity: 1;
    transform: translateX(0);
}

.folder-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.folder-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.chevron-icon {
    margin-right: 6px;
    color: var(--text-secondary);
    /* Brighter gray */
    transition: transform var(--transition-fast);
    flex-shrink: 0;
    opacity: 0.9;
    /* More visible */
}

.chevron--collapsed {
    transform: rotate(-90deg);
}

/* Action Portal (Create vs Upload Menu) */
.action-portal {
    position: absolute;
    z-index: 10000;
    /* Higher than tabs and editor */
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
    backdrop-filter: blur(10px);
    animation: portal-fade-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes portal-fade-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.action-portal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-portal-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-portal-item svg {
    color: var(--text-faint);
    transition: color var(--transition-fast);
}

.action-portal-item:hover svg {
    color: var(--accent);
}

.folder-btn--active {
    color: var(--accent) !important;
    background: var(--bg-hover) !important;
}

.folder-children {
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    max-height: 10000px;
    /* Increased from 1000px to accommodate large projects */
    opacity: 1;
}

.folder-children--collapsed {
    max-height: 0;
    opacity: 0;
}

.chevron-spacer {
    width: 14px;
    flex-shrink: 0;
}

.file-tree {
    position: relative;
}

/* Smooth sliding active indicator bar */
.file-tree-indicator {
    position: absolute;
    right: 0;
    width: 3px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius-full) 0 0 var(--radius-full);
    box-shadow: 0 0 12px var(--accent-glow), -2px 0 8px var(--accent-glow);
    transition: top 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
    z-index: 2;
    pointer-events: none;
}

/* Standardized Devicon / File Symbol */
.file-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    line-height: 1;
    text-align: center;
}

.file-symbol--font {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 9px !important;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    color: #f472b6;
}

.file-symbol--font {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.12);
    font-size: 9px;
    font-style: italic;
}


/* --- Navbar --- */
.navbar {
    height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.navbar-left,
.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
}

/* --- Tab Bar --- */
.tab-bar {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: var(--tab-height);
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
    padding: 0 4px;
    /* Subtle gutter */
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    /* Balanced padding */
    font-size: 12px;
    font-weight: 500;
    color: var(--text-faint);
    border-right: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    flex-shrink: 0;
    height: 100%;
}

.tab:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.tab--active {
    background: var(--bg-primary);
    color: var(--text-primary);
    transform: scale(1.02);
    z-index: 5;
}

.tab-name {
    line-height: 1;
    margin-right: 4px;
}

.tab-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0;
}

.tab:hover .tab-close-btn,
.tab--active .tab-close-btn {
    opacity: 1;
    color: var(--text-primary);
}

.tab-close-btn:hover {
    background: var(--bg-hover);
    color: var(--error) !important;
}

.tab {
    padding-right: 32px;
}

.tab-unsaved-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: all var(--transition-base);
    pointer-events: none;
    box-shadow: 0 0 8px var(--accent-glow);
}

.tab--dirty .tab-unsaved-dot {
    opacity: 1;
}

/* Hide dot when hovering or active to make room for the close button */
.tab:hover .tab-unsaved-dot,
.tab--active .tab-unsaved-dot {
    opacity: 0 !important;
    transform: translateY(-50%) scale(0.5);
}

@keyframes tab-exit {
    0% {
        opacity: 1;
        transform: scale(1);
        width: var(--tab-width-current, auto);
    }

    100% {
        opacity: 0;
        transform: scale(0.9);
        width: 0;
        padding: 0;
        margin: 0;
        border: none;
    }
}

.tab--exit {
    animation: tab-exit 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

.tab-underline {
    position: absolute;
    bottom: 0;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 2px 2px 0 0;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
    pointer-events: none;
    z-index: 10;
}

/* --- New File Input --- */

.new-file-input {
    width: 100%;
    background: var(--bg-active);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}

.new-file-input::placeholder {
    color: var(--text-faint);
}

.rename-input {
    flex: 1;
    background: var(--bg-active);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    margin: -2px 0;
    width: 0;
    /* Let flex handle it */
    min-width: 50px;
}

.new-file-input:focus {
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.new-file-prompt .file-item {
    padding-top: 2px;
    padding-bottom: 2px;
}


/* --- Editor (CodeMirror Overrides) --- */

.editor-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(to bottom right, rgba(91, 19, 236, 0.03), rgba(168, 85, 247, 0.02));
}

.editor-instance {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Fynal CodeMirror Theme */
.cm-s-fynal.CodeMirror {
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.65;
    height: 100%;
    padding: 8px 0;
}

.cm-s-fynal .CodeMirror-gutters {
    background: rgba(13, 13, 14, 0.4);
    border-right: 1px solid var(--border);
    padding-right: 4px;
}

.cm-s-fynal .CodeMirror-linenumber {
    color: var(--text-disabled);
    font-size: 12px;
    padding: 0 8px 0 12px;
}

.cm-s-fynal .CodeMirror-cursor {
    border-left: 2px solid var(--accent);
}

.cm-s-fynal .CodeMirror-activeline-background {
    background: rgba(91, 19, 236, 0.05);
}

.cm-s-fynal .CodeMirror-selected {
    background: rgba(91, 19, 236, 0.15) !important;
}

.cm-s-fynal .CodeMirror-focused .CodeMirror-selected {
    background: rgba(91, 19, 236, 0.2) !important;
}

.cm-s-fynal .CodeMirror-matchingbracket {
    color: var(--accent) !important;
    font-weight: 600;
    text-decoration: underline;
}

.cm-s-fynal .CodeMirror-nonmatchingbracket {
    color: var(--error) !important;
}

/* Syntax colors */
.cm-s-fynal .cm-keyword {
    color: #c084fc;
}

.cm-s-fynal .cm-atom {
    color: #c084fc;
}

.cm-s-fynal .cm-number {
    color: #f59e0b;
}

.cm-s-fynal .cm-def {
    color: #60a5fa;
}

.cm-s-fynal .cm-variable {
    color: #e4e4e7;
}

.cm-s-fynal .cm-variable-2 {
    color: #67e8f9;
}

.cm-s-fynal .cm-variable-3,
.cm-s-fynal .cm-type {
    color: #f472b6;
}

.cm-s-fynal .cm-property {
    color: #93c5fd;
}

.cm-s-fynal .cm-operator {
    color: #94a3b8;
}

.cm-s-fynal .cm-comment {
    color: #52525b;
    font-style: italic;
}

.cm-s-fynal .cm-string {
    color: #86efac;
}

.cm-s-fynal .cm-string-2 {
    color: #86efac;
}

.cm-s-fynal .cm-meta {
    color: #fbbf24;
}

.cm-s-fynal .cm-qualifier {
    color: #67e8f9;
}

.cm-s-fynal .cm-builtin {
    color: #67e8f9;
}

.cm-s-fynal .cm-bracket {
    color: #71717a;
}

.cm-s-fynal .cm-tag {
    color: #f97316;
}

.cm-s-fynal .cm-attribute {
    color: #93c5fd;
}

.cm-s-fynal .cm-hr {
    color: #3f3f46;
}

.cm-s-fynal .cm-link {
    color: #60a5fa;
}

.cm-s-fynal .cm-error {
    color: #ef4444;
}

/* Scrollbar overlay for CodeMirror */
.cm-s-fynal .CodeMirror-simplescroll-horizontal div,
.cm-s-fynal .CodeMirror-simplescroll-vertical div {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

.cm-s-fynal .CodeMirror-simplescroll-horizontal,
.cm-s-fynal .CodeMirror-simplescroll-vertical {
    background: transparent;
}


/* --- Preview Panel --- */

.preview-toolbar {
    height: var(--preview-toolbar-height);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.device-toggles {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-hover);
    padding: 3px;
    border-radius: var(--radius-md);
}

.device-btn {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-btn:hover {
    color: var(--text-secondary);
}

.device-btn--active {
    background: var(--bg-active);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.refresh-btn {
    padding: 8px;
    color: var(--text-faint);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.refresh-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.refresh-btn.spinning svg {
    animation: spin 0.8s ease-in-out;
    color: var(--accent);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Preview Content */
.preview-content {
    flex: 1;
    padding: 20px;
    display: flex;
    justify-content: center;
    overflow: hidden;
    background: #070708;
}

.preview-frame-wrap {
    height: 100%;
    width: 100%;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-smooth), max-width var(--transition-smooth);
}

.preview-frame-wrap.device-desktop {
    max-width: 100%;
}

.preview-frame-wrap.device-tablet {
    max-width: 768px;
}

.preview-frame-wrap.device-mobile {
    max-width: 375px;
}

/* Browser Chrome */
.browser-chrome {
    height: 32px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 6px;
    flex-shrink: 0;
}

.traffic-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.traffic-dot.red {
    background: #f87171;
}

.traffic-dot.yellow {
    background: #fbbf24;
}

.traffic-dot.green {
    background: #4ade80;
}

.browser-url-bar {
    flex: 1;
    margin-left: 12px;
    background: white;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 10px;
    color: #94a3b8;
    overflow: hidden;
}

.browser-url-bar span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Iframe container */
.iframe-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.refresh-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    z-index: 10;
}

.refresh-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.refresh-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(91, 19, 236, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* --- Fullscreen Preview Mode --- */

.preview-panel--fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    z-index: 2000;
    border-left: none !important;
    background: var(--bg-primary) !important;
    display: flex !important;
    flex-direction: column !important;
}

.preview-panel--fullscreen .preview-toolbar {
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.preview-fullscreen-title {
    display: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    white-space: nowrap;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px 14px;
    letter-spacing: 0.3px;
}

.preview-panel--fullscreen .preview-fullscreen-title {
    display: block;
}

.preview-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.preview-panel--fullscreen .device-toggles {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.preview-panel--fullscreen .browser-chrome {
    display: none;
}

.preview-panel--fullscreen .preview-content {
    background: var(--bg-primary);
    padding: 0;
    flex: 1;
    min-height: 0;
}

.preview-panel--fullscreen .preview-frame-wrap {
    border-radius: 0;
    box-shadow: none;
    height: 100%;
    max-width: 100%;
}

.preview-panel--fullscreen .preview-frame-wrap.device-tablet {
    max-width: 768px;
    margin: 0 auto;
}

.preview-panel--fullscreen .preview-frame-wrap.device-mobile {
    max-width: 375px;
    margin: 0 auto;
}

/* Hide normal view mode toggle in fullscreen? Or just ignore */
/* The navbar is hidden by the fixed overlay anyway */






.agent-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 24px 16px;
}

.agent-placeholder-icon {
    width: 56px;
    height: 56px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.agent-placeholder-label {
    font-size: 13px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
}

.agent-placeholder-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

/* --- Status Bar --- */


.status-bar {
    height: var(--statusbar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-faint);
}

.status-left,
.status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.status-autosave {
    color: var(--success);
}

.status-autosave.saved-flash {
    animation: flashGreen 1.5s ease;
}

@keyframes flashGreen {

    0%,
    100% {
        color: var(--success);
    }

    30% {
        color: #4ade80;
        text-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    }
}


/* --- Scrollbar --- */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    transition: background var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.16);
}

::-webkit-scrollbar-corner {
    background: transparent;
}


/* --- Utility Animations --- */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.4s ease;
}


/* --- Custom Tooltips --- */

.fynal-tooltip {
    position: fixed;
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 999999;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
}

.fynal-tooltip--visible {
    opacity: 1;
    transform: translateY(0);
}


/* --- Context Menu --- */

.fynal-context-menu {
    position: fixed;
    z-index: 99999;
    /* Higher than action portal */
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    display: none;
    min-width: 160px;
    backdrop-filter: blur(12px);
    padding: 6px 0;
    animation: context-menu-in 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes context-menu-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Fynal Loading Splash --- */
.fynal-loading-splash {
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: splashFadeIn 0.4s ease;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.splash-logo {
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.splash-logo.floating {
    animation: splashFloat 3s ease-in-out infinite;
}

.splash-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.splash-loader {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: splashSpin 0.8s linear infinite;
    box-shadow: 0 0 10px var(--accent-glow);
}

@keyframes splashFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes splashSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes splashFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

/* --- Share Modal (Phase 22) --- */
.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-base);
}

.share-modal-card {
    width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp var(--transition-base);
}

.share-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.share-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.close-modal:hover {
    color: var(--text-primary);
}

.share-modal-body {
    padding: 24px 20px;
}

.share-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    background: var(--bg-hover);
    padding: 16px;
    border-radius: var(--radius-md);
}

.share-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.share-toggle-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.share-toggle-desc {
    font-size: 12px;
    color: var(--text-faint);
}

/* Fynal Switch Component */
.fynal-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.fynal-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
    margin: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-active);
    transition: .4s;
    border: 1px solid var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent);
    border-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: white;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Share Link Box */
.share-link-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeIn var(--transition-base);
}

.share-hint {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 4px;
    font-style: italic;
}

.input--disabled {
    opacity: 0.6;
    color: var(--text-disabled) !important;
}

/* Read Only Strict Lockdown */
.is-read-only {
    user-select: none !important;
    -webkit-user-select: none !important;
}

.live-status-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    transition: all 0.2s;
}

.live-status-badge:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    color: #34d399;
}

.is-read-only .nav-btn#btn-save,
.is-read-only .nav-btn#btn-publish,
.is-read-only .nav-btn#btn-reset,
.is-read-only .nav-btn#btn-export,
.is-read-only .nav-btn#btn-settings,
.is-read-only .auth-login-btn,
.is-read-only .project-rename-btn,
.is-read-only .add-file-icon,
.is-read-only .folder-btn,
.is-read-only .project-name-input {
    display: none !important;
}

.is-read-only .CodeMirror {
    pointer-events: none !important;
}

.read-only-badge {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(234, 179, 8, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 12px;
}

.share-link-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.share-url-box {
    display: flex;
    gap: 8px;
}

.share-url-box input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}

.share-url-box button {
    width: 42px;
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.share-url-box button:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.share-url-box button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Share Warning Modal */
.share-warning-overlay {
    position: fixed;
    inset: 0;
    z-index: 6000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.share-warning-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.warning-icon {
    margin-bottom: 20px;
}

.share-warning-card h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.share-warning-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.warning-sub {
    background: rgba(91, 19, 236, 0.1);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 12px !important;
    color: var(--accent) !important;
}

.warning-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.warning-actions button {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cancel-warning {
    background: var(--bg-active);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-cancel-warning:hover {
    background: var(--bg-hover);
}

.btn-continue-warning:hover {
    background: var(--accent-hover);
}

/* Publish Warning Modal */
.publish-warning-overlay {
    position: fixed;
    inset: 0;
    z-index: 6100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.publish-warning-card {
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), 0 0 20px rgba(234, 179, 8, 0.1);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.publish-warning-card h3 {
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 700;
}

.publish-warning-card p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.publish-warning-card strong {
    color: var(--accent);
}

.publish-warning-detail {
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
    margin-bottom: 24px;
}

.publish-warning-detail ul {
    margin: 8px 0 0 20px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 0;
}

.publish-warning-detail li {
    margin-bottom: 6px;
}

.publish-warning-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-proceed-anyway {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-proceed-anyway:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

.btn-fix-now {
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(91, 19, 236, 0.3);
}

.btn-fix-now:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(91, 19, 236, 0.4);
}

.btn-cancel-publish {
    background: transparent;
    border: none;
    color: var(--text-faint);
    padding: 8px;
    font-size: 13px;
    cursor: pointer;
}

.btn-cancel-publish:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}


/* --- Landing Screen Overlay --- */
.landing-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(9, 9, 11, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border for the whole screen */
}

.landing--visible {
    opacity: 1;
}

.landing--exit {
    opacity: 0;
    pointer-events: none;
}

.landing-modal {
    width: 100%;
    max-width: 680px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(91, 19, 236, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.98);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.landing--visible .landing-modal {
    transform: translateY(0) scale(1);
}

/* Landing Header */
.landing-header {
    padding: 40px 40px 30px;
    display: flex;
    align-items: center;
    gap: 24px;
    background: linear-gradient(to bottom, rgba(91, 19, 236, 0.05), transparent);
}

.landing-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px var(--accent-glow));
}

.landing-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.landing-title p {
    font-size: 14px;
    color: var(--text-muted);
}

/* Action Cards */
.landing-cards {
    padding: 0 40px 40px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.landing-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    text-align: left;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.landing-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent);
}

.landing-card--primary {
    background: rgba(91, 19, 236, 0.03);
    border-color: var(--accent-subtle);
}

.landing-card-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 20px;
    transition: all var(--transition-fast);
}

.landing-card:hover .landing-card-icon {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

.landing-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.landing-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.landing-card-desc {
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
}

.landing-card-arrow {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 18px;
    color: var(--text-faint);
    transition: all var(--transition-fast);
    opacity: 0;
    transform: translateX(-10px);
}

.landing-card:hover .landing-card-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent);
}

/* Landing Footer */
.landing-footer {
    padding: 20px 40px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
    background: var(--bg-active);
}

.landing-footer strong {
    color: var(--text-secondary);
}

.landing-footer-link {
    font-weight: 600;
    color: var(--accent);
    transition: color var(--transition-fast);
}

.landing-footer-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Responsive Landing Screen */
@media (max-width: 768px) {
    .landing-modal {
        max-width: 440px;
    }

    .landing-cards {
        grid-template-columns: 1fr;
    }

    .landing-header {
        flex-direction: column;
        text-align: center;
        padding-top: 30px;
    }
}


/* --- Loading Splash Screen --- */
.fynal-loading-splash {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.splash-logo {
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

.splash-logo.floating {
    animation: splash-float 3s ease-in-out infinite;
}

@keyframes splash-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.splash-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.splash-loader {
    width: 48px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    position: relative;
    overflow: hidden;
}

.splash-loader::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    animation: loader-slide 1.5s infinite ease-in-out;
}

@keyframes loader-slide {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.context-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.context-menu-item--danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px;
}

.context-menu-item svg {
    opacity: 0.6;
}

.context-menu-item:hover svg {
    opacity: 1;
}



/* --- Settings Modal --- */
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.settings-modal-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.settings-modal {
    width: 480px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(91, 19, 236, 0.1);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.settings-modal-overlay.is-visible .settings-modal {
    transform: scale(1);
}

.settings-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-active);
}

.settings-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-title svg {
    color: var(--accent);
}

.settings-close {
    font-size: 24px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    line-height: 1;
    cursor: pointer;
}

.settings-close:hover {
    color: var(--error);
}

.settings-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.setting-item label {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-item input[type="number"] {
    width: 65px;
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    text-align: center;
    color: var(--text-primary);
}

.setting-item input[type="range"] {
    flex: 1;
    margin: 0 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

.value-display {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
    min-width: 45px;
}

/* --- Styled Toggle Switch --- */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-active);
    transition: .3s;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.toggle-switch label:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked+label {
    background-color: var(--accent-subtle);
    border-color: var(--accent);
}

.toggle-switch input:checked+label:before {
    transform: translateX(16px);
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.settings-footer {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
}

/* --- Responsive (large desktop primary) --- */

@media (max-width: 1200px) {
    .nav-btn-label {
        display: none;
    }

    .brand-text {
        display: none;
    }

    #preview-panel {
        width: 35%;
        min-width: 280px;
    }
}


/* --- Shortcuts Modal --- */
.shortcuts-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.shortcuts-modal-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.shortcuts-modal {
    width: 440px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 20px rgba(91, 19, 236, 0.1);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.shortcuts-modal-overlay.is-visible .shortcuts-modal {
    transform: scale(1);
}

.shortcuts-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-active);
}

.shortcuts-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.shortcuts-title svg {
    color: var(--accent);
}

.shortcuts-close {
    font-size: 24px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    line-height: 1;
    cursor: pointer;
}

.shortcuts-close:hover {
    color: var(--error);
}

.shortcuts-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.shortcut-group {
    margin-bottom: 24px;
}

.shortcut-group h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    margin-bottom: 12px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.shortcut-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.shortcut-keys {
    display: flex;
    gap: 4px;
    align-items: center;
}

kbd {
    display: inline-block;
    padding: 3px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1;
    color: var(--text-primary);
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 0 var(--border);
    min-width: 24px;
    text-align: center;
}

.shortcuts-footer {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-faint);
    text-align: center;
}

@media (max-width: 900px) {
    .file-explorer {
        width: var(--sidebar-collapsed);
    }

    .explorer-body,
    .explorer-search-wrap {
        display: none;
    }

    #preview-panel {
        width: 30%;
        min-width: 250px;
    }
}

/* Binary Editor Placeholder */
.binary-editor-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-faint);
    background: var(--bg-primary);
    text-align: center;
    padding: 40px;
}

.binary-editor-placeholder .placeholder-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.binary-editor-placeholder h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.binary-editor-placeholder p {
    margin: 0;
    max-width: 300px;
    line-height: 1.5;
    font-size: 13px;
}

/* --- Empty Editor State --- */
.empty-editor-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 5;
    animation: fade-in 0.4s ease-out;
}

.empty-state-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px;
    max-width: 400px;
}

.empty-state-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 20px var(--accent-glow));
    animation: logo-float 4s ease-in-out infinite;
}

@keyframes logo-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.empty-state-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.empty-state-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-faint);
    padding: 8px 16px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.empty-state-hint .key {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-hover);
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 11px;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ðŸŸ¢ NAVBAR ACCOUNT MENU & CLOUD STORAGE */
.user-avatar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.user-avatar {
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.user-avatar--active {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    background: var(--bg-hover);
}

.status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border: 1.5px solid var(--bg-primary);
    border-radius: 50%;
}

.navbar-account-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 280px;
    background: rgba(13, 13, 14, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 1000;
    overflow: hidden;
    animation: menu-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menu-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.navbar-account-menu.hidden {
    display: none;
}

.menu-user-header {
    padding: 20px;
    background: linear-gradient(135deg, rgba(91, 19, 236, 0.1), transparent);
    border-bottom: 1px solid var(--border);
}

.tier-identity {
    margin-bottom: 8px;
}

.tier-badge {
    background: var(--accent-subtle);
    color: var(--accent);
    font-size: 9px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border-accent);
}

.menu-user-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.menu-user-email {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-storage-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.storage-metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
}

.storage-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.storage-percent {
    font-size: 12px;
    font-weight: 800;
    color: var(--accent);
}

.progressive-storage-bar-bg {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}

.progressive-storage-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.storage-detail-text {
    font-size: 10px;
    color: var(--text-muted);
    margin: 0;
    text-align: right;
    font-weight: 500;
}

.menu-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
}

.menu-action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
    gap: 8px;
}

.menu-action-card:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.menu-action-card svg {
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.menu-action-card:hover svg {
    color: var(--accent);
}

.menu-action-card span {
    font-size: 11px;
    font-weight: 600;
}

.menu-footer {
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
}

.btn-signout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--error);
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-signout:hover {
    opacity: 1;
}

/* ===== REMOVED CORRUPTED VISUAL EDITOR RULES ===== */
/* The correct rules are at the top of this file (lines 305-326) */

/* View selector highlight â€” 4th position for Visual */
.view-selector-highlight.pos-visual {
    transform: translateX(168px);
    /* 2 * (80px + 4px) */
}

/* Streaming cursor blink */
.agent-cursor {
    display: inline-block;
    color: var(--accent);
    animation: agent-blink 0.8s step-end infinite;
    margin-left: 1px;
}

@keyframes agent-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* --- ADVANCED ANTIGRAVITY FEATURES --- */

/* Cortex Status Bar */
#cortex-bar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
    display: none; /* Hidden by default */
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--accent);
    animation: cortex-slide-in 0.3s ease;
}

#cortex-bar.active { display: flex; }

.cortex-pulse {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-glow);
    animation: cortex-pulse 1.5s ease-in-out infinite;
}

.cortex-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.8;
}

@keyframes cortex-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes cortex-slide-in {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* UI Preview Card */
.agent-preview {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.preview-header {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-body {
    min-height: 200px;
    background: white; /* Default light background for previews unless specified */
    position: relative;
}

.preview-iframe {
    width: 100%;
    height: 300px;
    border: none;
    display: block;
}

/* DB Visualizer (Mermaid) */
.agent-diagram {
    margin: 12px 0;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

.mermaid {
    background: transparent !important;
}

/* Intent-Based Drafting Table */
.agent-draft {
    margin: 16px 0;
    padding: 16px;
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-tertiary));
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    animation: agent-msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.draft-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.draft-title::before {
    content: "DRAFT";
    font-size: 9px;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.draft-section {
    margin-bottom: 12px;
}

.draft-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.draft-content {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.draft-reviewers {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.reviewer-tag {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-faint);
}

