ement('canvas');
        const ctx = canvas.getContext('2d');
        const aspectRatio = img.height / img.width;
        canvas.width = Math.min(800, img.width);
        canvas.height = canvas.width * aspectRatio;
        ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
        const quality = qualityRange.value / 100;
        optimizedSrc = canvas.toDataURL('image/jpeg', quality);
        
        output.classList.add('active');
        downloadBtn.classList.add('active');
        previewHint.style.