    newItem.onclick = () => addTag(input.value.trim());
                    dropdown.appendChild(newItem);
                }

                filteredTags.forEach(tag => {
                    const item = document.createElement('div');
                    item.textContent = tag;
                    item.onclick = () => addTag(tag);
                    dropdown.appendChild(item);
                });
                
                dropdown.style.display = dropdown.children.length > 0 ? 'block' : 'none';
   