/* OPEN MUSIC LABS // MASTER VISUAL CORE
   Architecture: CSS Grid + Hardware Accelerated Compositing
   Status: PRODUCTION READY // UNIFIED
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Oswald:wght@500;700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    /* --- COLOR PALETTE --- */
    --bg-void: #020202;
    --bg-panel: rgba(9, 9, 11, 0.98);
    --bg-surface: #121214;
    
    --border: #27272a;
    --border-light: #3f3f46;
    
    --accent: #f59e0b;
    --accent-dim: rgba(245, 158, 11, 0.15);
    
    --text-main: #e4e4e7;
    --text-muted: #a1a1aa;
    
    --danger: #ef4444;
    --success: #10b981;
    
    /* --- TYPOGRAPHY --- */
    --font-ui: 'Inter', sans-serif; 
    --font-data: 'Space Mono', monospace;
    --font-head: 'Oswald', sans-serif;
}

/* RESET & BASE */
*, *::before, *::after { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

/* GLOBAL SCROLLBAR THEME */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-corner { background: transparent; }

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    background-color: var(--bg-void);
    color: var(--text-main);
    font-family: var(--font-ui);
    overflow: hidden; 
    font-size: 12px;
    letter-spacing: -0.01em;
}

/* --- VISUALS --- */
.noise-overlay {
    position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* --- VIEWPORT SYSTEM (HARDWARE ACCELERATED) --- */
#os-root {
    position: relative;
    width: 100vw; height: 100vh;
    overflow: hidden;
}

.view-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-void);
    z-index: 10;
    
    /* GPU Composition Hints */
    transform: translate3d(0, 0, 0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
}

/* ACTIVE STATE: Fully Visible & Interactive */
.view-layer.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 20;
    content-visibility: visible;
}

/* SUSPENDED STATE: Hidden & Optimized */
/* 'content-visibility: hidden' stops rendering calculations (Massive CPU Saver) */
.view-layer.suspended {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    transform: scale(0.98); /* Subtle depth effect */
    content-visibility: hidden; 
}

/* --- PART 1: SENTINEL (LOGIN) --- */
.sentinel-wrapper {
    display: flex; align-items: center; justify-content: center;
    height: 100%; width: 100%;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
}

.sentinel-card {
    width: 380px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 50px 100px rgba(0,0,0,0.8);
    display: flex; flex-direction: column; gap: 24px;
    backdrop-filter: blur(10px);
}

.brand-large {
    font-family: var(--font-head);
    font-size: 32px; font-weight: 700; letter-spacing: 0.1em;
    color: var(--text-muted); text-align: center;
    margin-bottom: 10px;
}
.brand-large span { color: var(--text-main); }

.login-grid { display: flex; flex-direction: column; gap: 16px; }

.input-group label {
    display: block; font-family: var(--font-data);
    font-size: 10px; color: var(--text-muted); margin-bottom: 6px;
    letter-spacing: 0.05em;
}

.status-line {
    font-family: var(--font-data); font-size: 9px;
    color: var(--text-muted); text-align: center;
    opacity: 0.6;
    margin-top: 10px;
    height: 12px;
}

/* --- PART 2: SOCIAL HUB --- */
.hub-nav {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    background: var(--bg-surface);
}

.hub-actions { display: flex; gap: 12px; }

.hub-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100% - 60px);
}

.hub-sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
}

.hub-feed {
    padding: 40px;
    overflow-y: auto;
    background: radial-gradient(circle at top, #111 0%, #020202 60%);
}

#network-list {
    list-style: none; padding: 0; margin: 0;
}
.network-item {
    padding: 10px; margin-bottom: 4px;
    border-radius: 4px; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    transition: background 0.2s;
}
.network-item:hover { background: rgba(255,255,255,0.05); }
.net-avatar {
    width: 32px; height: 32px; background: #333; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-head); font-weight: 700; color: #666;
    font-size: 10px;
}
.net-info { display: flex; flex-direction: column; }
.net-name { font-weight: 700; color: var(--text-main); font-size: 11px; }
.net-status { font-size: 9px; color: var(--text-muted); font-family: var(--font-data); }

