document.addEventListener("click", async (e) => { const el = e.target.closest("[data-copy]"); if (!el) return; try { await navigator.clipboard.writeText(el.dataset.copy); } catch (err) { console.error("copy failed:", err); return; } const scope = el.closest("[data-copy-scope]") ?? el; scope.setAttribute("data-copied", ""); clearTimeout(scope._copyTimer); scope._copyTimer = setTimeout(() => scope.removeAttribute("data-copied"), 1500); });