:root {
    --primary-color: #FF6B8B;
    --primary-gradient: linear-gradient(135deg, #FF9A9E 0%, #FECFEF 99%, #FECFEF 100%);
    --bg-color: #f5f5f7;
    --bg-gradient: linear-gradient(135deg, #f5f5f7 0%, #e8e8ed 100%);
    --card-bg: rgba(255, 255, 255, 0.15);
    --dropdown-bg: rgba(255, 255, 255, 0.85);
    --card-hover: rgba(255, 255, 255, 0.25);
    --card-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 20px 40px rgba(0,0,0,0.06), inset 0 2px 4px rgba(255,255,255,0.8), inset 0 -2px 4px rgba(255,255,255,0.2);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    
    --status-green: #38b2ac;
    --status-green-bg: rgba(56, 178, 172, 0.15);
    --status-yellow: #ed8936;
    --status-yellow-bg: rgba(237, 137, 54, 0.15);
    --status-red: #e53e3e;
    --status-red-bg: rgba(229, 62, 62, 0.15);
    
    --btn-dark: rgba(0, 0, 0, 0.05);
    --btn-purple: #9f7aea;
    --btn-blue: #4299e1;
    
    --shadow-soft: 0 10px 30px 0 rgba(0, 0, 0, 0.05);
    --shadow-neon: 0 8px 24px 0 rgba(255, 107, 139, 0.4);
}

[data-theme="dark"] {
    --primary-color: #FF7EB3;
    --primary-gradient: linear-gradient(135deg, #FF7EB3 0%, #FF758C 100%);
    --bg-color: #1a1a2e;
    --bg-gradient: radial-gradient(circle at top left, #2f1b41, #1a1a2e 80%);
    --card-bg: rgba(30, 30, 45, 0.2);
    --dropdown-bg: rgba(30, 30, 45, 0.85);
    --card-hover: rgba(40, 40, 60, 0.3);
    --card-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 20px 40px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.15), inset 0 -2px 4px rgba(255,255,255,0.05);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    
    --status-green: #00f2fe;
    --status-green-bg: rgba(0, 242, 254, 0.15);
    --status-yellow: #fee140;
    --status-yellow-bg: rgba(254, 225, 64, 0.15);
    --status-red: #ff512f;
    --status-red-bg: rgba(255, 81, 47, 0.15);
    
    --btn-dark: rgba(255, 255, 255, 0.1);
    --btn-purple: #b336ff;
    --btn-blue: #4facfe;
    
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --shadow-neon: 0 8px 24px 0 rgba(255, 126, 179, 0.4);
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    background-color: var(--bg-color);
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    min-height: 100vh;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="rgba(255,255,255,0.7)" stroke="%23FF6B8B" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>') 2 22, auto;
}

a, button, .btn, .btn-quick, .subject-card, .settings-menu-item, .dropdown-selected, .dropdown-option, .glass-panel {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="%23FF6B8B" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>') 2 22, pointer !important;
}

/* Effetto Liquido su Clic */
.subject-card:active, .btn:active, .btn-quick:active, .settings-menu-item:active, .dropdown-option:active, .dropdown-selected:active {
    transform: scale(0.95) skew(1deg, -1deg) !important;
    border-radius: 35px !important;
    border-color: var(--primary-color) !important;
    transition: all 0.1s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

/* Esplosione di Colori dal Centro rimossa come richiesto */

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23000000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' stroke-opacity='0.04'%3E%3C!-- Book --%3E%3Cpath d='M20 30 h15 v20 h-15 z'/%3E%3Cpath d='M35 30 h15 v20 h-15 z'/%3E%3C!-- Pencil --%3E%3Cpath d='M80 80 l15 -15 l8 8 l-15 15 z M95 65 l8 -8 l8 8 l-8 8'/%3E%3Cpath d='M80 80 l-5 5 l8 2 l2 -8 z'/%3E%3C!-- Cap --%3E%3Cpath d='M20 90 l15 -8 l15 8 l-15 8 z M35 98 v12 M20 90 v12'/%3E%3C!-- Math --%3E%3Cpath d='M90 25 h10 M95 20 v10 M75 30 l8 -8 M75 22 l8 8'/%3E%3C/g%3E%3C/svg%3E");
    z-index: -1;
    animation: drift 60s linear infinite;
    pointer-events: none;
}
[data-theme="dark"] body::before {
    background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' stroke-opacity='0.03'%3E%3C!-- Book --%3E%3Cpath d='M20 30 h15 v20 h-15 z'/%3E%3Cpath d='M35 30 h15 v20 h-15 z'/%3E%3C!-- Pencil --%3E%3Cpath d='M80 80 l15 -15 l8 8 l-15 15 z M95 65 l8 -8 l8 8 l-8 8'/%3E%3Cpath d='M80 80 l-5 5 l8 2 l2 -8 z'/%3E%3C!-- Cap --%3E%3Cpath d='M20 90 l15 -8 l15 8 l-15 8 z M35 98 v12 M20 90 v12'/%3E%3C!-- Math --%3E%3Cpath d='M90 25 h10 M95 20 v10 M75 30 l8 -8 M75 22 l8 8'/%3E%3C/g%3E%3C/svg%3E");
}

/* Glow dinamico per rendere il tema personalizzato più impattante */
body::after {
    content: '';
    position: fixed;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 50% 50%, var(--primary-color) 0%, transparent 35%);
    opacity: 0.12;
    z-index: -2;
    pointer-events: none;
    animation: driftColor 20s infinite alternate ease-in-out;
}
[data-theme="dark"] body::after {
    opacity: 0.25;
}

@keyframes driftColor {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(20vw, 15vh) scale(1.2); }
}

@keyframes drift {
    from { background-position: 0 0; }
    to { background-position: 1200px 1200px; }
}

* { box-sizing: border-box; }

#app-container {
    max-width: 1000px;
    margin: 0 auto;
    min-height: 100dvh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    padding: 24px;
}
@media (max-width: 768px) { .view { padding: 16px; } }