/* --- PART 3: STUDIO (LEGACY EDITOR CONTAINER) --- */
/* We preserve existing class names exactly so 
   Editor.js and Stage.js continue to work without modification.
*/
.app-layout {
    position: relative; z-index: 10;
    display: grid;
    grid-template-columns: 1fr 340px; 
    height: 100%; /* Changed from 100vh to 100% to fit container */
    width: 100%;
    overflow: hidden;
}

/* --- REGION: STAGE (LEFT) --- */
#stage-region {
    position: relative;
    background: var(--bg-void);
    background-image: radial-gradient(circle at center, #111 0%, #020202 80%);
    
    /* Subtle Grid Pattern */
    background-size: 40px 40px;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.02) 1px, transparent 1px);
    
    display: block; 
    height: 100%;      
    overflow-y: auto; 
    overflow-x: hidden;
    padding: 40px 0; 
}

#stage-wrapper {
    margin: 0 auto;
    display: block;
    box-shadow: 0 0 150px rgba(0,0,0,0.8);
    border: 1px solid #1a1a1a;
    background: #000;
    transition: width 0.3s ease, height 0.3s ease;
    transform: translateZ(0); 
}

canvas { display: block; }

/* --- REGION: COMMAND CENTER (RIGHT) --- */
#command-center {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
    z-index: 50; 
    backdrop-filter: blur(20px);
    height: 100%;
}

.brand-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
}

.brand-logo {
    font-family: var(--font-head);
    font-weight: 700; font-size: 14px;
    color: #000; background: var(--accent);
    padding: 2px 6px; border-radius: 2px;
}

.brand-text {
    font-family: var(--font-head);
    font-weight: 700; font-size: 16px; letter-spacing: 0.1em;
    color: var(--text-muted); text-transform: uppercase;
}
.brand-text span { color: var(--text-main); }

.sidebar-content {
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden;
    display: flex; flex-direction: column;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
    display: flex; gap: 10px;
}

/* --- COMPONENTS --- */
.panel-section {
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding-bottom: 8px;
}

.section-title {
    padding: 16px 24px 12px;
    font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
    color: var(--text-muted); text-transform: uppercase;
    display: flex; justify-content: space-between; align-items: center;
}

.tool-grid {
    display: flex; 
    flex-wrap: wrap; 
    gap: 1px;        
    background: var(--border);
    margin: 0 24px 16px;
    border: 1px solid var(--border);
    border-radius: 4px; 
    overflow: hidden;
}

