/* petrarca-diary style.css v2 — 2025 */
/* ══════════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════════ */
:root {
  --red:         #8B0000;
  --red-light:   #B22222;
  --red-pale:    #fdf0f0;
  --red-mid:     #e8c5c5;
  --red-dark:    #6b0000;
  --white:       #ffffff;
  --off-white:   #fafafa;
  --grey-100:    #f1f3f5;
  --grey-200:    #e9ecef;
  --grey-300:    #dee2e6;
  --grey-500:    #adb5bd;
  --grey-600:    #868e96;
  --grey-700:    #495057;
  --grey-900:    #212529;
  --green:       #2e7d32;
  --green-pale:  #e8f5e9;
  --amber:       #e65100;
  --amber-pale:  #fff3e0;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --nav-h:       68px;
  --header-h:    64px;
  --bg:              #0f0f0f;
  --surface:         #1a1a1a;
  --surface-2:       #242424;
  --text-primary:    #f0f0f0;
  --text-secondary:  #888;
  --border:          #2a2a2a;
  --input-bg:        #222;
  --grey-100-val:    #222;
  --grey-200-val:    #2a2a2a;
  --grey-300-val:    #333;
  --red-pale:        #1c0a0a;
  --red-mid:         #3a1515;
  --green-pale:      #0a1e0b;
  --amber-pale:      #1e1200;
}

/* DEFAULT DARK — sovrascriviamo con .light per tema chiaro */
body {
  --bg:              #0f0f0f;
  --surface:         #1a1a1a;
  --surface-2:       #242424;
  --text-primary:    #f0f0f0;
  --text-secondary:  #888;
  --border:          #2a2a2a;
  --input-bg:        #222;
  --grey-100:        #222;
  --grey-200:        #2a2a2a;
  --grey-300:        #333;
  --red-pale:        #1c0a0a;
  --red-mid:         #3a1515;
  --green-pale:      #0a1e0b;
  --amber-pale:      #1e1200;
}

/* LIGHT THEME */
body.light {
  --bg:              #fafafa;
  --surface:         #ffffff;
  --surface-2:       #f1f3f5;
  --text-primary:    #212529;
  --text-secondary:  #868e96;
  --border:          #e9ecef;
  --input-bg:        #f1f3f5;
  --grey-100:        #f1f3f5;
  --grey-200:        #e9ecef;
  --grey-300:        #dee2e6;
  --red-pale:        #fdf0f0;
  --red-mid:         #e8c5c5;
  --green-pale:      #e8f5e9;
  --amber-pale:      #fff3e0;
}

