:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #a855f7;
    --secondary-light: #c084fc;
    --danger: #ef4444;
    --success: #10b981;
    --accent: #06b6d4;
    --bg: #020617;
    --bg-card: rgba(15, 23, 42, 0.6);
    --glass: rgba(255, 255, 255, 0.04);
    --glass-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.18);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --glow-primary: rgba(99, 102, 241, 0.4);
    --glow-secondary: rgba(168, 85, 247, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-aurora::before, .bg-aurora::after { content: ''; position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35; animation: auroraFloat 12s ease-in-out infinite alternate; }
.bg-aurora::before { width: 600px; height: 600px; background: radial-gradient(circle, var(--primary) 0%, transparent 70%); top: -200px; left: -100px; }
.bg-aurora::after { width: 500px; height: 500px; background: radial-gradient(circle, var(--secondary) 0%, transparent 70%); bottom: -150px; right: -100px; animation-delay: -6s; }
.aurora-orb { position: fixed; border-radius: 50%; filter: blur(80px); opacity: 0.2; pointer-events: none; z-index: 0; }
.aurora-orb:nth-child(1) { width: 400px; height: 400px; background: var(--accent); top: 40%; left: 50%; animation: orbDrift1 18s ease-in-out infinite alternate; }
.aurora-orb:nth-child(2) { width: 300px; height: 300px; background: #f43f5e; top: 60%; right: 20%; animation: orbDrift2 15s ease-in-out infinite alternate; }

@keyframes auroraFloat { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(60px, 40px) scale(1.15); } 100% { transform: translate(-30px, 80px) scale(0.95); } }
@keyframes orbDrift1 { 0% { transform: translate(0, 0) rotate(0deg); } 100% { transform: translate(-120px, -80px) rotate(30deg); } }
@keyframes orbDrift2 { 0% { transform: translate(0, 0); } 100% { transform: translate(100px, -60px); } }

.particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.particle { position: absolute; width: 3px; height: 3px; background: rgba(255, 255, 255, 0.3); border-radius: 50%; animation: particleFloat linear infinite; }
@keyframes particleFloat { 0% { transform: translateY(100vh) translateX(0) scale(0); opacity: 0; } 10% { opacity: 1; transform: translateY(90vh) translateX(10px) scale(1); } 90% { opacity: 0.5; } 100% { transform: translateY(-10vh) translateX(-20px) scale(0.5); opacity: 0; } }

.grid-pattern { position: fixed; inset: 0; z-index: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px); background-size: 60px 60px; mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 20%, transparent 100%); -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 20%, transparent 100%); }

/* ===== LAYOUT ===== */
.container { width: 92%; max-width: 1050px; margin: 0 auto; padding: 40px 0 60px; text-align: center; position: relative; z-index: 1; }
.view { display: none; animation: viewEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes viewEnter { from { opacity: 0; transform: translateY(20px) scale(0.98); filter: blur(4px); } to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
h2 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 1.15rem; font-weight: 600; }
.gradient-text { background: linear-gradient(135deg, var(--primary-light), var(--secondary-light), var(--accent)); background-size: 200% 200%; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; animation: gradientShift 4s ease-in-out infinite; }
@keyframes gradientShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ===== GLASSMORPHISM CARDS ===== */
.card { background: var(--bg-card); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 24px; border: 1px solid var(--glass-border); padding: 32px; cursor: pointer; position: relative; overflow: hidden; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.card::before { content: ''; position: absolute; inset: 0; border-radius: 24px; padding: 1px; background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(168,85,247,0.1), transparent, rgba(6,182,212,0.2)); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0; transition: opacity 0.4s ease; pointer-events: none; }
.card::after { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(99,102,241,0.08) 0%, transparent 60%); pointer-events: none; opacity: 0; transition: opacity 0.4s ease; }
.card:hover { transform: translateY(-6px) scale(1.01); border-color: var(--glass-border-hover); box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 40px rgba(99,102,241,0.08); }
.card:hover::before { opacity: 1; }
.card:hover::after { opacity: 1; }
.card:active { transform: translateY(-2px) scale(0.99); transition-duration: 0.1s; }
.grid .card { opacity: 0; animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.grid .card:nth-child(1) { animation-delay: 0.05s; } .grid .card:nth-child(2) { animation-delay: 0.12s; } .grid .card:nth-child(3) { animation-delay: 0.19s; } .grid .card:nth-child(4) { animation-delay: 0.26s; } .grid .card:nth-child(5) { animation-delay: 0.33s; } .grid .card:nth-child(6) { animation-delay: 0.40s; }
@keyframes cardEntrance { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

.card-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin: 0 auto 16px; }
.card-icon.icon-flashcard { background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(99,102,241,0.05)); box-shadow: 0 0 30px rgba(99,102,241,0.15); }
.card-icon.icon-quiz { background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(168,85,247,0.05)); box-shadow: 0 0 30px rgba(168,85,247,0.15); }
.card-icon.icon-exercise { background: linear-gradient(135deg, rgba(6,182,212,0.2), rgba(6,182,212,0.05)); box-shadow: 0 0 30px rgba(6,182,212,0.15); }
.card-icon.icon-settings { background: linear-gradient(135deg, rgba(148,163,184,0.15), rgba(148,163,184,0.05)); }
.card-icon.icon-browse { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.05)); box-shadow: 0 0 30px rgba(245,158,11,0.15); }
.card p { color: var(--text-muted); font-size: 0.88rem; margin-top: 6px; line-height: 1.5; }

