/* Palette del design "The Professor": tinte OKLCH, accenti a luminosità e croma costanti
   (L=0.75, C=0.13) con la sola tonalità che cambia, così i quattro colori hanno lo stesso peso
   visivo. Il tema scuro è quello di riferimento; il chiaro è l'alternativa. */
:root {
  --bg: oklch(0.98 0.004 75);
  --sidebar: oklch(1 0 0);
  --surface: oklch(1 0 0);
  --surface-hover: oklch(0.95 0.008 75);
  --border: oklch(0.90 0.01 75);
  --text: oklch(0.20 0.012 75);
  --text-muted: oklch(0.48 0.012 75);
  --text-faint: oklch(0.62 0.012 75);

  --accent: oklch(0.75 0.13 85);          /* oro: azioni principali */
  --accent-hover: oklch(0.80 0.13 85);
  --accent-soft: oklch(0.95 0.05 85);
  --on-accent: oklch(0.22 0.03 85);       /* testo sopra l'oro */
  --teal: oklch(0.75 0.13 200);           /* conferme, dimostrazioni */
  --coral: oklch(0.75 0.13 30);           /* quiz, avvisi */
  --violet: oklch(0.75 0.13 300);
  --sky: oklch(0.75 0.13 250);            /* calendario, date */
  /* Gli stessi accenti li rigenera app.js per numero, per dare a ogni materia una tonalità
     diversa nella dashboard. */

  --success: oklch(0.62 0.15 145);
  --success-soft: oklch(0.93 0.07 145);
  --error: oklch(0.60 0.17 25);
  --error-soft: oklch(0.93 0.07 25);
  --warning: oklch(0.62 0.13 85);
  --warning-soft: oklch(0.95 0.06 85);

  --grid-line: oklch(0.85 0.01 75 / 0.35);
  --spotlight: oklch(0.9 0.015 75 / 0.30);

  --radius: 16px;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
}

/* Il tema scuro si applica sia seguendo le preferenze di sistema (finché l'utente non sceglie
   esplicitamente il tema chiaro) sia quando è stato selezionato a mano dal menu Opzioni. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(0.24 0.017 250);
    --sidebar: oklch(0.21 0.016 250);
    --surface: oklch(0.28 0.018 250);
    --surface-hover: oklch(0.33 0.02 250);
    --border: oklch(0.38 0.022 250);
    --text: oklch(0.96 0.004 75);
    --text-muted: oklch(0.72 0.014 250);
    --text-faint: oklch(0.55 0.014 250);
    --accent-soft: oklch(0.32 0.06 85);
    --on-accent: oklch(0.18 0.03 85);
    --success: oklch(0.75 0.14 145);
    --success-soft: oklch(0.32 0.09 145);
    --error: oklch(0.72 0.15 25);
    --error-soft: oklch(0.32 0.09 25);
    --warning: oklch(0.78 0.12 85);
    --warning-soft: oklch(0.32 0.07 85);
    --grid-line: oklch(0.42 0.02 250 / 0.25);
    --spotlight: oklch(0.55 0.03 250 / 0.14);
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: oklch(0.24 0.017 250);
  --sidebar: oklch(0.21 0.016 250);
  --surface: oklch(0.28 0.018 250);
  --surface-hover: oklch(0.33 0.02 250);
  --border: oklch(0.38 0.022 250);
  --text: oklch(0.96 0.004 75);
  --text-muted: oklch(0.72 0.014 250);
  --text-faint: oklch(0.55 0.014 250);
  --accent-soft: oklch(0.32 0.06 85);
  --on-accent: oklch(0.18 0.03 85);
  --success: oklch(0.75 0.14 145);
  --success-soft: oklch(0.32 0.09 145);
  --error: oklch(0.72 0.15 25);
  --error-soft: oklch(0.32 0.09 25);
  --warning: oklch(0.78 0.12 85);
  --warning-soft: oklch(0.32 0.07 85);
  --grid-line: oklch(0.42 0.02 250 / 0.25);
  --spotlight: oklch(0.55 0.03 250 / 0.14);
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

/* Fa seguire ai controlli nativi (date picker, scrollbar) il tema scelto a mano. */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  /* senza questo Manrope trasforma "(c)" in © e rovina le formule fra parentesi */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.35); border-radius: 8px; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounceDot { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-6px); opacity: 1; } }
@keyframes blink { 0%, 88%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } }

.app-shell { display: flex; height: 100vh; width: 100%; }

.sidebar {
  width: 250px;
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: width 0.18s ease, padding 0.18s ease;
}

.sidebar.collapsed { width: 62px; padding: 22px 10px; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  flex: none;
}
.sidebar-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar.collapsed .sidebar-toggle { margin: 0 auto; }

/* Logo: gli occhiali del professore + il marchio in Lora */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; opacity: 0.8; }
.brand .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.sidebar.collapsed .brand { justify-content: center; padding: 0; }
.sidebar.collapsed .brand .wordmark { display: none; }
.mascot { flex: none; display: block; }
.mascot .pupil { animation: blink 4.5s infinite; transform-origin: center; }
.mascot .pupil.right { animation-delay: 0.2s; }
.mascot-float { animation: float 4s ease-in-out infinite; }

