/* Quaderno a quadretti, con i colori dell'icona: carta crema, inchiostro blu notte, salvia per le parti colorate
   delle frazioni e gli evidenziatori, rosso mattone per la correzione.
   Layout: colonna di lettura da ~70 caratteri; barra in basso in verticale, colonna a sinistra in orizzontale. */
:root {
  --paper: #f4f2ec;
  --sheet: #fffdf8;
  --grid: #e2e6dd;
  --ink: #1f2b44;
  --ink-soft: #56627a;
  --line: #cdd3c9;
  --pen: #1f2b44;
  --pen-soft: #e3ebe4;
  --mark: #b0473a;
  --mark-soft: #f6e4df;
  --ok: #2f6b4f;
  --ok-soft: #e2eee5;
  --hl: #a9c2b1;
  --hl-soft: #e6eee8;
  --hatch: rgba(31, 43, 68, .22);
  --font: "Lexend", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "Lexend", -apple-system, system-ui, sans-serif; /* cifre e codici: stesso carattere, zero non barrato */
  --radius: 14px;
  --sq: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141b27; --sheet: #1b2434; --grid: #253043; --ink: #eef0ea; --ink-soft: #aab4c3; --line: #36435a;
    --pen: #c5d6ca; --pen-soft: #26343a; --mark: #ef8f80; --mark-soft: #3a2320; --ok: #8fd0ab; --ok-soft: #18301f;
    --hl: #6f8f7b; --hl-soft: #26352d; --hatch: rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141b27; --sheet: #1b2434; --grid: #253043; --ink: #eef0ea; --ink-soft: #aab4c3; --line: #36435a;
  --pen: #c5d6ca; --pen-soft: #26343a; --mark: #ef8f80; --mark-soft: #3a2320; --ok: #8fd0ab; --ok-soft: #18301f;
  --hl: #6f8f7b; --hl-soft: #26352d; --hatch: rgba(0, 0, 0, .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { overscroll-behavior: none; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.6; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; margin: 0 0 .5em; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; margin-top: 1.2em; }
h4 { font-size: 1rem; margin: 0 0 .25em; }
p { margin: 0 0 .75em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 6px; }
.small { font-size: .88rem; }
.muted { color: var(--ink-soft); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: .88rem; color: var(--ink-soft); margin-bottom: .3em; }
.code { font-family: var(--mono); font-size: .8rem; font-weight: 600; padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--sheet); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- bottoni ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 48px; padding: 10px 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--sheet); color: var(--ink); font-weight: 600; cursor: pointer; text-align: center; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pen); border-color: var(--pen); color: var(--sheet); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--pen); }
.btn.danger { border-color: var(--mark); color: var(--mark); }
.btn.big { min-height: 56px; padding: 12px 26px; font-size: 1.05rem; }
.btn[disabled] { opacity: .45; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--pen); text-decoration: underline; padding: 6px 4px; font-size: .85rem; cursor: pointer; min-height: 32px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 8px; }
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1.5px solid var(--mark); border-radius: 12px; }

