/** Copy text, falling back to execCommand for non-secure contexts (HTTP) */ export async function copyText(text: string): Promise { try { await navigator.clipboard.writeText(text) return true } catch { const textarea = document.createElement("textarea") textarea.value = text textarea.style.position = "fixed" textarea.style.left = "-9999px" textarea.style.opacity = "0" document.body.appendChild(textarea) try { textarea.select() return document.execCommand("copy") } catch { return false } finally { document.body.removeChild(textarea) } } }