.sidebar.collapsed .side-nav,
.sidebar.collapsed .sidebar-footer { display: none; }
/* Chiusa restano 62px: del riquadro in fondo ci sta solo la foto. Il nome e "Esci" andrebbero a
   finire fuori, lasciando vedere una lettera sola accanto alla foto. */
.sidebar.collapsed .sidebar-user { justify-content: center; gap: 0; margin-top: auto; }
.sidebar.collapsed .sidebar-user a:not(.chi-foto) { display: none; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.side-link:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.side-link.active { background: var(--surface-hover); color: var(--text); font-weight: 700; }
.side-icon { width: 17px; height: 17px; flex: none; opacity: 0.9; }
.side-link.active .side-icon { opacity: 1; }
#home-link .side-icon { color: var(--accent); }
#options-link .side-icon { color: var(--teal); }
#faq-link .side-icon { color: var(--violet); }
#activity-link .side-icon { color: var(--coral); }
#profile-link .side-icon { color: var(--success); }
#calendar-link .side-icon { color: var(--sky); }
#buy-link .side-icon { color: var(--success); }

/* Portafoglio nella barra: quanti crediti restano */
.wallet-mini {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-top: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
}
.wallet-mini:hover { border-color: var(--accent); text-decoration: none; }
.wallet-mini-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.wallet-mini-valore { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
/* A zero diventa rosso: il blocco si vede arrivare invece di scoprirlo al primo clic */
.wallet-mini.finito { border-color: var(--error); }
.wallet-mini.finito .wallet-mini-valore { color: var(--error); }
.sidebar.collapsed .wallet-mini { display: none; }

/* In fondo alla barra: interruttore rapido del tema */
.sidebar-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-footer .theme-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.theme-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex: none;
  padding: 0;
  border-radius: 13px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  cursor: pointer;
}
.theme-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  transition: left 0.25s ease;
}
.theme-switch.is-dark .knob { left: calc(100% - 24px); }

/* Area principale: sfondo con griglia leggera e alone che segue il puntatore */
.main-content { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--bg); }
.main-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(500px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), var(--spotlight) 0%, transparent 65%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 34px 34px, 34px 34px;
}
/* Formule e citazioni che compaiono e svaniscono negli angoli, puramente decorative */
.backdrop-quotes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.backdrop-quote {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  opacity: 0;
  transition: opacity 6.5s ease-in-out;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  font-family: monospace;
  font-size: 19px;
  font-weight: 600;
}
.backdrop-quote.quote { font-family: var(--font-display); font-style: italic; font-size: 15px; font-weight: 500; }
.backdrop-quote.visible { opacity: 0.16; }

.container {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow: auto;
  max-width: 1400px;
  margin: 0 auto;
  padding: 36px 48px 60px;
  display: flex;
  flex-direction: column;
}

/* Percorso di navigazione in cima a ogni pagina */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 22px;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { font-weight: 700; color: var(--text); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; height: auto; }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main-content { overflow: visible; }
  .container { height: auto; overflow: visible; padding: 24px 20px 48px; }
}

h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 30px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 20px; font-weight: 600; margin: 30px 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { background: var(--accent-hover); }
/* Pulsante "fantasma": solo bordo, per le azioni secondarie */
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
}
.btn.secondary:hover { background: var(--surface-hover); }
.btn.teal { background: var(--teal); color: var(--on-accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 7px 14px; font-size: 12.5px; border-radius: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* Intestazione di pagina: titolo a sinistra, mascotte o azioni a destra */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head .subtitle { font-size: 14px; color: var(--text-muted); margin: 4px 0 0; }
/* Crediti rimasti sotto al titolo della materia: è la pagina da cui partono le operazioni che
   li consumano, quindi qui il numero serve a colpo d'occhio. */
.crediti-rimasti { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.crediti-rimasti:hover { color: var(--text); text-decoration: none; }
.crediti-rimasti.vuoto { color: var(--error); }

/* Riquadri con i numeri della dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.stat-card .value.vuoto { color: var(--error); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.subject-card {
  position: relative;
  display: block;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.subject-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.subject-card .name { font-weight: 700; font-size: 15px; }
.subject-card .meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.subject-card .coverage { color: var(--text-faint); font-size: 12px; margin-top: 6px; }
.subject-card-link { display: block; color: inherit; }
.subject-card-link:hover { text-decoration: none; }
.subject-card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.subject-card .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--accent); }
.subject-card .btn { position: absolute; right: 16px; bottom: 16px; }
.subject-card .meter, .subject-card .coverage { margin-right: 92px; }

/* Barra di riempimento riusata da materie, XP e avanzamenti */
.meter { position: relative; height: 6px; border-radius: 4px; background: var(--surface-hover); margin-top: 14px; }
.meter > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.6s ease; }
/* Dove si dovrebbe essere oggi rispetto alla data d'esame */
.meter > .marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  border-radius: 2px;
  background: var(--text);
  transform: translateX(-1px);
}

/* Riquadro tratteggiato "aggiungi" */
.dashed-card {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  background: none;
  font-family: inherit;
}
.dashed-card:hover { border-color: var(--accent); color: var(--accent); }

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge.completato { background: var(--success); color: var(--on-accent); }
.badge.errore { background: var(--error-soft); color: var(--error); }
.badge.pending, .badge.default { background: var(--surface-hover); color: var(--text-muted); }

.lesson-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  background: var(--surface);
  transition: border-color 0.2s ease;
}
.lesson-row:hover { border-color: var(--accent); }
.lesson-row .title { font-weight: 600; font-size: 14.5px; }
.lesson-row .right { display: flex; align-items: center; gap: 10px; }