/* ---------- struttura ---------- */
#app { min-height: 100%; }
/* niente altezza minima: con 100vh, sull'iPad le pagine corte scorrevano di qualche pixel (100vh conta anche la barra di stato) */
.main { max-width: 820px; margin: 0 auto; padding-block: 28px 120px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.main:focus { outline: none; }
/* dopo l'ultimo riquadro niente spazio in più: la pagina scorre solo quanto serve per vedere il contenuto */
.main > :last-child, .main > form:last-child, .main > section:last-child { margin-bottom: 0; }
.tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--sheet); border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
.tab { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 60px; padding: 6px 4px; border: 0; background: none; color: var(--ink-soft); font-size: .8rem; font-weight: 600; cursor: pointer; border-radius: 10px; }
.tab .ico { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--pen); background: var(--pen-soft); }
@media (min-width: 1000px) and (orientation: landscape) {
  /* barra laterale fissa: non segue lo scorrimento né il «rimbalzo» in cima e in fondo alla pagina */
  .shell { padding-left: calc(112px + env(safe-area-inset-left, 0px)); }
  .tabs { position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: calc(112px + env(safe-area-inset-left, 0px)); height: auto; flex-direction: column; justify-content: flex-start; gap: 6px; border-top: 0; border-right: 1px solid var(--line); padding: 24px 10px 24px calc(10px + env(safe-area-inset-left, 0px)); }
  .tab { flex: none; max-width: none; min-height: 72px; }
  .main { padding-bottom: 24px; }
}
.page-head { margin-bottom: 20px; }
.page-head .sub { color: var(--ink-soft); }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.hero-panel { background-color: var(--sheet); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: var(--sq) var(--sq); }
.hero-panel h2 { font-size: 1.5rem; }
.note-panel { border-style: dashed; }
.danger-zone { border-color: var(--mark); }
.sim { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--hl-soft); color: var(--ink); text-align: center; font-size: .85rem; padding: 6px 16px; border-bottom: 1px solid var(--hl); }
.empty { padding: 28px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--ink-soft); }

/* liste */
.objlist, .todolist, .lessons, .entries, .toc, .toc ul { list-style: none; margin: 0; padding: 0; }
.objlist li { padding: 12px 0; border-top: 1px solid var(--grid); }
.objlist li:first-child { border-top: 0; }
.objlist li.this-week .otext { font-weight: 600; }
.objline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.otext { flex: 1 1 260px; min-width: 0; }
.objlist .small { margin: 6px 0 0; }
.todo { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--grid); }
.todo:first-child { border-top: 0; }
.todo > div { flex: 1; min-width: 0; }
.todo p { margin: 2px 0 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 999px; font-size: .82rem; font-weight: 600; border: 1.5px solid var(--line); white-space: nowrap; background: var(--sheet); }
.chip-ic { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .78rem; background: var(--paper); }
.st-acquisito { border-color: var(--ok); color: var(--ok); }
.st-acquisito .chip-ic { background: var(--ok); color: var(--sheet); }
.st-da-consolidare { border-color: var(--mark); color: var(--mark); }
.st-da-consolidare .chip-ic { background: var(--mark); color: var(--sheet); }
.st-esercitato { border-color: var(--pen); color: var(--pen); }
.st-non-affrontato { border-style: dashed; color: var(--ink-soft); }
.legend-states { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: .82rem; color: var(--ink-soft); border: 1px dashed var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }

