        
        :root {
            --bgs-bg-app: #f1f5f9;
            --bgs-bg-card: #ffffff;
            --bgs-bg-panel: #f8fafc;
            
            --bgs-primary: #2563eb;       
            --bgs-primary-dark: #1d4ed8;
            --bgs-primary-light: #eff6ff;
            --bgs-primary-ring: rgba(37, 99, 235, 0.2);
            
            --bgs-text-main: #0f172a;     
            --bgs-text-muted: #64748b;    
            
            --bgs-border: #e2e8f0;
            --bgs-border-hover: #cbd5e1;
            
            --bgs-success: #10b981;
            --bgs-warning: #f59e0b;
            --bgs-danger: #ef4444;
            --bgs-info: #0ea5e9;
            
            --bgs-radius-sm: 8px;
            --bgs-radius-md: 12px;
            --bgs-radius-lg: 20px;
            
            --bgs-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --bgs-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
            --bgs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.025);
        }

        .bgs-app-wrapper, .bgs-app-wrapper * { 
            box-sizing: border-box; 
            outline: none; 
            -webkit-tap-highlight-color: transparent; 
        }

        .bgs-app-wrapper {
            font-family: 'Inter', sans-serif;
            color: var(--bgs-text-main);
            margin: 0;
            padding: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            position: relative; 
        }

        .bgs-app-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0rem;
            width: 100%;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        @media (min-width: 768px) {
            .bgs-app-container { padding: 0rem; gap: 2rem; }
        }

        .bgs-mode-selector {
            background: white;
            padding: 4px;
            border-radius: 14px;
            box-shadow: var(--bgs-shadow-sm);
            border: 1px solid var(--bgs-border);
            display: flex;
            position: relative;
            width: 100%;
            overflow-x: auto;
            align-items: center;
            margin: 15px auto !important;
            white-space: nowrap;
        }

        @media (min-width: 768px) {
            .bgs-mode-selector { width: auto; overflow-x: visible; }
        }

        .bgs-mode-option {
            position: relative;
            z-index: 2;
            padding: 10px 16px;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--bgs-text-muted);
            cursor: pointer;
            border-radius: 10px;
            transition: color 0.3s ease;
            text-align: center;
            flex: 1;
            min-width: 80px;
            max-width: 180px;
        }

        @media (min-width: 768px) {
            .bgs-mode-option { padding: 10px 24px; min-width: 100px; }
        }

        .bgs-mode-option.bgs-active { color: var(--bgs-primary); }

        .bgs-mode-glider {
            position: absolute;
            top: 4px;
            left: 4px;
            height: calc(100% - 8px);
            background: var(--bgs-primary-light);
            border-radius: 10px;
            z-index: 1;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
        }

        .bgs-main-layout {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1.5rem;
            align-items: start;
        }

        @media (min-width: 1024px) {
            .bgs-main-layout {
                grid-template-columns: 340px 1fr;
                gap: 2rem;
            }
            .bgs-sidebar {
                position: sticky;
                top: 2rem;
                max-height: calc(100vh - 4rem);
                overflow-y: auto;
                scrollbar-width: none; 
            }
            .bgs-sidebar::-webkit-scrollbar { display: none; }
        }

        .bgs-card {
            background: var(--bgs-bg-card);
            border-radius: var(--bgs-radius-lg);
            border: 1px solid var(--bgs-border);
            box-shadow: var(--bgs-shadow-sm);
            overflow: hidden;
        }

        .bgs-card-body { padding: 1.25rem; }
        @media (min-width: 768px) { .bgs-card-body { padding: 1.5rem; } }

        .bgs-section-title {
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            font-weight: 700;
            color: var(--bgs-text-muted);
            margin-bottom: 1.25rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .bgs-control-group { margin-bottom: 1.5rem; }

        .bgs-label-flex {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.6rem;
        }

        .bgs-label-text {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--bgs-text-main);
        }

        .bgs-label-badge {
            font-size: 0.7rem;
            background: var(--bgs-bg-panel);
            color: var(--bgs-text-muted);
            padding: 2px 8px;
            border-radius: 6px;
            border: 1px solid var(--bgs-border);
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .bgs-input-box {
            position: relative;
            display: flex;
            align-items: center;
        }

        .bgs-input-field {
            width: 100%;
            padding: 12px 16px;
            padding-right: 3.5rem;
            font-family: 'JetBrains Mono', monospace;
            font-size: 1rem;
            color: var(--bgs-text-main);
            background: var(--bgs-bg-panel);
            border: 1px solid var(--bgs-border);
            border-radius: var(--bgs-radius-md);
            transition: all 0.2s;
        }

        .bgs-input-field:focus {
            background: white;
            border-color: var(--bgs-primary);
            box-shadow: 0 0 0 3px var(--bgs-primary-ring);
        }

        select.bgs-input-field {
            padding-right: 2.5rem;
            appearance: none;
            cursor: pointer;
            height: auto;
        }

        .bgs-unit-label {
            position: absolute;
            right: 16px;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--bgs-text-muted);
            pointer-events: none;
        }

        /* Integrated Boxes */
        .bgs-integrated-box {
            background: var(--bgs-bg-panel);
            border: 1px solid var(--bgs-border);
            border-radius: var(--bgs-radius-md);
            padding: 12px 16px;
            transition: all 0.2s;
        }
        .bgs-integrated-box:focus-within {
            background: white;
            border-color: var(--bgs-primary);
            box-shadow: 0 0 0 3px var(--bgs-primary-ring);
        }
        
        .bgs-gc-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 8px;
        }
        
        .bgs-inline-input-minimal {
            background: transparent;
            border: none;
            font-family: 'JetBrains Mono', monospace;
            font-size: 1rem;
            font-weight: 700;
            color: var(--bgs-text-main);
            width: 60px;
            text-align: right;
            padding: 0;
        }
        
        .bgs-range-wrap { height: 20px; display: flex; align-items: center; }
        .bgs-app-wrapper input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; border: none; }
        .bgs-app-wrapper input[type=range]::-webkit-slider-thumb {
            -webkit-appearance: none;
            height: 18px; width: 18px;
            border-radius: 50%;
            background: white;
            border: 2px solid var(--bgs-primary);
            cursor: pointer;
            margin-top: -7px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.15);
            transition: transform 0.1s;
        }
        .bgs-app-wrapper input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
        .bgs-app-wrapper input[type=range]::-webkit-slider-runnable-track {
            width: 100%; height: 4px;
            cursor: pointer;
            background: var(--bgs-border-hover);
            border-radius: 2px;
        }

        .bgs-comp-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid var(--bgs-border);
        }
        
        .bgs-comp-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: white;
            border: 1px solid var(--bgs-border);
            border-radius: 6px;
            padding: 4px 8px;
        }
        
        .bgs-comp-item label {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--bgs-text-muted);
            width: 30px;
        }
        
        .bgs-comp-item input {
            width: 45px;
            border: none;
            background: transparent;
            font-family: 'JetBrains Mono', monospace;
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--bgs-text-main);
            text-align: right;
            padding: 0;
        }

        .bgs-btn-grid {
            display: grid;
            grid-template-columns: 1.5fr 1fr;
            gap: 12px;
            margin-top: 1.5rem;
        }

        .bgs-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 12px 16px;
            border-radius: var(--bgs-radius-md);
            font-weight: 600;
            font-size: 0.95rem;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            border: none;
            min-height: 44px; 
        }

        .bgs-btn:active { transform: scale(0.97); }

        .bgs-btn-primary {
            background: var(--bgs-primary);
            color: white;
            box-shadow: 0 4px 12px var(--bgs-primary-ring);
        }
        .bgs-btn-primary:hover { background: var(--bgs-primary-dark); }

        .bgs-btn-ghost {
            background: white;
            border: 1px solid var(--bgs-border);
            color: var(--bgs-text-muted);
        }
        .bgs-btn-ghost:hover { border-color: var(--bgs-text-main); color: var(--bgs-text-main); background: var(--bgs-bg-panel); }

        .bgs-options-toggle {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            padding: 1rem 1.25rem;
            background: none;
            border: none;
            border-top: 1px solid var(--bgs-border);
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 600;
            color: var(--bgs-text-muted);
            transition: background 0.2s;
        }
        .bgs-options-toggle:hover { background: var(--bgs-bg-panel); color: var(--bgs-text-main); }
        
        .bgs-options-content {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease;
            background: var(--bgs-bg-panel);
        }
        .bgs-options-content.bgs-open { max-height: 400px; border-top: 1px solid var(--bgs-border); }
        .bgs-options-inner { padding: 1.25rem; display: grid; gap: 1rem; }

        .bgs-toggle-label {
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            padding: 4px 0;
        }
        .bgs-toggle-switch {
            position: relative;
            width: 40px; height: 22px;
            background-color: var(--bgs-border-hover);
            border-radius: 12px;
            transition: background-color 0.3s;
        }
        .bgs-toggle-knob {
            position: absolute;
            top: 2px; left: 2px;
            width: 18px; height: 18px;
            background-color: white;
            border-radius: 50%;
            transition: transform 0.3s;
            box-shadow: var(--bgs-shadow-sm);
        }
        .bgs-app-wrapper input[type="checkbox"]:checked + .bgs-toggle-switch { background-color: var(--bgs-primary); }
        .bgs-app-wrapper input[type="checkbox"]:checked + .bgs-toggle-switch .bgs-toggle-knob { transform: translateX(18px); }
        .bgs-app-wrapper input[type="radio"] { accent-color: var(--bgs-primary); }

        .bgs-info-icon {
            color: var(--bgs-text-muted);
            width: 14px;
            height: 14px;
            margin-left: 4px;
            vertical-align: middle;
            cursor: help;
        }

        .bgs-results-card {
            display: flex;
            flex-direction: column;
            border-color: var(--bgs-primary-light);
            box-shadow: var(--bgs-shadow-lg);
        }

        .bgs-toolbar {
            padding: 1rem;
            border-bottom: 1px solid var(--bgs-border);
            display: flex;
            flex-direction: column;
            gap: 1rem;
            background: white;
        }

        @media (min-width: 640px) {
            .bgs-toolbar {
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
                padding: 1rem 1.5rem;
            }
        }

        .bgs-status-group {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .bgs-pulse-dot {
            width: 10px; height: 10px;
            background: var(--bgs-border-hover); 
            border-radius: 50%;
            transition: all 0.3s;
        }
        .bgs-pulse-dot.bgs-active { background: var(--bgs-success); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2); }
        .bgs-pulse-dot.bgs-busy { background: var(--bgs-warning); animation: bgs-pulse 1s infinite; }
        .bgs-pulse-dot.bgs-error { background: var(--bgs-danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); }

        .bgs-toolbar-title {
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--bgs-text-main);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .bgs-unit-count {
            font-size: 0.75rem;
            color: var(--bgs-text-muted);
            font-weight: 500;
            background: var(--bgs-bg-panel);
            padding: 2px 8px;
            border-radius: 6px;
        }

        .bgs-action-bar {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            width: 100%;
        }

        @media (min-width: 640px) {
            .bgs-action-bar {
                display: flex;
                width: auto;
            }
        }

        .bgs-mini-btn {
            padding: 8px 12px;
            font-size: 0.8rem;
            border-radius: 8px;
            border: 1px solid var(--bgs-border);
            background: white;
            color: var(--bgs-text-muted);
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            transition: all 0.2s;
            min-height: 38px;
        }
        .bgs-mini-btn:hover { border-color: var(--bgs-primary); color: var(--bgs-primary); background: var(--bgs-primary-light); }
        .bgs-mini-btn.bgs-filled { background: var(--bgs-text-main); color: white; border-color: var(--bgs-text-main); }
        .bgs-mini-btn.bgs-filled:hover { background: black; }

        .bgs-editor {
            background: #0f172a; 
            position: relative;
            border-bottom-left-radius: var(--bgs-radius-lg);
            border-bottom-right-radius: var(--bgs-radius-lg);
        }

        .bgs-editor-scroller {
            width: 100%;
            min-height: 250px;
            max-height: 65vh;
            overflow-y: auto;
            padding: 1.5rem;
            color: #e2e8f0;
            font-family: 'JetBrains Mono', monospace;
            font-size: 0.85rem;
            line-height: 1.6;
            word-break: break-all;
        }

        @media (min-width: 768px) {
            .bgs-editor-scroller { padding: 3.8rem; font-size: 0.9rem; max-height: 600px; }
        }

        /* Syntax Colors */
        .bgs-base-gc { color: #34d399; font-weight: 700; } /* Emerald */
        .bgs-base-at { color: #94a3b8; opacity: 0.9; } /* Slate */
        .bgs-base-pseudo { color: #d946ef; font-weight: 700; } /* Fuchsia for Ψ */
        
        .bgs-line-num { 
            display: inline-block; 
            width: 3rem; 
            margin-right: 1rem; 
            text-align: right; 
            color: #475569; 
            user-select: none; 
            font-size: 0.75rem;
        }

        .bgs-hidden { display: none !important; }
        .bgs-icon { width: 18px; height: 18px; stroke-width: 2; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
        .bgs-spin { animation: bgs-spin 1s linear infinite; }
        @keyframes bgs-spin { to { transform: rotate(360deg); } }
        @keyframes bgs-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

        .bgs-toast {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%) translateY(100px);
            background: var(--bgs-text-main);
            color: white;
            padding: 12px 24px;
            border-radius: 99px;
            font-size: 0.9rem;
            font-weight: 600;
            box-shadow: var(--bgs-shadow-lg);
            opacity: 0;
            pointer-events: none;
            transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            z-index: 100;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .bgs-toast.bgs-success { background: var(--bgs-success); }
        .bgs-toast.bgs-danger { background: var(--bgs-danger); }
        .bgs-toast.bgs-show { opacity: 1; transform: translateX(-50%) translateY(0); }

        .bgs-loader-overlay {
            position: absolute;
            inset: 0;
            background: rgba(15, 23, 42, 0.85);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 50;
            backdrop-filter: blur(4px);
            border-bottom-left-radius: var(--bgs-radius-lg);
            border-bottom-right-radius: var(--bgs-radius-lg);
        }
        .bgs-loader-bar-bg { width: 80%; max-width: 300px; height: 6px; background: #334155; border-radius: 3px; margin-top: 1rem; overflow: hidden; }
        .bgs-loader-bar { width: 0%; height: 100%; background: #34d399; transition: width 0.1s; }