.view.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
}

/* Animations */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(255, 126, 179, 0.4)); }
    50% { filter: drop-shadow(0 0 20px rgba(255, 126, 179, 0.8)); }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--dropdown-bg);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid var(--card-border);
    border-radius: 32px;
    box-shadow: var(--glass-shadow);
    transition: border-radius 0.4s ease, transform 0.3s ease;
}
.glass-panel:hover {
    border-radius: 28px 36px 28px 36px / 36px 28px 36px 28px;
}

/* Splash Screen */
#view-splash {
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100dvh;
    touch-action: none;
    background: var(--bg-gradient);
    z-index: 100;
}
.splash-content { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.splash-logo { animation: pulse-glow 2s infinite ease-in-out; color: var(--primary-color); }
.splash-title { font-size: 3rem; font-weight: 800; letter-spacing: 2px; margin: 0; background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 10px rgba(255,107,139,0.3)); }
.fade-out { opacity: 0 !important; pointer-events: none; }

/* Drop Scanner Animation for Login */
.glass-drop-scanner {
    position: absolute;
    width: 90px; height: 90px;
    top: -5px; left: -100px;
    z-index: 10;
    pointer-events: none;
    animation: scan-drop 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.glass-drop-scanner .glass-lens.drop-shape {
    position: absolute; top: 0; left: 0; width: 60px; height: 60px;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 4px 10px rgba(255, 255, 255, 0.8), inset 0 -4px 10px rgba(0, 0, 0, 0.1), 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: liquid-wobble 3s ease-in-out infinite alternate;
}

.glass-drop-scanner .glass-handle {
    position: absolute; bottom: 20px; right: 20px; width: 35px; height: 12px;
    background: linear-gradient(145deg, var(--primary-color), #ff9a9e);
    border-radius: 10px; transform: rotate(45deg);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.4), 0 4px 10px rgba(255,107,139,0.4);
    z-index: -1;
}

@keyframes scan-drop {
    0% { transform: translateX(50px) translateY(120px) scale(1.4) rotate(-10deg); opacity: 0; }
    15% { opacity: 1; transform: translateX(110px) translateY(55px) scale(1.6) rotate(0deg); }
    60% { opacity: 1; transform: translateX(380px) translateY(55px) scale(1.6) rotate(10deg); }
    100% { transform: translateX(430px) translateY(-10px) scale(0.7) rotate(25deg); opacity: 1; }
}

@keyframes liquid-wobble {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    50% { border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%; }
    100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
}

/* Animazione ingrandimento testo in sync con la lente (Senza shift di layout) */
.scan-word {
    display: inline-block;
    animation: text-magnify 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.scan-word:nth-child(1) { animation-delay: 0.1s; }
.scan-word:nth-child(2) { animation-delay: 0.6s; }
.scan-word:nth-child(3) { animation-delay: 1.1s; }
.beta-badge.scan-word { animation-delay: 1.4s; }

@keyframes text-magnify {
    0%, 15% { transform: scale(1); color: inherit; text-shadow: none; }
    25% { transform: scale(1.15); color: var(--primary-color); text-shadow: 0 4px 12px rgba(255,107,139,0.4); }
    35%, 100% { transform: scale(1); color: inherit; text-shadow: none; }
}

/* Login & Onboarding */
#view-login, #view-onboarding { align-items: center; justify-content: center; }
.login-box, .onboarding-box {
    padding: 48px 32px;
    text-align: center;
    width: 100%;
    max-width: 440px;
    animation: slideUpFade 0.6s ease-out;
}
.login-logo { color: var(--primary-color); margin-bottom: 24px; filter: drop-shadow(0 0 12px rgba(255, 126, 179,0.5)); display: none; }
.login-box h2, .onboarding-box h2 { font-size: 1.8rem; margin-bottom: 12px; font-weight: 700; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 1.05rem; line-height: 1.5; font-weight: 600; }

.beta-badge {
    font-size: 0.75rem;
    background: linear-gradient(135deg, #F59E0B, #FF512F);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    vertical-align: middle;
    margin-left: 8px;
    font-weight: 800;
    letter-spacing: 1px;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; padding: 14px 28px; border-radius: 20px; border: none;
    font-size: 1.05rem; font-weight: 600; cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
    font-family: 'Nunito', sans-serif;
}
.btn::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    opacity: 0; transition: opacity 0.3s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.96) skew(1deg, -1deg); border-radius: 25px; }

.btn-google {
    background-color: #ffffff; color: #3c4043;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.btn-google:hover { background-color: #f8f9fa; box-shadow: 0 6px 20px rgba(255,255,255,0.2); transform: translateY(-2px); }

.btn-primary {
    background: var(--primary-gradient); color: white;
    box-shadow: var(--shadow-neon);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(255, 126, 179, 0.5); transform: translateY(-2px); }

.btn-secondary {
    background-color: rgba(255,255,255,0.08); color: var(--text-primary);
    border: 1px solid var(--card-border); backdrop-filter: blur(8px);
}
.btn-secondary:hover { background-color: rgba(255,255,255,0.15); transform: translateY(-1px); }

/* Inputs */
.input-group { position: relative; margin-bottom: 24px; display: flex; align-items: center; justify-content: center; }
.input-group input, .form-row input, .search-input, .sort-select {
    width: 100%; padding: 14px 16px; font-size: 1.05rem;
    border: 2px solid var(--card-border); border-radius: 20px;
    background-color: rgba(0,0,0,0.2); color: var(--text-primary);
    outline: none; transition: all 0.3s ease;
    backdrop-filter: blur(8px); font-family: inherit;
    -webkit-appearance: none; /* Remove default dropdown arrow */
    appearance: none;
}
.input-group input:focus, .form-row input:focus, .search-input:focus, .sort-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 126, 179, 0.15);
    background-color: rgba(0,0,0,0.4);
}
.input-group input { padding-right: 40px; text-align: center; font-size: 1.25rem; font-weight: 600; }
.input-suffix { position: absolute; right: 20px; font-size: 1.2rem; color: var(--text-secondary); pointer-events: none; }

