let currentEntries = []; let editId = null; let editGroups = []; let groupsLoaded = false; let studentsLoaded = false; const PAGE_SIZE = 20; let page = 1; let totalEntries = 0; let searchTimer = null; let view = localStorage.getItem('journalView') === 'cards' ? 'cards' : 'list'; let aiCorrecting = false; let editDeletePhoto = false; function isImageFile(name) { return /\.(jpe?g|png|gif|webp|bmp|avif|svg|ico)$/i.test(name || ''); } function mainPhotoPath(e) { if (e.photo_path) return e.photo_path; if (e.photos && e.photos.length) return e.photos[0].photo_path; return null; } function filesHTML(files) { if (!files || !files.length) return ''; return `