{"id":984,"date":"2026-08-10T17:08:41","date_gmt":"2026-08-10T17:08:41","guid":{"rendered":"https:\/\/freewebtools.co.in\/?page_id=984"},"modified":"2026-08-10T17:10:17","modified_gmt":"2026-08-10T17:10:17","slug":"smart-ai-copy-paste-2","status":"publish","type":"page","link":"https:\/\/freewebtools.co.in\/index.php\/smart-ai-copy-paste-2\/","title":{"rendered":"Smart AI Copy Paste"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>AI Notes Smart Copy<\/title>\n    <style>\n        \/* Scoped to #ai-notes-smart-copy wrapper for WordPress safety *\/\n        #ai-notes-smart-copy {\n            --bg-primary: #f8fafc;\n            --bg-secondary: #ffffff;\n            --bg-card: #ffffff;\n            --text-primary: #0f172a;\n            --text-secondary: #475569;\n            --border-color: #cbd5e1;\n            --accent-color: #2563eb;\n            --accent-hover: #1d4ed8;\n            --accent-light: #eff6ff;\n            --danger-color: #dc2626;\n            --danger-hover: #b91c1c;\n            --success-color: #16a34a;\n            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);\n            --radius: 8px;\n            font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n            background-color: var(--bg-primary);\n            color: var(--text-primary);\n            min-height: 80vh;\n            display: flex;\n            flex-direction: column;\n            box-sizing: border-box;\n            transition: background-color 0.2s, color 0.2s;\n            width: 100%;\n            max-width: 100%;\n            overflow-x: hidden;\n            padding: 20px;\n            border-radius: 12px;\n        }\n\n        #ai-notes-smart-copy *, #ai-notes-smart-copy *::before, #ai-notes-smart-copy *::after {\n            box-sizing: inherit;\n        }\n\n        #ai-notes-smart-copy[data-theme=\"dark\"] {\n            --bg-primary: #0f172a;\n            --bg-secondary: #1e293b;\n            --bg-card: #1e293b;\n            --text-primary: #f8fafc;\n            --text-secondary: #94a3b8;\n            --border-color: #334155;\n            --accent-color: #3b82f6;\n            --accent-hover: #2563eb;\n            --accent-light: #172554;\n            --danger-color: #ef4444;\n            --danger-hover: #dc2626;\n            --success-color: #22c55e;\n            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);\n            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);\n        }\n\n        .ansc-container {\n            max-width: 1200px;\n            width: 100%;\n            margin: 0 auto;\n            display: flex;\n            flex-direction: column;\n            gap: 20px;\n            min-width: 0;\n            flex: 1;\n        }\n\n        \/* Header *\/\n        .ansc-header {\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            background: var(--bg-card);\n            padding: 16px 24px;\n            border-radius: var(--radius);\n            border: 1px solid var(--border-color);\n            box-shadow: var(--shadow-sm);\n            flex-wrap: wrap;\n            gap: 12px;\n        }\n\n        .ansc-title-area h2 {\n            font-size: 1.5rem;\n            margin: 0 0 4px 0;\n            font-weight: 700;\n            word-break: break-word;\n            color: var(--text-primary);\n        }\n\n        .ansc-subtitle {\n            font-size: 0.875rem;\n            color: var(--text-secondary);\n            margin: 0;\n        }\n\n        .ansc-header-actions {\n            display: flex;\n            align-items: center;\n            gap: 8px;\n            flex-wrap: wrap;\n        }\n\n        \/* Toolbar \/ Actions *\/\n        .ansc-toolbar {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 10px;\n            background: var(--bg-card);\n            padding: 12px 16px;\n            border-radius: var(--radius);\n            border: 1px solid var(--border-color);\n            box-shadow: var(--shadow-sm);\n            align-items: center;\n            justify-content: space-between;\n        }\n\n        .ansc-toolbar-group {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 8px;\n            align-items: center;\n        }\n\n        \/* Search & Replace Bar *\/\n        .ansc-search-bar {\n            display: none;\n            flex-direction: column;\n            gap: 8px;\n            background: var(--bg-card);\n            padding: 12px 16px;\n            border-radius: var(--radius);\n            border: 1px solid var(--border-color);\n            box-shadow: var(--shadow-sm);\n        }\n\n        .ansc-search-bar.active {\n            display: flex;\n        }\n\n        .ansc-search-row {\n            display: flex;\n            gap: 8px;\n            align-items: center;\n            flex-wrap: wrap;\n        }\n\n        \/* Buttons *\/\n        .ansc-btn {\n            background-color: var(--bg-secondary);\n            color: var(--text-primary);\n            border: 1px solid var(--border-color);\n            padding: 8px 14px;\n            border-radius: 6px;\n            font-size: 0.875rem;\n            font-weight: 500;\n            cursor: pointer;\n            display: inline-flex;\n            align-items: center;\n            gap: 6px;\n            transition: background-color 0.15s, border-color 0.15s, transform 0.05s;\n            white-space: nowrap;\n            min-height: 40px;\n        }\n\n        .ansc-btn:hover {\n            background-color: var(--accent-light);\n            border-color: var(--accent-color);\n        }\n\n        .ansc-btn:active {\n            transform: scale(0.98);\n        }\n\n        .ansc-btn-primary {\n            background-color: var(--accent-color);\n            color: #ffffff;\n            border-color: var(--accent-color);\n        }\n\n        .ansc-btn-primary:hover {\n            background-color: var(--accent-hover);\n            border-color: var(--accent-hover);\n        }\n\n        .ansc-btn-danger {\n            color: var(--danger-color);\n        }\n\n        .ansc-btn-danger:hover {\n            background-color: #fef2f2;\n            border-color: var(--danger-color);\n        }\n\n        #ai-notes-smart-copy[data-theme=\"dark\"] .ansc-btn-danger:hover {\n            background-color: #450a0a;\n        }\n\n        \/* Dropdowns & Inputs *\/\n        .ansc-select, .ansc-input {\n            background-color: var(--bg-secondary);\n            color: var(--text-primary);\n            border: 1px solid var(--border-color);\n            padding: 8px 12px;\n            border-radius: 6px;\n            font-size: 0.875rem;\n            outline: none;\n            max-width: 100%;\n            min-height: 40px;\n        }\n\n        .ansc-select:focus, .ansc-input:focus {\n            border-color: var(--accent-color);\n            box-shadow: 0 0 0 2px var(--accent-light);\n        }\n\n        \/* Main Workspace Layout *\/\n        .ansc-workspace {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 20px;\n            flex: 1;\n            min-width: 0;\n        }\n\n        @media (max-width: 900px) {\n            .ansc-workspace {\n                grid-template-columns: 1fr;\n            }\n        }\n\n        .ansc-panel {\n            background: var(--bg-card);\n            border: 1px solid var(--border-color);\n            border-radius: var(--radius);\n            box-shadow: var(--shadow-sm);\n            display: flex;\n            flex-direction: column;\n            overflow: hidden;\n            min-height: 400px;\n            min-width: 0;\n        }\n\n        .ansc-panel-header {\n            padding: 12px 16px;\n            border-bottom: 1px solid var(--border-color);\n            display: flex;\n            justify-content: space-between;\n            align-items: center;\n            background-color: var(--bg-secondary);\n            gap: 8px;\n            flex-wrap: wrap;\n        }\n\n        .ansc-panel-title {\n            font-weight: 600;\n            font-size: 0.95rem;\n            margin: 0;\n            color: var(--text-primary);\n        }\n\n        .ansc-panel-body {\n            flex: 1;\n            display: flex;\n            flex-direction: column;\n            position: relative;\n            min-width: 0;\n        }\n\n        \/* Editors and Previews *\/\n        .ansc-textarea, .ansc-preview-pane {\n            flex: 1;\n            width: 100%;\n            border: none;\n            padding: 16px;\n            resize: none;\n            font-family: inherit;\n            font-size: 0.95rem;\n            line-height: 1.6;\n            background: transparent;\n            color: var(--text-primary);\n            outline: none;\n            word-break: break-word;\n            overflow-wrap: anywhere;\n        }\n\n        .ansc-preview-pane {\n            overflow-y: auto;\n        }\n\n        .ansc-preview-pane h1, .ansc-preview-pane h2, .ansc-preview-pane h3 {\n            margin-top: 1em;\n            margin-bottom: 0.5em;\n            color: var(--text-primary);\n        }\n\n        .ansc-preview-pane ul, .ansc-preview-pane ol {\n            padding-left: 20px;\n            margin-bottom: 1em;\n        }\n\n        .ansc-preview-pane pre {\n            background: var(--bg-primary);\n            padding: 10px;\n            border-radius: 4px;\n            overflow-x: auto;\n        }\n\n        \/* Stats Bar *\/\n        .ansc-stats-bar {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 16px;\n            background: var(--bg-card);\n            padding: 10px 16px;\n            border-radius: var(--radius);\n            border: 1px solid var(--border-color);\n            font-size: 0.8rem;\n            color: var(--text-secondary);\n            align-items: center;\n        }\n\n        .ansc-stat-item {\n            display: flex;\n            gap: 4px;\n        }\n\n        .ansc-stat-value {\n            font-weight: 600;\n            color: var(--text-primary);\n        }\n\n        \/* Footer *\/\n        .ansc-footer {\n            text-align: center;\n            font-size: 0.8rem;\n            color: var(--text-secondary);\n            padding: 10px 0;\n        }\n\n        \/* Toast Notifications *\/\n        .ansc-toast-container {\n            position: fixed;\n            bottom: 20px;\n            right: 20px;\n            display: flex;\n            flex-direction: column;\n            gap: 10px;\n            z-index: 99999;\n        }\n\n        .ansc-toast {\n            background: var(--bg-card);\n            color: var(--text-primary);\n            border: 1px solid var(--border-color);\n            padding: 12px 18px;\n            border-radius: 6px;\n            box-shadow: var(--shadow-md);\n            font-size: 0.875rem;\n            display: flex;\n            align-items: center;\n            gap: 10px;\n            animation: anscSlideIn 0.2s ease-out;\n        }\n\n        .ansc-toast.success { border-left: 4px solid var(--success-color); }\n        .ansc-toast.error { border-left: 4px solid var(--danger-color); }\n\n        @keyframes anscSlideIn {\n            from { transform: translateY(100%); opacity: 0; }\n            to { transform: translateY(0); opacity: 1; }\n        }\n\n        \/* Modal Overlay *\/\n        .ansc-modal-backdrop {\n            position: fixed;\n            top: 0; left: 0; width: 100%; height: 100%;\n            background: rgba(0, 0, 0, 0.5);\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            z-index: 100000;\n            opacity: 0;\n            pointer-events: none;\n            transition: opacity 0.2s;\n            padding: 16px;\n        }\n\n        .ansc-modal-backdrop.active {\n            opacity: 1;\n            pointer-events: auto;\n        }\n\n        .ansc-modal {\n            background: var(--bg-card);\n            border: 1px solid var(--border-color);\n            border-radius: var(--radius);\n            width: 100%;\n            max-width: 500px;\n            padding: 24px;\n            box-shadow: var(--shadow-md);\n            display: flex;\n            flex-direction: column;\n            gap: 16px;\n            max-height: 90vh;\n            overflow-y: auto;\n        }\n\n        .ansc-modal h3 {\n            margin: 0;\n            font-size: 1.2rem;\n            color: var(--text-primary);\n        }\n\n        \/* Print CSS *\/\n        @media print {\n            body * {\n                visibility: hidden !important;\n            }\n            #ai-notes-smart-copy, #ai-notes-smart-copy * {\n                visibility: visible !important;\n            }\n            #ai-notes-smart-copy {\n                position: absolute !important;\n                left: 0 !important;\n                top: 0 !important;\n                width: 100% !important;\n                background: #ffffff !important;\n                color: #000000 !important;\n                padding: 0 !important;\n            }\n            .ansc-toolbar, .ansc-header-actions, .ansc-search-bar, .ansc-stats-bar, .ansc-footer, .ansc-panel:first-child, .ansc-header {\n                display: none !important;\n            }\n            .ansc-workspace {\n                display: block !important;\n            }\n            .ansc-panel {\n                border: none !important;\n                box-shadow: none !important;\n                height: auto !important;\n                background: transparent !important;\n            }\n        }\n    <\/style>\n<\/head>\n<body>\n\n<div id=\"ai-notes-smart-copy\" data-theme=\"light\">\n    <div class=\"ansc-container\">\n        \n        <!-- Header -->\n        <header class=\"ansc-header\">\n            <div class=\"ansc-title-area\">\n                <h2>AI Notes Smart Copy<\/h2>\n                <p class=\"ansc-subtitle\">Client-side intelligent note cleaner, formatter, and multi-format exporter.<\/p>\n            <\/div>\n            <div class=\"ansc-header-actions\">\n                <button class=\"ansc-btn\" id=\"anscNewBtn\" title=\"Create New Document\" aria-label=\"Create New Document\" type=\"button\">\ud83d\udcc4 New<\/button>\n                <button class=\"ansc-btn\" id=\"anscRecentBtn\" title=\"Recent Documents\" aria-label=\"Recent Documents\" type=\"button\">\ud83d\udcc2 Recent<\/button>\n                <button class=\"ansc-btn\" id=\"anscPrintBtn\" title=\"Print Notes\" aria-label=\"Print Notes\" type=\"button\">\ud83d\udda8\ufe0f Print<\/button>\n                <button class=\"ansc-btn\" id=\"anscThemeBtn\" title=\"Toggle Theme\" aria-label=\"Toggle Theme\" type=\"button\">\ud83c\udf19 Theme<\/button>\n            <\/div>\n        <\/header>\n\n        <!-- Toolbar -->\n        <div class=\"ansc-toolbar\">\n            <div class=\"ansc-toolbar-group\">\n                <button class=\"ansc-btn ansc-btn-primary\" id=\"anscPasteBtn\" aria-label=\"Paste Notes\" type=\"button\">\ud83d\udccb Paste Notes<\/button>\n                <button class=\"ansc-btn\" id=\"anscDetectBtn\" aria-label=\"Detect Structure\" type=\"button\">\ud83d\udd0d Detect Structure<\/button>\n                <select class=\"ansc-select\" id=\"anscFormatStyleSelect\" aria-label=\"Format Style\">\n                    <option value=\"study\">Study Notes<\/option>\n                    <option value=\"clean\">Clean Notes<\/option>\n                    <option value=\"outline\">Outline<\/option>\n                    <option value=\"revision\">Revision Notes<\/option>\n                    <option value=\"qa\">Q&#038;A Notes<\/option>\n                    <option value=\"summary\">Summary<\/option>\n                    <option value=\"bullets\">Bullet Points<\/option>\n                    <option value=\"exam\">Exam Revision<\/option>\n                    <option value=\"cornell\">Cornell-style Notes<\/option>\n                <\/select>\n                <button class=\"ansc-btn ansc-btn-primary\" id=\"anscFormatBtn\" aria-label=\"Format Notes\" type=\"button\">\u26a1 Format<\/button>\n            <\/div>\n            <div class=\"ansc-toolbar-group\">\n                <button class=\"ansc-btn\" id=\"anscUndoBtn\" title=\"Undo (Ctrl+Z)\" aria-label=\"Undo\" type=\"button\">\u21a9\ufe0f Undo<\/button>\n                <button class=\"ansc-btn\" id=\"anscRedoBtn\" title=\"Redo (Ctrl+Y)\" aria-label=\"Redo\" type=\"button\">\u21aa\ufe0f Redo<\/button>\n                <button class=\"ansc-btn\" id=\"anscSearchToggleBtn\" title=\"Search (Ctrl+F)\" aria-label=\"Search\" type=\"button\">\ud83d\udd0e Search<\/button>\n                <button class=\"ansc-btn ansc-btn-danger\" id=\"anscClearBtn\" aria-label=\"Clear Editor\" type=\"button\">\ud83d\uddd1\ufe0f Clear<\/button>\n            <\/div>\n        <\/div>\n\n        <!-- Search & Replace Bar -->\n        <div class=\"ansc-search-bar\" id=\"anscSearchBar\">\n            <div class=\"ansc-search-row\">\n                <input type=\"text\" class=\"ansc-input\" id=\"anscSearchInput\" placeholder=\"Find...\" aria-label=\"Find text\" style=\"flex: 1;\">\n                <input type=\"text\" class=\"ansc-input\" id=\"anscReplaceInput\" placeholder=\"Replace with...\" aria-label=\"Replace with text\" style=\"flex: 1;\">\n                <label style=\"font-size: 0.85rem; display: flex; align-items: center; gap: 4px; cursor: pointer;\">\n                    <input type=\"checkbox\" id=\"anscCaseCheck\" aria-label=\"Case sensitive\"> Case sensitive\n                <\/label>\n                <button class=\"ansc-btn\" id=\"anscSearchCloseBtn\" aria-label=\"Close search\" type=\"button\">\u2715<\/button>\n            <\/div>\n            <div class=\"ansc-search-row\">\n                <span id=\"anscMatchCountLabel\" style=\"font-size: 0.8rem; color: var(--text-secondary);\">0 matches<\/span>\n                <button class=\"ansc-btn\" id=\"anscSearchPrevBtn\" aria-label=\"Previous match\" type=\"button\">Previous<\/button>\n                <button class=\"ansc-btn\" id=\"anscSearchNextBtn\" aria-label=\"Next match\" type=\"button\">Next<\/button>\n                <button class=\"ansc-btn\" id=\"anscReplaceBtn\" aria-label=\"Replace current match\" type=\"button\">Replace<\/button>\n                <button class=\"ansc-btn ansc-btn-primary\" id=\"anscReplaceAllBtn\" aria-label=\"Replace all matches\" type=\"button\">Replace All<\/button>\n            <\/div>\n        <\/div>\n\n        <!-- Workspace -->\n        <div class=\"ansc-workspace\">\n            <!-- Left Panel: Editor \/ Input -->\n            <div class=\"ansc-panel\">\n                <div class=\"ansc-panel-header\">\n                    <input type=\"text\" class=\"ansc-input\" id=\"anscTitleInput\" value=\"Untitled Notes\" aria-label=\"Document Title\" style=\"border: none; background: transparent; font-weight: 600; padding: 0; width: 100%;\">\n                    <span id=\"anscSaveStatus\" style=\"font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap;\">New<\/span>\n                <\/div>\n                <div class=\"ansc-panel-body\">\n                    <textarea class=\"ansc-textarea\" id=\"anscEditor\" placeholder=\"Paste or type your messy notes here...\" aria-label=\"Notes Editor\"><\/textarea>\n                <\/div>\n            <\/div>\n\n            <!-- Right Panel: Preview \/ Formatted Result -->\n            <div class=\"ansc-panel\">\n                <div class=\"ansc-panel-header\">\n                    <h3 class=\"ansc-panel-title\">Formatted Preview<\/h3>\n                    <div class=\"ansc-toolbar-group\" style=\"gap: 6px;\">\n                        <button class=\"ansc-btn\" id=\"anscCopyBtn\" aria-label=\"Copy Formatted Notes\" type=\"button\">\ud83d\udccb Copy<\/button>\n                        <select class=\"ansc-select\" id=\"anscExportFormatSelect\" aria-label=\"Export Format\" style=\"padding: 6px 8px;\">\n                            <option value=\"txt\">.txt<\/option>\n                            <option value=\"md\">.md<\/option>\n                            <option value=\"html\">.html<\/option>\n                            <option value=\"json\">.json<\/option>\n                            <option value=\"csv\">.csv<\/option>\n                            <option value=\"rtf\">.rtf<\/option>\n                        <\/select>\n                        <button class=\"ansc-btn\" id=\"anscDownloadBtn\" aria-label=\"Download File\" type=\"button\">\ud83d\udcbe Download<\/button>\n                        <button class=\"ansc-btn ansc-btn-primary\" id=\"anscSaveBtn\" aria-label=\"Save Note\" type=\"button\">Save<\/button>\n                    <\/div>\n                <\/div>\n                <div class=\"ansc-panel-body\">\n                    <div class=\"ansc-preview-pane\" id=\"anscPreview\" role=\"region\" aria-label=\"Formatted Preview Pane\">Your formatted notes preview will appear here&#8230;<\/div>\n                <\/div>\n            <\/div>\n        <\/div>\n\n        <!-- Statistics Bar -->\n        <div class=\"ansc-stats-bar\">\n            <div class=\"ansc-stat-item\">Words: <span class=\"ansc-stat-value\" id=\"anscStatWords\">0<\/span><\/div>\n            <div class=\"ansc-stat-item\">Characters: <span class=\"ansc-stat-value\" id=\"anscStatChars\">0<\/span><\/div>\n            <div class=\"ansc-stat-item\">Chars (no spaces): <span class=\"ansc-stat-value\" id=\"anscStatCharsNoSpace\">0<\/span><\/div>\n            <div class=\"ansc-stat-item\">Lines: <span class=\"ansc-stat-value\" id=\"anscStatLines\">0<\/span><\/div>\n            <div class=\"ansc-stat-item\">Paragraphs: <span class=\"ansc-stat-value\" id=\"anscStatParagraphs\">0<\/span><\/div>\n            <div class=\"ansc-stat-item\">Reading Time: <span class=\"ansc-stat-value\" id=\"anscStatReadingTime\">0 min<\/span><\/div>\n        <\/div>\n\n        <!-- Footer -->\n        <footer class=\"ansc-footer\">\n            AI Notes Smart Copy &copy; 2026. Fully Client-Side &#038; Secure.\n        <\/footer>\n\n    <\/div>\n<\/div>\n\n<!-- Paste Modal -->\n<div class=\"ansc-modal-backdrop\" id=\"anscPasteModal\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"anscPasteTitle\">\n    <div class=\"ansc-modal\">\n        <h3 id=\"anscPasteTitle\">Paste Your Notes<\/h3>\n        <p style=\"font-size: 0.85rem; color: var(--text-secondary); margin: 0;\">Paste text below to insert into your editor:<\/p>\n        <textarea id=\"anscModalPasteInput\" placeholder=\"Paste text here...\" aria-label=\"Paste modal input\" style=\"width: 100%; height: 150px; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-secondary); color: var(--text-primary); resize: vertical; outline: none;\"><\/textarea>\n        <div class=\"ansc-modal-actions\" style=\"display: flex; justify-content: flex-end; gap: 10px;\">\n            <button class=\"ansc-btn\" id=\"anscModalCancelBtn\" aria-label=\"Cancel paste\" type=\"button\">Cancel<\/button>\n            <button class=\"ansc-btn ansc-btn-primary\" id=\"anscModalInsertBtn\" aria-label=\"Insert text\" type=\"button\">Insert Text<\/button>\n        <\/div>\n    <\/div>\n<\/div>\n\n<!-- Recent Documents Modal -->\n<div class=\"ansc-modal-backdrop\" id=\"anscRecentModal\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"anscRecentTitle\">\n    <div class=\"ansc-modal\" style=\"max-width: 600px;\">\n        <h3 id=\"anscRecentTitle\">Recent Notes<\/h3>\n        <div id=\"anscRecentList\" style=\"display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto;\" role=\"region\" aria-label=\"Recent Notes List\"><\/div>\n        <div class=\"ansc-modal-actions\" style=\"display: flex; justify-content: flex-end; gap: 10px;\">\n            <button class=\"ansc-btn\" id=\"anscRecentCloseBtn\" aria-label=\"Close recent notes\" type=\"button\">Close<\/button>\n        <\/div>\n    <\/div>\n<\/div>\n\n<!-- Draft Recovery Modal -->\n<div class=\"ansc-modal-backdrop\" id=\"anscDraftModal\" role=\"dialog\" aria-modal=\"true\" aria-labelledby=\"anscDraftTitle\">\n    <div class=\"ansc-modal\">\n        <h3 id=\"anscDraftTitle\">Recover Unsaved Draft?<\/h3>\n        <p style=\"font-size: 0.9rem; color: var(--text-secondary); margin: 0;\">An unsaved draft from your previous session was found.<\/p>\n        <div class=\"ansc-modal-actions\" style=\"display: flex; justify-content: flex-end; gap: 10px;\">\n            <button class=\"ansc-btn\" id=\"anscDraftDiscardBtn\" aria-label=\"Discard draft\" type=\"button\">Discard<\/button>\n            <button class=\"ansc-btn ansc-btn-primary\" id=\"anscDraftRecoverBtn\" aria-label=\"Recover draft\" type=\"button\">Recover<\/button>\n        <\/div>\n    <\/div>\n<\/div>\n\n<!-- Toast Container -->\n<div class=\"ansc-toast-container\" id=\"anscToastContainer\" aria-live=\"polite\"><\/div>\n\n<script>\n(() => {\n    'use strict';\n\n    const rootEl = document.getElementById('ai-notes-smart-copy');\n    if (!rootEl) return;\n    if (rootEl.dataset.initialized === 'true') return;\n    rootEl.dataset.initialized = 'true';\n\n    const NOTES_KEY = 'ai_notes_smart_copy_notes';\n    const DRAFT_KEY = 'ai_notes_smart_copy_draft';\n    const THEME_KEY = 'ai_notes_smart_copy_theme';\n\n    const state = {\n        title: 'Untitled Notes',\n        content: '',\n        formattedContent: '',\n        mode: 'study',\n        exportFormat: 'txt',\n        currentNoteId: null,\n        dirty: false,\n        formattedStale: true,\n        isRestoringHistory: false,\n        history: [''],\n        historyIndex: 0,\n        searchMatchIndex: -1,\n        searchMatches: [],\n        theme: 'light',\n        activeModal: null,\n        lastFocusedElement: null,\n        structure: { title: '', headings: [], bullets: [], numberedItems: [], questions: [], paragraphs: [] }\n    };\n\n    let autoSaveTimer = null;\n\n    const editorEl = rootEl.querySelector('#anscEditor');\n    const previewEl = rootEl.querySelector('#anscPreview');\n    const titleInputEl = rootEl.querySelector('#anscTitleInput');\n    const saveStatusEl = rootEl.querySelector('#anscSaveStatus');\n\n    const newBtn = rootEl.querySelector('#anscNewBtn');\n    const recentBtn = rootEl.querySelector('#anscRecentBtn');\n    const printBtn = rootEl.querySelector('#anscPrintBtn');\n    const themeBtn = rootEl.querySelector('#anscThemeBtn');\n    const pasteBtn = rootEl.querySelector('#anscPasteBtn');\n    const clearBtn = rootEl.querySelector('#anscClearBtn');\n    const formatBtn = rootEl.querySelector('#anscFormatBtn');\n    const detectBtn = rootEl.querySelector('#anscDetectBtn');\n    const formatStyleSelect = rootEl.querySelector('#anscFormatStyleSelect');\n    const copyBtn = rootEl.querySelector('#anscCopyBtn');\n    const downloadBtn = rootEl.querySelector('#anscDownloadBtn');\n    const saveBtn = rootEl.querySelector('#anscSaveBtn');\n    const exportFormatSelect = rootEl.querySelector('#anscExportFormatSelect');\n\n    const undoBtn = rootEl.querySelector('#anscUndoBtn');\n    const redoBtn = rootEl.querySelector('#anscRedoBtn');\n    const searchToggleBtn = rootEl.querySelector('#anscSearchToggleBtn');\n    const searchBar = rootEl.querySelector('#anscSearchBar');\n    const searchInput = rootEl.querySelector('#anscSearchInput');\n    const replaceInput = rootEl.querySelector('#anscReplaceInput');\n    const caseCheck = rootEl.querySelector('#anscCaseCheck');\n    const matchCountLabel = rootEl.querySelector('#anscMatchCountLabel');\n    const searchPrevBtn = rootEl.querySelector('#anscSearchPrevBtn');\n    const searchNextBtn = rootEl.querySelector('#anscSearchNextBtn');\n    const replaceBtn = rootEl.querySelector('#anscReplaceBtn');\n    const replaceAllBtn = rootEl.querySelector('#anscReplaceAllBtn');\n    const searchCloseBtn = rootEl.querySelector('#anscSearchCloseBtn');\n\n    const statWords = rootEl.querySelector('#anscStatWords');\n    const statChars = rootEl.querySelector('#anscStatChars');\n    const statCharsNoSpace = rootEl.querySelector('#anscStatCharsNoSpace');\n    const statLines = rootEl.querySelector('#anscStatLines');\n    const statParagraphs = rootEl.querySelector('#anscStatParagraphs');\n    const statReadingTime = rootEl.querySelector('#anscStatReadingTime');\n    const toastContainer = rootEl.querySelector('#anscToastContainer');\n\n    const pasteModal = rootEl.querySelector('#anscPasteModal');\n    const modalPasteInput = rootEl.querySelector('#anscModalPasteInput');\n    const modalCancelBtn = rootEl.querySelector('#anscModalCancelBtn');\n    const modalInsertBtn = rootEl.querySelector('#anscModalInsertBtn');\n\n    const recentModal = rootEl.querySelector('#anscRecentModal');\n    const recentList = rootEl.querySelector('#anscRecentList');\n    const recentCloseBtn = rootEl.querySelector('#anscRecentCloseBtn');\n\n    const draftModal = rootEl.querySelector('#anscDraftModal');\n    const draftRecoverBtn = rootEl.querySelector('#anscDraftRecoverBtn');\n    const draftDiscardBtn = rootEl.querySelector('#anscDraftDiscardBtn');\n\n    function showToast(message, type = 'success') {\n        try {\n            if (!toastContainer) return;\n            const toast = document.createElement('div');\n            toast.className = `ansc-toast ${type}`;\n            toast.textContent = message;\n            toastContainer.appendChild(toast);\n            setTimeout(() => {\n                toast.style.opacity = '0';\n                setTimeout(() => toast.remove(), 200);\n            }, 3000);\n        } catch (e) {}\n    }\n\n    function updateSaveState(status) {\n        if (saveStatusEl) saveStatusEl.textContent = status;\n    }\n\n    function generateUUID() {\n        if (typeof crypto !== 'undefined' && crypto.randomUUID) return crypto.randomUUID();\n        return 'note_' + Date.now() + '_' + Math.random().toString(36).substring(2, 9);\n    }\n\n    function escapeHtml(str) {\n        if (!str) return '';\n        return String(str).replace(\/&\/g, \"&amp;\").replace(\/<\/g, \"&lt;\").replace(\/>\/g, \"&gt;\").replace(\/\"\/g, \"&quot;\").replace(\/'\/g, \"&#039;\");\n    }\n\n    function sanitizeFilename(name) {\n        if (!name || typeof name !== 'string') return 'ai-notes';\n        return name.toLowerCase().replace(\/[\\\\\/:*?\"<>|]\/g, '').trim().replace(\/\\s+\/g, '-').replace(\/-+\/g, '-').replace(\/^-|-$\/g, '') || 'ai-notes';\n    }\n\n    function updateStats(text) {\n        if (!text || typeof text !== 'string') {\n            if (statWords) statWords.textContent = '0';\n            if (statChars) statChars.textContent = '0';\n            if (statCharsNoSpace) statCharsNoSpace.textContent = '0';\n            if (statLines) statLines.textContent = '0';\n            if (statParagraphs) statParagraphs.textContent = '0';\n            if (statReadingTime) statReadingTime.textContent = '0 min';\n            return;\n        }\n        const chars = text.length;\n        const charsNoSpace = text.replace(\/\\s\/g, '').length;\n        const wordsMatch = text.match(\/[\\p{L}\\p{N}_]+\/gu);\n        const words = wordsMatch ? wordsMatch.length : 0;\n        const lines = text === '' ? 0 : text.split(\/\\r\\n|\\r|\\n\/).length;\n        const paragraphs = text === '' ? 0 : text.split(\/\\n\\s*\\n\/).filter(p => p.trim().length > 0).length;\n        const readingTimeMins = Math.max(1, Math.ceil(words \/ 200));\n\n        if (statWords) statWords.textContent = words;\n        if (statChars) statChars.textContent = chars;\n        if (statCharsNoSpace) statCharsNoSpace.textContent = charsNoSpace;\n        if (statLines) statLines.textContent = lines;\n        if (statParagraphs) statParagraphs.textContent = paragraphs;\n        if (statReadingTime) statReadingTime.textContent = `${readingTimeMins} min`;\n    }\n\n    function renderPreview() {\n        if (!previewEl) return;\n        if (state.formattedStale || !state.formattedContent || !state.formattedContent.trim()) {\n            previewEl.innerHTML = state.content.trim() ? '<i>Notes changed. Click <b>Format<\/b> to refresh preview.<\/i>' : 'Your formatted notes preview will appear here...';\n            return;\n        }\n\n        const escaped = escapeHtml(state.formattedContent);\n        const html = escaped.split('\\n').map(line => {\n            const t = line.trim();\n            if (t.startsWith('# ')) return `<h1>${t.substring(2)}<\/h1>`;\n            if (t.startsWith('## ')) return `<h2>${t.substring(3)}<\/h2>`;\n            if (t.startsWith('### ')) return `<h3>${t.substring(4)}<\/h3>`;\n            if (t.startsWith('\u2022 ') || t.startsWith('- ') || t.startsWith('* ')) return `<li>${t.substring(2)}<\/li>`;\n            if (\/^\\d+\\.\\s\/.test(t)) return `<li>${t.replace(\/^\\d+\\.\\s\/, '')}<\/li>`;\n            if (t === '') return '<br>';\n            return `<p>${t}<\/p>`;\n        }).join('');\n        previewEl.innerHTML = html;\n    }\n\n    function pushHistory(newContent) {\n        if (state.isRestoringHistory) return;\n        if (state.history[state.historyIndex] === newContent) return;\n        state.history = state.history.slice(0, state.historyIndex + 1);\n        state.history.push(newContent);\n        if (state.history.length > 50) state.history.shift();\n        state.historyIndex = state.history.length - 1;\n    }\n\n    function undo() {\n        if (state.historyIndex > 0) {\n            state.isRestoringHistory = true;\n            state.historyIndex--;\n            state.content = state.history[state.historyIndex];\n            if (editorEl) editorEl.value = state.content;\n            state.formattedStale = true;\n            updateStats(state.content);\n            renderPreview();\n            state.isRestoringHistory = false;\n            markDirty();\n            showToast('Undo performed', 'success');\n        } else {\n            showToast('Nothing more to undo', 'error');\n        }\n    }\n\n    function redo() {\n        if (state.historyIndex < state.history.length - 1) {\n            state.isRestoringHistory = true;\n            state.historyIndex++;\n            state.content = state.history[state.historyIndex];\n            if (editorEl) editorEl.value = state.content;\n            state.formattedStale = true;\n            updateStats(state.content);\n            renderPreview();\n            state.isRestoringHistory = false;\n            markDirty();\n            showToast('Redo performed', 'success');\n        } else {\n            showToast('Nothing more to redo', 'error');\n        }\n    }\n\n    function markDirty() {\n        state.dirty = true;\n        updateSaveState('Unsaved');\n        if (autoSaveTimer) clearTimeout(autoSaveTimer);\n        autoSaveTimer = setTimeout(() => {\n            try {\n                const draft = { title: titleInputEl ? titleInputEl.value : state.title, content: state.content, timestamp: Date.now() };\n                localStorage.setItem(DRAFT_KEY, JSON.stringify(draft));\n            } catch (e) {}\n        }, 1000);\n    }\n\n    function formatNotes(style) {\n        const text = state.content || '';\n        if (!text.trim()) {\n            showToast('Editor is empty. Nothing to format.', 'error');\n            return;\n        }\n\n        const lines = text.split(\/\\r\\n|\\r|\\n\/);\n        let result = '';\n\n        switch (style) {\n            case 'study':\n                result = `# \ud83d\udcda Study Notes: ${titleInputEl ? titleInputEl.value : 'Document'}\\n\\n## \ud83c\udfaf Key Objectives\\n\u2022 Review core principles and summaries below.\\n\\n## \ud83d\udcdd Core Concepts\\n`;\n                lines.forEach(l => { if (l.trim()) result += `\u2022 ${l.trim()}\\n`; });\n                result += `\\n## \u2705 Summary & Takeaways\\n\u2022 Successfully cleaned and structured.`;\n                break;\n            case 'clean':\n                result = lines.filter(l => l.trim().length > 0).map(l => l.trim()).join('\\n\\n');\n                break;\n            case 'outline':\n                result = `# Outline: ${titleInputEl ? titleInputEl.value : 'Notes'}\\n\\n`;\n                lines.forEach((l, idx) => { if (l.trim()) { if (idx % 3 === 0) result += `### \ud83d\udccc ${l.trim()}\\n`; else result += `  - ${l.trim()}\\n`; } });\n                break;\n            case 'revision':\n                result = `# \ud83d\udd04 Revision Notes\\n\\n`;\n                lines.forEach(l => { if (l.trim()) result += `> \ud83d\udca1 **Review:** ${l.trim()}\\n\\n`; });\n                break;\n            case 'qa':\n                result = `# \u2753 Q&A Notes\\n\\n`;\n                lines.forEach((l, idx) => { if (l.trim()) { result += `**Q${idx + 1}: What is meant by \"${l.trim().substring(0, 30)}...\"?**\\nA: ${l.trim()}\\n\\n`; } });\n                break;\n            case 'summary':\n                result = `# \ud83d\udccb Executive Summary\\n\\nThis document contains summarized notes containing ${lines.length} lines.\\n\\n## Key Highlights:\\n`;\n                lines.slice(0, 5).forEach(l => { if (l.trim()) result += `\u2022 ${l.trim()}\\n`; });\n                break;\n            case 'bullets':\n                result = lines.filter(l => l.trim()).map(l => `\u2022 ${l.trim()}`).join('\\n');\n                break;\n            case 'exam':\n                result = `# \ud83d\udea8 Exam High-Yield Points\\n\\n`;\n                lines.forEach(l => { if (l.trim()) result += `\ud83d\udd25 **Must Memorize:** ${l.trim()}\\n\\n`; });\n                break;\n            case 'cornell':\n                result = `# \ud83c\udf93 Cornell Notes\\n\\n## Cues \/ Questions\\n- Key concept overview\\n\\n## Notes\\n`;\n                lines.forEach(l => { if (l.trim()) result += `  ${l.trim()}\\n`; });\n                result += `\\n## Summary\\n- Brief synthesis.`;\n                break;\n            default:\n                result = text;\n        }\n\n        state.formattedContent = result;\n        state.formattedStale = false;\n        renderPreview();\n        showToast('Notes formatted successfully!', 'success');\n    }\n\n    function detectStructure() {\n        const text = state.content || '';\n        if (!text.trim()) {\n            showToast('No content to analyze.', 'error');\n            return;\n        }\n        const lines = text.split(\/\\r\\n|\\r|\\n\/);\n        let headings = 0, bullets = 0;\n        lines.forEach(l => {\n            const t = l.trim();\n            if (t.startsWith('#') || (t === t.toUpperCase() && t.length < 50)) headings++;\n            else if (t.startsWith('\u2022') || t.startsWith('-') || t.startsWith('*')) bullets++;\n        });\n        showToast(`Structure detected: ${headings} headings, ${bullets} bullets found.`, 'success');\n    }\n\n    function openModal(modalEl) {\n        if (!modalEl) return;\n        state.lastFocusedElement = document.activeElement;\n        modalEl.classList.add('active');\n        state.activeModal = modalEl;\n    }\n\n    function closeModal(modalEl) {\n        if (!modalEl) return;\n        modalEl.classList.remove('active');\n        state.activeModal = null;\n        if (state.lastFocusedElement &#038;&#038; typeof state.lastFocusedElement.focus === 'function') state.lastFocusedElement.focus();\n    }\n\n    function setTheme(theme) {\n        state.theme = theme;\n        if (rootEl) rootEl.setAttribute('data-theme', theme);\n        try { localStorage.setItem(THEME_KEY, theme); } catch (e) {}\n    }\n\n    function toggleTheme() {\n        setTheme(state.theme === 'light' ? 'dark' : 'light');\n    }\n\n    function downloadFile() {\n        const textToExport = state.formattedStale || !state.formattedContent ? state.content : state.formattedContent;\n        const format = exportFormatSelect ? exportFormatSelect.value : 'txt';\n        const title = titleInputEl ? titleInputEl.value : 'ai-notes';\n        const filename = `${sanitizeFilename(title)}.${format}`;\n\n        let mimeType = 'text\/plain;charset=utf-8';\n        let content = textToExport;\n\n        if (format === 'html') {\n            mimeType = 'text\/html;charset=utf-8';\n            content = `<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>${escapeHtml(title)}<\/title><\/head><body>${previewEl ? previewEl.innerHTML : escapeHtml(content)}<\/body><\/html>`;\n        } else if (format === 'json') {\n            mimeType = 'application\/json;charset=utf-8';\n            content = JSON.stringify({ title, content: textToExport, exportedAt: new Date().toISOString() }, null, 2);\n        } else if (format === 'csv') {\n            mimeType = 'text\/csv;charset=utf-8';\n            content = `\"Line\"\\n` + textToExport.split('\\n').map(l => `\"${l.replace(\/\"\/g, '\"\"')}\"`).join('\\n');\n        } else if (format === 'rtf') {\n            mimeType = 'application\/rtf;charset=utf-8';\n            content = `{\\\\rtf1\\\\ansi\\\\deff0 {\\\\fonttbl {\\\\f0 Arial;}} \\\\f0\\\\fs20 ${textToExport.replace(\/\\n\/g, '\\\\par ')}}`;\n        }\n\n        const blob = new Blob([content], { type: mimeType });\n        const url = URL.createObjectURL(blob);\n        const a = document.createElement('a');\n        a.href = url;\n        a.download = filename;\n        document.body.appendChild(a);\n        a.click();\n        document.body.removeChild(a);\n        URL.revokeObjectURL(url);\n        showToast(`File downloaded as ${filename}`, 'success');\n    }\n\n    function saveNote() {\n        const title = titleInputEl ? titleInputEl.value.trim() || 'Untitled Notes' : 'Untitled Notes';\n        const noteId = state.currentNoteId || generateUUID();\n        const noteData = { id: noteId, title, content: state.content, updatedAt: Date.now() };\n\n        try {\n            let notes = JSON.parse(localStorage.getItem(NOTES_KEY) || '[]');\n            const existingIndex = notes.findIndex(n => n.id === noteId);\n            if (existingIndex >= 0) notes[existingIndex] = noteData;\n            else notes.unshift(noteData);\n            localStorage.setItem(NOTES_KEY, JSON.stringify(notes));\n            state.currentNoteId = noteId;\n            state.dirty = false;\n            updateSaveState('Saved');\n            localStorage.removeItem(DRAFT_KEY);\n            showToast('Note saved successfully!', 'success');\n        } catch (e) {\n            showToast('Failed to save note.', 'error');\n        }\n    }\n\n    function loadRecentNotesList() {\n        if (!recentList) return;\n        recentList.innerHTML = '';\n        try {\n            const notes = JSON.parse(localStorage.getItem(NOTES_KEY) || '[]');\n            if (notes.length === 0) {\n                recentList.innerHTML = '<p style=\"color: var(--text-secondary); text-align: center; padding: 20px;\">No saved notes found.<\/p>';\n                return;\n            }\n            notes.forEach(note => {\n                const item = document.createElement('div');\n                item.style.cssText = 'display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer;';\n                item.innerHTML = `\n                    <div>\n                        <div style=\"font-weight: 600; font-size: 0.9rem; color: var(--text-primary);\">${escapeHtml(note.title)}<\/div>\n                        <div style=\"font-size: 0.75rem; color: var(--text-secondary);\">${new Date(note.updatedAt).toLocaleString()}<\/div>\n                    <\/div>\n                    <button class=\"ansc-btn ansc-btn-danger\" style=\"padding: 4px 8px; min-height: 30px; font-size: 0.75rem;\" data-id=\"${note.id}\">Delete<\/button>\n                `;\n                item.addEventListener('click', (e) => {\n                    if (e.target.tagName === 'BUTTON') {\n                        e.stopPropagation();\n                        try {\n                            let nList = JSON.parse(localStorage.getItem(NOTES_KEY) || '[]');\n                            nList = nList.filter(n => n.id !== note.id);\n                            localStorage.setItem(NOTES_KEY, JSON.stringify(nList));\n                            loadRecentNotesList();\n                            showToast('Note deleted', 'success');\n                        } catch (err) {}\n                        return;\n                    }\n                    state.currentNoteId = note.id;\n                    state.content = note.content;\n                    if (editorEl) editorEl.value = note.content;\n                    if (titleInputEl) titleInputEl.value = note.title;\n                    state.formattedStale = true;\n                    updateStats(note.content);\n                    renderPreview();\n                    updateSaveState('Saved');\n                    closeModal(recentModal);\n                    showToast('Note loaded successfully', 'success');\n                });\n                recentList.appendChild(item);\n            });\n        } catch (e) {\n            recentList.innerHTML = '<p style=\"color: var(--danger-color); text-align: center;\">Error loading recent notes.<\/p>';\n        }\n    }\n\n    function performSearch() {\n        if (!searchInput) return;\n        const query = searchInput.value;\n        const caseSensitive = caseCheck ? caseCheck.checked : false;\n        state.searchMatches = [];\n        state.searchMatchIndex = -1;\n\n        if (!query || !editorEl) {\n            if (matchCountLabel) matchCountLabel.textContent = '0 matches';\n            return;\n        }\n\n        const text = editorEl.value;\n        const flags = caseSensitive ? 'g' : 'gi';\n        try {\n            const regex = new RegExp(query.replace(\/[.*+?^${}()|[\\]\\\\]\/g, '\\\\$&'), flags);\n            let match;\n            while ((match = regex.exec(text)) !== null) {\n                state.searchMatches.push({ start: match.index, end: match.index + match[0].length });\n            }\n        } catch (e) {}\n\n        if (matchCountLabel) matchCountLabel.textContent = `${state.searchMatches.length} matches`;\n        if (state.searchMatches.length > 0) highlightMatch(0);\n    }\n\n    function highlightMatch(index) {\n        if (state.searchMatches.length === 0 || !editorEl) return;\n        state.searchMatchIndex = (index + state.searchMatches.length) % state.searchMatches.length;\n        const match = state.searchMatches[state.searchMatchIndex];\n        editorEl.focus();\n        editorEl.setSelectionRange(match.start, match.end);\n    }\n\n    function replaceCurrentMatch() {\n        if (state.searchMatchIndex < 0 || state.searchMatches.length === 0 || !editorEl || !replaceInput) return;\n        const match = state.searchMatches[state.searchMatchIndex];\n        const replacement = replaceInput.value;\n        const text = editorEl.value;\n        editorEl.value = text.substring(0, match.start) + replacement + text.substring(match.end);\n        state.content = editorEl.value;\n        markDirty();\n        pushHistory(state.content);\n        performSearch();\n    }\n\n    function replaceAllMatches() {\n        if (!searchInput || !replaceInput || !editorEl) return;\n        const query = searchInput.value;\n        const replacement = replaceInput.value;\n        if (!query) return;\n        const caseSensitive = caseCheck ? caseCheck.checked : false;\n        const flags = caseSensitive ? 'g' : 'gi';\n        try {\n            const regex = new RegExp(query.replace(\/[.*+?^${}()|[\\]\\\\]\/g, '\\\\$&#038;'), flags);\n            editorEl.value = editorEl.value.replace(regex, replacement);\n            state.content = editorEl.value;\n            markDirty();\n            pushHistory(state.content);\n            performSearch();\n            showToast('All matches replaced', 'success');\n        } catch (e) {}\n    }\n\n    function initListeners() {\n        if (editorEl) {\n            editorEl.addEventListener('input', () => {\n                state.content = editorEl.value;\n                state.formattedStale = true;\n                updateStats(state.content);\n                renderPreview();\n                markDirty();\n                pushHistory(state.content);\n            });\n        }\n\n        if (titleInputEl) titleInputEl.addEventListener('input', markDirty);\n        if (newBtn) newBtn.addEventListener('click', () => {\n            state.content = '';\n            state.currentNoteId = null;\n            if (editorEl) editorEl.value = '';\n            if (titleInputEl) titleInputEl.value = 'Untitled Notes';\n            state.formattedContent = '';\n            state.formattedStale = true;\n            updateStats('');\n            renderPreview();\n            updateSaveState('New');\n            showToast('New document created', 'success');\n        });\n\n        if (recentBtn) recentBtn.addEventListener('click', () => { loadRecentNotesList(); openModal(recentModal); });\n        if (recentCloseBtn) recentCloseBtn.addEventListener('click', () => closeModal(recentModal));\n        if (printBtn) printBtn.addEventListener('click', () => { formatNotes(formatStyleSelect ? formatStyleSelect.value : 'study'); window.print(); });\n        if (themeBtn) themeBtn.addEventListener('click', toggleTheme);\n\n        if (pasteBtn) pasteBtn.addEventListener('click', () => { if (modalPasteInput) modalPasteInput.value = ''; openModal(pasteModal); });\n        if (modalCancelBtn) modalCancelBtn.addEventListener('click', () => closeModal(pasteModal));\n        if (modalInsertBtn) {\n            modalInsertBtn.addEventListener('click', () => {\n                if (modalPasteInput && editorEl) {\n                    const text = modalPasteInput.value;\n                    const start = editorEl.selectionStart;\n                    const end = editorEl.selectionEnd;\n                    const val = editorEl.value;\n                    editorEl.value = val.substring(0, start) + text + val.substring(end);\n                    state.content = editorEl.value;\n                    state.formattedStale = true;\n                    updateStats(state.content);\n                    renderPreview();\n                    markDirty();\n                    pushHistory(state.content);\n                }\n                closeModal(pasteModal);\n                showToast('Text inserted', 'success');\n            });\n        }\n\n        if (clearBtn) clearBtn.addEventListener('click', () => {\n            if (confirm('Clear the editor?')) {\n                state.content = '';\n                if (editorEl) editorEl.value = '';\n                state.formattedStale = true;\n                updateStats('');\n                renderPreview();\n                markDirty();\n                pushHistory('');\n                showToast('Editor cleared', 'success');\n            }\n        });\n\n        if (formatBtn) formatBtn.addEventListener('click', () => formatNotes(formatStyleSelect ? formatStyleSelect.value : 'study'));\n        if (detectBtn) detectBtn.addEventListener('click', detectStructure);\n        if (copyBtn) copyBtn.addEventListener('click', () => {\n            const textToCopy = state.formattedStale || !state.formattedContent ? state.content : state.formattedContent;\n            navigator.clipboard.writeText(textToCopy).then(() => showToast('Copied to clipboard!', 'success')).catch(() => showToast('Failed to copy', 'error'));\n        });\n        if (downloadBtn) downloadBtn.addEventListener('click', downloadFile);\n        if (saveBtn) saveBtn.addEventListener('click', saveNote);\n\n        if (undoBtn) undoBtn.addEventListener('click', undo);\n        if (redoBtn) redoBtn.addEventListener('click', redo);\n\n        if (searchToggleBtn && searchBar) {\n            searchToggleBtn.addEventListener('click', () => {\n                searchBar.classList.toggle('active');\n                if (searchBar.classList.contains('active') && searchInput) searchInput.focus();\n            });\n        }\n        if (searchCloseBtn && searchBar) searchCloseBtn.addEventListener('click', () => searchBar.classList.remove('active'));\n        if (searchInput) searchInput.addEventListener('input', performSearch);\n        if (caseCheck) caseCheck.addEventListener('change', performSearch);\n        if (searchPrevBtn) searchPrevBtn.addEventListener('click', () => highlightMatch(state.searchMatchIndex - 1));\n        if (searchNextBtn) searchNextBtn.addEventListener('click', () => highlightMatch(state.searchMatchIndex + 1));\n        if (replaceBtn) replaceBtn.addEventListener('click', replaceCurrentMatch);\n        if (replaceAllBtn) replaceAllBtn.addEventListener('click', replaceAllMatches);\n\n        document.addEventListener('keydown', (e) => {\n            if (!rootEl.contains(document.activeElement)) return;\n            if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'z') { e.preventDefault(); undo(); }\n            else if ((e.ctrlKey || e.metaKey) && (e.key.toLowerCase() === 'y' || (e.shiftKey && e.key.toLowerCase() === 'z'))) { e.preventDefault(); redo(); }\n            else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'f') { e.preventDefault(); if (searchBar) { searchBar.classList.add('active'); if (searchInput) searchInput.focus(); } }\n            else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 's') { e.preventDefault(); saveNote(); }\n        });\n\n        try {\n            const savedDraft = localStorage.getItem(DRAFT_KEY);\n            if (savedDraft) {\n                const draft = JSON.parse(savedDraft);\n                if (draft && draft.content && draft.content.trim().length > 0) {\n                    openModal(draftModal);\n                    if (draftRecoverBtn) {\n                        draftRecoverBtn.onclick = () => {\n                            state.content = draft.content;\n                            if (editorEl) editorEl.value = draft.content;\n                            if (titleInputEl && draft.title) titleInputEl.value = draft.title;\n                            updateStats(draft.content);\n                            renderPreview();\n                            closeModal(draftModal);\n                            showToast('Draft recovered', 'success');\n                        };\n                    }\n                    if (draftDiscardBtn) {\n                        draftDiscardBtn.onclick = () => { localStorage.removeItem(DRAFT_KEY); closeModal(draftModal); };\n                    }\n                }\n            }\n        } catch (e) {}\n\n        try {\n            const savedTheme = localStorage.getItem(THEME_KEY);\n            if (savedTheme) setTheme(savedTheme);\n        } catch (e) {}\n    }\n\n    initListeners();\n    updateStats('');\n    renderPreview();\n\n})();\n<\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>AI Notes Smart Copy AI Notes Smart Copy Client-side intelligent note cleaner, formatter, and multi-format exporter. \ud83d\udcc4 New \ud83d\udcc2 Recent \ud83d\udda8\ufe0f Print \ud83c\udf19 Theme \ud83d\udccb Paste Notes \ud83d\udd0d Detect Structure Study NotesClean NotesOutlineRevision NotesQ&#038;A NotesSummaryBullet PointsExam RevisionCornell-style Notes \u26a1 Format \u21a9\ufe0f Undo \u21aa\ufe0f Redo \ud83d\udd0e Search \ud83d\uddd1\ufe0f Clear Case sensitive \u2715 0 matches Previous Next [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-984","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/984","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=984"}],"version-history":[{"count":2,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/984\/revisions"}],"predecessor-version":[{"id":986,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/984\/revisions\/986"}],"wp:attachment":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=984"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}