/* Dashboard Header */
.dashboard-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px; padding-bottom: 20px;
    border-bottom: 1px solid var(--card-border);
    animation: slideUpFade 0.5s ease-out;
}
.user-info { display: flex; align-items: center; gap: 16px; }
.user-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-color); box-shadow: 0 4px 12px rgba(255,126,179,0.3); }
.user-text h2 { font-size: 1.4rem; margin: 0; font-weight: 700; }
.user-email { font-size: 0.9rem; color: var(--text-secondary); }
.header-actions { display: flex; gap: 12px; }
.btn-icon {
    background: rgba(255,255,255,0.05); border: 1px solid var(--card-border); color: var(--text-primary);
    cursor: pointer; padding: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(4px);
}
.btn-icon:hover { background: var(--primary-color); border-color: var(--primary-color); transform: translateY(-2px) rotate(8deg); box-shadow: var(--shadow-neon); }

.dashboard-controls { display: flex; gap: 16px; margin-bottom: 24px; animation: slideUpFade 0.6s ease-out; }
.search-input { flex: 2; }

/* Custom Dropdown Animato */
.custom-dropdown { flex: 1; position: relative; user-select: none; z-index: 10; }
.custom-dropdown.open { z-index: 9999; }
.dropdown-selected {
    width: 100%; padding: 14px 16px; font-size: 1.05rem;
    border: 2px solid var(--card-border); border-radius: 20px;
    background-color: rgba(0,0,0,0.2); color: var(--text-primary);
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    backdrop-filter: blur(8px); transition: all 0.3s ease;
}
.custom-dropdown.open .dropdown-selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
    background-color: rgba(0,0,0,0.4);
}
.dropdown-selected:active { transform: scale(0.96) skew(1deg, -1deg); border-radius: 22px; }
.dropdown-arrow { transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.custom-dropdown.open .dropdown-arrow { transform: rotate(180deg); color: var(--primary-color); }

.dropdown-options {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--dropdown-bg);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid var(--card-border); border-radius: 20px;
    box-shadow: var(--glass-shadow);
    overflow: hidden; opacity: 0; pointer-events: none;
    transform: translateY(-10px); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}
