document.addEventListener('DOMContentLoaded', () => { const chatWindow = document.getElementById('chat-window'); const chatInput = document.getElementById('chat-input'); const sendBtn = document.getElementById('send-btn'); const modeItems = document.querySelectorAll('.mode-item'); const currentModeBadge = document.getElementById('current-mode-badge'); const newChatBtn = document.getElementById('new-chat-btn'); const chatHistoryList = document.getElementById('chat-history'); // Settings elements const creativityRange = document.getElementById('creativity-range'); const creativityVal = document.getElementById('creativity-val'); const limitsToggle = document.getElementById('limits-toggle'); const themeSwatches = document.querySelectorAll('.theme-swatch'); const saveSettingsBtn = document.getElementById('save-settings-btn'); let currentMode = 'regular'; let currentChatId = null; // --- Sidebar & Mode Switching --- modeItems.forEach(item => { item.addEventListener('click', () => { if (item.classList.contains('active')) return; modeItems.forEach(i => i.classList.remove('active')); item.classList.add('active'); currentMode = item.dataset.mode; currentModeBadge.textContent = item.querySelector('span').textContent; startNewChat(); }); }); function startNewChat() { currentChatId = null; chatWindow.innerHTML = `
How can I help you in this mode?
${escapeHtml(code.trim())}`;
});
// Simple line breaks for non-code parts
if (!formatted.includes('