:root {
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --success: #22c55e;
    --warning: #f59e0b;
    --bg-dark: #0a0a0f;
    --bg-editor: #0d0d14;
    --bg-card: rgba(20, 20, 30, 0.8);
    --border: rgba(139, 92, 246, 0.15);
    --text: #e4e4e7;
    --text-muted: #71717a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    height: 56px;
    background: rgba(10, 10, 15, 0.95);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    backdrop-filter: blur(20px);
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.live-badge {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 5px var(--accent-glow);
    }

    to {
        box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(139, 92, 246, 0.2);
    }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-dot.compiling {
    background: var(--accent);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.compile-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.export-btn {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

/* Main Layout */
.main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* File Tree Sidebar (New v1.3) */
.file-tree {
    width: 200px;
    background: #08080c;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.file-tree-header {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    justify-content: space-between;
}

.add-file-btn {
    cursor: pointer;
    color: var(--accent);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.file-item {
    padding: 8px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.file-item:hover {
    background: rgba(139, 92, 246, 0.05);
    color: var(--text);
}

.file-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent);
    border-right: 2px solid var(--accent);
}

/* Editor Panel */
.editor-panel {
    flex: 1;
    background: var(--bg-editor);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-header {
    height: 40px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 8px;
}

.file-icon {
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 3px;
}

.file-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

#editor {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    padding: 20px;
    resize: none;
    outline: none;
    overflow-y: auto;
}

/* Preview Panel */
.preview-panel {
    width: 50%;
    background: #1a1a24;
    display: flex;
    flex-direction: column;
    position: relative;
    border-left: 1px solid var(--border);
}

.preview-header {
    height: 40px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
}

.pdf-container {
    flex: 1;
    position: relative;
    background-color: #0f0f18;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.pdf-wrapper {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
}

.pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.25s ease;
}

.pdf-frame.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ERROR TOAST */
.error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(239, 68, 68, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    max-width: 500px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.error-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Floating Mobile UI */
.mobile-view-toggle {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 20px var(--accent-glow);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
    .file-tree {
        width: 150px;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .header-right .status-text {
        display: none;
    }

    .main {
        flex-direction: column;
    }

    .file-tree {
        position: absolute;
        bottom: 80px;
        left: 24px;
        width: 180px;
        height: 300px;
        border-radius: 12px;
        border: 1px solid var(--border);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        z-index: 500;
        display: none;
        /* Toggle with JS */
    }

    .file-tree.visible {
        display: flex;
    }

    .editor-panel,
    .preview-panel {
        width: 100% !important;
        height: 100%;
        position: absolute;
        inset: 0;
    }

    .editor-panel.hidden,
    .preview-panel.hidden {
        display: none;
    }

    .mobile-view-toggle {
        display: flex;
    }

    .pdf-container {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .brand-name {
        font-size: 14px;
    }

    .compile-time {
        display: none;
    }
}