                 option.selected = isSelected;
                }
            });

            tagCloud.appendChild(tagElement);
        });

        // Site selection functionality
        const siteInput = document.getElementById('siteInput');
        const hiddenInput = document.getElementById('site');
        const selectedSitesContainer = document.getElementById('selectedSites');
        let selectedSites = new Set();

        function updateHiddenInput() {
            hiddenInput.value = Array.from(sel