function initTheme(){const t=localStorage.getItem("theme")||"light";document.documentElement.setAttribute("data-theme",t),updateThemeIcon(t)}function toggleTheme(){const t=document.documentElement.getAttribute("data-theme"),e="dark"===t?"light":"dark";document.documentElement.setAttribute("data-theme",e),localStorage.setItem("theme",e),updateThemeIcon(e)}function updateThemeIcon(t){const e=document.getElementById("theme-icon");e&&(e.innerHTML="dark"===t?"☀️":"🌙")}function toggleSidebar(){const t=document.querySelector(".sidebar");t&&t.classList.toggle("active")}function copyToClipboard(t,e){const n=document.createElement("textarea");n.value=t,document.body.appendChild(n),n.select();try{document.execCommand("copy"),e?(e.innerHTML="✓ Copied!",e.disabled=!0,setTimeout(()=>{e.innerHTML="📋 Copy Link",e.disabled=!1},2e3)):alert("Copied to clipboard!")}catch(t){alert("Failed to copy")}document.body.removeChild(n)}document.addEventListener("DOMContentLoaded",function(){initTheme();const t=document.getElementById("theme-toggle");t&&t.addEventListener("click",toggleTheme)});