/* segmenti e filtri */
.segctl { display: flex; gap: 4px; padding: 4px; background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 20px; overflow-x: auto; }
.segctl button { flex: 1; min-height: 46px; padding: 8px 14px; border: 0; border-radius: 10px; background: none; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.segctl button[aria-selected="true"] { background: var(--pen-soft); color: var(--pen); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.fchip { min-height: 44px; padding: 6px 14px; border: 1.5px solid var(--line); background: var(--sheet); border-radius: 999px; font-weight: 600; cursor: pointer; }
.fchip[aria-pressed="true"] { border-color: var(--pen); color: var(--pen); background: var(--pen-soft); }
.fchip[aria-pressed="true"]::before { content: "\2713\00a0"; }

/* corso */
.week { margin-bottom: 28px; }
.week h2 { font-size: 1.15rem; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.wk { font-family: var(--mono); font-size: .85rem; color: var(--ink-soft); font-weight: 600; }
.muted-week h3 { color: var(--ink-soft); font-weight: 600; }
.lrow { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.lrow h3 { margin: 0 0 2px; font-size: 1.02rem; }
.lrow p { margin: 2px 0 0; }
.lmain { flex: 1; min-width: 0; }
.lnum { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); font-family: var(--mono); font-weight: 600; font-size: .9rem; }
.muted-week .lrow { background: transparent; }
.table-wrap { overflow-x: auto; margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-weight: 700; color: var(--ink-soft); font-size: .85rem; }
caption { text-align: left; padding: 0 0 10px; color: var(--ink-soft); }
.cal tr.rv td { color: var(--ink-soft); font-style: italic; }

/* ---------- lezione ---------- */
.lesson { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 40; background: var(--sheet); }
.lhead { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; background: var(--sheet); border-bottom: 1px solid var(--line);
  padding-block: 6px; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.ltitle { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; line-height: 1.25; }
.ltitle strong { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lprog { max-width: 820px; width: 100%; margin: 0 auto; padding: 12px max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px)); }
.phases { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ph { font-size: .78rem; padding: 3px 10px; border-radius: 999px; color: var(--ink-soft); border: 1px solid transparent; white-space: nowrap; }
.ph.on { border-color: var(--pen); color: var(--pen); font-weight: 700; }
.pbar { height: 6px; background: var(--grid); border-radius: 3px; margin: 10px 0 4px; overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--pen); border-radius: 3px; }
.counter { margin: 0; }
.lbody { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding-block: 14px 24px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.lfoot { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: space-between; gap: 12px; background: var(--sheet); border-top: 1px solid var(--line);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.lfoot .btn { flex: 1; max-width: 280px; }

.sheet { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; }
.sheet h2 { font-size: 1.5rem; }
.sheet h2:focus { outline: none; }
.paper { background-color: var(--sheet); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: var(--sq) var(--sq); background-position: -1px -1px; }
.paper p, .paper li { max-width: 66ch; }
.formula { font-size: 1.3rem; text-align: center; padding: 14px 10px; margin: 10px 0 16px; background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.pts { padding-left: 1.2em; margin: 0 0 1em; }
.pts li { margin-bottom: .55em; }
.box { border-radius: 12px; padding: 14px 16px; margin: 14px 0; border: 1.5px solid var(--line); background: var(--sheet); }
.box p:last-child { margin-bottom: 0; }
.box-label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: .3em; }
.box-def { background: var(--pen-soft); border-color: var(--pen); }
.box-def .box-label { color: var(--pen); }
.box-attenzione { background: var(--mark-soft); border-color: var(--mark); }
.box-attenzione .box-label { color: var(--mark); }
.box-metodo { background: var(--ok-soft); border-color: var(--ok); }
.box-metodo .box-label { color: var(--ok); }
.box-prima, .box-seconda { border-style: dashed; border-color: var(--pen); }
.task { font-size: 1.15rem; font-weight: 600; }
.wsteps { padding-left: 1.4em; }
.wsteps li { margin-bottom: 14px; padding: 12px 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: 10px; }
.wt { font-size: 1.12rem; margin-bottom: 6px; }
.why { color: var(--ink-soft); margin: 0; }
.why-l { font-weight: 700; color: var(--ink); }
.sumrow { margin-bottom: 12px; }

/* frazioni */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 0 .12em; font-size: .95em; }
.frac .fn { border-bottom: 2px solid currentColor; padding: 0 .2em .05em; }
.frac .fd { padding: .05em .2em 0; }
.nw { display: inline-block; white-space: nowrap; }
.formula .frac, .task .frac, .prompt .frac, .fill .frac, .opt .frac { font-size: 1em; }

/* figure */
.fig { margin: 14px 0 18px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 520px) auto; justify-content: start; align-items: center; gap: 18px; margin-bottom: 10px; }
.bar { display: flex; height: 40px; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; background: var(--sheet); max-width: 520px; }
.seg { flex: 1; border-left: 1.5px solid var(--ink); }
.seg:first-child { border-left: 0; }
.seg.on, .sseg.on { background-color: var(--hl); background-image: repeating-linear-gradient(135deg, transparent 0 7px, var(--hatch) 7px 9px); }
.bar-label { font-size: 1.05rem; }
.bar-rest { display: block; color: var(--ink-soft); font-size: .9rem; }
.area-grid { display: grid; width: min(320px, 100%); aspect-ratio: 2 / 1; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; }
.cell { border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); background: var(--sheet); }
.cell.col { background-color: var(--hl-soft); background-image: repeating-linear-gradient(90deg, transparent 0 8px, var(--hatch) 8px 9px); }
.cell.both { background-color: var(--hl); background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--hatch) 6px 8px), repeating-linear-gradient(45deg, transparent 0 6px, var(--hatch) 6px 8px); }
.area figcaption { margin-top: 10px; font-size: 1.05rem; display: flex; flex-direction: column; gap: 6px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .88rem; color: var(--ink-soft); }
.sw { display: inline-block; width: 20px; height: 16px; border: 1.5px solid var(--ink); }
.sw.col { background-color: var(--hl-soft); background-image: repeating-linear-gradient(90deg, transparent 0 4px, var(--hatch) 4px 5px); }
.sw.both { background-color: var(--hl); background-image: repeating-linear-gradient(135deg, transparent 0 3px, var(--hatch) 3px 5px); }

