/* YouppyCalendar. I colori stanno tutti qui sotto, una volta per il tema chiaro e una per lo scuro. Accento: verde acqua #0e9f8e. */
[data-tema="chiaro"] {
  --sfondo: #f3f6f5; --carta: #ffffff; --testo: #172120; --tenue: #687675; --linea: #e3eae8;
  --accento: #0e9f8e; --accento-forte: #0b8476; --su-accento: #ffffff; --accento-tenue: #d9f2ee;
  --rosso: #d8392f; --verde: #1a9d55; --blu: #2f6bd8; --viola: #7a52d6; --arancio: #e0781e; --rosa: #d6418e;
  --ombra: 0 2px 14px rgba(10, 60, 55, .08); --campo: #edf2f1;
  /* colori degli eventi */
  --c0: #0e9f8e; --c1: #2f6bd8; --c2: #1a9d55; --c3: #d8392f; --c4: #7a52d6; --c5: #e0781e; --c6: #d6418e; --c7: #5a6b7a;
}
[data-tema="scuro"] {
  --sfondo: #14191a; --carta: #1d2425; --testo: #ecf2f1; --tenue: #93a3a1; --linea: #2b3537;
  --accento: #2fd3bd; --accento-forte: #5fe0cd; --su-accento: #0c1f1c; --accento-tenue: #173b37;
  --rosso: #ff6b60; --verde: #45d08f; --blu: #7d9bff; --viola: #b79bff; --arancio: #ffa04d; --rosa: #ff7fb8;
  --ombra: 0 2px 14px rgba(0, 0, 0, .4); --campo: #263031;
  --c0: #2fd3bd; --c1: #7d9bff; --c2: #45d08f; --c3: #ff6b60; --c4: #b79bff; --c5: #ffa04d; --c6: #ff7fb8; --c7: #9aabbd;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--sfondo); color: var(--testo); font: 16px/1.45 system-ui, 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--blu); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
[hidden] { display: none !important; }
.cifre { font-variant-numeric: tabular-nums; }

#app { height: 100dvh; max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; background: var(--sfondo); position: relative; overflow: hidden; }
#vista { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* ---- barra in basso ---- */
#barra { display: flex; justify-content: space-around; padding: 6px 2px calc(6px + env(safe-area-inset-bottom)); background: var(--carta); border-top: 1px solid var(--linea); z-index: 2; }
#barra button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 3px; color: var(--tenue); font-size: 10.5px; font-weight: 600; border-radius: 14px; white-space: nowrap; }
#barra button.attiva { color: var(--accento-forte); }
#barra button .ic { position: relative; width: 44px; height: 27px; padding: 3px 11px; border-radius: 12px; transition: background .2s; }
#barra button.attiva .ic { background: var(--accento-tenue); }
#barra svg { width: 100%; height: 100%; display: block; }
#barra .num { position: absolute; top: -3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--rosso); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 17px; text-align: center; }

/* ---- pezzi comuni ---- */
.pagina { padding: calc(14px + env(safe-area-inset-top)) 16px 96px; display: flex; flex-direction: column; gap: 14px; }
.testata { display: flex; align-items: center; gap: 10px; min-height: 44px; }
@font-face { font-family: "Baloo 2"; src: url("/caratteri/Baloo2.ttf") format("truetype"); font-weight: 400 800; font-display: swap; }
.testata h1 { flex: 1; min-width: 0; font-family: "Baloo 2", system-ui, sans-serif; font-size: clamp(23px, 7vw, 29px); font-weight: 800; letter-spacing: -.01em; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.testata h1 b { color: var(--accento-forte); }
.sotto { color: var(--tenue); font-size: 13.5px; margin-top: -8px; }
.tondo { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--tenue); background: var(--carta); box-shadow: var(--ombra); transition: transform .1s, background .15s; }
.tondo:active { transform: scale(.92); }
.tondo.pieno { background: var(--accento); color: var(--su-accento); box-shadow: 0 6px 16px color-mix(in srgb, var(--accento) 45%, transparent); }
.tondo svg { width: 22px; height: 22px; }
.carta { background: var(--carta); border-radius: 20px; padding: 16px; box-shadow: var(--ombra); }
.nota { color: var(--tenue); font-size: 14px; }
.nota.centro { text-align: center; }
.bottone { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 16px; background: var(--accento); color: var(--su-accento); font-weight: 700; font-size: 16.5px; transition: transform .1s, background .15s; text-align: center; }
.bottone:active { transform: scale(.97); }
.bottone:disabled { opacity: .4; transform: none; }
.bottone.secondario { background: var(--accento-tenue); color: var(--accento-forte); }
.bottone.chiaro { background: var(--campo); color: var(--testo); }
.bottone.pericolo { background: none; color: var(--rosso); }
.bottone.largo { width: 100%; }
.bottone.piccolo { min-height: 40px; padding: 0 14px; font-size: 14.5px; border-radius: 12px; }
.bottone svg { width: 20px; height: 20px; flex: none; }
.pillola { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px; background: var(--campo); color: var(--tenue); font-weight: 700; font-size: 12px; white-space: nowrap; }
.pillola.forte { background: var(--accento-tenue); color: var(--accento-forte); }
.pillola.tinta { background: color-mix(in srgb, var(--t) 16%, transparent); color: var(--t); }
.vuoto { text-align: center; padding: 34px 20px; color: var(--tenue); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vuoto > svg { width: 54px; height: 54px; color: var(--linea); }
.vuoto h3 { color: var(--testo); font-size: 19px; font-weight: 800; }
.titoletto { font-size: 13px; font-weight: 800; color: var(--tenue); text-transform: uppercase; letter-spacing: .06em; margin: 6px 2px -4px; }
.titoletto.rosso { color: var(--rosso); }

.campo { width: 100%; background: var(--campo); border: 1px solid transparent; border-radius: 14px; padding: 12px 14px; font-size: 16px; min-height: 48px; }
.campo:focus { border-color: var(--accento); outline: none; background: var(--carta); }
textarea.campo { resize: vertical; min-height: 80px; line-height: 1.5; }
select.campo { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--tenue) 50%), linear-gradient(135deg, var(--tenue) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.etichetta { display: block; font-size: 13px; font-weight: 700; color: var(--tenue); margin: 2px 2px 6px; }
.campoRiga { display: flex; flex-direction: column; margin-bottom: 12px; min-width: 0; }
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.interruttore { display: flex; align-items: center; gap: 12px; padding: 10px 2px; font-weight: 600; cursor: pointer; }
.interruttore span { flex: 1; }
.interruttore input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--linea); position: relative; transition: background .2s; flex: none; margin: 0; cursor: pointer; }
.interruttore input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.interruttore input:checked { background: var(--accento); }
.interruttore input:checked::after { transform: translateX(18px); }

