function audiotypedCopyTranscriptHtml() {
    var copyText = document.getElementById('audiotyped_generated_html');
    if (!copyText) {
        alert('Textarea not found.');
        return;
    }

    // Modern API
    if (navigator.clipboard && navigator.clipboard.writeText) {
        navigator.clipboard.writeText(copyText.value)
            .then(function () {
                alert('HTML copied to clipboard!');
            })
            .catch(function (err) {
                console.error('Failed to copy: ', err);
                alert('Copy failed. Please copy manually.');
            });
    } else {
        // Fallback for older browsers
        copyText.select();
        try {
            document.execCommand('copy');
            alert('HTML copied to clipboard!');
        } catch (e) {
            console.error('Fallback copy failed: ', e);
            alert('Copy failed. Please copy manually.');
        }
    }
}