.custom-dropdown.open .dropdown-options {
    opacity: 1; pointer-events: auto; transform: translateY(0);
}
.dropdown-option {
    padding: 14px 16px; cursor: pointer; transition: background 0.2s;
    display: flex; align-items: center; justify-content: space-between;
}
.dropdown-option:hover { background: rgba(255,255,255,0.08); }
.dropdown-option.active { color: var(--primary-color); font-weight: 700; background: rgba(0,0,0,0.2); }
.dropdown-option.active::after { content: '✓'; color: var(--primary-color); font-weight: bold; }

.add-subject-card {
    padding: 24px; margin-bottom: 32px; animation: slideUpFade 0.7s ease-out;
}
.add-subject-card h3 { margin: 0 0 16px 0; font-size: 1.25rem; font-weight: 700; }
.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
@media (max-width: 600px) { .form-row { flex-direction: column; } .dashboard-controls { flex-direction: column; } }
.flex-2 { flex: 2; } .flex-1 { flex: 1; }
.preview-hours { font-size: 0.9rem; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.preview-hours strong { color: var(--primary-color); font-size: 1.1rem; }

/* Subject Cards (Grid on Desktop) */
.subjects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding-bottom: 100px;
}

.subject-card {
    background: var(--dropdown-bg);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--glass-shadow);
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    overflow: hidden;
}
.subject-card:hover { transform: translateY(-4px) scale(1.01); border-radius: 22px 35px 22px 35px / 35px 22px 35px 22px; border-color: var(--primary-color); background: var(--card-hover); }
.subject-card:active { transform: scale(0.96) skew(1deg, -1deg); border-radius: 35px; }

/* Stile quando si superano le assenze */
.subject-card.over-limit {
    background: rgba(255, 60, 80, 0.85) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    color: white !important;
}
[data-theme="dark"] .subject-card.over-limit {
    background: rgba(220, 30, 60, 0.85) !important;
}
.subject-card.over-limit .subject-card-title,
.subject-card.over-limit .ui-absent,
.subject-card.over-limit .ui-max,
.subject-card.over-limit .remaining-text,
.subject-card.over-limit .ui-perc {
    color: white !important;
}
.subject-card.over-limit .subject-card-stats-row,
.subject-card.over-limit .subject-card-stats-row span {
    color: rgba(255, 255, 255, 0.9) !important;
}

.subject-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.subject-card-title { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); margin: 0; flex: 1; padding-right: 16px; line-height: 1.3; }

