/* 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; }

/* THEME ENGINE: Exact Variable Architecture Required by Prompt */
:root {
    --bg-dark: #0b0d10;
    --card-bg: #14171d;
    --card-bg-hover: #1f232b;
    --card-border: #272c36;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    
    --editor-bg: #0f1115;
    --output-bg: #000000;
    --output-text: #10b981;
    
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

html.light-theme {
    --bg-dark: #f8fafc;
    --card-bg: #ffffff;
    --card-bg-hover: #f1f5f9;
    --card-border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    
    --editor-bg: #f8fafc;
    --output-bg: #f1f5f9;
    --output-text: #059669; /* Darker green for contrast */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* THEME ENGINE: Chromium transition rule */
html, body {
    transition: background-color 0.2s ease;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    line-height: 1.6;
    /* CRITICAL FIX: Removed overflow-x: hidden to restore native accessibility */
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.hide-desktop { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-accent { color: var(--accent-primary); }

/* Layout Architecture */
.studio-wrapper { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; max-width: 100%; }

.studio-header { 
    height: 60px; display: flex; justify-content: space-between; align-items: center; 
    padding: 0 1.5rem; background: var(--card-bg); border-bottom: 1px solid var(--card-border); flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.back-link { color: var(--text-muted); 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-main); background: var(--card-bg-hover); }
.logo { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo i { color: var(--success); }
.logo span { color: var(--text-main); }
.header-actions { display: flex; align-items: center; gap: 15px; }

.privacy-badge { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; background: var(--success-bg); color: var(--success); display: flex; align-items: center; gap: 6px; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge { font-size: 0.75rem; padding: 4px 10px; border-radius: 6px; background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }

/* Buttons */
.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; border: none; font-family: var(--font-ui); min-height: 44px; }
.btn-primary { background: linear-gradient(180deg, var(--accent-primary) 0%, var(--accent-hover) 100%); color: #ffffff; box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-main); border: 1px solid var(--card-border); }
.btn-ghost:hover:not(:disabled) { background: var(--card-bg-hover); }
.btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: 0.3rem 0.85rem; font-size: 0.85rem; }

/* Theme Toggle Button */
.theme-toggle-btn { background: transparent; border: 1px solid var(--card-border); color: var(--text-main); min-width: 44px; min-height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; font-size: 1.1rem; }
.theme-toggle-btn:hover { background: var(--card-bg-hover); }

/* Alerts */
.alert { padding: 1rem; border-radius: 8px; display: flex; gap: 12px; font-size: 0.9rem; margin-bottom: 1.2rem; }
.alert i { margin-top: 3px; font-size: 1.1rem; }
.alert-warning { background: var(--warning-bg); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3); }
html.light-theme .alert-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* Layout & Editors */
.split-layout { display: flex; flex: 1; position: relative; max-width: 100%; }
.pane { flex: 1; display: flex; flex-direction: column; position: relative; max-width: 100%; }
.pane-left { background: var(--bg-dark); border-right: 1px solid var(--card-border); padding: 1.5rem; }
.pane-right { background: var(--card-bg); padding: 1.5rem; }
.pane-header { margin-bottom: 1rem; flex-shrink: 0; }
.pane-title-row { display: flex; justify-content: space-between; align-items: center; }
.pane-header h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.editor-wrapper { flex: 1; display: flex; position: relative; min-height: 250px; margin-bottom: 1.5rem; }
.code-editor { 
    width: 100%; height: 100%; resize: none; font-family: var(--font-ui); font-size: 1rem;
    background: var(--editor-bg); color: var(--text-main); border: 1px solid var(--card-border); 
    border-radius: 8px; padding: 1.2rem; outline: none; transition: border-color 0.2s;
    line-height: 1.6; white-space: pre-wrap; overflow-wrap: break-word; overflow-y: auto;
}
.code-editor:focus { border-color: var(--accent-primary); }
.output-editor { background: var(--output-bg); color: var(--output-text); }

/* Inspect Mode Visuals */
#inspectView { user-select: text; }
.inspect-homoglyph { background: rgba(234, 179, 8, 0.2); color: #eab308; border-bottom: 1px dashed #eab308; }
.inspect-zws { color: #ef4444; font-weight: bold; padding: 0 1px; }

.empty-overlay { 
    position: absolute; inset: 0; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; background: var(--bg-dark);
    backdrop-filter: blur(4px); border-radius: 8px; color: var(--text-muted);
    transition: opacity 0.2s; z-index: 3; pointer-events: none; opacity: 0.85;
}
.empty-overlay i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.code-editor:focus + .empty-overlay, .editor-wrapper.has-content .empty-overlay { opacity: 0; pointer-events: none; }

/* Options Panel */
.options-panel { background: var(--card-bg); border: 1px solid var(--card-border); padding: 1.2rem 1.5rem; border-radius: 8px; flex-shrink: 0; }
.options-panel h3 { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 1rem; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--text-main); cursor: pointer; user-select: none; }
.checkbox-label input { accent-color: var(--accent-primary); width: 16px; height: 16px; cursor: pointer; }
.inspect-mode-label { color: var(--accent-primary); font-weight: 500; }

/* Action Area */
.desktop-action-area { display: flex; gap: 12px; margin-top: auto; padding-top: 1.5rem; border-top: 1px solid var(--card-border); justify-content: flex-end; flex-shrink: 0;}

/* FAQ Section */
.faq-section { max-width: 900px; margin: 4rem auto; padding: 0 1.5rem 6rem 1.5rem; }
.faq-heading { font-size: 1.8rem; margin-bottom: 2rem; text-align: center; color: var(--text-main); }
.faq-item { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.2rem; transition: transform 0.2s; }
.faq-item:hover { transform: translateY(-2px); border-color: var(--accent-primary); }
.faq-item h3 { font-size: 1.1rem; color: var(--text-main); margin-bottom: 0.8rem; display: flex; align-items: center; gap: 10px; }
.faq-item h3 i { color: var(--accent-primary); font-size: 1.2rem; }
.faq-item p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; }
.faq-item strong { color: var(--text-main); }

/* Toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 100px); background: var(--text-main); color: var(--bg-dark); 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 View */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    
    .studio-layout { flex-direction: column; overflow: visible; padding-bottom: 80px; }
    
    .pane { border: none; padding: 1rem; flex: none; height: auto; }
    .pane-right { border-top: 1px solid var(--card-border); }
    .pane-header { padding: 0; }
    
    .options-grid { grid-template-columns: 1fr; }
    
    .editor-wrapper { min-height: 250px; margin-bottom: 1rem; }
    .code-editor { font-size: 0.9rem; padding: 0.8rem; }
    
    .options-panel { padding: 1rem; }
    
    .faq-section { padding-bottom: 100px; margin: 2rem auto; }

    /* Native Bottom Nav */
    .mobile-bottom-nav { 
        position: fixed; bottom: 0; left: 0; right: 0;
        background: var(--card-bg); backdrop-filter: blur(10px);
        display: flex; border-top: 1px solid var(--card-border); 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-muted);
        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 { color: var(--accent-primary); }
    .nav-btn i { font-size: 1.2rem; }
}