        </div>
    </div>
    <footer><a href="https://riliaichat.com/chat/585843e7-f172-417f-b7e5-213d6a34a7bd/" target="_blank">本页面采用rili-创作大师生成</a></footer>
    <div class="toast" id="toast">
        <div id="toast-message">信息已成功复制！</div>
        <div class="close-toast" id="toast-close">✦ 知晓</div>
    </div>
    <script>
        (function() {
            const nameInput = document.getElementById('char-name');
            const ageInput = document.getElementById('char-age');
            const lookInput = document.getElementById('char-look');
            const bgTextarea = document.getElementById('char-bg');
            const extraTextarea = document.getElementById('char-extra');
            const previewBox = document.getElementById('preview-box');
            const copyBtn = document.getElementById('copy-button');
            const resetBtn = document.getElementById('reset-button');
            const toast = document.getElementById('toast');
            const toastMsg = document.getElementById('toast-message');
            const toastClose = document.getElementById('toast-close');
            const genderRadios = document.querySelectorAll('input[name="gender"]');

            function buildPreview() {
                const name = nameInput.value.trim() || '未命名';
                const age = ageInput.value.trim() || '未知';
                let gender = '未指定';
                for (const r of genderRadios) {
                    if (r.checked) { gender = r.value; break; }
                }
                const look = lookInput.value.trim() || '未描述';
                const bg = bgTextarea.value.trim() || '无背景设定';
                const extra = extraTextarea.value.trim() || '无';
                let result = `【角色档案】\n`;
                result += `姓名：${name}\n`;
                result += `年龄：${age}\n`;
                result += `性别：${gender}\n`;
                result += `外观：${look}\n`;
                result += `身份背景：${bg}\n`;
                result += `额外印记：${extra}\n`;
                result += `—— 「NTR 协奏曲 · 暗影低语」 ——`;
                previewBox.textContent = result;
                return result;
            }

            function updatePreview() {
                buildPreview();
            }

            const inputs = [nameInput, ageInput, lookInput, bgTextarea, extraTextarea];
            for (const inp of inputs) {
                inp.addEventListener('input', updatePreview);
            }
            for (const r of genderRadios) {
                r.addEventListener('change', updatePreview);
            }

            // 初始化预览
            updatePreview();

            // 复制功能 (使用 document.execCommand)
            function copyToClipboard(text) {
                const textarea = document.createElement('textarea');
                textarea.value = text;
                textarea.style.position = 'fixed';
                textarea.style.left = '-9999px';
                textarea.style.top = '-9999px';
                textarea.style.width = '1px';
                textarea.style.height = '1px';
                textarea.style.opacity = '0';
                document.body.appendChild(textarea);
                textarea.focus();
                textarea.select();
                try {
                    const successful = document.execCommand('copy');
                    if (successful) {
                        showToast('✦ 角色档案已成功复制！');
                    } else {
                        showToast('✧ 复制失败，请手动复制');
                    }
                } catch (err) {
                    showToast('✧ 复制失败，请手动复制');
                }
                document.body.removeChild(textarea);
            }

            copyBtn.addEventListener('click', function() {
                const content = previewBox.textContent;
                if (!content || content === '') {
                    showToast('⸸ 尚无角色信息可复制');
                    return;
                }
                copyToClipboard(content);
            });

            function showToast(message) {
                toastMsg.textContent = message;
                toast.classList.add('show');
            }

            function hideToast() {
                toast.classList.remove('show');
            }

            toastClose.addEventListener('click', hideToast);
            toast.addEventListener('click', function(e) {
                if (e.target === toast) hideToast();
            });

            // 重置功能
            resetBtn.addEventListener('click', function() {
                nameInput.value = '';
                ageInput.value = '';
                lookInput.value = '';
                bgTextarea.value = '';
                extraTextarea.value = '';
                for (const r of genderRadios) {
                    if (r.value === '男性') { r.checked = true; break; }
                }
                updatePreview();
                showToast('⟲ 角色档案已重置');
            });

            // 点击toast外部可关闭
            document.addEventListener('keydown', function(e) {
                if (e.key === 'Escape' && toast.classList.contains('show')) {
                    hideToast();
                }
            });
        })();
    </script>
</body>
</html>
```