<!DOCTYPE html>
<html>
<head>
    <title>ROMEK-XD Code Editor</title>
    <meta charset="UTF-8">
    <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg: #0a0e14;
            --editor-bg: #1a1f29;
            --accent: #ffcc66;
            --text: #e6e1cf;
            --border: #3a3f4b;
        }

        body {
            margin: 0;
            padding: 20px;
            font-family: 'JetBrains Mono', monospace;
            background: var(--bg);
            color: var(--text);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            flex-grow: 1;
        }

        .editor-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--border);
        }

        .controls {
            display: flex;
            gap: 15px;
            align-items: center;
        }

        .preview-btn {
            background: var(--accent);
            color: var(--bg);
            border: none;
            padding: 12px 25px;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 600;
            transition: 0.3s all;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .preview-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255,204,102,0.3);
        }

        #editor {
            width: 100%;
            height: 70vh;
            background: var(--editor-bg);
            border: 2px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            padding: 20px;
            font-size: 15px;
            line-height: 1.6;
            resize: none;
            box-shadow: 0 10px 30px rgba(0,0,0,0.3);
            tab-size: 4;
        }

        .footer {
            text-align: center;
            padding: 25px;
            font-size: 14px;
            color: #6c7985;
            letter-spacing: 1px;
            margin-top: 40px;
        }

        .footer span {
            color: var(--accent);
            font-weight: 600;
        }

        #editor:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 25px rgba(255,204,102,0.2);
        }

        .html-tag { color: #ff6666; }
        .css-prop { color: #66ccff; }
        .js-keyword { color: #cc99ff; }
    </style>
</head>
<body>
    <div class="container">
        <div class="editor-header">
            <h2>ROMEK-XD CODE LAB</h2>
            <div class="controls">
                <button class="preview-btn" onclick="showPreview()">
                    🚀 RUN CODE
                </button>
            </div>
        </div>
        
        <textarea id="editor" spellcheck="false"></textarea>
    </div>

    <div class="footer">
        MADE BY <span>ROMEK-XD</span> | 2024 CODE EDITOR
    </div>

    <script>
        const codes = {
            html: `<!DOCTYPE html>
<html>
<head>
    <title>ROMEK-XD Editor</title>
    <style>${localStorage.getItem('romeCode') ? JSON.parse(localStorage.getItem('romeCode')).css : ''}</style>
</head>
<body>
    <h1>Welcome to ROMEK-XD Editor</h1>
    <script>${localStorage.getItem('romeCode') ? JSON.parse(localStorage.getItem('romeCode')).js : ''}<\/script>
</body>
</html>`,
            css: `body {
    background: #0a0e14;
    color: #e6e1cf;
    font-family: system-ui;
}`,
            js: `console.log('ROMEK-XD Editor Ready!');`
        };

        // Initialize editor
        document.getElementById('editor').value = codes.html;

        // Preview Function
        function showPreview() {
            const previewWindow = window.open('', '_blank');
            previewWindow.document.write(`
                <html>
                    <head>
                        <title>ROMEK-XD Preview</title>
                        <style>${codes.css}</style>
                    </head>
                    <body>
                        ${codes.html}
                        <script>${codes.js}<\/script>
                    </body>
                </html>
            `);
            previewWindow.document.close();
        }

        // Auto-save feature
        document.getElementById('editor').addEventListener('input', (e) => {
            codes.html = e.target.value;
            localStorage.setItem('romeCode', JSON.stringify(codes));
        });

        // Load saved code
        window.onload = () => {
            const savedCode = localStorage.getItem('romeCode');
            if(savedCode) {
                Object.assign(codes, JSON.parse(savedCode));
                document.getElementById('editor').value = codes.html;
            }
        };
    </script>
</body>
</html>