/* Syllabus e data d'esame: due riquadri appaiati sotto al titolo della materia. Quando il dato
   manca mostrano il campo per inserirlo; quando c'è diventano una riga compatta — etichetta
   piccola in alto, valore in evidenza, pulsante per cambiarlo a destra. */
.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 8px;
}
/* Questi riquadri stanno subito sotto al titolo della materia e sopra "Nuova lezione": senza
   restringere i margini dei vicini resterebbero due fasce vuote grandi quanto i riquadri. */
.page-head:has(+ .setup-grid) { margin-bottom: 14px; }
.setup-grid + h2 { margin-top: 8px; }
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  transition: border-color 0.2s ease;
  /* Il riquadro resta della stessa misura sia da riempire sia riempito: senza, caricando il
     syllabus o scegliendo la data la pagina si accorciava di colpo sotto le mani. */
  min-height: 140px;
}
.setup-card:hover { border-color: var(--accent); }
.setup-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.setup-hint { margin: 6px 0 12px; font-size: 0.82rem; color: var(--text-muted); }
.setup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.setup-row input { flex: 1 1 180px; min-width: 0; }

.setup-done { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
/* "hidden" deve vincere sul display dei componenti, altrimenti i riquadri si vedono tutti e due */
[hidden] { display: none !important; }
.setup-text { min-width: 0; }
.setup-value {
  display: block;
  margin-top: 5px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text);
  /* i nomi dei file possono essere lunghissimi: meglio tagliarli che sfondare il riquadro */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-note { display: block; margin-top: 3px; font-size: 0.82rem; color: var(--text-muted); }
.setup-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.setup-actions .btn { justify-content: center; }
/* Azioni che tolgono qualcosa: si vedono che sono diverse solo quando ci passi sopra */
.btn.secondary.danger:hover { border-color: var(--error); color: var(--error); background: var(--error-soft); }

@media (max-width: 720px) {
  .setup-grid { grid-template-columns: 1fr; }
}

/* Nuova lezione: i quattro campi in riga, larghi uguali, a riempire tutto il riquadro; il
   pulsante sotto, a destra. Sugli schermi stretti diventano due colonne e poi una. */
.lesson-form { display: flex; flex-direction: column; gap: 16px; }
.lesson-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.lesson-fields .field { min-width: 0; }
.lesson-fields input { width: 100%; }
.lesson-actions { display: flex; justify-content: center; }

@media (max-width: 1100px) {
  .lesson-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .lesson-fields { grid-template-columns: 1fr; }
  .lesson-actions .btn { width: 100%; justify-content: center; }
}

form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
/* La "✕" per annullare il file scelto sta dentro al campo, all'estremità destra */
.file-row { position: relative; display: flex; align-items: center; }
.file-row input { flex: 1; }
.file-clear {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}
.file-clear:hover { background: var(--accent-soft); color: var(--accent); }
.field label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], textarea, select {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
}
/* Va dopo la regola qui sopra, che ha la stessa specificità: serve spazio a destra per la ✕,
   così il testo (o il nome del file) non le finisce sotto. */
.file-row input { padding-right: 30px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type=date] {
  color-scheme: light dark;
  min-height: 38px;
}
textarea { resize: vertical; }

.tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  margin: 20px 0 0;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.tab-btn {
  padding: 10px 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.tab-panel { display: none; padding-top: 22px; animation: slideUp 0.35s ease; }
.tab-panel.active { display: block; }

.summary-content { line-height: 1.7; }
.summary-content h1 {
  margin: 28px 0 14px;
  padding-bottom: 10px;
  font-size: 24px;
  border-bottom: 2px solid var(--accent);
}
.summary-content h2 {
  margin: 30px 0 12px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  font-size: 17px;
}
.summary-content h2:first-child { margin-top: 0; }
.summary-content h3 {
  margin: 22px 0 8px;
  color: var(--accent);
  font-size: 15px;
}
.summary-content ul, .summary-content ol { padding-left: 22px; }
/* Testo giustificato come in Word, con sillabazione per evitare spaziature troppo larghe. */
.summary-content p, .summary-content li {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.summary-content p { margin: 10px 0; }
.summary-content code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
.summary-content hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.algo-block {
  display: block;
  max-width: 720px;
  margin: 18px auto;
  padding: 16px 22px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
}
.algo-block code { background: none; padding: 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

.table-wrap { overflow-x: auto; margin: 16px 0; }
.table-wrap table, .formula-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table-wrap th, .table-wrap td,
.formula-table th, .formula-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.table-wrap th, .formula-table th {
  background: var(--surface-hover);
  font-weight: 700;
  white-space: nowrap;
}
.table-wrap tr:nth-child(even) td, .formula-table tbody tr:nth-child(even) td {
  background: var(--surface-hover);
}
.formula-table td:nth-child(2) { min-width: 200px; }

.plan-block {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
  background: var(--surface);
}
.plan-block .period {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.plan-block .focus { font-weight: 600; margin: 3px 0 6px; }
.plan-block ul { margin: 0; padding-left: 18px; font-size: 0.88rem; color: var(--text-muted); }
.plan-block.done { border-left-color: var(--success); opacity: 0.6; }
.plan-block.done .focus { text-decoration: line-through; }
.plan-block-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.plan-block-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.plan-progress-wrap { margin-bottom: 18px; }
.plan-progress-status { font-weight: 700; font-size: 0.92rem; margin-bottom: 8px; }
.plan-progress-status.on-track { color: var(--success); }
.plan-progress-status.behind { color: var(--error); }
.plan-progress-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--border);
  overflow: visible;
}
.plan-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  overflow: hidden;
}
.plan-progress-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  border-radius: 2px;
  background: var(--text);
  transform: translateX(-1px);
}
.plan-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

