/* ==========================================================================
   Fisica — stile
   Due temi: grafite (scuro) e carta (chiaro). L'interfaccia usa un solo
   inchiostro a opacità diverse; il colore compare solo nei grafici, nei
   vettori e negli stati giusto/sbagliato.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  --app: #19191b;          /* fondo dietro al foglio (sidebar) */
  --sheet: #1f1f21;        /* foglio principale */
  --tray: #19191b;         /* vassoio per simulazioni e figure */
  --raised: #262628;       /* superfici sopra il foglio */
  --ink-rgb: 255, 255, 255;
  --paper-rgb: 31, 31, 33;
  --ink: rgba(var(--ink-rgb), 0.92);
  --ink-2: rgba(var(--ink-rgb), 0.62);
  --ink-3: rgba(var(--ink-rgb), 0.40);
  --ink-4: rgba(var(--ink-rgb), 0.24);
  --fill: rgba(var(--ink-rgb), 0.045);
  --fill-2: rgba(var(--ink-rgb), 0.08);
  --fill-3: rgba(var(--ink-rgb), 0.12);
  --stroke: rgba(var(--ink-rgb), 0.08);
  --stroke-2: rgba(var(--ink-rgb), 0.14);
  --solid: #f2f2f0;         /* bottone principale */
  --on-solid: #1a1a1c;
  --ok: #34c759;
  --ko: #ff5a4f;
  --ok-fill: rgba(52, 199, 89, 0.10);
  --ko-fill: rgba(255, 90, 79, 0.10);
  --hint: #e6b84a;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --app: #efede8;
  --sheet: #faf9f6;
  --tray: #f1efea;
  --raised: #ffffff;
  --ink-rgb: 29, 27, 24;
  --paper-rgb: 250, 249, 246;
  --ink: rgba(var(--ink-rgb), 0.92);
  --ink-2: rgba(var(--ink-rgb), 0.64);
  --ink-3: rgba(var(--ink-rgb), 0.44);
  --ink-4: rgba(var(--ink-rgb), 0.26);
  --fill: rgba(var(--ink-rgb), 0.035);
  --fill-2: rgba(var(--ink-rgb), 0.06);
  --fill-3: rgba(var(--ink-rgb), 0.10);
  --stroke: rgba(var(--ink-rgb), 0.09);
  --stroke-2: rgba(var(--ink-rgb), 0.15);
  --solid: #1d1b18;
  --on-solid: #faf9f6;
  --ok: #248a3d;
  --ko: #d1352b;
  --ok-fill: rgba(36, 138, 61, 0.08);
  --ko-fill: rgba(209, 53, 43, 0.07);
  --hint: #9a6a00;
  color-scheme: light;
}

:root {
  --r-sheet: 16px;
  --r-tray: 18px;
  --r: 12px;
  --r-sm: 9px;
  --sidebar-w: 272px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --measure: 720px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--app); }
/* scorrimento: di lato la pagina non si trascina mai; su e giù resta l'elastico naturale
   di iPhone/iPad, tolto solo nelle sezioni alte quanto lo schermo (quaderno, codice), dove
   trascinava il sito intero (classe messa dal router in app.js) */
html, body { overscroll-behavior-x: none; }
html.app-fixed, html.app-fixed body { overscroll-behavior: none; }
body {
  margin: 0;
  background: var(--app);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.6;
  letter-spacing: -0.006em;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
::selection { background: rgba(var(--ink-rgb), 0.16); }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg, canvas { display: block; max-width: 100%; }
/* anello del fuoco con la tinta del sistema (--tint in css/glass.css); qui e non in glass.css,
   così le regole con outline: none (testo della nota, titolo, campi) restano più forti */
:focus-visible { outline: 2px solid color-mix(in srgb, var(--tint, #0a84ff) 72%, transparent); outline-offset: 2px; border-radius: 6px; }

* { scrollbar-width: thin; scrollbar-color: var(--fill-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--fill-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ==========================================================================
   Struttura: sidebar + foglio
   ========================================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--app);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.4s var(--ease);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 14px;
  text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--stroke-2);
  display: grid; place-items: center;
  color: var(--ink);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }

.search {
  margin: 4px 12px 10px;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--fill-2);
  color: var(--ink-3);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  color: var(--ink); font: inherit; font-size: 14.5px;
}
.search input::placeholder { color: var(--ink-3); }
.search kbd { font-family: var(--font); font-size: 12px; color: var(--ink-4); }

.nav { flex: 1; overflow-y: auto; padding: 0 12px 16px; }
.nav-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-3);
  padding: 16px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--ink);
  font-size: 15px;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--fill); }
.nav-item.active { background: var(--fill-2); }
.nav-ic { width: 20px; height: 20px; flex: none; display: grid; place-items: center; color: var(--ink-2); }
.nav-ic svg { width: 18px; height: 18px; }
.nav-text { flex: 1; min-width: 0; line-height: 1.3; }
.nav-count { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; margin: 0 6px; }
.nav-item.done .nav-count::before { content: "✓ "; color: var(--ok); }

.chev {
  width: 16px; height: 16px; flex: none; display: grid; place-items: center;
  color: var(--ink-3); border: 0; background: none; padding: 0; cursor: pointer;
  transition: transform 0.25s var(--ease);
}
.chev svg { width: 12px; height: 12px; }
.nav-group.open > .nav-item .chev { transform: rotate(90deg); }

.nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.35s var(--ease); }
.nav-sub > div { overflow: hidden; }
.nav-group.open .nav-sub { grid-template-rows: 1fr; }
.nav-sub a {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px 5px 42px;
  font-size: 14px; line-height: 1.35;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--r-sm);
  position: relative;
}
.nav-sub a::before {
  content: ""; position: absolute; left: 27px; top: 0; bottom: 0; width: 1px; background: var(--stroke-2);
}
.nav-sub a:hover { color: var(--ink); background: var(--fill); }
.nav-sub a.current { color: var(--ink); }
.nav-sub a.current::before { background: var(--ink); width: 1.5px; }
.nav-sub > div > :last-child { margin-bottom: 6px; }
.nav-item[hidden], .nav-sub a[hidden], .nav-group[hidden] { display: none; }

.sidebar-foot {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--stroke);
  margin: 0 12px;
  padding-left: 0; padding-right: 0;
}
.foot-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 14.5px; color: var(--ink); }
.foot-row .nav-ic { color: var(--ink-2); }
.progress-line { flex: 1; height: 3px; border-radius: 3px; background: var(--fill-3); overflow: hidden; }
.progress-line i { display: block; height: 100%; width: 0; background: var(--ink-2); transition: width 0.6s var(--ease); }

.main {
  margin-left: var(--sidebar-w);
  padding: 8px 8px 8px 0;
  min-height: 100vh;
}
.sheet {
  background: var(--sheet);
  border: 1px solid var(--stroke);
  border-radius: var(--r-sheet);
  min-height: calc(100vh - 16px);
  position: relative;
}

.topbar {
  position: sticky; top: 8px; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 20px;
  background: var(--sheet);
  border-bottom: 1px solid var(--stroke);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
}
.topbar::before { /* copre il bordo sopra quando è attaccata in alto */
  content: ""; position: absolute; left: -1px; right: -1px; top: -9px; height: 9px; background: var(--app);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--ink-3); min-width: 0; flex: 1; }
.crumbs a { text-decoration: none; color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.crumbs b { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--ink-4); }
.menu-btn {
  display: none; width: 34px; height: 34px; border-radius: var(--r-sm); border: 0;
  background: var(--fill-2); place-items: center; cursor: pointer; color: var(--ink);
}
.menu-btn svg { width: 18px; height: 18px; }
.read-meter { width: 64px; height: 3px; border-radius: 3px; background: var(--fill-3); overflow: hidden; }
.read-meter i { display: block; height: 100%; width: 0; background: var(--ink-2); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 45; opacity: 0; pointer-events: none; transition: opacity 0.3s; }

