              window.location.href = match.href;
            });
            autocompleteList.appendChild(listItem);
        });

        autocompleteList.style.display = matches.length ? "block" : "none";
    }

    function highlightItem(index) {
        const items = autocompleteList.querySelectorAll("li");
        items.forEach((item, i) => {
            if (i === index) {
                item.classList.add("highlighted");
                item.scrollIntoView({ block: "nearest" });
            } else {
 