/* ===== BUTTONS ===== */
.btn { position: relative; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; padding: 13px 28px; border-radius: 14px; font-weight: 600; cursor: pointer; margin: 5px; font-size: 0.95rem; font-family: 'Inter', sans-serif; overflow: hidden; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); letter-spacing: -0.01em; }
.btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent); opacity: 0; transition: opacity 0.3s; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--glow-primary), 0 0 60px rgba(99,102,241,0.15); }
.btn:hover::before { opacity: 1; }
.btn:active { transform: translateY(0) scale(0.97); transition-duration: 0.1s; }
.btn .ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.3); transform: scale(0); animation: rippleAnim 0.6s ease-out; pointer-events: none; }
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }
.btn-back { background: none; border: 1px solid var(--glass-border); color: var(--text-muted); padding: 10px 20px; font-size: 0.88rem; }
.btn-back:hover { border-color: var(--glass-border-hover); color: var(--text); box-shadow: none; background: rgba(255,255,255,0.05); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); }
.btn-danger:hover { box-shadow: 0 8px 30px rgba(239,68,68,0.3); }
.btn-success { background: linear-gradient(135deg, #059669, var(--success)); }
.btn-success:hover { box-shadow: 0 8px 30px rgba(16,185,129,0.3); }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; border-radius: 10px; margin: 3px; }
.btn-ghost { background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); box-shadow: none; }