.segmento { display: flex; background: var(--campo); border-radius: 14px; padding: 3px; gap: 3px; }
.segmento button { flex: 1; min-width: 0; padding: 9px 0; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmento button.on { background: var(--carta); color: var(--testo); box-shadow: var(--ombra); }
.coloriScelta { display: flex; gap: 10px; flex-wrap: wrap; }
.coloriScelta button { width: 34px; height: 34px; border-radius: 50%; background: var(--c); position: relative; }
.coloriScelta button[aria-pressed="true"]::after { content: '✓'; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; }
.scelte { display: flex; gap: 8px; flex-wrap: wrap; }
.scelte button { min-height: 38px; padding: 0 14px; border-radius: 12px; background: var(--campo); font-weight: 700; font-size: 14px; color: var(--tenue); }
.scelte button[aria-pressed="true"] { background: var(--accento); color: var(--su-accento); }

/* ---- calendario: mese ---- */
.meseTesta { display: flex; align-items: center; gap: 8px; }
.meseTesta h2 { flex: 1; min-width: 0; font-size: 19px; font-weight: 800; text-transform: capitalize; }
.freccia { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--testo); background: var(--carta); box-shadow: var(--ombra); flex: none; }
.freccia svg { width: 20px; height: 20px; }
.griglia7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.griglia7 .gs { text-align: center; font-size: 11.5px; font-weight: 800; color: var(--tenue); padding: 2px 0 4px; }
.giorno { min-height: 52px; border-radius: 12px; padding: 5px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--carta); color: var(--testo); }
.giorno.fuori { background: transparent; color: var(--tenue); opacity: .55; }
.giorno .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.giorno.oggi .n { background: var(--accento); color: var(--su-accento); }
.giorno.scelto { box-shadow: inset 0 0 0 2px var(--accento); }
.giorno.festa .n { color: var(--rosso); }
.giorno.oggi.festa .n { color: var(--su-accento); }
.puntini { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 100%; min-height: 6px; }
.puntini i { width: 6px; height: 6px; border-radius: 50%; background: var(--t); }
.puntini b { font-size: 9px; line-height: 6px; color: var(--tenue); }