.view { display: none; }
.view.active { display: block; animation: viewIn 0.25s ease-out both; }
/* Pagine lunghe e ferme (materie, lezioni, palestra, flashcard: .keep, app.js) nascoste senza
   smontarle: con display:none il browser le ridisponeva da capo a ogni visita (la pagina di
   fisica, con le formule dei ripassi, ~1 s con la CPU rallentata 4 volte); con content-visibility: hidden
   tiene il lavoro fatto e il ritorno è immediato. Alte 0, fuori dall'accessibilità, dalla
   tastiera e dalla ricerca nella pagina come prima. */
@supports (content-visibility: hidden) {
  .view.keep:not(.active) { display: block; content-visibility: hidden; }
}
@media print { .view.keep:not(.active) { display: none; } }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

.content { max-width: 820px; margin: 0 auto; padding: 56px 48px 120px; }
.content.wide { max-width: 1180px; }

@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); background: var(--app); border-right: 1px solid var(--stroke); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; padding: 0; }
  .sheet { border-radius: 0; border: 0; min-height: 100vh; }
  .topbar { top: 0; border-radius: 0; padding: 0 12px; }
  .topbar::before { display: none; }
  .menu-btn { display: grid; }
  .content { padding: 36px 20px 100px; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .content { padding: 28px 16px 90px; }
  .read-meter { display: none; }
}

/* ==========================================================================
   Tipografia
   ========================================================================== */
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; font-weight: 650; }
h1 { font-size: clamp(36px, 5vw, 50px); line-height: 1.06; letter-spacing: -0.03em; }
h2 { font-size: clamp(25px, 3vw, 31px); line-height: 1.15; letter-spacing: -0.022em; margin-bottom: 16px; }
h3 { font-size: 19px; line-height: 1.3; letter-spacing: -0.015em; margin: 32px 0 8px; font-weight: 600; }
h4 { font-size: 16.5px; font-weight: 600; margin: 22px 0 6px; }
p { margin: 0 0 14px; color: var(--ink-2); max-width: var(--measure); }
p strong, li strong, td strong { color: var(--ink); font-weight: 600; }
ul, ol { color: var(--ink-2); padding-left: 22px; margin: 0 0 16px; max-width: var(--measure); }
li { margin: 5px 0; }
li::marker { color: var(--ink-4); }
em { color: var(--ink); }
code, .mono { font-family: var(--mono); font-size: 0.86em; background: var(--fill-2); padding: 1px 6px; border-radius: 5px; }
hr, .divider { border: 0; height: 1px; background: var(--stroke); margin: 44px 0; }

.eyebrow { font-size: 14.5px; font-weight: 500; color: var(--ink-3); margin-bottom: 12px; }
.lead { font-size: 19px; line-height: 1.55; color: var(--ink-2); margin-top: 16px; letter-spacing: -0.012em; max-width: 640px; }
.lead strong { color: var(--ink); }
.grad { color: inherit; }

/* colori semantici: nel testo restano sobri */
.c-blue, .c-green, .c-orange, .c-red, .c-purple, .c-pink, .c-teal, .c-yellow { color: var(--ink) !important; font-weight: 600; }
.c-muted { color: var(--ink-3) !important; }

/* ==========================================================================
   Lezione
   ========================================================================== */
.lesson-hero { padding: 8px 0 32px; border-bottom: 1px solid var(--stroke); }
.lesson-hero .eyebrow { display: flex; align-items: center; gap: 8px; }
.lesson-hero .eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tags { display: none; }

.block { padding: 48px 0 12px; scroll-margin-top: 70px; }
.block + .block { border-top: 1px solid var(--stroke); }

/* --- superfici --- */
.card {
  background: transparent;
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 20px 22px;
  margin: 20px 0;
}
.card > :last-child { margin-bottom: 0; }
.card h3:first-child, .card h4:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.grid-2 > .card, .grid-3 > .card { margin: 0; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* --- formule: riga chiave/valore come una scheda tecnica --- */
.formula {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  column-gap: 24px;
  align-items: center;
  padding: 14px 0;
  margin: 0;
  border-top: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
  overflow-x: auto;
}
.formula + .formula { border-top: 0; }
.formula-label { font-size: 15px; color: var(--ink-3); grid-column: 1; align-self: center; }
.formula > :not(.formula-label) { grid-column: 2; }
.formula .katex-display { margin: 4px 0; text-align: left; }
.formula .katex-display > .katex { text-align: left; }
.formula .katex { font-size: 1.2em; }
.formula-note { font-size: 14px; color: var(--ink-3); margin: 0; }
.formula.key {
  background: var(--tray);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  padding: 18px 22px;
  margin: 22px 0;
}
.formula.key .katex { font-size: 1.32em; }
* + .formula:not(.key):not(.formula + .formula) { margin-top: 20px; }
.formula:not(.key) + :not(.formula) { margin-top: 20px; }

.formula-grid { display: block; margin: 22px 0; }
.formula-grid .formula { border-top: 0; margin: 0; }
.formula-grid .formula:first-child { border-top: 1px solid var(--stroke); }
.formula-grid .formula.key { border-top: 1px solid var(--stroke); margin: 0; border-radius: 0; background: transparent; border-left: 0; border-right: 0; padding: 14px 0; }
.formula-grid .formula .katex { font-size: 1.14em; }
@media (max-width: 640px) {
  .formula { grid-template-columns: 1fr; row-gap: 2px; }
  .formula > * { grid-column: 1 !important; }
}

/* relative: la copia MathML nascosta di KaTeX (position: absolute) restava fuori dai riquadri
   che scorrono di lato e allargava la pagina sul telefono (si poteva trascinarla a destra) */
.katex { font-size: 1.06em; position: relative; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* --- note --- */
.callout {
  padding: 14px 0 14px 18px;
  border-left: 2px solid var(--ink-4);
  margin: 22px 0;
  font-size: 15.5px;
}
.callout > div > :last-child { margin-bottom: 0; }
.callout p { margin-bottom: 8px; }
.callout-title { display: block; font-weight: 600; color: var(--ink); margin-bottom: 2px; font-size: 15px; }
.callout.warn { border-left-color: var(--hint); }
.callout.key { border-left-color: var(--ink-2); }

/* --- vassoio: figure e simulazioni (come la cornice dell'anteprima) --- */
.figure {
  margin: 26px 0;
  background: var(--tray);
  border: 1px solid var(--stroke);
  border-radius: var(--r-tray);
  padding: 22px;
}
.figure svg { width: 100%; height: auto; margin: 0 auto; }
.figure svg text { font-family: var(--font); }
.figure figcaption, .figcaption { font-size: 14px; color: var(--ink-3); margin-top: 14px; text-align: left; max-width: var(--measure); }
.figure figcaption strong { color: var(--ink-2); }

.sim {
  margin: 28px 0;
  background: var(--tray);
  border: 1px solid var(--stroke);
  border-radius: var(--r-tray);
  padding: 10px 10px 6px;
}
.sim .readout { padding: 0 6px; }
.sim-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 6px 10px; flex-wrap: wrap; }
.sim-title { font-size: 14.5px; font-weight: 500; color: var(--ink-2); }
.sim-stage {
  position: relative; width: 100%;
  background: var(--sheet);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}
.sim-stage canvas { width: 100%; display: block; touch-action: none; }
.sim-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 12px 6px 4px; }
.sim-buttons { display: flex; gap: 6px; }
.btn-icon {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  background: transparent; border: 1px solid var(--stroke-2); color: var(--ink);
  display: grid; place-items: center;
}
.btn-icon:hover { background: var(--fill); }
.btn-icon.play { background: var(--solid); color: var(--on-solid); border-color: transparent; }
.btn-icon svg { width: 16px; height: 16px; }
.sim-controls { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 22px; min-width: 0; }

