:root {
    /* Colors */
    --bg-dark: #121212;
    --bg-card: rgba(30, 41, 59, 0.7);
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(15, 23, 42, 0.8);

    /* Spacing & Borders */
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* Layout Container */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.wireframe-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.wireframe-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wireframe-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border);
}

.wireframe-item.active {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

/* Main Content Styling */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top left, #262626, #0e0e0e);
    position: relative;
}

.toolbar {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
}

.viewer-area {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Viewport Shell */
.viewport-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.viewport-shell {
    background: #000;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Code Drawer */
.code-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: #1e1e1e;
    border-left: 1px solid var(--border);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 100;
}

.code-drawer.open {
    width: 50% !important;
}

.code-header {
    padding: 16px 24px;
    background: #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-content {
    padding: 24px;
    overflow: auto;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
}

/* Buttons and Controls */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* Utility */
.hidden {
    display: none !important;
}

/* CRT Effects */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(to bottom,
            rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle,
            rgba(0, 0, 0, 0) 40%,
            rgba(0, 0, 0, 0.8) 100%);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.crt-active .scanlines,
body.crt-active .vignette {
    opacity: var(--crt-intensity, 0.7);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
    }

    .code-drawer.open {
        width: 100% !important;
    }
}