.status-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 20px; font-size: 0.85rem; font-weight: 700; border: 1px solid transparent;
    letter-spacing: 0.5px; text-transform: uppercase;
}
.status-safe { color: var(--status-green); border-color: rgba(0,242,254,0.3); background-color: var(--status-green-bg); }
.status-warn { color: var(--status-yellow); border-color: rgba(254,225,64,0.3); background-color: var(--status-yellow-bg); }
.status-danger { color: var(--status-red); border-color: rgba(255,81,47,0.3); background-color: var(--status-red-bg); }

.subject-card-stats-row { display: flex; justify-content: space-between; font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 12px; }
.text-white { color: var(--text-primary) !important; }

.progress-container {
    height: 12px;
    background-color: rgba(0,0,0,0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 0 0 1px rgba(255,255,255,0.5);
    transition: box-shadow 0.4s ease;
    position: relative;
}

.progress-container.glow-update-green {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 0 16px rgba(56, 178, 172, 0.6);
}
.progress-container.glow-update-yellow {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 0 16px rgba(237, 137, 54, 0.6);
}
.progress-container.glow-update-red {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), 0 0 16px rgba(229, 62, 62, 0.6);
}

.progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    overflow: hidden;
    will-change: width;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%);
    animation: progressShimmer 3s infinite linear;
}

@keyframes progressShimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