/* ===== GRID ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 30px; }

/* ===== DROPDOWN ===== */
.dropdown-container { width: 100%; max-width: 520px; margin: 24px auto; position: relative; text-align: left; }
.dropdown-trigger { background: var(--bg-card); backdrop-filter: blur(20px); border: 1px solid var(--glass-border); color: white; padding: 16px 24px; border-radius: 16px; width: 100%; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 0.95rem; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); gap: 12px; }
.dropdown-trigger:hover { border-color: var(--primary); box-shadow: 0 0 30px rgba(99,102,241,0.1); }
.dropdown-trigger .arrow { transition: transform 0.3s ease; font-size: 0.8rem; opacity: 0.6; }
.dropdown-trigger.open .arrow { transform: rotate(180deg); }
.dropdown-menu { display: none; background: rgba(15,23,42,0.95); backdrop-filter: blur(30px); border: 1px solid var(--glass-border); border-radius: 16px; margin-top: 8px; max-height: 350px; overflow-y: auto; z-index: 1000; padding: 10px; position: absolute; width: 100%; box-shadow: 0 25px 60px rgba(0,0,0,0.5); }
.dropdown-menu.active { display: block; animation: dropdownIn 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes dropdownIn { from { opacity: 0; transform: translateY(-8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.dropdown-menu::-webkit-scrollbar { width: 6px; } .dropdown-menu::-webkit-scrollbar-track { background: transparent; } .dropdown-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.filter-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; font-size: 0.92rem; }
.filter-row:hover { background: rgba(255,255,255,0.06); }
.filter-row input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.2); border-radius: 6px; background: transparent; cursor: pointer; transition: all 0.25s ease; position: relative; flex-shrink: 0; }
.filter-row input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.filter-row input[type="checkbox"]:checked::after { content: '\2713'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 12px; font-weight: bold; }

/* ===== LOGIN ===== */
#login-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 9999; overflow: hidden; }
.login-card { background: var(--bg-card); backdrop-filter: blur(30px); border: 1px solid var(--glass-border); border-radius: 32px; padding: 48px 40px; width: 400px; max-width: 90%; position: relative; z-index: 1; animation: loginEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; overflow: hidden; }
.login-card::before { content: ''; position: absolute; top: -2px; left: -2px; right: -2px; bottom: -2px; border-radius: 33px; background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent), var(--primary)); background-size: 300% 300%; animation: borderGlow 6s ease-in-out infinite; z-index: -1; opacity: 0.5; }
.login-card::after { content: ''; position: absolute; inset: 1px; border-radius: 31px; background: var(--bg-card); z-index: -1; }
@keyframes loginEnter { from { opacity: 0; transform: translateY(40px) scale(0.9); filter: blur(10px); } to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }
@keyframes borderGlow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.login-logo { font-size: 3rem; margin-bottom: 16px; display: block; animation: logoPulse 3s ease-in-out infinite; }
@keyframes logoPulse { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(99,102,241,0.3)); } 50% { transform: scale(1.05); filter: drop-shadow(0 0 25px rgba(99,102,241,0.5)); } }

/* ===== INPUTS ===== */
input, select, textarea { background: rgba(15,23,42,0.8); border: 1px solid var(--glass-border); padding: 14px 18px; border-radius: 14px; color: white; margin: 8px 0; width: 100%; font-family: 'Inter', sans-serif; font-size: 0.95rem; transition: all 0.3s ease; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15), 0 0 20px rgba(99,102,241,0.08); }
input::placeholder, textarea::placeholder { color: rgba(148,163,184,0.6); }

/* ===== STUDY / FLASHCARD FLIP ===== */
.study-container { perspective: 1200px; margin: 30px auto; width: 100%; max-width: 560px; height: 400px; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1); transform-style: preserve-3d; cursor: pointer; }
.flipped { transform: rotateY(180deg); }
.flip-front, .flip-back { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    backface-visibility: hidden; 
    -webkit-backface-visibility: hidden; /* Fondamentale per evitare il glitch 3D sul retro */
    transform-style: preserve-3d;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    padding: 40px; 
    border-radius: 32px; 
    border: 1px solid var(--glass-border); 
    background: var(--bg-card); 
    backdrop-filter: blur(20px); 
    overflow: hidden; /* Rimuove la scrollbar indesiderata e stabilizza l'animazione */
}
.flip-front::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent)); border-radius: 32px 32px 0 0; }
.flip-back { transform: rotateY(180deg); background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.08)); }
.flip-back::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--secondary), var(--accent), var(--success)); border-radius: 32px 32px 0 0; }
.flip-hint { position: absolute; bottom: 20px; color: var(--text-muted); font-size: 0.78rem; opacity: 0.5; display: flex; align-items: center; gap: 6px; animation: hintPulse 2s ease-in-out infinite; }
@keyframes hintPulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.7; } }

