/* Font inclusi nel progetto (licenza OFL, vendor/fonts/OFL.txt): funzionano anche offline */
@font-face { font-family: 'Geist'; src: url('../vendor/fonts/geist.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('../vendor/fonts/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }

/* Palette: una sola famiglia di grigi freddi, un solo accento */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #17212b;
  --muted: #5a6573;
  --border: #dde2e8;
  --accent: #245d82;
  --accent-soft: rgb(36 93 130 / 0.09);
  --accent-text: #ffffff;
  --ok: #1e7149;
  --ok-bg: #e4f2ea;
  --ko: #ad3027;
  --ko-bg: #fbe9e7;
  --warn: #8a5a06;
  --warn-bg: #fbf1dc;
  --code-bg: #eef1f4;
  --shadow: 0 1px 2px rgb(20 38 56 / 0.05), 0 10px 28px -16px rgb(20 38 56 / 0.18);
  --ring: 0 0 0 3px rgb(36 93 130 / 0.32);
  --radius: 14px;
  --radius-sm: 8px;
  --nav-w: 248px;
  --top-h: 56px;
  --z-nav: 15; --z-top: 20; --z-sticky: 5; --z-toast: 50;
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f141a; --surface: #161c24; --surface-2: #1d2530; --text: #e3e8ee; --muted: #97a3b1;
    --border: #283240; --accent: #82b4d6; --accent-soft: rgb(130 180 214 / 0.12); --accent-text: #0c1620;
    --ok: #6cc893; --ok-bg: #15291e; --ko: #ef8f86; --ko-bg: #351c1a; --warn: #e9c06a; --warn-bg: #33290f;
    --code-bg: #1d2530; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 30px -18px rgb(0 0 0 / 0.6); --ring: 0 0 0 3px rgb(130 180 214 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f141a; --surface: #161c24; --surface-2: #1d2530; --text: #e3e8ee; --muted: #97a3b1;
  --border: #283240; --accent: #82b4d6; --accent-soft: rgb(130 180 214 / 0.12); --accent-text: #0c1620;
  --ok: #6cc893; --ok-bg: #15291e; --ko: #ef8f86; --ko-bg: #351c1a; --warn: #e9c06a; --warn-bg: #33290f;
  --code-bg: #1d2530; --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 30px -18px rgb(0 0 0 / 0.6); --ring: 0 0 0 3px rgb(130 180 214 / 0.35);
  color-scheme: dark;
}

/* Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15.5px/1.6 var(--font); font-feature-settings: 'ss01';
  -webkit-font-smoothing: antialiased;
}
/* grana leggerissima per togliere la piattezza dello sfondo */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, pre, .mono, kbd { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--code-bg); padding: 0.12em 0.38em; border-radius: 5px; }
pre { background: var(--code-bg); padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); overflow-x: auto; line-height: 1.5; border: 1px solid var(--border); }
pre code { background: none; padding: 0; }
h1, h2, h3 { text-wrap: balance; font-weight: 650; }
h1 { font-size: clamp(1.55rem, 1.2rem + 1.2vw, 2rem); line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 0.9rem; }
h2 { font-size: 1.22rem; letter-spacing: -0.015em; margin: 1.8rem 0 0.7rem; }
h3 { font-size: 1.04rem; letter-spacing: -0.01em; margin: 0 0 0.6rem; }
p { text-wrap: pretty; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.82rem; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }
.table-wrap { overflow-x: auto; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
main:focus-visible { box-shadow: none; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }

/* Accessibilità */
.skip-link { position: absolute; left: 0.75rem; top: -3rem; z-index: var(--z-toast); background: var(--accent); color: var(--accent-text); padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); transition: top 0.2s; }
.skip-link:focus { top: 0.75rem; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: var(--z-top); height: var(--top-h);
  display: flex; align-items: center; gap: 0.6rem; padding: 0 1rem;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 650; letter-spacing: -0.015em; color: var(--text); text-decoration: none; flex: 1; }
.brand small { font-weight: 450; color: var(--muted); letter-spacing: 0; }
.brand-logo { width: 1.75rem; height: 1.75rem; display: block; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 10px;
  width: 40px; height: 40px; font-size: 1.05rem; cursor: pointer; transition: background 0.2s, transform 0.12s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.96); }
