/* 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 */
: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;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    
    --editor-bg: #0f1115;
    --input-bg: #0f1115;
    
    --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;
    --input-bg: #f8fafc;
}

* { 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. Removed overflow-x band-aid. */
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;
}

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; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }

/* 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(--accent-primary); }
.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: rgba(59, 130, 246, 0.1); color: var(--accent-primary); display: flex; align-items: center; gap: 6px; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; font-weight: 600; margin-left: 8px; vertical-align: middle; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

/* Buttons & Inputs */
.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-ghost { background: transparent; color: var(--text-main); border: 1px solid var(--card-border); }
.btn-ghost:hover:not(:disabled) { background: var(--card-bg-hover); }
.btn-sm { min-height: 32px; padding: 0.3rem 0.85rem; font-size: 0.85rem; }
.icon-btn { background: transparent; color: var(--text-muted); border: none; font-size: 1rem; cursor: pointer; padding: 5px; transition: color 0.2s; }
.icon-btn:hover { color: var(--danger); }

/* 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; }
.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; }

.input-dark, .select-dark { width: 100%; background: var(--input-bg); border: 1px solid var(--card-border); color: var(--text-main); padding: 0.6rem 0.8rem; border-radius: 6px; font-family: var(--font-ui); outline: none; transition: border 0.2s; min-height: 40px; }
.input-dark:focus, .select-dark:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.textarea-sm { min-height: 70px; resize: vertical; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; font-weight: 500; }
.input-row { display: flex; gap: 12px; }

/* Layout Architecture */
.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); }
.pane-right { background: var(--card-bg); }
.pane-header { padding: 1.5rem 1.5rem 0 1.5rem; margin-bottom: 1rem; flex-shrink: 0; }
.pane-right .pane-header { padding: 1.5rem 1.5rem 0 1.5rem; margin-bottom: 0.5rem; }
.pane-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.pane-header h2, .pane-title-row h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.panel-scroll-content { padding: 1.5rem; overflow-y: auto; flex: 1; }

.form-section { background: var(--card-bg); padding: 1.2rem; border-radius: 8px; border: 1px solid var(--card-border); margin-bottom: 1rem; }
.form-section h3 { font-size: 0.9rem; color: var(--text-main); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--card-border); }

/* Dynamic List Items */
.endpoint-item { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; background: var(--bg-dark); padding: 8px; border-radius: 6px; border: 1px solid var(--card-border); }
.endpoint-item input { flex: 1; }

/* Editors & Dual View */
.output-group { display: flex; flex-direction: column; }
.editor-wrapper { flex: 1; display: flex; position: relative; min-height: 250px; }
.robots-wrapper { min-height: 150px; }
.code-editor { 
    width: 100%; height: 100%; resize: none; font-family: var(--font-mono); font-size: 0.95rem;
    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;
}

/* Desktop Action Area */
.desktop-action-area { display: flex; gap: 12px; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--card-border); justify-content: flex-end; }

/* 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, .faq-item code { color: var(--text-main); }
.faq-item code { background: var(--bg-dark); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--card-border); font-family: var(--font-mono); font-size: 0.85em; }

/* 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 Progressive Viewport */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    
    .studio-layout { flex-direction: column; overflow: visible; padding-bottom: 80px; }
    
    .pane { flex: none; height: auto; border: none; }
    .pane-right { border-top: 1px solid var(--card-border); }
    
    /* Ensure padding for scrollability above mobile nav */
    .panel-scroll-content { padding: 1rem 1rem 3rem 1rem; overflow-y: visible; }
    .pane-header { padding: 1rem 1rem 0 1rem; }
    
    .input-row { flex-direction: column; gap: 0; }
    
    .editor-wrapper { min-height: 350px; }
    .robots-wrapper { min-height: 200px; }
    .code-editor { font-size: 0.8rem; padding: 0.75rem; }

    .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.active { color: var(--accent-primary); }
    .nav-btn i { font-size: 1.2rem; }
}