Changed around line 1
+ // Theme switching
+ const themeToggle = document.getElementById('theme-toggle');
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
+
+ function setTheme(isDark) {
+ document.documentElement.setAttribute('data-theme', isDark ? 'dark' : 'light');
+ themeToggle.checked = isDark;
+ }
+
+ themeToggle.addEventListener('change', () => setTheme(themeToggle.checked));
+ setTheme(prefersDark.matches);
+
+ // Particle system
+ const particles = [];
+ const particleCount = 50;
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+ document.getElementById('particles').appendChild(canvas);
+
+ function resizeCanvas() {
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ }
+
+ class Particle {
+ constructor() {
+ this.reset();
+ }
+
+ reset() {
+ this.x = Math.random() * canvas.width;
+ this.y = Math.random() * canvas.height;
+ this.size = Math.random() * 3 + 1;
+ this.speedX = Math.random() * 2 - 1;
+ this.speedY = Math.random() * 2 - 1;
+ this.opacity = Math.random() * 0.5 + 0.2;
+ }
+
+ update() {
+ this.x += this.speedX;
+ this.y += this.speedY;
+
+ if (this.x < 0 || this.x > canvas.width || this.y < 0 || this.y > canvas.height) {
+ this.reset();
+ }
+ }
+
+ draw() {
+ ctx.fillStyle = `hsla(${Date.now() / 50 % 360}, 70%, 70%, ${this.opacity})`;
+ ctx.beginPath();
+ ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ }
+
+ function initParticles() {
+ for (let i = 0; i < particleCount; i++) {
+ particles.push(new Particle());
+ }
+ }
+
+ function animate() {
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ particles.forEach(particle => {
+ particle.update();
+ particle.draw();
+ });
+ requestAnimationFrame(animate);
+ }
+
+ window.addEventListener('resize', resizeCanvas);
+ resizeCanvas();
+ initParticles();
+ animate();
+
+ // Chat functionality
+ const messageInput = document.getElementById('messageInput');
+ const sendButton = document.getElementById('sendButton');
+ const messageArea = document.getElementById('messageArea');
+
+ function addMessage(text, isUser = true) {
+ const message = document.createElement('div');
+ message.className = `message ${isUser ? 'user' : 'other'}`;
+ message.textContent = text;
+ messageArea.appendChild(message);
+ messageArea.scrollTop = messageArea.scrollHeight;
+ }
+
+ sendButton.addEventListener('click', () => {
+ const text = messageInput.value.trim();
+ if (text) {
+ addMessage(text);
+ messageInput.value = '';
+ }
+ });
+
+ messageInput.addEventListener('keypress', (e) => {
+ if (e.key === 'Enter') {
+ sendButton.click();
+ }
+ });