.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; font-size: 13.5px; color: var(--ink-2); }
.slider output { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; font-size: 13.5px; }
.slider input { grid-column: 1 / -1; }
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer;
  --fill: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--ink-2) var(--fill), var(--fill-3) var(--fill));
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--fill-3); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--ink-2); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--raised); margin-top: -6.5px;
  border: 1px solid var(--stroke-2);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--raised); border: 1px solid var(--stroke-2); }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { appearance: none; -webkit-appearance: none; width: 32px; height: 19px; border-radius: 19px; background: var(--fill-3); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--raised); box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.2s var(--ease); }
.toggle input:checked { background: var(--ink-2); }
.toggle input:checked::after { transform: translateX(13px); }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--fill-2); border-radius: 999px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-3);
  padding: 5px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 1px var(--stroke), 0 1px 2px rgba(0,0,0,0.12); }

/* letture: righe chiave/valore */
.readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; margin-top: 14px; }
.ro { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--stroke); min-width: 0; }
.ro > span { font-size: 14.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ro > b { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink) !important; white-space: nowrap; }
@media (max-width: 560px) { .readout { grid-template-columns: 1fr; } }

/* --- esempi svolti --- */
.example { margin: 22px 0; border: 1px solid var(--stroke); border-radius: var(--r); overflow: hidden; }
.ex-head { display: flex; align-items: baseline; gap: 12px; padding: 18px 22px 0; flex-wrap: wrap; }
.ex-tag { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.ex-level { font-size: 13.5px; color: var(--ink-3); margin-left: auto; }
.ex-head h3 { margin: 0; font-size: 17.5px; }
.ex-text { padding: 10px 22px 4px; }
.ex-text p { color: var(--ink); }
.ex-data { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.ex-data > span {font-size: 14px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--stroke); color: var(--ink-2); }
.example details { border-top: 1px solid var(--stroke); }
.example summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 12px 22px; font-size: 14.5px; font-weight: 500; color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.example summary:hover { color: var(--ink); background: var(--fill); }
.example summary::-webkit-details-marker { display: none; }
.example summary::before {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.25s var(--ease); margin-right: 4px;
}
.example details[open] summary::before { transform: rotate(45deg); }
.ex-body { padding: 6px 22px 22px; }
.steps { counter-reset: st; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: st; position: relative; padding: 1px 0 12px 34px; margin: 0; }
.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  border: 1px solid var(--stroke-2); color: var(--ink-2);
}
.result { margin-top: 6px; padding: 12px 16px; border-radius: var(--r-sm); background: var(--fill-2); color: var(--ink); }
.result::before { content: "Risultato"; display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 2px; }

/* --- FAQ --- */
.faq { margin: 16px 0; border-top: 1px solid var(--stroke); }
.faq details { border-bottom: 1px solid var(--stroke); }
.faq summary {
  list-style: none; cursor: pointer;
  padding: 16px 40px 16px 0; position: relative;
  font-size: 16.5px; font-weight: 500; color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 8px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg); transition: transform 0.25s var(--ease);
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -1px; }
.faq-a { padding: 0 0 18px; }
.faq-a > :last-child { margin-bottom: 0; }
details.animating { overflow: hidden; }

/* --- tabelle --- */
.table-wrap { overflow-x: auto; margin: 20px 0; border-top: 1px solid var(--stroke); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 11px 16px 11px 0; border-bottom: 1px solid var(--stroke); vertical-align: top; }
th { font-size: 14px; color: var(--ink-3); font-weight: 500; }
td { color: var(--ink-2); }

/* --- bottoni --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; cursor: pointer;
  font-size: 14.5px; font-weight: 500;
  background: transparent; color: var(--ink); border: 1px solid var(--stroke-2);
  text-decoration: none;
  transition: background 0.15s;
}
/* sotto il mouse: un velo più chiaro sopra il vetro. Qui (e non in glass.css, caricato per ultimo)
   così i bottoni con un colore loro («La so» delle flashcard, il microfono delle Finanze…) lo tengono */
@media (hover: hover) { .btn:where(:not(:disabled)):hover { background: linear-gradient(180deg, var(--sheen), transparent 60%), rgba(var(--ink-rgb), 0.08); } }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary, .btn-light { background: var(--solid); color: var(--on-solid); border-color: transparent; }
.btn-primary:hover, .btn-light:hover { background: var(--solid); opacity: 0.88; }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13.5px; }
.btn svg { width: 16px; height: 16px; }

/* --- fine lezione --- */
.lesson-foot { margin-top: 64px; border-top: 1px solid var(--stroke); }
.practice-cta { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 26px 0; border-bottom: 1px solid var(--stroke); }
.practice-cta h3 { margin: 0 0 2px; font-size: 19px; }
.practice-cta p { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; }
.pager a { display: block; padding: 20px 0; text-decoration: none; color: var(--ink); }
.pager a:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.pager small { display: block; font-size: 13.5px; color: var(--ink-3); margin-bottom: 2px; }
.pager b { font-weight: 500; font-size: 16px; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; text-align: left; border-top: 1px solid var(--stroke); } }

/* ==========================================================================
   Home
   ========================================================================== */
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 48px; align-items: center; padding: 24px 0 56px; border-bottom: 1px solid var(--stroke); }
.home-hero h1 { font-size: clamp(40px, 5.4vw, 60px); }
.home-hero .lead { max-width: 480px; }
.home-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.hero-tray { background: var(--tray); border: 1px solid var(--stroke); border-radius: var(--r-tray); padding: 10px; }
.hero-tray .hero-stage { background: var(--sheet); border: 1px solid var(--stroke); border-radius: 12px; overflow: hidden; }
.hero-tray canvas { width: 100%; height: 280px; display: block; }
.hero-caption { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-3); padding: 10px 6px 2px; }
@media (max-width: 900px) { .home-hero { grid-template-columns: 1fr; gap: 32px; } }

.home-section { padding: 48px 0 8px; }
.home-section > h2 { margin-bottom: 8px; }
.home-section > p { margin-bottom: 24px; }

.chapters { border-top: 1px solid var(--stroke); }
.chapter {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 26px 4px; border-bottom: 1px solid var(--stroke);
  text-decoration: none; color: var(--ink);
}
.chapter h3 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.chapter h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chapter p { margin: 0; padding-left: 18px; }
.chapter .ch-num { font-family: var(--font-display); font-size: 54px; font-weight: 700; letter-spacing: -0.04em; color: var(--fill-3); line-height: 1; font-variant-numeric: tabular-nums; }
.chapter:hover .ch-num { color: var(--ink-4); }
.chapter:hover h3 { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.chapter .ch-meta { font-size: 13.5px; color: var(--ink-3); padding-left: 18px; margin-top: 6px; }
.chapter.done .ch-meta::before { content: "✓ Letto · "; color: var(--ok); }

.tool-rows { border-top: 1px solid var(--stroke); }
.tool-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 16px 4px; border-bottom: 1px solid var(--stroke); text-decoration: none; color: var(--ink);
}
.tool-row .k { color: var(--ink-3); font-size: 15px; }
.tool-row .v { color: var(--ink); font-size: 15.5px; }
.tool-row .go { color: var(--ink-3); font-size: 14px; }
.tool-row:hover .go { color: var(--ink); }
@media (max-width: 640px) { .tool-row { grid-template-columns: 1fr; gap: 2px; } }