details.transcript { margin-top: 24px; }
details.transcript summary { cursor: pointer; font-weight: 600; color: var(--text-muted); }
details.transcript pre { white-space: pre-wrap; font-family: inherit; font-size: 0.88rem; margin-top: 10px; }

.faq-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 10px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  float: right;
  margin-top: 8px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-muted);
  transition: transform 0.2s ease;
}
.faq-item[open] summary::after { transform: rotate(180deg); }
.faq-answer {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

details.proof, details.table-block {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 16px;
}
details.proof summary, details.table-block summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--teal);
}
/* la tabella dentro il blocco a comparsa non deve aggiungere margine sopra */
details.table-block .table-wrap { margin-bottom: 0; }
details.proof .proof-body { margin-top: 10px; }
details.proof .proof-body > *:first-child { margin-top: 0; }
details.proof .proof-body > *:last-child { margin-bottom: 0; }

.status-line { display: flex; align-items: center; gap: 10px; padding: 14px; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Mappa concettuale a schema (nodi + connettori) */
.mindmap { overflow: auto; padding: 10px 0; }
.mindmap-canvas { position: relative; margin: 0 auto; }
/* contenitore fuori schermo usato solo per misurare l'altezza reale dei nodi */
.mindmap-measure { position: absolute; visibility: hidden; left: -10000px; top: 0; }
.mindmap-measure .mindmap-node { position: relative; }
.mindmap-links { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.mindmap-link { fill: none; stroke: var(--teal); stroke-width: 1.5; opacity: 0.5; }
.mindmap-dot { fill: var(--teal); opacity: 0.85; }

.mindmap-node {
  position: absolute;
  width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  line-height: 1.35;
  box-sizing: border-box;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.mindmap-node.has-children { cursor: pointer; }
.mindmap-node.has-children:hover { border-color: var(--accent); transform: translateY(-1px); }

.mindmap-num { color: var(--teal); font-weight: 700; font-size: 0.82rem; flex-shrink: 0; }
.mindmap-label { flex: 1; font-weight: 600; }
.mindmap-caret {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--teal);
  font-size: 0.8rem;
  line-height: 1;
}
.mindmap-node.is-open .mindmap-caret { background: var(--surface-hover); border-color: var(--teal); }

.mindmap-node-root {
  width: 300px;
  flex-direction: column;
  text-align: center;
  gap: 8px;
  padding: 22px 20px;
  border-color: var(--accent);
}
.mindmap-node-root .mindmap-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}

/* Quiz: ogni risposta è una scheda grande, che si colora quando si corregge */
.quiz-question { margin-bottom: 26px; }
.quiz-question .q-text { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.quiz-option:hover { border-color: var(--coral); background: var(--surface-hover); }
.quiz-option input { margin: 0; accent-color: var(--coral); }
.quiz-option.correct { background: var(--success-soft); border-color: var(--success); color: var(--success); font-weight: 600; }
.quiz-option.wrong { background: var(--error-soft); border-color: var(--error); color: var(--error); font-weight: 600; }
.quiz-explanation { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.quiz-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#quiz-score { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin: 16px 0; }

/* Flashcard: girandola con dissolvenza (niente rotazione 3D, che specchierebbe il testo) */
.flash-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 20px; }
.flashcard {
  width: 100%; max-width: 520px; min-height: 260px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 32px; cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease;
}
.flashcard.flipped { background: var(--surface-hover); transform: scaleX(0.97); }
.flashcard .back-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
}
.flashcard.flipped .back-label { color: var(--teal); }
.flashcard .face { font-size: 20px; font-weight: 600; }
.flash-controls { display: flex; gap: 10px; }
.flash-progress { color: var(--text-muted); font-size: 13px; }

/* Domande d'esame probabili */
.exam-q-item { margin-bottom: 12px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.exam-q-item .q { font-weight: 600; font-size: 14.5px; }
.exam-q-item .kp { color: var(--text-muted); font-size: 13.5px; margin-top: 8px; line-height: 1.6; }

/* Chat */
/* La scheda della chat riempie lo schermo: scorrono solo i messaggi, il campo di scrittura
   resta fisso in fondo. L'altezza del pannello la calcola sizeChatPanel() in lesson.html. */
.container.chat-mode { padding-bottom: 16px; }
.tab-panel#tab-chat.active { display: flex; flex-direction: column; }
#chat-container { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat-box { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; padding: 6px 2px; margin-bottom: 12px; }
/* Le risposte del professore hanno la mascotte a fianco, le domande dell'utente no */
.chat-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-row.user { justify-content: flex-end; }
.chat-avatar { flex: none; margin-bottom: 4px; }
.chat-msg { padding: 12px 16px; max-width: 480px; font-size: 14.5px; line-height: 1.5; }
.chat-row.user .chat-msg {
  background: var(--accent); color: var(--on-accent);
  border-radius: 16px 16px 4px 16px;
}
.chat-row.assistant .chat-msg {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
}
.chat-typing { display: flex; gap: 5px; padding: 14px 16px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: bounceDot 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
.chat-input-row { display: flex; gap: 10px; flex-shrink: 0; padding-top: 12px; border-top: 1px solid var(--border); background: var(--bg); }
.chat-input-row textarea { flex: 1; min-height: 48px; max-height: 30vh; background: var(--surface); border-radius: 12px; }

.generate-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }

/* Costo in crediti mostrato accanto ai pulsanti che consumano API. */
.cost-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
/* Gettone col costo in crediti, dentro il pulsante che consuma API */
.token-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
  padding: 1px 7px 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.8em;
  font-weight: 700;
  line-height: 1.6;
}
.token-icon { width: 1em; height: 1em; flex-shrink: 0; }
/* Sui pulsanti chiari il bianco translucido non si vedrebbe: si usa il colore del testo */
.btn.secondary .token-cost { background: var(--surface-hover); color: var(--text-muted); }

/* Consumo reale delle API, a confronto con la stima mostrata prima dell'operazione */
.usage-box {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 13px;
}
.usage-box > summary { cursor: pointer; color: var(--text-muted); }
.usage-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.usage-table th, .usage-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.usage-table th { color: var(--text-muted); font-weight: 600; }
/* Le due colonne dei numeri stanno a destra, intestazione compresa: incolonnate una sotto
   l'altra. Le cifre a larghezza fissa allineano anche unità e decimali. */
.usage-table th:not(:first-child) { text-align: right; }
/* un po' d'aria fra la stima e il consumo reale, che sono due numeri simili e vicini */
.usage-table th:nth-child(2), .usage-table td:nth-child(2) { padding-right: 56px; }
.usage-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.usage-table th:first-child, .usage-table td:first-child { width: 100%; }
.usage-table .strong { font-weight: 700; }
.usage-table .usage-total td { border-bottom: none; font-weight: 700; }

/* Pagina del profilo */
.profile-photo-card { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.profile-photo {
  width: 104px; height: 104px; flex: none;
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border); background: var(--surface-hover);
}
.profile-photo-text { flex: 1; min-width: 240px; }
.profile-photo-text .muted { font-size: 13px; margin: 0 0 12px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.profile-grid .field input { width: 100%; }
.profile-grid input:disabled { color: var(--text-faint); cursor: not-allowed; }
.profile-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 18px; }
.profile-actions .muted { font-size: 13px; color: var(--success); }

.wallet-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.wallet-balance { font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin-top: 6px; }
.wallet-balance .vuoto { color: var(--error); }
.wallet-detail { font-size: 13px; margin: 4px 0 0; }
.wallet-hint { flex: 1; min-width: 260px; font-size: 13px; margin: 0; }

/* Il riquadro in fondo: da qui non si torna indietro, e si vede */
.danger-zone { margin-top: 24px; border-color: var(--error); }
.danger-zone h3 { color: var(--error); }
.danger-zone .muted { font-size: 13px; margin: 0 0 14px; }
.btn.danger-solid { background: var(--error); color: #fff; }
.btn.danger-solid:hover { background: var(--error); filter: brightness(1.08); }

@media (max-width: 720px) {
  .profile-grid { grid-template-columns: 1fr; }
}

/* Esame */
.exam-question-block { margin-bottom: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.exam-question-block .q { font-weight: 600; margin-bottom: 8px; }
.grade-box { text-align: center; padding: 24px; }
.grade-box .grade { font-family: var(--font-display); font-size: 3rem; font-weight: 700; color: var(--accent); }
.feedback-item { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--border); }
.feedback-item.verdict-corretta { border-color: var(--success); background: var(--success-soft); }
.feedback-item.verdict-errata { border-color: var(--error); background: var(--error-soft); }
.feedback-item.verdict-parzialmente-corretta { border-color: var(--warning); background: var(--warning-soft); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* Titolo proposto dal riassunto: si legge come il resto del titolo — stesso carattere, stesso
   corpo, stesso colore — separato solo dal trattino. */
.titolo-proposto::before { content: " - "; }
.lesson-row .titolo-proposto { color: var(--text-muted); }

/* Prima i pulsanti, poi il titolo sotto: un titolo lungo ha tutta la riga per sé e non arriva
   mai a toccarli. I pulsanti non vanno a capo dentro sé stessi. */
.testa-lezione { margin-bottom: 28px; }
.testa-lezione h1 { margin-top: 24px; }
.azioni-lezione { display: flex; gap: 8px; justify-content: flex-end; }
.azioni-lezione .btn { white-space: nowrap; }
@media (max-width: 720px) {
  .azioni-lezione { flex-wrap: wrap; justify-content: flex-start; }
}

.rename-form { display: flex; align-items: center; gap: 8px; flex: 1; }
.rename-form input {
  flex: 1; min-width: 160px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-family: var(--font-display); font-size: 20px;
}

/* Acquisto crediti: i pacchetti in fila, il gettone grande e il prezzo sotto */
.pacchetti { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.pacchetto {
  border: 1px solid var(--border); border-radius: 16px; padding: 22px 18px;
  background: var(--surface); text-align: center;
  /* Colonna con il pulsante spinto in fondo: le schede hanno testi di lunghezza diversa, e
     senza questo i quattro «Acquista» finiscono a quattro altezze diverse. */
  display: flex; flex-direction: column;
}
.pacchetto .quanti { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.1; }
.pacchetto .unita { color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.pacchetto .nome {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 6px;
}
.pacchetto .prezzo { margin: 12px 0 10px; font-size: 20px; font-weight: 600; }
/* Prezzo barrato, prezzo d'offerta e -20% sulla stessa riga, in mezzo alla scheda */
.pacchetto.in-offerta .prezzo {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center;
  gap: 4px 8px; min-height: 2em;
}
.pacchetto .promessa { margin: 0 0 6px; font-size: 13.5px; line-height: 1.4; min-height: 2.8em; }
.pacchetto .quante-lezioni { margin: 0 0 16px; font-size: 12px; color: var(--text-muted); }
/* Il pulsante è un inline-flex: a tutta larghezza la scritta resterebbe a sinistra */
.pacchetto .btn { width: 100%; justify-content: center; margin-top: auto; }

/* Il piano consigliato: bordo pieno e un filo di rilievo, perché fra quattro schede uguali
   nessuna guida la scelta */
.pacchetto.consigliato {
  border: 2px solid var(--accent);
  box-shadow: 0 6px 20px color-mix(in oklch, var(--accent) 18%, transparent);
}
.pacchetto .targhetta-consigliato {
  /* A sinistra, non al centro: l'angolo destro è del nastrino dell'offerta */
  align-self: flex-start;
  height: 22px; line-height: 22px;
  margin-bottom: 8px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
}
/* Le altre schede lasciano in cima lo spazio esatto della targhetta, così i nomi dei quattro
   piani restano sulla stessa riga */
.pacchetto:not(.consigliato)::before { content: ""; display: block; height: 30px; }

/* --- Offerta di benvenuto: nastrino, prezzo barrato e conto alla rovescia --- */
.pacchetto.in-offerta { border-color: color-mix(in oklch, var(--accent) 45%, var(--border)); }
/* Il nastrino corre in diagonale sull'angolo: la carta ritaglia quello che esce */
.pacchetto { position: relative; overflow: hidden; }
.pacchetto .nastrino {
  position: absolute;
  top: 14px; right: -34px;
  width: 130px;
  transform: rotate(45deg);
  background: var(--accent);
  color: var(--on-accent);
  text-align: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  padding: 4px 0;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.18);
  pointer-events: none;
}
.pacchetto .prezzo-pieno {
  color: var(--text-muted);
  font-size: 15px; font-weight: 500;
  text-decoration-thickness: 2px;
}
.pacchetto .prezzo-offerta { font-size: 22px; font-weight: 700; }
.etichetta-sconto {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 22%, transparent);
  color: var(--accent);
  font-size: 12px; font-weight: 700;
  vertical-align: 2px;
}
.striscione-offerta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 16px 0 14px;
  padding: 12px 16px;
  border: 1px solid color-mix(in oklch, var(--accent) 40%, var(--border));
  border-radius: 12px;
  background: color-mix(in oklch, var(--accent) 10%, var(--surface));
}
.striscione-offerta .offerta-testo { flex: 1; min-width: 200px; font-size: 14px; }
/* Il conto alla rovescia in cifre a larghezza fissa: senza, la riga sobbalza a ogni secondo */
.striscione-offerta .offerta-tempo {
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 15px;
  white-space: nowrap;
}
/* La nota legale sotto i pacchetti: giustificata, così il blocco chiude dritto da entrambi i lati */
.legale { text-align: justify; hyphens: auto; }

.esito-pagamento {
  margin-bottom: 18px; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--success); background: var(--success-soft); color: var(--text);
}
.esito-pagamento.annullato { border-color: var(--border); background: var(--surface); color: var(--text-muted); }
.avviso-verifica {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--warning); background: var(--warning-soft); font-size: 14px;
}
.avviso-verifica form { margin: 0; }