.tool-btn {
    background: var(--bg-surface); border: none;
    color: var(--text-muted); padding: 14px 4px;
    font-family: var(--font-data); font-size: 9px; font-weight: 700;
    cursor: pointer; transition: all 0.2s; letter-spacing: 0.05em;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    flex: 1 0 60px; 
    height: 60px; justify-content: center;
}
.tool-btn i { width: 16px; height: 16px; stroke-width: 2px; }
.tool-btn:hover { background: #27272a; color: var(--text-main); }
.tool-btn:active { background: #000; color: var(--accent); }

#asset-list { min-height: 100px; list-style: none; padding: 0; margin: 0; }
.asset-item {
    padding: 12px 24px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.1s;
    border-left: 2px solid transparent; display: block;
    font-size: 11px; color: var(--text-muted);
}
.asset-item:hover { background: rgba(255,255,255,0.03); color: var(--text-main); }
.asset-item.active { border-left-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

#prop-panel { padding: 0 0 16px; }
.prop-row { display: flex; gap: 12px; margin-bottom: 12px; padding: 0 24px; }
.prop-col { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.prop-label { font-size: 9px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-family: var(--font-data); }

.input-dark, select.input-dark, textarea.input-dark {
    background: #000; border: 1px solid var(--border);
    color: var(--text-main); padding: 8px 10px;
    font-family: var(--font-data); font-size: 11px;
    width: 100%; transition: border-color 0.2s;
    border-radius: 4px;
}
.input-dark:focus { border-color: var(--accent); }

input[type=range].input-range {
    -webkit-appearance: none; width: 100%; background: transparent; height: 26px; margin: 0;
}
input[type=range].input-range::-webkit-slider-thumb {
    -webkit-appearance: none; height: 14px; width: 14px; border-radius: 50%;
    background: var(--accent); cursor: pointer; margin-top: -6px;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}
input[type=range].input-range::-webkit-slider-runnable-track {
    width: 100%; height: 2px; cursor: pointer; background: #333;
}

.mem-stat {
    padding: 12px 24px; border-top: 1px solid var(--border); 
    display: flex; justify-content: space-between; 
    font-size: 10px; color: var(--text-muted); margin-top: auto;
    background: rgba(0,0,0,0.2); font-family: var(--font-data);
}

.btn-primary {
    background: var(--accent); color: #000;
    border: none;
    padding: 12px 24px; width: 100%;
    font-family: var(--font-head); font-weight: 700; font-size: 12px;
    cursor: pointer; text-transform: uppercase; letter-spacing: 0.1em;
    transition: all 0.2s; border-radius: 4px;
}
.btn-primary:hover { background: #fbbf24; box-shadow: 0 0 20px var(--accent-dim); }

.btn-ghost {
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 12px 24px; width: 100%;
    font-family: var(--font-head); font-weight: 700; font-size: 12px;
    cursor: pointer; text-transform: uppercase; letter-spacing: 0.1em;
    transition: all 0.2s; border-radius: 4px;
}
.btn-ghost:hover { border-color: var(--text-main); color: var(--text-main); background: var(--bg-surface); }

.btn-text {
    background: transparent; border: none; color: var(--accent);
    font-family: var(--font-data); font-size: 10px; cursor: pointer; font-weight: 700;
}
.btn-text:hover { text-decoration: underline; }

/* --- OVERLAYS --- */
#preview-layer {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(2, 2, 2, 0.95); z-index: 999;
    display: none; flex-direction: column;
    backdrop-filter: blur(10px);
}
#preview-layer.active { display: flex; }

.sim-header {
    height: 64px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 40px;
    background: var(--bg-surface); flex-shrink: 0;
}

.sim-controls { display: flex; gap: 8px; }

#device-frame {
    flex: 1;
    position: relative; 
    overflow: hidden;
    width: 100%; height: 100%;
    background-image: radial-gradient(circle, #111 1px, transparent 1px);
    background-size: 20px 20px;
}

#preview-screen {
    position: absolute;
    top: 50%; left: 50%;
    box-shadow: 0 0 100px rgba(0,0,0,0.8), 0 0 0 1px #333;
    background: #000;
    transform-origin: center center;
}

.vp-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 8px 16px; cursor: pointer; display: flex; align-items: center; gap: 8px;
    font-family: var(--font-data); font-size: 10px; font-weight: 700; transition: all 0.2s;
    border-radius: 4px;
}
.vp-btn:hover { border-color: var(--text-main); color: var(--text-main); }
.vp-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.btn-close {
    background: transparent; border: 1px solid var(--danger); color: var(--danger); 
    padding: 8px 24px; cursor: pointer; font-family: var(--font-data); 
    font-size: 10px; font-weight: 700; border-radius: 4px;
}
.btn-close:hover { background: var(--danger); color: #fff; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 1000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-panel); border: 1px solid var(--border);
    width: 420px; box-shadow: 0 30px 60px rgba(0,0,0,0.8);
    display: flex; flex-direction: column;
    border-radius: 6px; overflow: hidden;
}

.modal-actions {
    display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px;
    border-top: 1px solid var(--border); background: var(--bg-surface);
}

.toast-container {
    position: fixed; bottom: 30px; right: 370px;
    display: flex; flex-direction: column; gap: 10px; z-index: 2000;
}
.toast {
    background: var(--bg-surface); border-left: 3px solid var(--accent);
    color: #fff; padding: 12px 16px;
    font-size: 11px; font-weight: 600; font-family: var(--font-data);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0; animation: toastIn 0.3s forwards;
    display: flex; align-items: center; gap: 12px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.empty-state {
    padding: 40px; text-align: center; color: var(--text-muted); 
    font-family: var(--font-data); font-size: 10px; opacity: 0.5;
}

/* Mobile Responsive */
@media (max-width: 800px) {
    .app-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
    #command-center { border-left: none; border-top: 1px solid var(--border); }
    .hub-layout { grid-template-columns: 1fr; }
    .hub-sidebar { display: none; } /* Hide sidebar on mobile for now */
}