(div);
    });

    // Update preview function
    function updatePreview() {
      const checkedOptions = Array.from(sandboxControls.querySelectorAll('input:checked'))
        .map(input => input.id)
        .join(' ');
      
      preview.setAttribute('sandbox', checkedOptions);
      preview.srcdoc = codeEditor.value;
    }

    // Event listeners
    updatePreviewBtn.addEventListener('click', updatePreview);
    sandboxControls.addEventListener('change', updatePreview);

    // Initial preview
    upda