.avviso-box {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  border: 1px solid var(--success); background: var(--success-soft); color: var(--text);
}
.avviso-pagamenti {
  margin-bottom: 18px; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--warning); background: var(--warning-soft); color: var(--text);
}

/* Calendario: una riga per esame, il giorno a sinistra come su un calendario da muro */
.exam-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--sky);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  transition: background 0.2s ease, transform 0.2s ease;
}
.exam-row:hover { background: var(--surface-hover); text-decoration: none; transform: translateX(2px); }
.exam-row .giorno {
  flex: none; width: 52px; text-align: center; line-height: 1.1;
  color: var(--sky);
}
.exam-row .giorno .numero { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-row .giorno .mese { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.exam-row .dettaglio { flex: 1; min-width: 0; }
.exam-row .materia { display: block; font-weight: 600; }
.exam-row .quando { display: block; font-size: 12.5px; color: var(--text-muted); }
.exam-row .mancano { flex: none; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* La data prende il colore della materia (inline, da coloreMateria). Qui resta l'urgenza: quanto
   manca si colora di corallo se l'esame è entro la settimana, e i passati si fanno da parte. */
.exam-row.imminente .mancano { color: var(--coral); }
.exam-row.passato { opacity: 0.55; border-left-color: var(--border); }
.exam-row.passato .giorno { color: var(--text-faint); }

.calendar-sub {
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); margin: 30px 0 10px;
}
/* Griglia del mese: sette colonne uguali, la settimana comincia di lunedì */
.mese-testata { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mese-scelta { display: flex; align-items: center; gap: 8px; }
.mese-scelta select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px;
}
.mese-griglia {
  display: grid;
  /* minmax(0, 1fr) e non 1fr: senza, il nome di un esame lungo allarga la sua colonna
     e schiaccia le altre, e il calendario smette di sembrare un calendario. */
  grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  border: 1px solid var(--border); border-radius: 14px; padding: 12px;
  background: var(--surface);
}
.mese-giorno-nome {
  text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-faint); padding-bottom: 4px;
}
.mese-cella {
  min-height: 74px; padding: 6px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-hover);
  display: flex; flex-direction: column; gap: 3px;
}
.mese-cella.vuota { background: transparent; }
.mese-cella .numero { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.mese-cella.oggi { border-color: var(--accent); }
.mese-cella.oggi .numero { color: var(--accent); font-weight: 700; }
.mese-cella.con-esame { background: color-mix(in oklab, var(--sky) 18%, var(--surface)); }
.mese-cella.con-esame .numero { color: var(--sky); font-weight: 700; }
.mese-cella.passato { opacity: 0.5; }
.pallino-esame {
  display: block; font-size: 11px; line-height: 1.3; font-weight: 600;
  padding: 2px 5px; border-radius: 6px;
  background: var(--sky); color: var(--on-accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pallino-esame:hover { text-decoration: none; filter: brightness(1.08); }

/* Sul telefono una casella è larga meno di 40px: il nome ci starebbe come "An…", che non dice
   niente. Diventa una banda colorata — il nome è nell'elenco qui sopra — e resta cliccabile. */
@media (max-width: 720px) {
  .mese-cella { min-height: 46px; padding: 4px; }
  .pallino-esame { height: 7px; padding: 0; font-size: 0; border-radius: 4px; }
  /* Stesso discorso per le note: "Ri…" non dice niente, una barretta almeno dice che c'è
     qualcosa. Il testo per intero si legge toccando il giorno. */
  .nota-riga {
    height: 5px; font-size: 0; padding: 0; border-left: none; border-radius: 3px;
    background: var(--text-faint); opacity: 0.55;
  }
}

/* Note appuntate su un giorno */
.mese-cella { cursor: pointer; }
.mese-cella.vuota { cursor: default; }
.mese-cella:hover:not(.vuota) { outline: 1px solid var(--border); }
.nota-riga {
  font-size: 10.5px; line-height: 1.3; color: var(--text-muted);
  padding-left: 6px; border-left: 2px solid var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mese-aiuto { font-size: 12px; color: var(--text-faint); margin: 8px 2px 0; }

.note-pannello {
  margin-top: 12px; padding: 16px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
}
.note-testata { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note-testata h3 { margin: 0; font-size: 15px; }
.nota-voce {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.nota-elimina {
  border: none; background: none; color: var(--text-faint);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.nota-elimina:hover { color: var(--error); background: var(--error-soft); }
.nota-vuoto { color: var(--text-faint); font-size: 13px; margin: 8px 0; }
.note-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.note-form input[type="time"] {
  flex: none; width: 120px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px;
}
.nota-ora { font-variant-numeric: tabular-nums; color: var(--sky); margin-right: 4px; }
.nota-riga b { font-variant-numeric: tabular-nums; font-weight: 700; }
.note-form input[type="text"] {
  flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 14px;
}

.senza-data { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-materia {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-muted); font-size: 13px;
}
.chip-materia:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.error-box { background: var(--error-soft); color: var(--error); padding: 12px 16px; border-radius: 8px; margin: 12px 0; font-size: 0.88rem; white-space: pre-wrap; }

/* Selettori delle Opzioni: pastiglie per la lingua, controllo a tre stati per il tema */
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.chip {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.segmented { display: flex; gap: 10px; margin-top: 12px; max-width: 420px; }
.segmented .chip { flex: 1; text-align: center; }

/* Elenco delle fasi di elaborazione, con pallino pieno/rotante/vuoto */
.step-list { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.step { display: flex; align-items: center; gap: 12px; }
.step .dot {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid var(--border);
}
.step.done .dot { background: var(--teal); border-color: var(--teal); }
.step.active .dot { border-color: var(--teal); border-top-color: transparent; animation: spin 1s linear infinite; }
.step .label { font-size: 14px; font-weight: 500; color: var(--text-faint); }
.step.done .label, .step.active .label { font-weight: 700; color: var(--text); }

/* Timer pomodoro: sta in alto al centro della pagina della materia */
.pomodoro { display: flex; justify-content: center; margin: -6px 0 22px; }

.pomodoro-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.pomodoro-btn:hover { border-color: var(--coral); transform: translateY(-2px); }
.pomodoro-tomato { display: inline-block; font-size: 1.15em; animation: wobble 3.2s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  40% { transform: rotate(7deg) scale(1.12); }
  70% { transform: rotate(-3deg) scale(1.03); }
}

/* In marcia: al posto del pulsante compare il conto alla rovescia */
.pomodoro-run {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--coral);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pomodoro-run.fase-pausaBreve, .pomodoro-run.fase-pausaLunga { border-color: var(--teal); }
.pomodoro-run.in-pausa { opacity: 0.65; }
/* Quanto manca alla fine della fase, dipinto dietro al testo */
.pomodoro-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--coral);
  opacity: 0.16;
  transition: width 1s linear;
}
.pomodoro-run.fase-pausaBreve .pomodoro-fill, .pomodoro-run.fase-pausaLunga .pomodoro-fill { background: var(--teal); }
.pomodoro-run > * { position: relative; }
.pomodoro-time { font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pomodoro-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pomodoro-mini {
  width: 24px; height: 24px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: none; border-radius: 50%;
  background: var(--surface-hover); color: var(--text-muted);
  font-size: 10px; line-height: 1; cursor: pointer;
}
.pomodoro-mini:hover { background: var(--coral); color: var(--on-accent); }

/* Finestre: presentazione del metodo e avvisi di fine fase */
.pomodoro-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.45);
  animation: popIn 0.18s ease;
}
.pomodoro-dialog {
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 26px 28px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.pomodoro-mascotte { font-size: 42px; line-height: 1; animation: wobble 3.2s ease-in-out infinite; }
.pomodoro-dialog h3 { font-size: 20px; margin: 10px 0 12px; }
.pomodoro-body { font-size: 14px; color: var(--text-muted); line-height: 1.6; text-align: left; }
.pomodoro-body p { margin: 0 0 10px; }
.pomodoro-body ol { margin: 0; padding-left: 20px; }
.pomodoro-body li { margin-bottom: 6px; }
.pomodoro-dialog-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* Pagina di accesso: nessuna barra laterale, solo il riquadro al centro */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(600px circle at 50% 0%, var(--accent-soft) 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  padding: 32px 30px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
/* Il logo intero della pagina di accesso: occhiali + marchio */
.logo-grande { margin: 4px 0 18px; animation: galleggia 5s ease-in-out 1.5s infinite; }

.logo-occhiali { width: min(260px, 78%); height: auto; display: block; margin: 0 auto 22px; }

/* Entrata: il profilo degli occhiali si disegna da sé, poi compaiono i riflessi */
.logo-occhiali .tratto {
  stroke-dasharray: var(--lunghezza, 1100);
  stroke-dashoffset: var(--lunghezza, 1100);
  animation: disegna 1.15s cubic-bezier(.65, 0, .35, 1) forwards;
}
.logo-occhiali .lente { --lunghezza: 1100; }
.logo-occhiali .ponte { --lunghezza: 180; animation-delay: .75s; }
.logo-occhiali .asta { --lunghezza: 130; animation-delay: .9s; }
.logo-occhiali .riflesso {
  fill: var(--text-faint);
  opacity: 0;
  animation: appari .5s ease 1.25s forwards, luccica 4s ease-in-out 2.5s infinite;
}
.logo-occhiali .riflesso.destro { animation-delay: 1.4s, 2.7s; }

.logo-testo { animation: sali .7s ease 1.1s backwards; }
.logo-the {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--text-muted);
}
.logo-professor {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-indent: 0.06em;
  line-height: 1.1;
  margin-top: 2px;
}
.logo-riga { width: 72%; height: 1px; margin: 10px auto 8px; background: var(--border); }
.logo-claim {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--text-muted);
}

@keyframes disegna { to { stroke-dashoffset: 0; } }
@keyframes appari { to { opacity: 1; } }
@keyframes luccica { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes galleggia { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes sali { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Chi ha chiesto meno animazioni vede il logo già disegnato e fermo */
@media (prefers-reduced-motion: reduce) {
  .logo-grande, .logo-testo, .logo-occhiali .tratto, .logo-occhiali .riflesso { animation: none; }
  .logo-occhiali .tratto { stroke-dashoffset: 0; }
  .logo-occhiali .riflesso { opacity: 1; }
}

.login-claim { font-size: 14px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form .field label { font-size: 12px; }
.login-submit { justify-content: center; margin-top: 6px; }
.login-switch { font-size: 13px; margin: 20px 0 0; }

/* Registro attività */
.activity-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 8px;
  font-size: 13.5px;
}
.activity-row .quando { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.activity-row .cosa { font-weight: 600; }
.activity-row .su { color: var(--text-muted); flex: 1; }

/* Righe di spesa: si distinguono a colpo d'occhio dalle azioni, e il costo sta a destra
   incolonnato, così si scorre la colonna dei crediti senza leggere il resto. */
.activity-row.spesa { border-left: 3px solid var(--accent); }
.activity-row.spesa .cosa { color: var(--accent); }
.activity-row .consumo { display: block; font-size: 12px; color: var(--text-faint); }
.activity-row .crediti {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  color: var(--text);
}

/* Utente in fondo alla barra laterale */
.sidebar-user { display: flex; align-items: center; gap: 10px; font-size: 12.5px; min-width: 0; }
.sidebar-user .chi { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .chi:hover { color: var(--text); text-decoration: none; }
.sidebar-user .chi-foto { flex: none; line-height: 0; }
.sidebar-user .chi-foto img {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--border); background: var(--surface-hover);
}
.sidebar-user a { color: var(--text-faint); font-weight: 600; white-space: nowrap; }
.sidebar-user a:hover { color: var(--accent); text-decoration: none; }