/* ---- voci (eventi, cose, verifiche...) ---- */
.voce { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--carta); border-radius: 16px; padding: 11px 13px; box-shadow: var(--ombra); position: relative; overflow: hidden; }
.voce::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--t); }
.voce .quando { width: 46px; flex: none; font-size: 13px; font-weight: 800; color: var(--tenue); text-align: center; line-height: 1.2; }
.voce .cuore { flex: 1; min-width: 0; }
.voce .cuore h3 { font-size: 15.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voce .cuore .riga2 { display: flex; gap: 6px; align-items: center; color: var(--tenue); font-size: 12.5px; margin-top: 2px; flex-wrap: wrap; min-width: 0; }
.voce .cuore .riga2 > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.voce.fatta .cuore h3 { text-decoration: line-through; color: var(--tenue); }
.voce .emo { font-size: 22px; flex: none; width: 30px; text-align: center; }
.spunta { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2.5px solid var(--t, var(--linea)); display: grid; place-items: center; color: transparent; transition: background .15s; }
.spunta svg { width: 16px; height: 16px; }
.spunta.on { background: var(--t, var(--accento)); color: #fff; }
.elenco { display: flex; flex-direction: column; gap: 8px; }
.giornoTitolo { display: flex; align-items: baseline; gap: 8px; margin: 8px 2px 0; }
.giornoTitolo h3 { font-size: 15px; font-weight: 800; }
.giornoTitolo h3::first-letter { text-transform: uppercase; }
.giornoTitolo span { font-size: 12.5px; color: var(--tenue); font-weight: 600; }
.giornoTitolo.oggi h3 { color: var(--accento-forte); }
.conto { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 10px; background: color-mix(in srgb, var(--t) 15%, transparent); color: var(--t); font-weight: 800; font-size: 13px; flex: none; }

/* ---- statistiche ---- */
.statline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.statbox { background: var(--carta); border-radius: 16px; padding: 11px 6px; text-align: center; box-shadow: var(--ombra); min-width: 0; }
.statbox .n { font-size: 23px; font-weight: 800; line-height: 1; color: var(--t, var(--testo)); }
.statbox .e { font-size: 11.5px; color: var(--tenue); margin-top: 4px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.25; }

/* ---- classi ---- */
.classe { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; background: var(--carta); border-radius: 18px; padding: 13px; box-shadow: var(--ombra); }
.classe .bollo { width: 48px; height: 48px; flex: none; border-radius: 15px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px; background: var(--c); }
.classe .cuore { flex: 1; min-width: 0; }
.classe .cuore h3 { font-size: 16.5px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classe .cuore .riga2 { display: flex; gap: 6px; align-items: center; color: var(--tenue); font-size: 12.5px; margin-top: 3px; flex-wrap: wrap; }
.classe > svg { width: 20px; height: 20px; color: var(--tenue); flex: none; }
.codiceBig { font-size: 30px; font-weight: 800; letter-spacing: .14em; text-align: center; color: var(--accento-forte); background: var(--accento-tenue); border-radius: 16px; padding: 14px; font-variant-numeric: tabular-nums; }
.persona { display: flex; align-items: center; gap: 11px; background: var(--carta); border-radius: 16px; padding: 10px 12px; box-shadow: var(--ombra); }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--c, var(--accento)); font-size: 15px; }
.avatar.grande { width: 72px; height: 72px; font-size: 30px; }
.persona .nome { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persona > svg { width: 20px; height: 20px; color: var(--tenue); flex: none; }
.persona .nome small { display: block; font-weight: 600; color: var(--tenue); font-size: 12px; }
/* appello: quattro pulsanti per studente */
.appello { display: grid; grid-template-columns: repeat(4, 38px); gap: 5px; flex: none; }
.appello button { height: 38px; border-radius: 11px; background: var(--campo); color: var(--tenue); font-weight: 800; font-size: 14px; }
.appello button[aria-pressed="true"] { background: var(--t); color: #fff; }
.persona.segnata { box-shadow: var(--ombra), inset 4px 0 0 var(--t); }
.tabella { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabella th { font-size: 11.5px; color: var(--tenue); font-weight: 800; text-align: center; padding: 6px 3px; }
.tabella th:first-child, .tabella td:first-child { text-align: left; }
.tabella td { padding: 10px 3px; border-top: 1px solid var(--linea); text-align: center; font-variant-numeric: tabular-nums; }
.tabella td:first-child { font-weight: 700; max-width: 0; width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabella tr.tocca { cursor: pointer; }
.barretta { height: 6px; border-radius: 3px; background: var(--campo); overflow: hidden; margin-top: 4px; }
.barretta i { display: block; height: 100%; background: var(--verde); }

/* ---- profilo ---- */
.profiloTesta { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 10px 0 4px; }
.profiloTesta h2 { font-size: 22px; font-weight: 800; }
.riga { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-top: 1px solid var(--linea); width: 100%; text-align: left; }
.riga:first-child { border-top: 0; }
.riga > svg { width: 22px; height: 22px; color: var(--accento-forte); flex: none; }
.riga span { flex: 1; min-width: 0; font-weight: 600; }
.riga small { color: var(--tenue); font-size: 13px; }

/* ---- pulsante + fluttuante ---- */
.fab { position: absolute; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 19px; background: var(--accento); color: var(--su-accento); display: grid; place-items: center;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accento) 50%, transparent); z-index: 3; transition: transform .1s; }
.fab:active { transform: scale(.93); }
.fab svg { width: 28px; height: 28px; }

/* ---- strati (fogli e avvisi) ---- */
#strati { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.velo { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.velo.on { opacity: 1; }
.foglio { position: absolute; left: 0; right: 0; bottom: 0; max-width: 620px; margin: 0 auto; background: var(--carta); border-radius: 24px 24px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(0,0,0,.25); transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); pointer-events: auto; max-height: 92dvh; overflow-y: auto; }
.foglio.on { transform: translateY(0); }
.foglio h2 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.manico { width: 40px; height: 4px; border-radius: 2px; background: var(--linea); margin: -6px auto 12px; }
.azioni { display: flex; gap: 8px; margin-top: 6px; }
.azioni .bottone { flex: 1; }
.menuScelta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.menuScelta button { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border-radius: 16px; background: var(--campo); text-align: left; font-weight: 700; }
.menuScelta button .emo { font-size: 24px; }
.menuScelta button small { font-weight: 500; color: var(--tenue); font-size: 12.5px; line-height: 1.3; }
.dettaglio { display: flex; flex-direction: column; gap: 10px; }
.dettaglio .testo { white-space: pre-wrap; word-break: break-word; }
.toast { position: absolute; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--testo); color: var(--sfondo); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90%; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