.color-green { background-image: linear-gradient(90deg, #81e6d9 0%, #38b2ac 100%); box-shadow: 0 0 10px rgba(56, 178, 172, 0.4); }
.color-yellow { background-image: linear-gradient(90deg, #fbd38d 0%, #ed8936 100%); box-shadow: 0 0 10px rgba(237, 137, 54, 0.4); }
.color-red { background-image: linear-gradient(90deg, #feb2b2 0%, #e53e3e 100%); box-shadow: 0 0 10px rgba(229, 62, 62, 0.4); }

.subject-card-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.remaining-text { font-size: 0.95rem; color: var(--text-secondary); }
.remaining-val { font-size: 1.15rem; font-weight: 800; margin-left: 4px; display: inline-block; }
.text-green { color: var(--status-green) !important; }
.text-yellow { color: var(--status-yellow) !important; }
.text-red { color: var(--status-red) !important; }

.card-quick-actions { display: flex; gap: 6px; align-items: center; }
.btn-quick-card {
    background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--card-border);
    border-radius: 14px; padding: 6px 10px; font-size: 0.85rem; font-weight: 700;
    cursor: pointer; transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease; backdrop-filter: blur(4px); font-family: 'Nunito', sans-serif;
    min-width: 36px; text-align: center; line-height: 1.2; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn-quick-card:hover { background: var(--primary-gradient); color: white; border-color: transparent; transform: translateY(-1px); box-shadow: var(--shadow-neon); }
.btn-quick-card:active { transform: scale(0.9) !important; }

.btn-quick {
    background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--card-border);
    border-radius: 14px; padding: 8px 16px; font-size: 0.95rem; font-weight: 800;
    cursor: pointer; transition: all 0.2s; backdrop-filter: blur(4px); font-family: 'Nunito', sans-serif;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn-quick:hover { background: var(--primary-gradient); color: white; border-color: transparent; transform: translateY(-2px); box-shadow: var(--shadow-neon); }
.btn-quick:active { transform: scale(0.92) skew(2deg, -2deg); border-radius: 20px; }

/* Animazioni Interattive Ore e Feedback Visuale */
.num-pop {
    animation: numPopAnim 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    display: inline-block;
}

@keyframes numPopAnim {
    0% { transform: scale(1); }
    50% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.floating-delta {
    position: absolute;
    pointer-events: none;
    font-weight: 800;
    font-size: 0.82rem;
    padding: 3px 9px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 99;
    animation: floatDelta 0.7s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.floating-delta.plus {
    background: linear-gradient(135deg, #ff7eb3 0%, #ff758c 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
}

.floating-delta.minus {
    background: linear-gradient(135deg, #00c6fb 0%, #005bea 100%);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
}

@keyframes floatDelta {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.8);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -8px) scale(1.08);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -22px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -30px) scale(0.85);
    }
}

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(255, 255, 255, 0.3); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center; z-index: 200;
    opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
}
[data-theme="dark"] .modal {
    background-color: rgba(0, 0, 0, 0.6);
}
.modal.active { opacity: 1; pointer-events: auto; }
.hidden { display: none !important; }

.modal-content {
    background: var(--dropdown-bg);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid var(--card-border); border-radius: 28px; padding: 32px;
    width: 90%; max-width: 440px; box-shadow: var(--glass-shadow);
    transform: scale(0.95) translateY(20px); transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.active .modal-content { transform: scale(1) translateY(0); }

.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 32px; }

/* Settings Menu Items */
.settings-menu { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.settings-menu-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.2); border: 1px solid var(--card-border);
    padding: 16px; border-radius: 16px; cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative; z-index: 1;
}
.settings-menu-item:has(.custom-dropdown.open) {
    z-index: 9999;
}
.settings-menu-item:hover { background: rgba(255,255,255,0.05); transform: translateY(-2px); border-color: rgba(255,255,255,0.3); }
.settings-menu-item:active { transform: scale(0.96) skew(1deg, -1deg); border-radius: 20px; }

/* Bottom Sheet specifically */
.align-bottom { align-items: flex-end !important; }
@media (min-width: 768px) {
    /* On desktop, bottom sheet becomes a centered modal */
    .align-bottom { align-items: center !important; padding: 20px 0; }
    .bottom-sheet { 
        border-radius: 28px !important; 
        margin: auto !important; 
        max-width: 460px !important; 
        max-height: 90vh !important; 
        overflow-y: auto !important; 
        padding: 24px !important; 
    }
    
    /* Ridimensionamento generale per PC */
    .sheet-header { margin-bottom: 20px !important; }
    .title-input { font-size: 1.5rem !important; margin-bottom: 4px !important; }
    
    .stats-grid { gap: 12px !important; margin-bottom: 24px !important; }
    .stat-box-detail { padding: 16px 8px !important; }
    .stat-value { font-size: 1.4rem !important; }
    .editable-stat { font-size: 1.4rem !important; width: 70px !important; }
    .stat-label { font-size: 0.7rem !important; margin-bottom: 8px !important; }
    
    .accumulated-section { padding: 24px 16px !important; margin-bottom: 16px !important; }
    .huge-value { font-size: 3.5rem !important; margin-bottom: 24px !important; }
    .h-suffix { font-size: 1.8rem !important; }
    
    .action-label { font-size: 0.95rem !important; margin-bottom: 12px !important; }
    .btn-action { padding: 12px 0 !important; width: 60px !important; font-size: 1rem !important; }
    .action-buttons { gap: 8px !important; margin-bottom: 16px !important; }
    
    .manual-input-container { margin-top: 16px !important; }
    #input-manual-absent { width: 100px !important; padding: 10px !important; font-size: 1.1rem !important; }
    .btn-quick { padding: 8px 16px !important; font-size: 0.9rem !important; }
    
    .mt-16 { margin-top: 8px !important; }
}

.bottom-sheet {
    background: var(--card-bg); width: 100%; max-width: 600px;
    border-radius: 32px 32px 0 0; padding: 24px 16px; margin: 0;
    max-height: 88vh; overflow-y: auto;
    transform: translateY(100%); border-top: 1px solid var(--card-border);
    backdrop-filter: blur(40px) saturate(150%); -webkit-backdrop-filter: blur(40px) saturate(150%);
    box-shadow: var(--glass-shadow);
}
.modal.active .bottom-sheet { transform: translateY(0); }

.sheet-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.sheet-header h2 { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px 0; display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.subtitle { font-size: 1rem; color: var(--text-secondary); margin: 0; }
.sheet-actions { display: flex; gap: 12px; }

.detail-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 14px 20px;
    margin-bottom: 24px;
}
.detail-toggle-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.detail-toggle-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}
.detail-toggle-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 20px; }
@media (max-width: 400px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-box-detail {
    background: rgba(255,255,255,0.05); border-radius: 20px; padding: 20px 8px;
    text-align: center; border: 1px solid var(--card-border);
}
.highlight-box { border-color: rgba(0,242,254,0.4); background: linear-gradient(180deg, rgba(0,242,254,0.1) 0%, transparent 100%); }
.highlight-box-danger { border-color: rgba(255,81,47,0.4); background: linear-gradient(180deg, rgba(255,81,47,0.1) 0%, transparent 100%); }

.stat-label { font-size: 0.75rem; font-weight: 800; color: var(--text-secondary); letter-spacing: 1px; margin-bottom: 12px; }
.stat-value { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; }
.stat-sub { font-size: 0.8rem; color: var(--text-secondary); }

.accumulated-section {
    background: rgba(0,0,0,0.3); border-radius: 24px; padding: 24px 12px;
    text-align: center; margin-bottom: 20px; border: 1px solid var(--card-border);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}
.huge-value { font-size: 3.2rem; font-weight: 800; line-height: 1; margin-bottom: 20px; text-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.h-suffix { font-size: 1.6rem; color: var(--text-secondary); }

.action-label { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.action-buttons { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.btn-action {
    border: none; border-radius: 16px; padding: 12px 0; width: 64px; font-family: 'Nunito', sans-serif;
    font-size: 1.1rem; font-weight: 700; color: white; cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.btn-action:active { transform: scale(0.92); }
.btn-action:hover { transform: translateY(-3px); filter: brightness(1.15); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.btn-action.dark { background: rgba(0,0,0,0.1); border: 1px solid rgba(0,0,0,0.05); color: var(--text-primary); }
.btn-action.purple { background: var(--primary-gradient); box-shadow: var(--shadow-neon); color: white; }
.btn-action.blue { background: linear-gradient(145deg, #4299e1, #3182ce); box-shadow: 0 4px 15px rgba(66,153,225,0.4); color: white; }

.action-hint { font-size: 0.85rem; color: var(--text-secondary); margin: 0; font-style: italic; }

.mt-16 { margin-top: 16px; } .full-width { width: 100%; }
.icon-edit { font-size: 1.2rem; opacity: 0.6; cursor: pointer; transition: opacity 0.2s; }
.icon-edit:hover { opacity: 1; }
.icon-edit.small { font-size: 0.9rem; margin-left: 4px; vertical-align: middle; }

/* FAB */
.fab {
    position: fixed; bottom: 32px; right: 32px;
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary-gradient); color: white;
    display: flex; align-items: center; justify-content: center;
    border: none; box-shadow: var(--shadow-neon); cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 90;
}
.fab:hover { transform: scale(1.1) rotate(90deg); box-shadow: 0 12px 40px rgba(255,126,179,0.6); }
.fab:active { transform: scale(0.95); }

/* Form Fields */
.form-group { position: relative; margin-bottom: 24px; text-align: left; }

/* Nascondere freccette incrementali (spinners) dei campi numerici */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

.form-input {
    width: 100%; padding: 24px 16px 8px; font-size: 1.1rem; font-weight: 700;
    border: 2px solid var(--card-border); border-radius: 20px;
    background: rgba(255,255,255,0.5); color: var(--text-primary); transition: all 0.3s ease;
    outline: none; font-family: inherit;
}
.form-input:focus { border-color: var(--primary-color); background: rgba(0,0,0,0.4); box-shadow: 0 0 15px rgba(255,126,179,0.2); }
.form-label {
    position: absolute; left: 16px; top: 18px; color: var(--text-secondary);
    transition: all 0.2s ease; pointer-events: none; font-size: 1.05rem;
}
.form-input:focus ~ .form-label, .form-input:not(:placeholder-shown) ~ .form-label {
    transform: translateY(-10px); font-size: 0.75rem; color: var(--primary-color); font-weight: 700;
}

/* Toggle Switch */
.toggle-container {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px; text-align: left; background: rgba(0,0,0,0.2);
    padding: 16px; border-radius: 12px; border: 1px solid var(--card-border);
}
.toggle-label { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); line-height: 1.4; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 34px; border: 1px solid var(--card-border); }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }

.site-credits {
    position: fixed;
    bottom: 8px;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    pointer-events: none;
    z-index: 9999;
    font-weight: 600;
}
input:checked + .slider { background: var(--primary-gradient); border-color: transparent; }
input:checked + .slider:before { transform: translateX(22px); }

/* Editable elements in Bottom Sheet */
.title-input {
    background: transparent; border: none; border-bottom: 2px dashed rgba(0,0,0,0.2);
    color: var(--text-primary); font-size: 1.8rem; font-weight: 900; width: 100%; outline: none;
    padding-bottom: 4px; margin-bottom: 8px; transition: border-color 0.2s;
    font-family: inherit;
}
.title-input:focus { border-color: var(--primary-color); border-bottom-style: solid; }
.editable-stat {
    background: transparent; border: none; border-bottom: 2px dashed rgba(0,0,0,0.2);
    color: var(--text-primary); font-size: 1.8rem; font-weight: 900; width: 90px; text-align: center; /* Width increased to avoid cutoff */
    outline: none; transition: border-color 0.2s; font-family: inherit;
}
.editable-stat:focus { border-color: var(--primary-color); border-bottom-style: solid; }

.manual-input-container {
    display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 24px;
}
#input-manual-absent {
    width: 120px; padding: 12px; border-radius: 20px; border: 2px solid var(--card-border);
    background: rgba(255,255,255,0.5); color: var(--text-primary); font-size: 1.2rem; font-weight: 800; text-align: center; outline: none;
    font-family: inherit;
}
#input-manual-absent:focus { border-color: var(--primary-color); background: rgba(0,0,0,0.5); }

/* Animazione oro per il pulsante tutorial */
@keyframes goldShimmer {
    0% { transform: translateX(-100%); }
    40% { transform: translateX(100%); } /* Più lento: impiega il 40% dell'animazione per attraversare */
    100% { transform: translateX(100%); }
}

@keyframes btnPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.gold-shimmer-btn {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1e1e2f, #2a2a40) !important;
    color: #ffd700 !important;
    border: 1px solid rgba(255, 223, 0, 0.5) !important;
    box-shadow: 0 4px 15px rgba(255, 223, 0, 0.15) !important;
    transition: all 0.3s ease;
    animation: btnPulse 3s infinite ease-in-out;
}

.gold-shimmer-btn:hover {
    box-shadow: 0 6px 20px rgba(255, 223, 0, 0.3) !important;
    border-color: rgba(255, 223, 0, 0.6) !important;
    animation-play-state: paused;
}

.gold-shimmer-btn:active {
    transform: scale(0.96) !important;
}

.gold-shimmer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        115deg,
        transparent 35%,
        rgba(255, 223, 0, 0.1) 40%,
        rgba(255, 235, 100, 0.7) 45%,
        rgba(255, 255, 255, 0.95) 50%,
        rgba(255, 235, 100, 0.7) 55%,
        rgba(255, 223, 0, 0.1) 60%,
        transparent 65%
    );
    z-index: 1;
    pointer-events: none;
    animation: goldShimmer 5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}


.lang-drop-anim {
    /* animates separating from main box and floating */
    animation: dropSeparate 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.5s both, floatStationary 4s ease-in-out 1.3s infinite;
    bottom: -95px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.4), 0 0 1px rgba(255,255,255,0.2) inset !important;
}
.lang-dropdown-custom {
    flex: 0 0 auto;
    min-width: 140px;
}
.lang-dropdown-custom .dropdown-selected {
    padding: 8px 16px;
    font-size: 0.95rem;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    color: var(--text-primary);
}
.lang-dropdown-custom .dropdown-selected:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
    border-color: rgba(255,255,255,0.25);
}
.lang-dropdown-custom.open .dropdown-selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 255, 107, 139), 0.2);
}
.lang-dropdown-custom .dropdown-options {
    border-radius: 16px;
    padding: 8px;
    min-width: 160px;
    left: auto;
    right: 0;
}
.lang-dropdown-custom .dropdown-option {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 4px;
}
.lang-dropdown-custom .dropdown-option:last-child {
    margin-bottom: 0;
}


@keyframes dropSeparate {
    0% {
        transform: translateY(-80px) scale(0.6, 1.4);
        opacity: 0;
    }
    40% {
        transform: translateY(-20px) scale(0.9, 1.2);
        opacity: 1;
    }
    70% {
        transform: translateY(5px) scale(1.05, 0.95);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1, 1);
        opacity: 1;
    }
}

@keyframes floatStationary {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

.scan-char {
    display: inline-block;
    position: relative;
    transition: transform 0.1s ease-out, color 0.1s ease-out, text-shadow 0.1s ease-out;
}