#nav {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w); overflow-y: auto; z-index: var(--z-nav);
  background: var(--surface); border-right: 1px solid var(--border); padding: 0.9rem 0.7rem 2rem;
  display: flex; flex-direction: column; gap: 1px;
}
#nav a {
  position: relative; display: flex; align-items: center; gap: 0.65rem; padding: 0.48rem 0.8rem; border-radius: var(--radius-sm); color: var(--text);
  text-decoration: none; font-size: 0.93rem; font-weight: 450; transition: background 0.18s, color 0.18s;
}
#nav a:hover { background: var(--surface-2); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#nav a.active::before { content: ''; position: absolute; left: -0.7rem; top: 0.45rem; bottom: 0.45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-group { margin: 1.1rem 0.8rem 0.3rem; font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
main {
  position: relative; z-index: 1; margin-left: var(--nav-w);
  padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: calc(var(--nav-w) + 1040px); outline: none;
}
#menu-btn { display: none; }
@media (max-width: 900px) {
  #menu-btn { display: inline-block; }
  #nav { transform: translateX(-100%); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: var(--shadow); }
  body.nav-open #nav { transform: none; }
  main { margin-left: 0; padding-top: 1.25rem; }
  .brand small { display: none; }
}

/* Componenti */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card.error { border-color: var(--ko); }
details.card > summary, details > summary { cursor: pointer; font-weight: 550; }
details > summary { padding: 0.25rem 0; }
details[open] > summary { margin-bottom: 0.5rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid .card { margin-bottom: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 0.65rem; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.big { font-size: 2.1rem; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.52rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background 0.18s, border-color 0.18s, transform 0.12s, box-shadow 0.18s;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 0.28rem 0.65rem; font-size: 0.86rem; border-radius: 8px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.5rem 0.65rem; max-width: 100%; transition: border-color 0.18s, box-shadow 0.18s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea { width: 100%; min-height: 9rem; resize: vertical; line-height: 1.55; }
input.cmd { width: 100%; font-family: var(--mono); }
label { display: inline-flex; flex-direction: column; gap: 0.25rem; font-size: 0.88rem; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: flex-start; gap: 0.55rem; color: var(--text); font-size: 0.97rem; font-weight: 400; }
input[type='checkbox'] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; margin-top: 0.2rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; margin-bottom: 1rem; }
.tag {
  display: inline-block; font-size: 0.74rem; font-weight: 500; padding: 0.08rem 0.45rem; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-variant-numeric: tabular-nums;
}
.tag.ok-tag { color: var(--ok); border-color: currentColor; }
.tag.alta { color: var(--ko); } .tag.media { color: var(--warn); } .tag.bassa { color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 0.35rem 0; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar.warn span { background: var(--ko); }
.fonte { font-size: 0.82rem; color: var(--muted); word-break: break-word; border-top: 1px dashed var(--border); padding-top: 0.6rem; margin-top: 1.2rem; }
.notice { background: var(--warn-bg); color: var(--text); border-left: 3px solid var(--warn); padding: 0.65rem 0.85rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0.8rem 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
tr.red td { background: var(--ko-bg); }
.toast {
  position: fixed; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 0.65rem 1.1rem; border-radius: 10px; z-index: var(--z-toast);
  box-shadow: var(--shadow); animation: rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Testo delle lezioni: misura di lettura e ritmo */
.md { line-height: 1.72; }
.md > p, .md > ul, .md > ol, .md > blockquote { max-width: 72ch; }
.md h2 { margin-top: 2.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.md h2:first-child { margin-top: 0.5rem; padding-top: 0; border-top: 0; }
.md h3 { margin-top: 1.4rem; }
.md li + li { margin-top: 0.25rem; }
.md strong { font-weight: 620; }
.md table { margin: 0.9rem 0 1.2rem; font-size: 0.93rem; }
.md tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.md blockquote { margin: 1rem 0; padding: 0.6rem 1rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.md blockquote p { margin: 0.3rem 0; }
.md img { max-width: 100%; }
article.card { padding: clamp(1.1rem, 2.5vw, 2rem) clamp(1.1rem, 3vw, 2.4rem); }
.glossary-box { margin-top: 1.5rem; padding: 0.9rem 1.1rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.glossary-box dl { margin: 0.4rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; font-size: 0.9rem; }
.glossary-box dt { font-weight: 600; font-family: var(--mono); font-size: 0.85rem; }
.glossary-box dd { margin: 0; color: var(--muted); }

/* Quiz */
.quiz-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.7rem; font-variant-numeric: tabular-nums; }
.question { font-size: 1.12rem; line-height: 1.45; font-weight: 600; }
.opts { display: grid; gap: 0.55rem; margin: 0.9rem 0; }
.opt {
  text-align: left; padding: 0.75rem 0.95rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; line-height: 1.45;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt:active:not(:disabled) { transform: scale(0.99); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--ko); background: var(--ko-bg); }
.opt b { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin-right: 0.5rem; border-radius: 6px; background: var(--surface-2); font-size: 0.82rem; font-weight: 600; }
.verdict { font-weight: 600; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); margin: 0.6rem 0; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.ko { background: var(--ko-bg); color: var(--ko); }
.timer { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 1.35rem; font-weight: 600; }
.timer.low { color: var(--ko); }
.qnav { display: flex; flex-wrap: wrap; gap: 5px; }
.qnav button { width: 2.25rem; height: 2.25rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums; transition: background 0.15s; }
.qnav button:hover { background: var(--surface-2); }
.qnav button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.qnav button.current { box-shadow: var(--ring); }
.flashcard { min-height: 12rem; display: flex; flex-direction: column; justify-content: center; cursor: pointer; }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs .btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
svg.chart { width: 100%; height: 140px; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .threshold { stroke: var(--ko); stroke-dasharray: 4 4; }
svg.chart text { fill: var(--muted); font-size: 10px; }

/* Stati: caricamento e pagina vuota */
.skeleton { display: grid; gap: 0.9rem; max-width: 760px; }
.skeleton span { display: block; height: 1.1rem; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.skeleton span:first-child { height: 2rem; width: 45%; }
.skeleton span:last-child { height: 8rem; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { max-width: 34rem; padding: 3rem 0; }

/* Utilità (al posto degli stili scritti nelle viste) */
.field { display: flex; }
.danger { color: var(--ko); }
.strong { font-weight: 600; }
.m0 { margin: 0; } .mt0 { margin-top: 0; } .mt { margin-top: 0.6rem; } .mt-lg { margin-top: 1rem; }
.w-full { width: 100%; } .grow { flex: 1; } .w-8 { width: 8rem; } .w-6 { width: 6rem; }
.minw-12 { min-width: 12rem; } .minw-8 { min-width: 120px; }
.pre-wrap { white-space: pre-wrap; }
.ta-xs { min-height: 3rem; } .ta-sm { min-height: 5rem; } .ta-lg { min-height: 12rem; }
.sticky-bar { position: sticky; top: calc(var(--top-h) + 4px); z-index: var(--z-sticky); }

/* Icone (sprite Phosphor) */
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
#nav .ico { width: 1.15rem; height: 1.15rem; color: var(--muted); transition: color 0.18s, transform 0.2s; }
#nav a:hover .ico { transform: translateX(1px); }
#nav a.active .ico { color: var(--accent); }
.icon-btn { display: inline-grid; place-items: center; }
.icon-btn .ico { width: 1.25rem; height: 1.25rem; }
.theme-light { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .theme-light { display: block; } :root:not([data-theme='light']) .theme-dark { display: none; } }
:root[data-theme='dark'] .theme-light { display: block; }
:root[data-theme='dark'] .theme-dark { display: none; }
.ok-text { color: var(--ok); }

/* Transizione tra le pagine (View Transitions API, dove disponibile) */
main { view-transition-name: page; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: vt-out 0.16s ease-in both; }
::view-transition-new(page) { animation: vt-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* Dashboard: testo a sinistra, mappa dei moduli a destra */
.hero { display: grid; grid-template-columns: minmax(16rem, 0.8fr) 1.6fr; gap: 1.5rem; align-items: center; margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.5rem); }
.hero-text > p { max-width: 38ch; }
.hero-stats { display: flex; gap: 2rem; margin: 1.2rem 0 1.4rem; }
.hero-map { background: radial-gradient(ellipse at 50% 50%, var(--accent-soft), transparent 70%); border-radius: var(--radius); }
@media (max-width: 1100px) { .hero { grid-template-columns: 1fr; } }

.topo { width: 100%; height: auto; display: block; overflow: visible; }
.topo-tall { display: none; }
.topo-link { stroke: var(--border); stroke-width: 2; stroke-dasharray: 100; animation: topo-draw 0.6s calc(var(--i) * 90ms) cubic-bezier(0.3, 0.7, 0.2, 1) both; }
.topo-link.live { stroke: var(--accent); stroke-width: 2.5; animation: topo-draw 0.6s calc(var(--i) * 90ms) both, topo-flow 1.8s calc(var(--i) * 90ms + 0.6s) linear infinite; }
@keyframes topo-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes topo-flow { from { stroke-dasharray: 2 4; stroke-dashoffset: 0; } to { stroke-dasharray: 2 4; stroke-dashoffset: -12; } }
.topo-core rect { fill: var(--accent); filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--accent) 45%, transparent)); }
.topo-core-big { fill: var(--accent-text); font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.topo-core-small { fill: var(--accent-text); opacity: 0.8; font-size: 11px; }
.topo-node { cursor: pointer; transform-box: fill-box; transform-origin: center; animation: topo-pop 0.45s calc(var(--i) * 90ms + 0.35s) cubic-bezier(0.3, 1.4, 0.5, 1) both; outline: none; }
@keyframes topo-pop { from { opacity: 0; transform: scale(0.6); } }
.topo-disc { fill: var(--surface); stroke: var(--border); stroke-width: 1; transition: fill 0.2s; filter: drop-shadow(0 4px 10px rgb(20 38 56 / 0.12)); }
.topo-track { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.topo-arc { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.topo-ico { color: var(--text); transition: color 0.2s; }
.topo-led { stroke: var(--surface); stroke-width: 2; }
.topo-led.ok { fill: var(--ok); } .topo-led.ko { fill: var(--ko); }
.topo-label { fill: var(--muted); font-size: 12px; font-weight: 550; }
.topo-node:hover .topo-disc, .topo-node:focus-visible .topo-disc { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.topo-node:hover .topo-ico, .topo-node:focus-visible .topo-ico { color: var(--accent); }
.topo-node:hover .topo-label { fill: var(--text); }

@media (max-width: 680px) { .hero-stats { gap: 1.25rem; } .topo-wide { display: none; } .topo-tall { display: block; max-width: 420px; margin: 0 auto; } }

.heatmap { width: 100%; max-width: 480px; height: auto; display: block; margin: 0.3rem 0 0.6rem; }
.heatmap text { fill: var(--muted); font-size: 9px; }
.hm { transition: transform 0.15s; transform-box: fill-box; transform-origin: center; }
.hm:hover { transform: scale(1.25); }
.hm.l0 { fill: var(--surface-2); }
.hm.l1 { fill: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.hm.l2 { fill: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.hm.l3 { fill: color-mix(in srgb, var(--accent) 78%, var(--surface-2)); }
.hm.l4 { fill: var(--accent); }

.ring { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.ring svg { width: 28px; height: 28px; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 4; }
.ring-arc { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray 0.6s; }
.mod-table td { vertical-align: middle; }
.mod-link { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--text); text-decoration: none; }
.mod-link:hover span { color: var(--accent); }
.mod-ico { width: 2.1rem; height: 2.1rem; padding: 0.42rem; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }

/* Elenco lezioni per modulo */
.mod-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; }
.mod-head h3 { margin: 0; flex: 1; }
.lesson-list { margin: 0; padding: 0; list-style: none; counter-reset: l; }
.lesson-list li { counter-increment: l; display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0; border-top: 1px solid var(--border); }
.lesson-list li::before { content: counter(l); width: 1.6rem; height: 1.6rem; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-list li.done::before { background: var(--accent); color: var(--accent-text); }
.lesson-list a { flex: 1; text-decoration: none; color: var(--text); font-weight: 500; }
.lesson-list a:hover { color: var(--accent); }
.mod-card { scroll-margin-top: calc(var(--top-h) + 1rem); }
.mod-card.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: var(--ring), var(--shadow); } }

/* Feedback del quiz e flashcard: il movimento risponde a un'azione */
.opt.right { animation: pop 0.35s cubic-bezier(0.3, 1.5, 0.5, 1); }
.opt.wrong { animation: shake 0.4s; }
@keyframes pop { 50% { transform: scale(1.02); } }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.verdict { animation: rise-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } }
.flashcard { perspective: 900px; }
.flashcard.flipped { animation: flip 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes flip { from { transform: rotateX(-70deg); opacity: 0.4; } }

/* Avviso dell'account demo, sotto la barra in alto */
.demo-notice {
  position: relative; z-index: var(--z-sticky); display: flex; gap: 1rem; align-items: center;
  margin-left: var(--nav-w); padding: 0.75rem clamp(1rem, 3vw, 2.5rem); font-size: 0.9rem;
  background: var(--warn-bg); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); animation: rise-in 0.3s;
}
.demo-notice > div { max-width: 90ch; }
.demo-notice .btn { flex: none; }
@media (max-width: 900px) { .demo-notice { margin-left: 0; flex-direction: column; align-items: flex-start; } }

/* Ricerca e sigle */
.search-box { position: relative; margin-bottom: 1.2rem; max-width: 46rem; }
.search-box .ico { position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 1.15rem; height: 1.15rem; }
.search-box input { width: 100%; padding: 0.75rem 1rem 0.75rem 2.6rem; font-size: 1.02rem; border-radius: 12px; }
.search-box input:only-child { padding-left: 1rem; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 0.1em; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 0.35em; background: var(--surface-2); font-size: 0.85em; }
dl.sigle { margin: 0; }
dl.sigle > div { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
dl.sigle > div:last-child { border-bottom: 0; }
dl.sigle > div[hidden] { display: none; }
dl.sigle dt { font-family: var(--mono); font-weight: 600; font-size: 0.9rem; }
dl.sigle dd { margin: 0; }
@media (max-width: 680px) { dl.sigle > div { grid-template-columns: 1fr; gap: 0.1rem; } }

/* Primo avvio e piano di studi */
.wiz-steps { display: flex; gap: 1rem; flex-wrap: wrap; list-style: none; padding: 0; margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; }
.wiz-steps .on { color: var(--accent); font-weight: 600; }
.wiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.wiz-topic { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; text-align: left; cursor: pointer; font: inherit; color: inherit; outline: 2px solid transparent; }
.wiz-topic, .wiz-seg button { transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.18s, border-color 0.18s, outline-color 0.18s; }
.wiz-topic:hover { transform: translateY(-2px); }
.wiz-topic:active, .wiz-seg button:active:not(:disabled) { transform: scale(0.97); }
.wiz-topic.on { outline-color: var(--accent); background: var(--accent-soft); animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
.wiz-check { position: absolute; top: 0.6rem; right: 0.6rem; color: var(--accent); opacity: 0; transform: scale(0.4); transition: opacity 0.18s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1); }
.wiz-topic.on .wiz-check { opacity: 1; transform: none; }
.wiz-row { display: flex; flex-direction: column; gap: 0.6rem; }
.wiz-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.wiz-seg button { display: flex; flex-direction: column; gap: 0.2rem; text-align: left; padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.wiz-seg button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.wiz-seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.wiz-bar { position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem 0; background: var(--bg); border-top: 1px solid var(--border); margin-top: 1rem; }
.wiz-next { border-left: 3px solid var(--accent); }
html[data-dir]::view-transition-old(page) { animation: wiz-out 0.2s ease-in both; }
html[data-dir]::view-transition-new(page) { animation: wiz-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
html[data-dir="indietro"]::view-transition-old(page) { animation-name: wiz-out-r; }
html[data-dir="indietro"]::view-transition-new(page) { animation-name: wiz-in-l; }
@keyframes wiz-out { to { opacity: 0; transform: translateX(-32px); } }
@keyframes wiz-in { from { opacity: 0; transform: translateX(48px); } }
@keyframes wiz-out-r { to { opacity: 0; transform: translateX(32px); } }
@keyframes wiz-in-l { from { opacity: 0; transform: translateX(-48px); } }
@media (max-width: 600px) { .wiz-seg { grid-template-columns: 1fr; } }
.btn.danger-btn { color: var(--ko); border-color: currentColor; }
form.card .field { max-width: 26rem; }