/* ==========================================================================
   Palestra
   ========================================================================== */
.practice-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 26px; }
.practice-head h1 { font-size: clamp(34px, 4.4vw, 46px); }
.stats { display: flex; border: 1px solid var(--stroke); border-radius: var(--r); overflow: hidden; }
.stat { min-width: 92px; padding: 10px 16px; border-right: 1px solid var(--stroke); }
.stat:last-child { border-right: 0; }
.stat > span { display: block; font-size: 13px; color: var(--ink-3); }
.stat > b { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat b.bump { animation: bump 0.4s var(--ease); }
@keyframes bump { 40% { transform: translateY(-2px); } }

.filters { display: grid; gap: 0; margin-bottom: 22px; border-top: 1px solid var(--stroke); }
.filter-group { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--stroke); }
.filter-group > label { font-size: 14.5px; color: var(--ink-3); }
.filter-group > .seg { justify-self: start; }
@media (max-width: 640px) { .filter-group { grid-template-columns: 1fr; gap: 6px; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--stroke-2); background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { color: var(--ink); background: var(--fill); }
.chip.active { background: var(--solid); color: var(--on-solid); border-color: transparent; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.practice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1180px) { .practice-layout { grid-template-columns: 1fr; } }

.q-card { border-radius: var(--r-tray); background: var(--tray); border: 1px solid var(--stroke); padding: 10px; }
.q-inner { background: var(--sheet); border: 1px solid var(--stroke); border-radius: 12px; padding: 26px; }
.q-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-3); }
.q-topic { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; }
.q-topic::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.q-level { display: inline-flex; gap: 3px; }
.q-level i { width: 6px; height: 6px; border-radius: 50%; background: var(--fill-3); }
.q-level i.on { background: var(--ink-2); }
.q-num { margin-left: auto; }
.q-text { font-size: 18px; line-height: 1.6; color: var(--ink); }
.q-text p { color: var(--ink); }
.q-anim { animation: viewIn 0.25s ease-out both; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 14px; border-radius: var(--r); cursor: pointer;
  background: transparent; border: 1px solid var(--stroke-2);
  color: var(--ink); font-size: 15.5px;
}
.choice:hover:not(:disabled) { background: var(--fill); }
.choice .letter {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--stroke-2); color: var(--ink-2);
}
.choice:disabled { cursor: default; }
.choice.correct { background: var(--ok-fill); border-color: var(--ok); }
.choice.correct .letter { background: var(--ok); color: #fff; border-color: transparent; }
.choice.wrong { background: var(--ko-fill); border-color: var(--ko); }
.choice.wrong .letter { background: var(--ko); color: #fff; border-color: transparent; }
.choice.dim { opacity: 0.5; }

.answer-row { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.answer-field {
  flex: 1; min-width: 200px; display: flex; align-items: center;
  border-radius: var(--r); background: transparent; border: 1px solid var(--stroke-2);
}
.answer-field:focus-within { border-color: var(--ink-3); }
.answer-field input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border: 0; background: transparent; outline: none;
  color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums; font-family: var(--font);
}
.answer-field input::placeholder { color: var(--ink-3); }
.answer-field .unit { padding: 0 14px; color: var(--ink-3); font-size: 15px; white-space: nowrap; }
.answer-field.ok { border-color: var(--ok); background: var(--ok-fill); }
.answer-field.ko { border-color: var(--ko); background: var(--ko-fill); }
.answer-row .btn { height: 48px; }

.q-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.q-actions .spacer { flex: 1; }
.feedback { margin-top: 20px; padding: 14px 0 0; border-top: 1px solid var(--stroke); display: none; }
.feedback.show { display: block; }
.feedback h4 { margin: 0 0 6px; font-size: 15.5px; }
.feedback.ok h4 { color: var(--ok); }
.feedback.ko h4 { color: var(--ko); }
.feedback.info h4 { color: var(--ink); }
.feedback p, .feedback li { color: var(--ink-2); font-size: 15px; }
.feedback > :last-child { margin-bottom: 0; }
.hint-box { margin-top: 16px; font-size: 15px; color: var(--ink-2); padding: 2px 0 2px 14px; border-left: 2px solid var(--hint); display: none; }
.hint-box.show { display: block; }
.hint-box b { color: var(--ink); font-weight: 600; }

.tools { position: sticky; top: 76px; border-radius: var(--r-tray); background: var(--tray); border: 1px solid var(--stroke); overflow: hidden; }
@media (max-width: 1180px) { .tools { position: static; } }
.tools-tabs { display: flex; padding: 8px 8px 0; }
.tools-tabs .seg { width: 100%; }
.tools-tabs .seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tools-tabs button svg { width: 15px; height: 15px; }
.tool-pane { display: none; padding: 12px; }
.tool-pane.active { display: block; }

/* calcolatrice */
.calc-screen {
  border-radius: 12px; background: var(--sheet); border: 1px solid var(--stroke);
  padding: 12px 14px 10px; margin-bottom: 10px; min-height: 92px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.calc-hist { font-size: 12.5px; color: var(--ink-3); text-align: right; min-height: 18px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.calc-expr { width: 100%; border: 0; background: transparent; outline: none; text-align: right; font-size: 18px; color: var(--ink-2); font-family: var(--font); font-variant-numeric: tabular-nums; padding: 0; }
.calc-out { text-align: right; font-size: 28px; font-weight: 400; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; min-height: 38px; overflow-x: auto; white-space: nowrap; }
.calc-out.err { color: var(--ko); font-size: 15px; padding-top: 10px; }
.calc-modes { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.calc-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.calc-keys button {
  height: 42px; border: 1px solid var(--stroke); border-radius: 10px; cursor: pointer;
  background: var(--sheet); color: var(--ink); font-size: 16px;
}
.calc-keys button:hover { background: var(--raised); }
.calc-keys button:active { transform: scale(0.96); }
.calc-keys .fn { background: transparent; color: var(--ink-2); font-size: 14px; }
.calc-keys .op { background: var(--fill-2); font-size: 18px; }
.calc-keys .eq { background: var(--solid); color: var(--on-solid); border-color: transparent; font-size: 19px; }
.calc-keys .clr { color: var(--ko); }
.calc-use { width: 100%; margin-top: 10px; }
.calc-memory { margin-top: 10px; max-height: 140px; overflow-y: auto; }
.calc-memory div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 2px; font-size: 13.5px; border-bottom: 1px solid var(--stroke); cursor: pointer; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.calc-memory div:hover { color: var(--ink); }
.calc-memory div b { color: var(--ink); font-weight: 500; }
.calc-const { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.calc-const button { border: 1px solid var(--stroke-2); background: transparent; color: var(--ink-2); border-radius: 999px; font-size: 12.5px; padding: 3px 9px; cursor: pointer; }
.calc-const button:hover { color: var(--ink); background: var(--fill); }

.scratch {
  width: 100%; min-height: 220px; resize: vertical;
  border-radius: 12px; border: 1px solid var(--stroke); background: var(--sheet); color: var(--ink);
  padding: 12px 14px; font-family: var(--font); font-size: 15px; line-height: 1.6; outline: none;
}
.scratch:focus { border-color: var(--stroke-2); }
.pad-wrap { border-radius: 12px; overflow: hidden; border: 1px solid var(--stroke); background: var(--sheet); }
.pad-wrap canvas { width: 100%; height: 260px; touch-action: none; cursor: crosshair; }
.pad-tools { display: flex; gap: 6px; align-items: center; margin: 10px 0 0; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--tray); box-shadow: 0 0 0 1px var(--stroke-2); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink-2); }
.small-note { font-size: 13px; color: var(--ink-3); margin: 8px 0 0; }

/* ==========================================================================
   Quaderno
   ========================================================================== */
.nb-empty { color: var(--ink-3); text-align: center; padding: 60px 20px; }

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); opacity: 0;
  background: var(--solid); color: var(--on-solid);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  z-index: 100; pointer-events: none; transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Tema chiaro: adatta i colori scritti nelle figure SVG delle lezioni
   ========================================================================== */
:root[data-theme="light"] .figure [fill="#f5f5f7"], :root[data-theme="light"] .figure [fill="#fff"], :root[data-theme="light"] .figure [fill="#ffffff"] { fill: rgba(29,27,24,.88); }
:root[data-theme="light"] .figure [stroke="#f5f5f7"], :root[data-theme="light"] .figure [stroke="#fff"] { stroke: rgba(29,27,24,.85); }
:root[data-theme="light"] .figure [fill="#a1a1a6"] { fill: rgba(29,27,24,.6); }
:root[data-theme="light"] .figure [fill="#86868b"] { fill: rgba(29,27,24,.5); }
:root[data-theme="light"] .figure [stroke="#86868b"] { stroke: rgba(29,27,24,.45); }
:root[data-theme="light"] .figure [fill="#000"], :root[data-theme="light"] .figure [fill="#1c1c1e"] { fill: #faf9f6; }
:root[data-theme="light"] .figure [stroke^="rgba(255,255,255"] { stroke: rgba(29,27,24,.28); }
:root[data-theme="light"] .figure [fill^="rgba(255,255,255"] { fill: rgba(29,27,24,.45); }
:root[data-theme="light"] .figure [fill="#2997ff"] { fill: #0a6fd6; } :root[data-theme="light"] .figure [stroke="#2997ff"] { stroke: #0a6fd6; }
:root[data-theme="light"] .figure [fill="#30d158"] { fill: #1f9d47; } :root[data-theme="light"] .figure [stroke="#30d158"] { stroke: #1f9d47; }
:root[data-theme="light"] .figure [fill="#ff9f0a"] { fill: #d47800; } :root[data-theme="light"] .figure [stroke="#ff9f0a"] { stroke: #d47800; }
:root[data-theme="light"] .figure [fill="#ff453a"] { fill: #d1352b; } :root[data-theme="light"] .figure [stroke="#ff453a"] { stroke: #d1352b; }
:root[data-theme="light"] .figure [fill="#bf5af2"] { fill: #9442c4; } :root[data-theme="light"] .figure [stroke="#bf5af2"] { stroke: #9442c4; }
:root[data-theme="light"] .figure [fill="#ff375f"] { fill: #d6254c; } :root[data-theme="light"] .figure [stroke="#ff375f"] { stroke: #d6254c; }
:root[data-theme="light"] .figure [fill="#64d2ff"] { fill: #138bb8; } :root[data-theme="light"] .figure [stroke="#64d2ff"] { stroke: #138bb8; }
:root[data-theme="light"] .figure [fill="#ffd60a"] { fill: #b58900; } :root[data-theme="light"] .figure [stroke="#ffd60a"] { stroke: #b58900; }
/* colori inseriti nelle formule KaTeX */
:root[data-theme="light"] .katex [style*="rgb(41, 151, 255)"] { color: #0a6fd6 !important; }
:root[data-theme="light"] .katex [style*="rgb(48, 209, 88)"] { color: #1f9d47 !important; }
:root[data-theme="light"] .katex [style*="rgb(255, 159, 10)"] { color: #c06d00 !important; }
:root[data-theme="light"] .katex [style*="rgb(255, 69, 58)"] { color: #d1352b !important; }
:root[data-theme="light"] .katex [style*="rgb(191, 90, 242)"] { color: #9442c4 !important; }
:root[data-theme="light"] .katex [style*="rgb(255, 55, 95)"] { color: #d6254c !important; }
:root[data-theme="light"] .katex [style*="rgb(100, 210, 255)"] { color: #138bb8 !important; }
:root[data-theme="light"] .katex [style*="rgb(255, 214, 10)"] { color: #a07900 !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================================
   Materie: sidebar, home, pagina materia
   ========================================================================== */
.nav-subj svg { color: var(--c); }
.nav-sub a.nav-lesson-link { color: var(--ink-2); font-size: 14.5px; }
.nav-sub a.nav-lesson-link.active { color: var(--ink); font-weight: 500; }
.nav-sub a.nav-lesson-link.active::before { background: var(--ink); width: 1.5px; }
.nav-sub a.nav-lesson-link.done::after { content: "✓"; margin-left: auto; color: var(--ok); font-size: 12px; }
.nav-sub2 { display: none; }
.nav-lesson.current .nav-sub2, .nav-lesson.searching .nav-sub2 { display: block; }
.nav-sub .nav-sub2 a { padding-left: 56px; font-size: 13.5px; }
.nav-sub .nav-sub2 a::before { left: 41px; }
.nav-lesson[hidden] { display: none; }
.nav-empty { display: block; padding: 4px 8px 8px 42px; font-size: 13.5px; color: var(--ink-3); }

.home-hero-simple { grid-template-columns: minmax(0, 1fr); padding-bottom: 44px; }
.home-hero-simple .lead { max-width: 620px; }

.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 18px; }
.subject-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center;
  padding: 16px; min-height: 76px;
  border: 1px solid var(--stroke); border-radius: var(--r);
  text-decoration: none; color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.subject-card:hover { background: var(--fill); border-color: var(--stroke-2); }
.subject-card .subject-ic { grid-row: span 2; }
.subject-name { font-weight: 600; font-size: 16.5px; letter-spacing: -0.01em; }
.subject-meta { font-size: 13px; color: var(--ink-3); }
.subject-ic {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; color: var(--c);
  background: var(--fill-2);
  background: color-mix(in srgb, var(--c) 15%, transparent);
}
.subject-ic svg { width: 22px; height: 22px; }
.subject-ic.sm { width: 24px; height: 24px; border-radius: 7px; }
.subject-ic.sm svg { width: 14px; height: 14px; }

.subject-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; align-items: center; padding: 8px 0 44px; border-bottom: 1px solid var(--stroke); }
.subject-hero.with-tray { grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); }
@media (max-width: 900px) { .subject-hero.with-tray { grid-template-columns: 1fr; gap: 32px; } }
.subject-eyebrow { display: flex; align-items: center; gap: 10px; }
.empty-subject { border: 1px dashed var(--stroke-2); border-radius: var(--r-tray); padding: 22px 24px; margin-top: 18px; }
.empty-subject p { margin-bottom: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.recap-section { padding-top: 32px; }

/* ==========================================================================
   Tabella di ripasso (nascondibile)
   ========================================================================== */
.recap { border: 1px solid var(--stroke); border-radius: var(--r-tray); background: var(--tray); margin: 28px 0 4px; }
.recap summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 14px 18px; cursor: pointer; border-radius: var(--r-tray); }
.recap summary::-webkit-details-marker { display: none; }
.recap summary:hover .recap-toggle { background: var(--fill-2); }
.recap-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--fill-2); display: grid; place-items: center; font-family: Georgia, "Times New Roman", serif; font-size: 19px; color: var(--ink); flex: none; }
.recap-head { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.recap-head b { font-weight: 600; color: var(--ink); font-size: 16px; }
.recap-head small { color: var(--ink-3); font-size: 13.5px; }
.recap-toggle { font-size: 13.5px; color: var(--ink-2); padding: 6px 14px; border: 1px solid var(--stroke-2); border-radius: 999px; flex: none; transition: background 0.15s; }
.recap[open] .when-closed, .recap:not([open]) .when-open { display: none; }
.recap-body { padding: 0 18px 10px; }
.recap .table-wrap { margin: 0; }
.recap-table th[scope="row"] { width: 24%; color: var(--ink); font-weight: 500; font-size: 14.5px; padding-right: 18px; }
.recap-table .recap-f { color: var(--ink); padding-right: 18px; }
.recap-table .recap-f .katex { font-size: 1.04em; }
.recap-table .recap-n { color: var(--ink-3); font-size: 14px; width: 30%; }
.recap-group th { padding-top: 20px; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.recap-table tr:last-child th, .recap-table tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) {
  .recap summary { padding: 12px 14px; gap: 10px; }
  .recap-head small { display: none; }
  .recap-body { padding: 0 14px 8px; }
  .recap-table, .recap-table tbody, .recap-table tr, .recap-table th, .recap-table td { display: block; width: auto !important; }
  .recap-table tr { padding: 10px 0; border-bottom: 1px solid var(--stroke); }
  .recap-table th, .recap-table td { border: 0; padding: 2px 0; }
  .recap-table .recap-f { overflow-x: auto; padding: 4px 0; }
}

/* ==========================================================================
   Argomenti (sotto-categorie di una materia)
   ========================================================================== */
.nav-unit { padding: 2px 0 4px; }
.nav-unit[hidden] { display: none; }
.nav-sub a.nav-unit-link {
  padding: 8px 8px 3px 30px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3);
}
.nav-sub a.nav-unit-link::before { display: none; }
.nav-sub a.nav-unit-link:hover { color: var(--ink); background: none; }

.unit-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding-top: 32px; }
.unit-index a {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: baseline;
  padding: 14px 16px; border: 1px solid var(--stroke); border-radius: var(--r);
  text-decoration: none; color: var(--ink);
}
.unit-index a:hover { background: var(--fill); border-color: var(--stroke-2); }
.unit-index span { grid-row: span 2; font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--c); font-variant-numeric: tabular-nums; }
.unit-index b { font-weight: 600; font-size: 15.5px; }
.unit-index small { font-size: 13px; color: var(--ink-3); }

.unit-section { scroll-margin-top: 70px; }
.unit-section + .unit-section { margin-top: 24px; border-top: 1px solid var(--stroke); }
.unit-head { display: flex; gap: 16px; align-items: baseline; }
.unit-head h2 { margin-bottom: 4px; }
.unit-head p { margin: 0; }
.unit-num { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--c); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.unit-section .recap { margin: 22px 0 18px; }
@media (max-width: 640px) { .crumbs .crumb-unit, .crumbs .crumb-unit + .sep { display: none; } }

/* ==========================================================================
   Accesso e profilo
   ========================================================================== */
html.auth-wait body > *:not(.auth-gate):not(.lang-gate):not(.toast):not(.nb-modal-back) { display: none !important; }
.auth-gate {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--app);
}
.auth-card {
  width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  padding: 32px 28px 26px;
  background: var(--sheet); border: 1px solid var(--stroke); border-radius: var(--r-tray);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.auth-mark { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--stroke-2); display: grid; place-items: center; color: var(--ink); }
.auth-mark svg { width: 24px; height: 24px; }
.auth-card h1 { font-size: 32px; margin-top: 4px; }
.auth-lead { margin: -6px 0 6px; font-size: 15.5px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.auth-field .nb-input { height: 48px; font-size: 16px; }
.auth-pw { position: relative; display: block; }
.auth-pw .nb-input { padding-right: 50px; }
.auth-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3);
  display: grid; place-items: center; cursor: pointer;
}
.auth-eye:hover { color: var(--ink); background: var(--fill-2); }
.auth-eye svg { width: 20px; height: 20px; }
.auth-err { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--ko-fill); color: var(--ko); font-size: 14.5px; }
.auth-err[hidden] { display: none; }
.auth-submit { height: 48px; font-size: 16px; margin-top: 4px; }
.auth-foot { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); text-align: center; }

/* lingua: richiesta iniziale (a tutto schermo) e scelta dal profilo (sopra il sito) */
.auth-card { position: relative; }
.auth-lang {
  position: absolute; top: 16px; right: 16px;
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--stroke); border-radius: 999px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.auth-lang:hover { color: var(--ink); background: var(--fill-2); }
.auth-lang svg { width: 16px; height: 16px; }
.lang-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; overflow: auto;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.42);
}
.lang-gate.lang-first { background: var(--app); }
.lang-card {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  padding: 32px 28px 26px;
  background: var(--sheet); border: 1px solid var(--stroke); border-radius: var(--r-tray);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.lang-card h1 { font-size: 28px; margin-top: 4px; }
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 60px; padding: 10px 14px; text-align: left;
  border: 1px solid var(--stroke); border-radius: 12px; background: var(--sheet); color: var(--ink);
  font: inherit; cursor: pointer;
}
.lang-opt b { font-size: 16px; font-weight: 600; }
.lang-opt small { font-size: 12.5px; color: var(--ink-3); }
.lang-opt:hover { background: var(--fill-2); }
.lang-opt.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.lang-cancel { align-self: flex-end; }
@media (max-width: 360px) { .lang-list { grid-template-columns: 1fr; } }

.profile-btn {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 38px; padding: 0 10px 0 4px; border-radius: 999px;
  border: 1px solid var(--stroke-2); background: transparent; color: var(--ink); cursor: pointer;
  font-size: 14px; font-weight: 500; max-width: 220px;
}
.profile-btn:hover, .profile-btn[aria-expanded="true"] { background: var(--fill); }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--solid); color: var(--on-solid); font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em;
}
.profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* il proprio colore (js/live.js, colorOf), con le iniziali scure sui colori chiari come in css/live.css */
.profile-avatar[style*="--pv"] { background: var(--pv); color: #fff; }
@supports (color: oklch(from red l c h)) {
  .profile-avatar[style*="--pv"] { color: oklch(from var(--pv) clamp(0.2, (0.72 - l) * 1000, 1) 0 0); }
}
@media (max-width: 640px) {
  .profile-name, .profile-btn .ink-caret { display: none; }
  .profile-btn { padding: 0 3px; border: 0; }
}
/* stato della sincronizzazione sull'avatar */
.profile-btn { position: relative; }
.profile-btn[data-sync="pending"] .profile-avatar::after,
.profile-btn[data-sync="busy"] .profile-avatar::after,
.profile-btn[data-sync="offline"] .profile-avatar::after,
.profile-btn[data-sync="error"] .profile-avatar::after {
  content: ""; position: absolute; left: 25px; top: 3px; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--sheet); background: var(--hint);
}
.profile-btn[data-sync="error"] .profile-avatar::after { background: var(--ko); }
/* «Modifiche in attesa»: le voci della coda di sincronizzazione */
.sync-pending { width: min(560px, 100%); }
.sync-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: min(52vh, 420px); overflow-y: auto; border-top: 1px solid var(--stroke); }
.sync-item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--stroke); }
.sync-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sync-item-txt b { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-item-txt small { font-size: 12.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.sync-item.is-err small { color: var(--ko); }
.sync-item-acts { display: flex; gap: 6px; flex: none; }
.sync-empty { padding: 14px 2px; color: var(--ink-2); font-size: 14.5px; }
@media (max-width: 420px) {
  .sync-item { flex-wrap: wrap; }
  .sync-item-acts { width: 100%; justify-content: flex-end; }
}
.profile-btn[data-sync="offline"] .profile-avatar::after { background: var(--ink-3); }

/* ==========================================================================
   Movimento: comparse e risposte al tocco (leggere, mai d'intralcio)
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.view.active { animation: viewRise 0.2s var(--ease) both; }
@keyframes viewRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* cambio di sezione con le View Transitions (app.js): la pagina nuova compare sopra la
   vecchia scendendo di pochi pixel, la barra in alto resta ferma e cambia solo il titolo.
   Senza supporto resta viewRise qui sopra. Con il supporto viewRise non c'è mai (html.vt, app.js):
   prima ripartiva appena finita la transizione, quando si toglieva vt-nav, e la pagina
   sembrava caricarsi due volte. */
html.vt-nav .view.active, html.vt .view.active { animation: none; }
.topbar { view-transition-name: topbar; }
/* la vecchia pagina sparisce prima che arrivi la nuova: niente testi sovrapposti. È l'unico
   movimento del cambio di pagina: le entrate delle sezioni (rise…) si chiudono subito (settle, app.js) */
::view-transition-old(root) { animation: vtOut 0.1s ease-out both; mix-blend-mode: normal; }
::view-transition-new(root) { animation: vtIn 0.16s 0.06s ease-out both; mix-blend-mode: normal; }
@keyframes vtOut { to { opacity: 0; } }
@keyframes vtIn { from { opacity: 0; } }
::view-transition-group(topbar) { animation-duration: 0.18s; }
/* il menu laterale non fa parte della transizione: prima ricompariva (saliva e si dissolveva)
   insieme alla pagina a ogni voce toccata */
.sidebar { view-transition-name: sidebar; }
::view-transition-group(sidebar), ::view-transition-new(sidebar) { animation: none; }
::view-transition-old(sidebar) { display: none; }
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* bottoni: piccola pressione e passaggi morbidi */
.btn { transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.18s var(--ease), box-shadow 0.18s, opacity 0.15s; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); }
.btn-icon, .nb-icon-btn, .menu-btn, .seg button { transition: background 0.15s, color 0.15s, transform 0.18s var(--ease); }
.btn-icon:active, .nb-icon-btn:active, .menu-btn:active, .seg button:active { transform: scale(0.9); }
.btn-icon.play svg { transition: transform 0.2s var(--ease); }
.btn-icon.play:active svg { transform: scale(0.85); }
.nav-item, .nav-sub a { transition: background 0.15s, color 0.15s, transform 0.18s var(--ease); }
.nav-item:active, .nav-sub a:active { transform: scale(0.98); }
.nav-item .nav-ic svg { transition: transform 0.25s var(--ease); }
.nav-item:hover .nav-ic svg { transform: translateY(-1px); }

/* comparsa a cascata di schede e sezioni */
.subject-card, .chapter, .home-section, .unit-head, .recap-section, .practice-cta { animation: rise 0.42s var(--ease) both; }
.subjects > :nth-child(2), .chapters > :nth-child(2) { animation-delay: 35ms; }
.subjects > :nth-child(3), .chapters > :nth-child(3) { animation-delay: 70ms; }
.subjects > :nth-child(4), .chapters > :nth-child(4) { animation-delay: 105ms; }
.subjects > :nth-child(5), .chapters > :nth-child(5) { animation-delay: 140ms; }
.subjects > :nth-child(6), .chapters > :nth-child(6) { animation-delay: 175ms; }
.subjects > :nth-child(7), .chapters > :nth-child(7) { animation-delay: 210ms; }
.subjects > :nth-child(n+8), .chapters > :nth-child(n+8) { animation-delay: 245ms; }
.subject-card { transition: background 0.15s, border-color 0.15s, transform 0.22s var(--ease), box-shadow 0.22s; }
.subject-card:active { transform: scale(0.98); }
@media (hover: hover) {
  .subject-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14); }
}
.chapter { transition: background 0.15s; }
.chapter .ch-num { transition: color 0.2s, transform 0.3s var(--ease); }
.chapter:hover .ch-num { transform: translateX(3px); }

/* lezioni: i blocchi compaiono mentre scorri (classe aggiunta da app.js) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease-out, transform 0.6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* finestre, menu e toast con un filo di elasticità */
.toast { transition: opacity 0.25s, transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1); }
.toast.show { transform: translate(-50%, 0) scale(1); }
.scrim { transition: opacity 0.3s; }