/* ===== EXERCISE ===== */
.exercise-card { background: var(--bg-card); backdrop-filter: blur(20px); border-radius: 28px; padding: 40px; text-align: left; max-width: 800px; margin: 20px auto; border: 1px solid var(--glass-border); position: relative; overflow: hidden; animation: exerciseEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.exercise-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, var(--primary), var(--secondary), var(--accent)); }
@keyframes exerciseEnter { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
.solution-box { background: rgba(0,0,0,0.3); padding: 24px; border-radius: 18px; margin-top: 20px; display: none; line-height: 1.8; border: 1px solid rgba(16,185,129,0.15); font-family: 'Inter', monospace; font-size: 0.92rem; animation: solutionReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes solutionReveal { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== QUIZ OPTIONS ===== */
.quiz-option { display: block; width: 100%; text-align: left; background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border); color: white; padding: 16px 22px; border-radius: 14px; font-weight: 500; cursor: pointer; margin: 8px 0; font-family: 'Inter', sans-serif; font-size: 0.95rem; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); position: relative; overflow: hidden; }
.quiz-option:hover:not(.correct):not(.wrong) { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); transform: translateX(4px); }
.quiz-option.correct { background: rgba(16,185,129,0.15) !important; border-color: var(--success) !important; animation: correctPop 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.quiz-option.wrong { background: rgba(239,68,68,0.15) !important; border-color: var(--danger) !important; animation: wrongShake 0.4s ease; }
.quiz-option.disabled { pointer-events: none; opacity: 0.7; }
@keyframes correctPop { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes wrongShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* ===== PANELS ===== */
.panel { background: var(--bg-card); backdrop-filter: blur(20px); padding: 28px; border-radius: 24px; border: 1px solid var(--glass-border); margin: 20px 0; text-align: left; transition: all 0.3s ease; }
.panel:hover { border-color: var(--glass-border-hover); }
.panel h4 { margin-bottom: 16px; font-size: 1.05rem; font-weight: 600; }

/* ===== BADGE ===== */
.badge { font-size: 0.72rem; background: linear-gradient(135deg, var(--primary), var(--secondary)); padding: 5px 14px; border-radius: 20px; margin-bottom: 16px; font-weight: 700; display: inline-block; letter-spacing: 0.03em; text-transform: uppercase; }

/* ===== PROGRESS BAR ===== */
.progress-bar { width: 100%; display: flex; align-items: center; gap: 12px; }
.progress-track { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent)); background-size: 200% 100%; border-radius: 3px; transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1); animation: progressShimmer 2s ease-in-out infinite; }
@keyframes progressShimmer { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.progress-text { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; min-width: 50px; text-align: right; }

/* ===== COUNTER PILLS ===== */
.counter-pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.06); padding: 6px 14px; border-radius: 20px; font-size: 0.82rem; color: var(--text-muted); margin-top: 8px; }
.counter-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: dotBlink 2s ease-in-out infinite; }
@keyframes dotBlink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(15,23,42,0.95); backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 14px; padding: 14px 22px; color: white; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 10px; animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s ease 2.7s forwards; box-shadow: 0 15px 40px rgba(0,0,0,0.3); max-width: 350px; }
.toast.success { border-left: 3px solid var(--success); } .toast.error { border-left: 3px solid var(--danger); } .toast.info { border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(0.95); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(40px); } }

