/* Core Variables & Typography */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    --bg-base: #0b0d10;
    --bg-surface: #14171d;
    --bg-surface-hover: #1f232b;
    --border-color: #272c36;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

body { 
    background-color: var(--bg-base); color: var(--text-primary); 
    font-family: var(--font-ui); line-height: 1.6; 
    overflow-x: hidden;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.hide-desktop { display: none !important; }

/* Layout Architecture */
.studio-wrapper { display: flex; flex-direction: column; height: 100vh; min-height: 100dvh; }

.studio-header { 
    height: 60px; display: flex; justify-content: space-between; align-items: center; 
    padding: 0 1.5rem; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.back-link { color: var(--text-secondary); font-size: 1.2rem; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 6px; text-decoration: none; transition: 0.2s; }
.back-link:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.logo { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo i { color: var(--accent-primary); }
.logo span { color: var(--text-primary); }
.header-actions { display: flex; align-items: center; gap: 15px; }

.privacy-badge { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; background: rgba(16, 185, 129, 0.1); color: var(--success); display: flex; align-items: center; gap: 6px; border: 1px solid rgba(16, 185, 129, 0.2); }

/* Buttons & Selects */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0.6rem 1.4rem; border-radius: 9999px; font-weight: 500; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); border: none; font-family: var(--font-ui); min-height: 44px; }
.btn-primary { background: linear-gradient(180deg, var(--accent-primary) 0%, #1d4ed8 100%); color: #ffffff; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #5b9af8 0%, #2563eb 100%); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-hover); }
.btn-sm { min-height: 32px; padding: 0.3rem 0.85rem; font-size: 0.85rem; }

.format-select { background: var(--bg-base); color: var(--text-primary); border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 6px; font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500; outline: none; cursor: pointer; transition: 0.2s; }
.format-select:focus { border-color: var(--accent-primary); }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; }
.checkbox-label input { accent-color: var(--accent-primary); width: 16px; height: 16px; cursor: pointer; }

/* Layout Architecture */
.split-layout { display: flex; flex: 1; overflow: hidden; position: relative; }
.pane { flex: 1; display: flex; flex-direction: column; padding: 1.5rem; overflow: hidden; position: relative; }
.pane-left { background: var(--bg-base); border-right: 1px solid var(--border-color); }
.pane-right { background: var(--bg-surface); }
.pane-header { margin-bottom: 1rem; display: flex; flex-direction: column; }
.pane-title-row { display: flex; justify-content: space-between; align-items: center; }
.pane-title-row h2 { font-size: 1rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* Editors */
.editor-wrapper { flex: 1; display: flex; position: relative; min-height: 250px; }
.code-editor { 
    width: 100%; height: 100%; resize: none; font-family: var(--font-mono); font-size: 0.95rem;
    background: #0f1115; color: #cbd5e1; border: 1px solid var(--border-color); 
    border-radius: 8px; padding: 1rem; outline: none; transition: border-color 0.2s;
    line-height: 1.6; white-space: pre; overflow-wrap: normal; overflow-x: auto;
    position: relative; z-index: 2; 
}
.code-editor:focus { border-color: var(--accent-primary); }
.output-editor { background: #000; color: #f8fafc; }

.empty-overlay { 
    position: absolute; inset: 0; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; background: rgba(11,13,16,0.8);
    backdrop-filter: blur(4px); border-radius: 8px; color: var(--text-secondary);
    transition: opacity 0.2s; z-index: 3; pointer-events: none;
}
.empty-overlay i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.editor-wrapper.dragover .empty-overlay { background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); border: 2px dashed var(--accent-primary); }

.code-editor:focus + .empty-overlay,
.editor-wrapper.has-content .empty-overlay { opacity: 0; pointer-events: none; }

/* Desktop Action Area */
.desktop-action-area { display: flex; gap: 12px; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); justify-content: flex-end; }

/* Toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 100px); background: var(--text-primary); color: var(--bg-base); padding: 12px 24px; border-radius: 8px; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.5); opacity: 0; transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1000; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.mobile-bottom-nav { display: none; }

/* Mobile Progressive Viewport */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    .hide-desktop { display: flex !important; } 

    .studio-layout { flex: none; overflow: visible; flex-direction: column; padding-bottom: 80px; }
    
    .pane { padding: 1rem; flex: none; height: auto; border: none; }
    .pane-left { border-bottom: 1px solid var(--border-color); min-height: 45vh; }
    
    .editor-wrapper { min-height: 250px; }
    .code-editor { font-size: 0.85rem; padding: 0.75rem; }

    /* Native Bottom Nav */
    .mobile-bottom-nav { 
        position: fixed; bottom: 0; left: 0; right: 0;
        background: rgba(20, 23, 29, 0.95); backdrop-filter: blur(10px);
        display: flex; border-top: 1px solid var(--border-color); z-index: 900; 
        padding-bottom: env(safe-area-inset-bottom); transition: opacity 0.3s;
    }
    .nav-btn {
        flex: 1; background: transparent; border: none; color: var(--text-secondary);
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 12px 0; font-size: 0.7rem; font-family: var(--font-ui); cursor: pointer; gap: 4px; transition: color 0.2s;
    }
    .nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
    .nav-btn:active:not(:disabled) { color: var(--accent-primary); }
    .nav-btn.active { color: var(--accent-primary); }
    .nav-btn i { font-size: 1.2rem; }
}