if (window.electronAPI?.isElectron) {
    document.documentElement.classList.add("electron");
}

document.addEventListener("DOMContentLoaded", () => {
    document.documentElement.style.visibility = "visible";
    if (!window.electronAPI?.isElectron) return;
    document.body.classList.add("electron");

    const titlebar = document.getElementById("titlebar");
    if (!titlebar) return;

    titlebar.style.display = "flex";

    titlebar.querySelector(".min").onclick = () => window.electronAPI.win.minimize();
    titlebar.querySelector(".max").onclick = () => window.electronAPI.win.maximize();
    titlebar.querySelector(".close").onclick = () => window.electronAPI.win.close();
});