/* ══════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ══════════════════════════════════════════
   SPLASH
══════════════════════════════════════════ */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #111;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }
.splash-inner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.splash-logo {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(139,0,0,.3);
}
.splash-title { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; color: #f0f0f0; }
.splash-title span { color: #B22222; }
.splash-sub { font-size: .85rem; color: #888; margin-top: 4px; }
.splash-loader { margin-top: 32px; width: 36px; height: 3px; background: #2a2a2a; border-radius: 2px; overflow: hidden; }
.splash-loader div { height: 100%; width: 40%; background: #B22222; border-radius: 2px; animation: loader 1.2s ease infinite; }
@keyframes loader { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes fadeUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ══════════════════════════════════════════
   ONBOARDING OVERLAY
══════════════════════════════════════════ */
#onboardingOverlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.onboarding-box {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 28px 24px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); animation: fadeUp .3s ease;
}
.onboarding-box h2 { font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }
.onboarding-box p  { font-size: .82rem; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }
.onboarding-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.onboarding-row:last-of-type { border-bottom: none; }
.onboarding-row-left { display: flex; align-items: center; gap: 12px; }
.onboarding-icon { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); display: flex; align-items: center; justify-content: center; font-size: .9rem; color: #fff; flex-shrink: 0; }
.onboarding-label { font-size: .9rem; font-weight: 600; }
.onboarding-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer; width: 100%; margin-top: 20px; padding: 13px; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color: #fff; border: none; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 700; box-shadow: 0 4px 14px rgba(139,0,0,.3); transition: opacity .2s; }
.onboarding-btn:hover { opacity: .9; }

/* ══════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════ */
#authScreen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 36px 28px;
  box-shadow: var(--shadow-lg); animation: fadeUp .4s ease;
}
.auth-logo-row { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 28px; }
.auth-logo-row img { width: 44px; height: 44px; border-radius: 50%; }
.auth-logo-row .brand { font-size: 1.3rem; font-weight: 800; }
.auth-logo-row .brand span { color: var(--red); }
.auth-tabs { display: flex; background: var(--surface-2); border-radius: var(--radius-md); padding: 3px; margin-bottom: 24px; }
.auth-tab { flex: 1; padding: 9px; font-size: .85rem; font-weight: 600; border: none; background: none; border-radius: 11px; color: var(--text-secondary); transition: all .2s; }
.auth-tab.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.auth-panel { display: none; }
.auth-panel.active { display: block; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-group input { width: 100%; padding: 11px 14px; background: var(--input-bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; color: var(--text-primary); outline: none; transition: border-color .2s, box-shadow .2s; }
.form-group input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,0,0,.12); }
.auth-input-icon { position: relative; }
.auth-input-icon input, .auth-input-icon select { padding-left: 40px; }
.auth-input-icon i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: .85rem; pointer-events: none; z-index: 1; }
#authScreen .form-group input, #authScreen .form-group select { width: 100%; padding: 11px 14px; background: var(--input-bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; color: var(--text-primary); outline: none; transition: border-color .2s, box-shadow .2s; appearance: none; }
#authScreen .form-group input:focus, #authScreen .form-group select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,0,0,.12); }
#authScreen .auth-input-icon input, #authScreen .auth-input-icon select { padding-left: 40px; }
.btn-auth { width: 100%; padding: 13px; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color: #fff; border: none; border-radius: var(--radius-sm); font-size: .95rem; font-weight: 700; margin-top: 4px; box-shadow: 0 4px 14px rgba(139,0,0,.3); transition: opacity .2s, transform .1s; }
.btn-auth:hover { opacity: .9; }
.btn-auth:active { transform: scale(.98); }
.reset-link { text-align: right; margin-top: 8px; font-size: .78rem; }
.reset-link a { color: var(--text-secondary); cursor: pointer; text-decoration: none; transition: color .2s; }
.reset-link a:hover { color: var(--red); text-decoration: underline; }
.reset-link a:disabled { opacity: .5; pointer-events: none; }
.auth-error { background: var(--red-pale); border: 1px solid var(--red-mid); color: var(--red); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .82rem; margin-bottom: 12px; display: none; }
.auth-error.show { display: block; }





.auth-divider { text-align: center; color: var(--text-secondary); font-size: .78rem; margin: 24px 0 0; }
.auth-divider a { color: var(--red); font-weight: 600; cursor: pointer; text-decoration: none; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-theme-btn { position: fixed; top: 16px; right: 16px; width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); font-size: .9rem; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); transition: background .2s; }

/* ══════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════ */
#app { display: none; flex-direction: column; min-height: 100vh; }
#app.visible { display: flex; }

.app-header { position: sticky; top: 0; z-index: 100; height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.header-name { font-size: .95rem; font-weight: 700; }
.header-name strong { color: var(--red); }
.header-date { font-size: .7rem; color: var(--text-secondary); display: block; }
.header-right { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--grey-100); border: none; display: flex; align-items: center; justify-content: center; color: var(--text-primary); font-size: .88rem; transition: background .2s; }
.icon-btn:hover { background: var(--red-mid); color: var(--red); }

.user-chip { display: flex; align-items: center; gap: 6px; background: var(--red-pale); border: 1px solid var(--red-mid); border-radius: 20px; padding: 4px 10px 4px 4px; font-size: .78rem; font-weight: 600; color: var(--red); cursor: pointer; user-select: none; transition: opacity .15s; }
.user-chip:hover { opacity: .85; }
.user-chip-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 800; }
.user-chip-wrap { position: relative; }

.user-menu { position: absolute; top: calc(100% + 10px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 220px; z-index: 500; overflow: hidden; animation: fadeUp .18s ease; }
.user-menu-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.user-menu-avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color: #fff; font-size: .95rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.user-menu-name { font-size: .88rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-class { font-size: .72rem; color: var(--text-secondary); margin-top: 2px; }
.user-menu-divider { height: 1px; background: var(--border); }
.user-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; background: none; border: none; font-size: .85rem; font-weight: 600; color: var(--text-primary); cursor: pointer; text-align: left; transition: background .15s; }
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-logout { color: var(--red); }

.page-content { flex: 1; overflow-y: auto; padding-bottom: calc(var(--nav-h) + 16px); }
.page { display: none; padding: 16px; max-width: 680px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.page.active { display: block; }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; height: var(--nav-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 8px env(safe-area-inset-bottom, 0); box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 4px; background: none; border: none; color: var(--text-secondary); font-size: .68rem; font-weight: 600; border-radius: var(--radius-md); transition: color .2s, background .2s; position: relative; }
.nav-item i { font-size: 1.1rem; transition: transform .2s; }
.nav-item:hover { color: var(--red); background: var(--red-pale); }
.nav-item.active { color: var(--red); }
.nav-item.active i { transform: scale(1.15); }
.nav-badge { position: absolute; top: 4px; right: calc(50% - 16px); background: var(--red); color: #fff; border-radius: 10px; padding: 1px 5px; font-size: .6rem; font-weight: 700; min-width: 16px; text-align: center; }

/* ══════════════════════════════════════════
   CARDS & FORMS
══════════════════════════════════════════ */
.section-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.section-hero-icon { width: 48px; height: 48px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--red-light), var(--red-dark)); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: #fff; flex-shrink: 0; box-shadow: 0 4px 12px rgba(139,0,0,.25); }
.section-hero h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.section-hero p  { font-size: .78rem; color: var(--text-secondary); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.card-header { margin-bottom: 14px; }
.card-header h3 { font-size: .9rem; font-weight: 700; color: var(--text-primary); }
.card-header h3 i { color: var(--red); margin-right: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.form-grid .full-span { grid-column: 1 / -1; }
.form-group label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; background: var(--input-bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .85rem; color: var(--text-primary); outline: none; transition: border-color .2s, box-shadow .2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,0,0,.1); }
.form-group textarea { resize: vertical; }
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23868e96' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 20px; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color: #fff; border: none; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 700; box-shadow: 0 3px 10px rgba(139,0,0,.25); transition: opacity .2s, transform .1s; }
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full-width { width: 100%; }

/* Collapsible */
.card-collapsible .card-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; margin-bottom: 0; }
.card-collapsible .card-header h3 { margin: 0; }
.card-toggle-icon { color: var(--text-secondary); font-size: .8rem; transition: transform .25s ease; flex-shrink: 0; }
.card-collapsible.open .card-toggle-icon { transform: rotate(180deg); }
.card-body { overflow: hidden; max-height: 0; transition: max-height .3s ease, padding .3s ease; padding-top: 0; }
.card-collapsible.open .card-body { max-height: 1000px; padding-top: 14px; }

/* ══════════════════════════════════════════
   TIMETABLE
══════════════════════════════════════════ */
.timetable-container { margin-top: 4px; }
.timetable-empty { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.timetable-empty i { font-size: 2.5rem; margin-bottom: 10px; opacity: .4; display: block; }
.tt-day-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tt-day-tabs::-webkit-scrollbar { display: none; }
.tt-day-tab { flex-shrink: 0; padding: 6px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: .78rem; font-weight: 700; color: var(--text-secondary); cursor: pointer; transition: all .2s; }
.tt-day-tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.tt-day-tab.has-lessons { border-color: var(--red-mid); color: var(--red); }
.tt-day-tab.active.has-lessons { background: var(--red); color: #fff; }
.tt-day-panel { display: none; }
.tt-day-panel.active { display: block; }
.tt-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.tt-table thead tr { background: linear-gradient(135deg, var(--red-light), var(--red-dark)); }
.tt-table thead th { padding: 10px 12px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #fff; text-align: left; }
.tt-table thead th:last-child { width: 36px; text-align: center; }
.tt-table tbody tr { border-top: 1px solid var(--border); transition: background .15s; }
.tt-table tbody tr:hover { background: var(--surface-2); }
.tt-table tbody td { padding: 11px 12px; font-size: .84rem; color: var(--text-primary); vertical-align: middle; }
.tt-table tbody td:first-child { font-size: .75rem; font-weight: 700; color: var(--red); white-space: nowrap; min-width: 80px; }
.tt-materia-cell { font-weight: 700; }
.tt-sub-cell { font-size: .72rem; color: var(--text-secondary); margin-top: 2px; }
.tt-del-btn { background: none; border: none; color: var(--grey-500); font-size: .8rem; padding: 4px 6px; border-radius: 4px; cursor: pointer; transition: color .2s, background .2s; display: flex; align-items: center; justify-content: center; }
.tt-del-btn:hover { color: var(--red); background: var(--red-pale); }
.tt-empty-row td { text-align: center; padding: 22px; color: var(--text-secondary); font-size: .82rem; font-style: italic; }

/* ══════════════════════════════════════════
   COMPITI
══════════════════════════════════════════ */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 8px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-chip span { font-size: 1.4rem; font-weight: 800; display: block; }
.stat-chip small { font-size: .68rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; }
.stat-chip.accent span { color: var(--amber); }
.stat-chip.success span { color: var(--green); }
.stat-chip.danger span  { color: var(--red); }
.filter-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.filter-tab { padding: 6px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: .78rem; font-weight: 600; color: var(--text-secondary); transition: all .2s; }
.filter-tab.active { background: var(--red); color: #fff; border-color: var(--red); }
.filter-tab:hover:not(.active) { border-color: var(--red); color: var(--red); }
.list-container { display: flex; flex-direction: column; gap: 8px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); width: 100%; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: 10px; opacity: .4; }
.empty-state p { font-size: .85rem; line-height: 1.5; }
.compito-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; display: flex; gap: 12px; align-items: flex-start; box-shadow: var(--shadow-sm); transition: opacity .3s; }
.compito-card.completato { opacity: .55; }
.compito-card.scaduto { border-left: 3px solid var(--red); }
.compito-check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); background: var(--input-bg); flex-shrink: 0; cursor: pointer; margin-top: 1px; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.compito-check.checked { background: var(--green); border-color: var(--green); }
.compito-check.checked::after { content: '✓'; font-size: .7rem; color: #fff; font-weight: 700; }
.compito-info { flex: 1; min-width: 0; }
.compito-materia { font-size: .88rem; font-weight: 700; }
.compito-desc { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.compito-footer { display: flex; align-items: center; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: .68rem; font-weight: 700; }
.badge-alta  { background: var(--red-pale); color: var(--red); }
.badge-media { background: var(--amber-pale); color: var(--amber); }
.badge-bassa { background: var(--green-pale); color: var(--green); }
.badge-date  { background: var(--grey-100); color: var(--text-secondary); }
.badge-scad  { background: var(--red-pale); color: var(--red); }
.compito-actions { display: flex; gap: 4px; }
.item-del-btn { background: none; border: none; color: var(--grey-500); font-size: .8rem; padding: 4px 6px; border-radius: 4px; transition: color .2s, background .2s; }
.item-del-btn:hover { color: var(--red); background: var(--red-pale); }

/* ══════════════════════════════════════════
   VOTI
══════════════════════════════════════════ */
.avg-banner { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.avg-circle { width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(139,0,0,.3); }
.avg-circle span { font-size: 1.2rem; font-weight: 800; color: #fff; }
.avg-info strong { font-size: .9rem; font-weight: 700; display: block; }
.avg-info small  { font-size: .78rem; color: var(--text-secondary); }
.materia-group { margin-bottom: 14px; }
.materia-label { display: flex; align-items: center; justify-content: space-between; font-size: .8rem; font-weight: 700; margin-bottom: 6px; padding: 0 2px; }
.materia-avg { background: var(--red-pale); color: var(--red); border: 1px solid var(--red-mid); border-radius: 20px; padding: 2px 10px; font-size: .75rem; font-weight: 700; }
.voto-chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 6px; box-shadow: var(--shadow-sm); }
.voto-chip.voto-no-media { opacity: .6; border-style: dashed; }
.voto-val { width: 40px; height: 40px; border-radius: var(--radius-sm); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 800; color: #fff; }
.voto-val.high { background: linear-gradient(135deg, #2e7d32, #1b5e20); }
.voto-val.mid  { background: linear-gradient(135deg, #f57f17, #e65100); }
.voto-val.low  { background: linear-gradient(135deg, var(--red-light), var(--red-dark)); }
.voto-info { flex: 1; }
.voto-tipo-date { font-size: .72rem; color: var(--text-secondary); margin-top: 1px; }
.voto-note { font-size: .72rem; color: var(--text-secondary); font-style: italic; }

/* ══════════════════════════════════════════
   ESAMI
══════════════════════════════════════════ */
.esame-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.esame-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(to bottom, var(--red-light), var(--red-dark)); }
.esame-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.esame-materia { font-size: .95rem; font-weight: 700; }
.esame-tipo { font-size: .75rem; color: var(--text-secondary); margin-top: 2px; }
.countdown-badge { background: var(--red-pale); color: var(--red); border: 1px solid var(--red-mid); border-radius: var(--radius-sm); padding: 4px 10px; font-size: .72rem; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.countdown-badge.soon { background: var(--amber-pale); color: var(--amber); border-color: #ffcc80; }
.countdown-badge.today { background: var(--red-pale); color: var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.esame-argomenti { font-size: .78rem; color: var(--text-secondary); margin-top: 8px; line-height: 1.4; }
.esame-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ══════════════════════════════════════════
   APPUNTI
══════════════════════════════════════════ */
.notes-fab { position: fixed; bottom: calc(var(--nav-h) + 16px); right: 16px; width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color: #fff; border: none; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(139,0,0,.35); z-index: 200; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.notes-fab:hover { transform: scale(1.08); }
.notes-fab:active { transform: scale(.95); }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 4px; }
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; box-shadow: var(--shadow-sm); min-height: 100px; display: flex; flex-direction: column; transition: box-shadow .2s; }
.note-card:hover { box-shadow: var(--shadow-md); }
.note-text { font-size: .84rem; line-height: 1.5; color: var(--text-primary); flex: 1; word-break: break-word; white-space: pre-wrap; }
.note-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.note-date { font-size: .65rem; color: var(--text-secondary); }
.note-actions { display: flex; gap: 4px; }
.note-btn { background: none; border: none; cursor: pointer; font-size: .75rem; padding: 3px 5px; border-radius: 4px; color: var(--text-secondary); transition: color .2s, background .2s; }
.note-btn:hover { background: var(--surface-2); }
.note-btn.del:hover { color: var(--red); background: var(--red-pale); }
.note-btn.save { color: var(--red); }
.note-btn.save:hover { background: var(--red-pale); }
.note-modal-box { background: var(--surface); border-radius: var(--radius-xl); padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); animation: fadeUp .25s ease; }
.note-modal-box h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }
.note-modal-box textarea { width: 100%; min-height: 120px; background: var(--input-bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .88rem; color: var(--text-primary); resize: vertical; outline: none; font-family: inherit; transition: border-color .2s; }
.note-modal-box textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(139,0,0,.12); }
.note-modal-btns { display: flex; gap: 10px; margin-top: 14px; }
.btn-confirm { flex: 1; padding: 11px; background: linear-gradient(135deg, var(--red-light), var(--red-dark)); color:#fff; border:none; border-radius: var(--radius-sm); font-size:.88rem; font-weight:700; cursor:pointer; transition: opacity .2s; }
.btn-confirm:hover { opacity: .88; }

/* ══════════════════════════════════════════
   MODALI & TOAST
══════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeIn .2s ease; }
.modal-overlay.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--radius-xl); padding: 28px 24px; width: 100%; max-width: 340px; text-align: center; box-shadow: var(--shadow-lg); animation: fadeUp .25s ease; }
.modal-icon { font-size: 2rem; margin-bottom: 12px; }
.modal h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.modal p  { font-size: .82rem; color: var(--text-secondary); margin-bottom: 18px; }
.modal-btns { display: flex; gap: 10px; }
.btn-secondary { flex: 1; padding: 10px; background: var(--grey-100); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; color: var(--text-primary); }
.btn-danger { flex: 1; padding: 10px; background: var(--red); border: none; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 700; color: #fff; }
.toast { position: fixed; bottom: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%) translateY(20px); background: #f0f0f0; color: #111; border-radius: 22px; padding: 10px 20px; font-size: .82rem; font-weight: 600; opacity: 0; pointer-events: none; z-index: 9998; transition: opacity .25s, transform .25s; white-space: nowrap; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
body.light .toast { background: #1a1a1a; color: #fff; }

/* ══════════════════════════════════════════
   IMPOSTAZIONI
══════════════════════════════════════════ */
#page-impostazioni .settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.settings-section-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-secondary); padding: 12px 16px 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-top: 1px solid var(--border); }
.settings-row:first-of-type { border-top: none; }
.settings-row-left { display: flex; align-items: center; gap: 12px; }
.settings-row-icon { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .9rem; color: #fff; }
.settings-row-label { font-size: .88rem; font-weight: 600; }
.settings-row-sub { font-size: .72rem; color: var(--text-secondary); margin-top: 1px; }
.toggle-wrap { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--grey-300); border-radius: 12px; cursor: pointer; transition: background .25s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-wrap input:checked + .toggle-slider { background: var(--red); }
.toggle-wrap input:checked + .toggle-slider::before { transform: translateX(20px); }
/* ── Checkbox custom ── */
.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: .88rem; font-weight: 600;
  color: var(--text-primary); user-select: none;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--input-bg);
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s;
}
.checkbox-label input:checked + .checkbox-custom {
  background: var(--red); border-color: var(--red);
}
.checkbox-label input:checked + .checkbox-custom::after {
  content: '✓'; color: #fff; font-size: .75rem; font-weight: 800;
}
══════════════════════════════════════════════════════════════ */
.profile-avatar-big {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--red-light), var(--red-dark));
  color: #fff; font-size: 1.4rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.profile-avatar-big img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.settings-upload-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; transition: background .2s, color .2s;
}
.settings-upload-btn:hover { background: var(--red-pale); color: var(--red); border-color: var(--red-mid); }
.settings-edit-row { align-items: center; }
.settings-edit-btn {
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .8rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .2s, color .2s; font-family: inherit;
}
.settings-edit-btn:hover { background: var(--red-pale); color: var(--red); border-color: var(--red-mid); }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — nascosta su mobile
══════════════════════════════════════════════════════════════ */
.app-sidebar { display: none; }

/* ══════════════════════════════════════════════════════════════
   DESKTOP LAYOUT (≥ 900px)
   Completamente diverso dal mobile — sidebar + contenuto
══════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {

  /* ── Reset mobile-specific styles ── */
  .bottom-nav { display: none !important; }
  .notes-fab  { bottom: 28px; }

  /* ── Grid layout ── */
  #app,
  #app.visible {
    display: grid !important;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
      "sidebar header"
      "sidebar main";
    height: 100vh;
    overflow: hidden;
    flex-direction: unset;
    min-height: unset;
  }

  /* ── Sidebar ── */
  .app-sidebar {
    display: flex !important;
    flex-direction: column;
    grid-area: sidebar;
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: 100vh;
    padding: 0 0 16px;
    overflow-y: auto;
    z-index: 50;
  }

  .sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }
  .sidebar-logo img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
  .sidebar-logo .brand { font-size: .95rem; font-weight: 800; color: var(--text-primary); }
  .sidebar-logo .brand span { color: var(--red); }

  .sidebar-nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; margin: 1px 8px;
    border-radius: var(--radius-md);
    background: none; border: none;
    color: var(--text-secondary);
    font-size: .88rem; font-weight: 600;
    cursor: pointer; text-align: left; width: calc(100% - 16px);
    font-family: inherit;
    transition: background .15s, color .15s;
    position: relative;
  }
  .sidebar-nav-item i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
  .sidebar-nav-item:hover  { background: var(--surface-2); color: var(--text-primary); }
  .sidebar-nav-item.active { background: var(--red-pale);  color: var(--red); font-weight: 700; }
  .sidebar-badge {
    margin-left: auto; background: var(--red); color: #fff;
    border-radius: 10px; padding: 1px 6px;
    font-size: .62rem; font-weight: 700; min-width: 16px; text-align: center;
  }
  .sidebar-bottom {
    margin-top: auto; padding: 12px 8px 0;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 2px;
  }

  /* ── Header ── */
  .app-header {
    grid-area: header;
    height: 60px;
    position: sticky; top: 0; z-index: 100;
  }

  /* ── Main content ── */
  main.page-content {
    grid-area: main;
    overflow-y: auto;
    padding-bottom: 40px;
    height: calc(100vh - 60px);
  }

  /* ── Pages ── */
  .page { max-width: 900px; padding: 28px 36px; }

  /* ── Form più spaziosi ── */
  .form-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }

  /* ── Cards ── */
  .card { padding: 22px; }
  .section-hero { padding: 22px; margin-bottom: 20px; }
  .section-hero h2 { font-size: 1.25rem; }

  /* ── Timetable ── */
  .tt-table tbody td { padding: 13px 16px; font-size: .9rem; }
  .tt-table thead th { padding: 12px 16px; }

  /* ── Stats ── */
  .stats-row { gap: 12px; margin-bottom: 18px; }
  .stat-chip span { font-size: 1.6rem; }

  /* ── Notes grid ── */
  .notes-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .note-card { min-height: 120px; padding: 16px; }

  /* ── Impostazioni ── */
  #page-impostazioni .settings-section { margin-bottom: 20px; }
  .settings-row { padding: 16px 20px; }
}

/* ── Tasto condividi voti ── */
.btn-share-voti {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #B22222;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  transition: background .2s, transform .15s;
  font-family: Inter, sans-serif;
}
.btn-share-voti:hover { background: #9b1c1c; transform: translateY(-1px); }
.btn-share-voti:active { transform: translateY(0); }

.avg-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