/* installazione come app */
.install-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--stroke-2); border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; text-align: left; transition: background 0.15s, transform 0.18s var(--ease); animation: rise 0.4s var(--ease) both; }
.install-row:hover { background: var(--fill); }
.install-row:active { transform: scale(0.98); }
.install-row[hidden] { display: none; }
.install-row svg { width: 18px; height: 18px; flex: none; }
.install-row small { display: block; font-size: 12px; color: var(--ink-3); }
.install-steps { margin: 0; padding: 0; list-style: none; counter-reset: st; display: grid; gap: 12px; }
.install-steps li { counter-increment: st; display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--ink-2); }
.install-steps li::before { content: counter(st); width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--fill-2); color: var(--ink); font-size: 13px; font-weight: 600; }
.install-steps svg { width: 17px; height: 17px; vertical-align: -3px; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ==========================================================================
   App sulla Home di iPhone/iPad: la barra di stato (ora, batteria) sta sopra
   la pagina. Tutto ciò che è in alto scende della sua altezza e una striscia
   del colore del foglio la copre mentre si scorre.
   ========================================================================== */
:root {
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  /* iPhone di lato: la tacca sta a sinistra o a destra */
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
body::before {
  content: ""; position: fixed; left: 0; right: 0; top: 0; height: var(--sat); z-index: 70;
  background: var(--app); pointer-events: none;
}
.sidebar { padding-top: var(--sat); padding-bottom: var(--sab); padding-left: var(--sal); width: calc(var(--sidebar-w) + var(--sal)); }
.main { padding-top: calc(8px + var(--sat)); margin-left: calc(var(--sidebar-w) + var(--sal)); padding-right: calc(8px + var(--sar)); }
.sheet { min-height: calc(100vh - 16px - var(--sat)); }
.topbar { top: calc(8px + var(--sat)); }
.block, .unit-section { scroll-margin-top: calc(70px + var(--sat)); }
.tools { top: calc(76px + var(--sat)); }
.cal .cal-day { top: calc(80px + var(--sat)); }
.toast { bottom: calc(24px + var(--sab)); }
@media (max-width: 980px) {
  body::before { background: var(--sheet); }
  .main { padding-top: var(--sat); margin-left: 0; padding-right: 0; }
  .sheet { min-height: calc(100vh - var(--sat)); padding-left: var(--sal); padding-right: var(--sar); }
  .topbar { top: var(--sat); }
  /* quel che sporge di lato resta dentro lo schermo (clip, a differenza di hidden, non
     blocca la barra in alto che resta attaccata mentre si scorre) */
  @supports (overflow: clip) { .main { overflow-x: clip; } }
}
/* tastiera e pulsanti più piccoli di 16 px: iPhone ingrandiva la pagina toccando la ricerca */
@media (max-width: 980px) { .search input { font-size: 16px; } }

/* cambio password */
.auth-pw-form { display: grid; gap: 12px; }
.auth-pw-form h3 { margin: 0 0 2px; }
.auth-pass { position: relative; display: block; }
.auth-pass .nb-input { padding-right: 48px; }
.auth-pass .auth-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.auth-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: -4px; }
.auth-meter i { height: 4px; border-radius: 4px; background: var(--fill-3); transition: background 0.2s; }
.auth-meter[data-s="1"] i:nth-child(-n+1) { background: var(--ko); }
.auth-meter[data-s="2"] i:nth-child(-n+2) { background: #ff9f0a; }
.auth-meter[data-s="3"] i:nth-child(-n+3) { background: #30d158; }
.auth-meter[data-s="4"] i { background: var(--ok); }
.auth-hint { margin: -4px 0 0; }
.auth-others { font-size: 14px; }

/* telefono: le funzioni della barra in alto in un menu «⋯» */
.top-more { display: none; place-items: center; width: 38px; height: 38px; flex: none; padding: 0; border: 0; border-radius: 12px; background: var(--fill-2); color: var(--ink-2); cursor: pointer; }
.top-more svg { width: 20px; height: 20px; }
.top-more[aria-expanded="true"] { background: var(--fill-3); color: var(--ink); }
@media (max-width: 600px) {
  .top-more { display: grid; }
  .topbar #calc-btn, .topbar #ask-btn, .topbar #theme-seg { display: none; }
}

/* barra in alto: Calcola, Chiedi, tema e profilo tutti alti 36 px, a 8 px l'uno dall'altro */
.topbar .ask-btn { height: 36px; margin: 0; padding: 0 14px 0 11px; font-size: 14px; }
.topbar .ask-btn + .ask-btn, .topbar .ask-btn + .seg, .topbar .seg + .profile-btn, .topbar .ask-btn + .profile-btn { margin-left: -4px; }
.topbar #theme-seg { height: 36px; align-items: stretch; }
.topbar #theme-seg button { display: inline-flex; align-items: center; padding: 0 14px; font-size: 14px; font-weight: 600; }
.topbar .profile-btn { height: 36px; padding: 0 10px 0 3px; }
.topbar .profile-avatar { width: 28px; height: 28px; font-size: 12px; }

/* riquadri della home aggiornati ogni minuto: animazioni d'entrata solo la prima volta */
.home-quiet, .home-quiet * { animation: none !important; }

/* palestra: argomenti per materia e argomento */
.filter-group:has(.pr-topics) { align-items: start; }
.pr-topics { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pr-subj { width: 100%; border: 1px solid var(--stroke); border-radius: var(--r); padding: 10px 12px; box-shadow: inset 3px 0 0 var(--c); }
.pr-subj-b { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 2px 0; font: inherit; font-size: 15px; font-weight: 650; color: var(--ink); cursor: pointer; }
.pr-subj-b small { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.pr-subj-b.active small { color: var(--ink); }
.pr-subj-b.active small::before { content: "✓ "; }
.pr-subj-ic { display: inline-grid; place-items: center; width: 22px; height: 22px; color: var(--c); }
.pr-subj-ic svg { width: 18px; height: 18px; }
.pr-units { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pr-unit { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 10px; align-items: center; }
.pr-unit-b { justify-self: start; border: 0; background: none; padding: 4px 0; font: inherit; font-size: 13.5px; color: var(--ink-2); cursor: pointer; text-align: left; }
.pr-unit-b:hover { color: var(--ink); }
.pr-unit-b.active { color: var(--ink); font-weight: 600; }
.pr-unit-b.active::before { content: "✓ "; }
@media (max-width: 640px) { .pr-unit { grid-template-columns: 1fr; gap: 4px; } }

/* --- menu laterale: categorie --- */
.nav-cat-head {
  width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left;
  font-size: 13.5px; font-weight: 500; color: var(--ink-3);
  justify-content: space-between; border-radius: var(--r-sm);
}
.nav-cat-head:hover { color: var(--ink); }
.nav-cat-head .chev { transform: rotate(90deg); }
.nav-cat.closed .nav-cat-head .chev { transform: none; }
.nav-cat-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.3s var(--ease); }
.nav-cat-body > div { overflow: hidden; min-height: 0; }
.nav-cat.closed:not(.searching) .nav-cat-body { grid-template-rows: 0fr; }
.nav-cat[hidden] { display: none; }

/* --- impostazioni --- */
.foot-settings { width: 100%; border: 0; background: none; font-family: inherit; cursor: pointer; text-align: left; border-radius: var(--r-sm); }
.foot-settings:hover { background: var(--fill); }
.dnd-moon { display: none; width: 16px; height: 16px; color: var(--ink-2); }
.dnd-moon svg { width: 16px; height: 16px; }
html.dnd .dnd-moon { display: inline-grid; place-items: center; }
.set-modal { width: min(520px, 100%); }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.set-head h3 { margin: 0; }
.set-sec { padding: 14px 0 6px; border-top: 1px solid var(--stroke); margin-top: 12px; }
.set-sec h4 { margin: 0 0 4px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-note { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-3); line-height: 1.4; }
.set-row { display: flex; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--stroke); }
.set-row:last-child { border-bottom: 0; }
.set-row > span:first-child { flex: 1; min-width: 0; display: grid; gap: 1px; }
.set-row b { font-weight: 500; font-size: 15px; }
.set-row small { font-size: 12.5px; color: var(--ink-3); }
.set-pill { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--fill-2); color: var(--ink-3); }
.set-pill.on { background: var(--solid); color: var(--on-solid); }
.set-chips { margin: 8px 0 6px; }
.set-sched[hidden] { display: none; }
.set-times { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.set-times label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.set-times input { width: auto; }
@media (max-width: 480px) { .set-row:has(.toggle + .toggle) { flex-wrap: wrap; gap: 8px 14px; } .set-row:has(.toggle + .toggle) > span:first-child { flex-basis: 100%; } }

/* --- pagine private: solo numeri e grafici nella nebbia (css/glass.css, .privacy-fog) --- */

.set-diag { max-height: 220px; overflow: auto; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--fill); font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }

/* ==========================================================================
   Barra in alto che si adatta allo spazio che ha davvero (non allo schermo):
   con il menu laterale aperto su un portatile, su un iPad di lato o in una finestra
   stretta i pulsanti perdono prima le scritte e poi finiscono nel menu «⋯»,
   così il titolo della pagina resta leggibile e niente esce dalla barra.
   ========================================================================== */
.topbar { container: topbar / inline-size; }
.crumbs { min-width: 0; }
.crumbs b { min-width: 3ch; }
@container topbar (max-width: 940px) {
  .topbar .ask-btn span, .topbar .top-search span, .topbar .top-search kbd { display: none; }
  .topbar .ask-btn { padding: 0 10px; margin-right: 6px; }
  .topbar .top-search { padding: 0 10px; }
  .topbar .profile-name, .topbar .profile-btn .ink-caret { display: none; }
  .topbar .profile-btn { padding: 0 3px; border: 0; }
  .topbar .read-meter { width: 40px; }
}
@container topbar (max-width: 640px) {
  .topbar #calc-btn, .topbar #ask-btn, .topbar #theme-seg { display: none; }
  .topbar .top-more { display: grid; }
}
@container topbar (max-width: 420px) {
  .topbar .read-meter { display: none; }
  .crumbs .crumb-unit, .crumbs .crumb-unit + .sep { display: none; }
}

/* piede del menu laterale: la riga «offline» come le altre (prima prendeva il corpo del testo) */
.sidebar-foot .off-row { font-size: 14.5px; line-height: 1.3; }
.sidebar-foot #progress-text { line-height: 1.3; }

/* titoli sugli schermi bassi (telefono di lato, finestre basse): non riempiono mezza pagina */
@media (max-height: 500px) {
  h1 { font-size: clamp(28px, 6svh + 8px, 40px); }
  .content { padding-top: 24px; }
}
/* finestre lunghe e larghe: il testo non cresce oltre la misura di lettura */
@media (min-width: 2200px) { .content.wide { max-width: 1320px; } }

/* palestra sul telefono stretto: i quattro numeri stanno tutti (prima «Precisione» era tagliata)
   e le schede degli strumenti non escono dal riquadro */
@media (max-width: 420px) {
  .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-width: 0; border-right: 0; }
  .stat:nth-child(odd) { border-right: 1px solid var(--stroke); }
  .stat:nth-child(n+3) { border-top: 1px solid var(--stroke); }
  .tools-tabs .seg button { min-width: 0; padding-left: 6px; padding-right: 6px; font-size: 13.5px; }
  .tools-tabs button svg { display: none; }
}