/* ===== TIMER ===== */
.timer-display { display: inline-flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); padding: 8px 18px; border-radius: 12px; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.05em; min-width: 100px; justify-content: center; }
.timer-display.warning { color: #f59e0b; border-color: rgba(245,158,11,0.3); animation: timerPulse 1s ease-in-out infinite; }
.timer-display.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ===== SCORE DISPLAY ===== */
.score-display { display: inline-flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); padding: 8px 18px; border-radius: 12px; font-weight: 600; font-size: 0.92rem; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); z-index: 5000; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: rgba(15,23,42,0.97); border: 1px solid var(--glass-border); border-radius: 28px; padding: 36px; width: 500px; max-width: 92%; max-height: 85vh; overflow-y: auto; animation: modalEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-card::-webkit-scrollbar { width: 6px; } .modal-card::-webkit-scrollbar-track { background: transparent; } .modal-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
@keyframes modalEnter { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ===== GROUP BROWSER ===== */
.group-item { background: rgba(255,255,255,0.03); border: 1px solid var(--glass-border); border-radius: 16px; margin: 12px 0; overflow: hidden; transition: all 0.3s ease; }
.group-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; cursor: pointer; transition: background 0.2s ease; }
.group-header:hover { background: rgba(255,255,255,0.04); }
.group-header .group-name { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 10px; }
.group-header .group-count { font-size: 0.82rem; color: var(--text-muted); background: rgba(255,255,255,0.06); padding: 4px 12px; border-radius: 10px; }
.group-header .chevron { transition: transform 0.3s ease; font-size: 0.8rem; opacity: 0.5; }
.group-header .chevron.open { transform: rotate(90deg); }
.group-body { display: none; padding: 0 16px 16px; }
.group-body.open { display: block; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
.question-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,0.02); margin: 6px 0; border: 1px solid transparent; transition: all 0.2s ease; }
.question-row:hover { background: rgba(255,255,255,0.05); border-color: var(--glass-border); }
.question-row .q-text { flex: 1; font-size: 0.88rem; line-height: 1.5; color: var(--text-muted); }
.question-row .q-type { font-size: 0.72rem; background: rgba(99,102,241,0.15); color: var(--primary-light); padding: 3px 10px; border-radius: 8px; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.delete-btn { background: none; border: none; color: rgba(239,68,68,0.5); cursor: pointer; font-size: 1.1rem; padding: 4px 8px; border-radius: 8px; transition: all 0.2s ease; flex-shrink: 0; }
.delete-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ===== PRESET MODAL SPECIFICS ===== */
.preset-group-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; cursor: pointer; transition: all 0.2s ease; }
.preset-group-row:hover { background: rgba(255,255,255,0.04); }
.preset-group-row input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.2); border-radius: 6px; background: transparent; cursor: pointer; transition: all 0.25s ease; position: relative; flex-shrink: 0; }
.preset-group-row input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.preset-group-row input[type="checkbox"]:checked::after { content: '\2713'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 12px; font-weight: bold; }
.number-input { width: 80px !important; text-align: center; padding: 10px !important; font-weight: 700; font-size: 1.1rem !important; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.toggle-row label { font-weight: 500; font-size: 0.92rem; color: var(--text-muted); }
.toggle { width: 48px; height: 26px; background: rgba(255,255,255,0.1); border-radius: 13px; cursor: pointer; position: relative; transition: background 0.3s ease; border: none; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; width: 20px; height: 20px; background: white; border-radius: 50%; top: 3px; left: 3px; transition: transform 0.3s ease; }
.toggle.active { background: var(--primary); }
.toggle.active::after { transform: translateX(22px); }

/* ===== RESULTS SCREEN ===== */
.results-card { background: var(--bg-card); backdrop-filter: blur(20px); border-radius: 28px; padding: 48px; max-width: 550px; margin: 30px auto; border: 1px solid var(--glass-border); text-align: center; animation: modalEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.results-score { font-size: 4rem; font-weight: 800; margin: 20px 0 10px; }
.results-detail { color: var(--text-muted); font-size: 0.92rem; margin: 6px 0; }
.best-score-badge { display: inline-flex; align-items: center; gap: 6px; background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.05)); border: 1px solid rgba(245,158,11,0.3); padding: 6px 16px; border-radius: 20px; font-size: 0.82rem; font-weight: 700; color: #f59e0b; margin-top: 12px; animation: bestScorePop 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes bestScorePop { 0% { transform: scale(0); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    h1 { font-size: 2rem; }
    .container { padding: 20px 0 40px; }
    .card { padding: 24px; border-radius: 20px; }
    .login-card { padding: 36px 28px; }
    .study-container { height: 350px; }
    .flip-front, .flip-back { padding: 28px; }
    .exercise-card { padding: 28px; }
    .modal-card { padding: 28px; }
}

/* ===== STILE VISTA STATISTICHE & GRAFICI ===== */

#view-stats h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-main, #ffffff);
    letter-spacing: -0.5px;
}

#stats-content {
    background: var(--glass-bg, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.4);
}

/* Scheda del singolo tipo (Flashcard, Quiz, Esercizi) */
.stat-card-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 16px;
    transition: all 0.25s ease;
}

.stat-card-item:hover {
    border-color: var(--glass-border-hover, rgba(255, 255, 255, 0.2));
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-2px);
}

/* Contenitori delle barre del grafico */
.stat-bar-track {
    background: rgba(255, 255, 255, 0.05);
    height: 10px;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 6px;
    margin-bottom: 14px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Riempimento animato barra del tempo */
.stat-bar-time {
    background: linear-gradient(90deg, var(--accent, #6366f1), var(--success, #10b981));
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Riempimento animato barra degli errori */
.stat-bar-error {
    background: linear-gradient(90deg, var(--danger, #ef4444), #f59e0b);
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