/* ---------- esercizio ---------- */
.exsheet { padding-top: 18px; }
.exhead { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-bottom: 14px; }
.exlabel { font-weight: 700; margin-right: 6px; }
.tagp { font-size: .78rem; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.prompt { font-size: 1.2rem; }
.prompt:focus { outline: none; }
.part { margin: 16px 0; }
.part.locked { opacity: .85; }
.plabel { font-weight: 600; }
.pn { font-family: var(--mono); color: var(--ink-soft); }
.okmark { color: var(--ok); font-weight: 700; margin: 6px 0 0; }
.numrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.unit { font-size: 1.2rem; }
.slot { min-width: 72px; min-height: 56px; padding: 6px 12px; border: 2px dashed var(--line); border-radius: 10px; background: var(--sheet); font-family: var(--mono); font-size: 1.45rem; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot.active { border-style: solid; border-color: var(--pen); background: var(--pen-soft); box-shadow: 0 0 0 3px var(--pen-soft); }
.slot[disabled] { cursor: default; border-style: solid; }
.ph-slot { color: var(--ink-soft); opacity: .6; }
.frac-in { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.fline { width: 100%; min-width: 84px; height: 3px; background: var(--ink); border-radius: 2px; }
.fill { font-size: 1.35rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fill .frac .slot { font-size: 1.2rem; min-width: 62px; min-height: 50px; margin: 2px 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 340px; margin: 18px 0 6px; }
.key { min-height: 56px; border: 1.5px solid var(--line); background: var(--paper); border-radius: 12px; font-family: var(--mono); font-size: 1.35rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.key:active { background: var(--pen-soft); }
.key.wide { grid-column: span 3; font-family: var(--font); font-size: 1rem; }
@media (min-width: 560px) { .key.wide { grid-column: span 1; } .keypad { grid-template-columns: repeat(3, 1fr) 1.6fr; } .key.wide:nth-last-child(2) { grid-column: 4; grid-row: 1 / span 2; } .key.wide:last-child { grid-column: 4; grid-row: 3 / span 2; } }
.opts { display: flex; flex-wrap: wrap; gap: 10px; }
.opt { position: relative; min-height: 56px; min-width: 64px; padding: 10px 18px 10px 40px; border: 2px solid var(--line); border-radius: 12px; background: var(--sheet); font-size: 1.15rem; cursor: pointer; text-align: left; }
.opt::before { content: ""; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; border: 2px solid var(--ink-soft); }
.opt[aria-pressed="true"] { border-color: var(--pen); background: var(--pen-soft); border-width: 3px; }
.opt[aria-pressed="true"]::before { border-color: var(--pen); background: var(--pen); box-shadow: inset 0 0 0 3px var(--pen-soft); }
.opts.inline .opt { font-family: var(--mono); font-size: 1.6rem; min-width: 96px; text-align: center; }
.opt[disabled] { cursor: default; opacity: .55; }
.esteps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.estep { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 12px; background: var(--sheet); font-size: 1.1rem; text-align: left; cursor: pointer; }
.enum { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.estep[aria-pressed="true"] { border-color: var(--mark); border-width: 3px; background: var(--mark-soft); }
.estep[aria-pressed="true"] .enum::after { content: " \00b7 indicato come sbagliato"; color: var(--mark); }
.shade { display: flex; max-width: 640px; height: 72px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.sseg { flex: 1; border: 0; border-left: 1.5px solid var(--ink); background: var(--sheet); cursor: pointer; min-width: 0; padding: 0; }
.sseg:first-child { border-left: 0; }
.nline { position: relative; display: flex; justify-content: space-between; max-width: 640px; padding: 0 2px; margin: 8px 0 4px; }
.axis { position: absolute; left: 22px; right: 22px; top: 26px; height: 3px; background: var(--ink); }
.tick { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 44px; min-height: 76px; padding-top: 12px; border: 0; background: none; cursor: pointer; }
.tk { width: 3px; height: 30px; background: var(--ink); border-radius: 2px; }
.tl { font-family: var(--mono); font-weight: 600; margin-top: 4px; min-height: 1.2em; }
.tick.on .tk { width: 22px; height: 22px; margin-top: 4px; border-radius: 50%; background: var(--pen); border: 3px solid var(--sheet); box-shadow: 0 0 0 2px var(--pen); }
.tick[disabled] { cursor: default; }
.seq { padding-left: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; }
.seq li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1.5px solid var(--pen); border-radius: 10px; font-size: 1.1rem; }
.ord { font-family: var(--mono); font-size: .8rem; color: var(--pen); font-weight: 700; }
.tx { width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); font-size: 1.05rem; margin: 6px 0 12px; resize: vertical; }
.rubric { display: grid; gap: 8px; margin-bottom: 12px; }
.rub { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--sheet); cursor: pointer; min-height: 52px; }
.box-ic { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--ink-soft); border-radius: 6px; font-weight: 700; }
.rub[aria-pressed="true"] { border-color: var(--ok); }
.rub[aria-pressed="true"] .box-ic { background: var(--ok); border-color: var(--ok); color: var(--sheet); }
.answer-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
.fb { border-radius: 12px; padding: 12px 16px; margin: 14px 0; border: 1.5px solid var(--line); }
.fb p:last-child { margin-bottom: 0; }
.fbt { font-weight: 700; font-size: 1.08rem; }
.fb-ok { background: var(--ok-soft); border-color: var(--ok); }
.fb-ok .fbt { color: var(--ok); }
.fb-no { background: var(--mark-soft); border-color: var(--mark); }
.fb-no .fbt { color: var(--mark); }
.fb-info { background: var(--pen-soft); border-color: var(--pen); }
.hint-box { background: var(--hl-soft); border: 1.5px solid var(--hl); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
.hint-box p:last-child { margin: 0; }
.exacts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.solution { margin-top: 16px; border: 1.5px solid var(--line); border-radius: 12px; padding: 4px 16px; background: var(--paper); }
.solution summary { font-weight: 700; cursor: pointer; padding: 10px 0; min-height: 44px; }
.solution ol { padding-left: 1.3em; }
.solution li { margin-bottom: .5em; }

/* indice */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(20, 27, 39, .45); }
.sheetbox { position: fixed; z-index: 51; right: 0; top: 0; bottom: 0; width: min(440px, 100%); background: var(--sheet); overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) 20px; border-left: 1px solid var(--line); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.toc h3 { font-size: 1rem; margin: 18px 0 6px; }
.tocbtn { width: 100%; text-align: left; padding: 10px 12px; min-height: 48px; border: 1px solid transparent; border-radius: 10px; background: none; cursor: pointer; }
.tocbtn[aria-current="true"] { border-color: var(--pen); background: var(--pen-soft); font-weight: 700; }

/* riepilogo */
.score { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; margin: 12px 0 20px; }
.voto { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 140px; height: 140px; border-radius: 50%; border: 3px solid var(--mark); color: var(--mark); flex: none; }
.vnum { font-size: 3.2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.vlab { font-size: .75rem; text-align: center; padding: 0 16px; color: var(--ink-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; flex: 1; min-width: 240px; }
.kv dt { color: var(--ink-soft); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.three > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }

/* quaderno */
.entry { background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 10px; }
.entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; align-items: baseline; margin-bottom: 8px; }
.entry-head h3 { margin: 0; font-size: 1.05rem; }
.entry-q { margin-bottom: 6px; }
.entry-q p { margin: 0; }
.entry p.small { margin: 4px 0; }
.entry-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.res { font-size: .82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1.5px solid var(--line); white-space: nowrap; }
.res-ok1 { color: var(--ok); border-color: var(--ok); }
.res-ok2 { color: var(--pen); border-color: var(--pen); }
.res-sol, .res-wip { color: var(--mark); border-color: var(--mark); }
.teacher { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.glossary { margin: 0; }
.gitem { padding: 14px 0; border-bottom: 1px solid var(--grid); }
.gitem dt { font-weight: 700; }
.gitem dd { margin: 4px 0 0; }

/* moduli */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-weight: 600; }
.field input[type="text"], .field input[type="date"], .field input[type="search"], .field select { min-height: 50px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); width: 100%; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.seg2 { display: flex; gap: 10px; flex-wrap: wrap; }
.radio { flex: 1 1 160px; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; }
.radio input { width: 22px; height: 22px; accent-color: var(--pen); }
.radio:has(input:checked) { border-color: var(--pen); background: var(--pen-soft); }
.hint { font-size: .85rem; color: var(--ink-soft); margin: 0; }
.form-err { color: var(--mark); font-weight: 600; min-height: 1em; margin: 0; }
.search { margin-bottom: 8px; }
.textout textarea { width: 100%; font-family: var(--mono); font-size: .8rem; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.setup { min-height: 100vh; min-height: 100dvh; display: grid; place-items: start center; padding-block: 48px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: var(--sq) var(--sq); }
.setup-in { width: min(640px, 100%); background: var(--sheet); border: 1px solid var(--line); border-radius: 18px; padding: 32px 30px; }
.brand { font-family: var(--mono); font-weight: 600; color: var(--pen); margin-bottom: 4px; }
.setup h1 { font-size: 2.4rem; }
.lead { font-size: 1.1rem; color: var(--ink-soft); }
.setup-alt { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }

.practice { position: fixed; inset: 0; z-index: 45; background: var(--paper); display: flex; flex-direction: column; }
.practice .pbody { overflow-y: auto; flex: 1; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--ink); color: var(--sheet); padding: 10px 18px; border-radius: 12px; font-weight: 600; }
.toast:empty { display: none; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .sheet { padding: 18px 16px; }
  .panel { padding: 16px; }
  .lrow { flex-wrap: wrap; }
  .lrow .btn { width: 100%; }
  .todo { flex-wrap: wrap; }
  .todo .btn { width: 100%; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  h1 { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

@media print {
  .shell { padding-left: 0 !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .tabs, .lfoot, .lhead, .keypad, .toast, .card-actions, .exacts, .sim, .lprog, .filters, .segctl, .entry-acts { display: none !important; }
  .cert { border: 3px double #000 !important; break-inside: avoid; }
  .main, .lbody { max-width: none; padding: 0; }
  .sheet, .panel { border: 0; padding: 0; }
  .paper, .hero-panel { background-image: none; }
  .solution { border: 0; }
}

/* tabella del valore posizionale, retta fissa, prova diagnostica */
abbr { text-decoration: none; }
.place { width: auto; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.place th, .place td { vertical-align: middle; text-align: center; padding: 8px 12px; border: 1px solid var(--line); background: var(--sheet); }
.place thead th { color: var(--pen); font-weight: 700; }
.place tbody th { text-align: left; font-weight: 600; }
.place .comma { border-left: 0; border-right: 0; padding: 8px 2px; font-weight: 700; }
.hsub { display: block; font-size: .7rem; font-weight: 400; color: var(--ink-soft); }
.tick.static { cursor: default; }
.diag-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 16px; border: 1.5px solid var(--pen); border-radius: 12px; background: var(--pen-soft); }
.diag-saved p { margin: 0; font-weight: 600; }
.unanswered { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.profile { font-weight: 700; white-space: nowrap; }
.profile-forza { color: var(--ok); }
.profile-consolidare { color: var(--pen); }
.profile-priorita { color: var(--mark); }
.pgoals { display: grid; gap: 8px; margin: 10px 0; }
.pgoal { display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--sheet); cursor: pointer; min-height: 52px; }
.pgoal[aria-pressed="true"] { border-color: var(--pen); background: var(--pen-soft); }
.pgoal[aria-pressed="true"] .box-ic { background: var(--pen); border-color: var(--pen); color: var(--sheet); }

/* Esponenti e scomposizione in colonna */
sup { font-size: .7em; line-height: 0; vertical-align: .55em; margin-left: .04em; }
.column { border-collapse: collapse; margin: .25rem auto; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.column, .column tr, .column td { border: 0; background: none; }
.column td { padding: .2rem .9rem; text-align: right; min-width: 3ch; }
.column td.cq { border-right: 2px solid var(--ink); }
.column td.cd { text-align: left; color: var(--pen); font-weight: 600; }

/* percentuali, tabella delle unità, figure geometriche */
.g100 { display: grid; grid-template-columns: repeat(10, 1fr); width: min(220px, 70vw); aspect-ratio: 1; border: 2px solid var(--ink); background: var(--sheet); }
.g100 .cell { border: 1px solid var(--line); }
.g100 .cell.col { background: var(--hl); background-image: repeating-linear-gradient(45deg, var(--hatch) 0 2px, transparent 2px 7px); }
.units { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.ucell { min-width: 3.2em; padding: 8px 6px; text-align: center; font-weight: 700; border: 1.5px solid var(--line); border-radius: 8px; background: var(--sheet); }
.ucell.base { border-color: var(--ink); }
.ucell.on { border: 2.5px solid var(--pen); background: var(--pen-soft); color: var(--pen); }
.ustep { font-size: .72rem; line-height: 1.15; color: var(--ink-soft); text-align: center; }
.shape { width: 100%; height: auto; display: block; margin: 0 auto; overflow: visible; }
.shape .sh-fill { fill: var(--pen-soft); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.shape .sh-dash { stroke: var(--pen); stroke-width: 2; stroke-dasharray: 6 5; }
.shape .sh-right { fill: none; stroke: var(--pen); stroke-width: 1.5; }
.shape .sh-label { fill: var(--ink); font: 600 15px var(--font); }

/* attestato */
.cert { margin: 8px 0 16px; padding: 28px 24px; border: 3px double var(--ink); border-radius: 6px; text-align: center; background: var(--sheet); }
.cert .kv { text-align: left; max-width: 520px; margin: 14px auto; }
.cert .pts { text-align: left; max-width: 560px; margin: 4px auto 10px; }
.cert-brand { margin: 0; font-weight: 700; color: var(--pen); letter-spacing: .02em; }
.cert-kind { margin: 4px 0 18px; font-size: 1.5rem; font-weight: 700; }
.cert-line { margin: 6px 0; }
.cert-name { margin: 6px 0 10px; font-size: 1.9rem; font-weight: 700; border-bottom: 1.5px solid var(--line); display: inline-block; padding: 0 18px 4px; }
.cert-sub { margin: 14px 0 0; font-weight: 700; }
.cert-sign { display: flex; justify-content: space-around; gap: 24px; margin: 34px 0 10px; }
.cert-sign div { flex: 1; max-width: 220px; }
.cert-sign span { display: block; border-bottom: 1.5px solid var(--ink); height: 34px; }
.cert-note { margin-top: 14px; }

.sim.upd { background: var(--pen-soft); border-bottom-color: var(--pen); display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.sim.upd .btn { padding: 4px 14px; min-height: 0; }

/* palestra */
.gym-h { margin: 6px 0 12px; }
.gym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 20px; }
.gym-topic, .gym-level { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); cursor: pointer; touch-action: manipulation; min-height: 52px; }
.gym-topic[aria-pressed="true"], .gym-level[aria-pressed="true"] { border-color: var(--pen); background: var(--pen-soft); box-shadow: inset 0 0 0 1px var(--pen); }
.gym-topic[aria-disabled="true"] { border-style: dashed; background: transparent; }
.gym-topic[aria-disabled="true"] .gt-title, .gym-topic[aria-disabled="true"] .gt-text { color: var(--ink-soft); }
.gt-title, .gl-title { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.gt-text { font-size: .85rem; color: var(--ink-soft); line-height: 1.4; }
.gt-lock { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.gt-lock::before { content: "\1F512\00a0"; }
.lvstars { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: .8rem; color: var(--ink-soft); }
.lvn { font-weight: 600; }
.stars { white-space: nowrap; letter-spacing: 1px; font-size: 1rem; line-height: 1; }
.star { color: var(--line); }
.star.on { color: var(--pen); }
.gym-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 12px 0; }
.gym-level .stars { font-size: 1.1rem; }
.gym-level .pill { margin-left: 4px; font-weight: 600; }
.gym-start .confirm { margin-top: 8px; }
.weekdots { display: flex; gap: 6px; list-style: none; padding: 0; margin: 6px 0 10px; flex-wrap: wrap; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 38px; }
.wdn { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.wd.today .wdn { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.wdm { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--sheet); }
.wd.today .wdm { border-color: var(--ink-soft); }
.wd.on .wdm { background: var(--ok); border-color: var(--ok); }
.gym-voto { border-color: var(--pen); color: var(--pen); }
.gym-voto .vlab { text-align: center; padding: 0 12px; font-size: .78rem; line-height: 1.2; }
.gym-review { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.gym-rv { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--sheet); color: var(--ink); cursor: pointer; min-height: 48px; }
.gr-ic { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; border: 2px solid var(--line); color: var(--ink-soft); }
.gym-ok .gr-ic { background: var(--ok); border-color: var(--ok); color: var(--sheet); }
.gym-mid .gr-ic { border-color: var(--ok); color: var(--ok); }
.gym-no .gr-ic { border-color: var(--mark); color: var(--mark); }
.gr-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.gym-confirm { margin-top: 12px; }
@media (max-width: 480px) {
  .tab { font-size: .7rem; padding: 6px 1px; }
  .tab .ico { width: 24px; height: 24px; }
  .wd { min-width: 34px; }
  .wdm { width: 32px; height: 32px; }
}

/* sincronizzazione */
.synccode { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; letter-spacing: .08em; padding: 10px 14px; border: 2px dashed var(--line); border-radius: 12px; display: inline-block; background: var(--paper); user-select: all; -webkit-user-select: all; }
.sync-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; background: var(--line); }
.sync-dot.ok { background: var(--ok); }
.sync-dot.off { background: var(--ink-soft); }
.sync-dot.err { background: var(--mark); }
.sync-dot.busy { background: var(--hl); }
.sync-join { margin-top: 14px; }
.sync-join input { text-transform: uppercase; letter-spacing: .06em; font-family: var(--mono); }
.sync-more { margin-top: 14px; }
.sync-more summary { cursor: pointer; color: var(--ink-soft); min-height: 32px; }
@media (max-width: 480px) {
  .segctl { flex-wrap: wrap; overflow-x: visible; }
  .segctl button { flex: 1 1 40%; padding: 8px 6px; }
  .synccode { font-size: 1.05rem; letter-spacing: .04em; white-space: nowrap; }
}
