/* =========================================================================
   VPI — Preparazione Scienze Biologiche (Urbino)
   Design system unificato · light/dark · mobile first
   ========================================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }

/* ---------- Tokens ---------- */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
             Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg:          #f7f8fa;
  --surface:     #ffffff;
  --surface-2:   #f1f3f7;
  --surface-3:   #e8ebf1;
  --fig-plate:   #ffffff;

  --ink:         #14171d;
  --ink-soft:    #525c6b;
  --ink-faint:   #7d8798;

  --line:        #e2e6ec;
  --line-strong: #ccd3dd;

  --accent:      #3d5ccc;
  --accent-ink:  #2c46a8;
  --accent-soft: #eaeefb;

  --ok:          #10794f;
  --ok-soft:     #e6f4ec;
  --ko:          #b3261e;
  --ko-soft:     #fceceb;
  --warn:        #9a5709;
  --warn-soft:   #fbf1e3;

  --radius:   14px;
  --radius-s: 9px;
  --shadow:   0 1px 2px rgba(20, 23, 29, .05), 0 6px 20px -8px rgba(20, 23, 29, .12);
  --shadow-lg:0 2px 4px rgba(20, 23, 29, .05), 0 18px 40px -16px rgba(20, 23, 29, .22);

  --maxw: 780px;
  --bar-h: 56px;
}

/* Accento per materia */
[data-subject="matematica"] { --accent:#4a53c8; --accent-ink:#3a41ab; --accent-soft:#ecedfb; }
[data-subject="biologia"]   { --accent:#1f7a52; --accent-ink:#186340; --accent-soft:#e6f4ed; }
[data-subject="chimica"]    { --accent:#0d7d7c; --accent-ink:#0a6362; --accent-soft:#e4f3f2; }
[data-subject="fisica"]     { --accent:#1f5f97; --accent-ink:#194d7b; --accent-soft:#e7f0f9; }
[data-subject="esame"]      { --accent:#8a4bbd; --accent-ink:#6f3a99; --accent-soft:#f3eafb; }

/* ---------- Dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #10131a;
    --surface:     #171b24;
    --surface-2:   #1e2330;
    --surface-3:   #262c3b;
    --fig-plate:   #e9edf3;

    --ink:         #e8ebf1;
    --ink-soft:    #a4aebd;
    --ink-faint:   #7c8697;

    --line:        #262c38;
    --line-strong: #39414f;

    --accent:      #8aa0ff;
    --accent-ink:  #a9baff;
    --accent-soft: #1c2340;

    --ok:          #4fc78d;
    --ok-soft:     #12291f;
    --ko:          #ff8a80;
    --ko-soft:     #2c1614;
    --warn:        #e0a552;
    --warn-soft:   #2a2013;

    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px -8px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 18px 40px -16px rgba(0,0,0,.7);
  }
  :root:not([data-theme="light"]) [data-subject="matematica"] { --accent:#8f97ff; --accent-ink:#adb3ff; --accent-soft:#1d2044; }
  :root:not([data-theme="light"]) [data-subject="biologia"]   { --accent:#57c793; --accent-ink:#7ad6ac; --accent-soft:#123024; }
  :root:not([data-theme="light"]) [data-subject="chimica"]    { --accent:#3fc2bf; --accent-ink:#69d3d1; --accent-soft:#0f2e2e; }
  :root:not([data-theme="light"]) [data-subject="fisica"]     { --accent:#6aaef0; --accent-ink:#8fc3f5; --accent-soft:#122539; }
  :root:not([data-theme="light"]) [data-subject="esame"]      { --accent:#c08cea; --accent-ink:#d1abf1; --accent-soft:#251938; }
}

:root[data-theme="dark"] {
  --bg:          #10131a;
  --surface:     #171b24;
  --surface-2:   #1e2330;
  --surface-3:   #262c3b;
  --fig-plate:   #e9edf3;

  --ink:         #e8ebf1;
  --ink-soft:    #a4aebd;
  --ink-faint:   #7c8697;

  --line:        #262c38;
  --line-strong: #39414f;

  --accent:      #8aa0ff;
  --accent-ink:  #a9baff;
  --accent-soft: #1c2340;

  --ok:          #4fc78d;
  --ok-soft:     #12291f;
  --ko:          #ff8a80;
  --ko-soft:     #2c1614;
  --warn:        #e0a552;
  --warn-soft:   #2a2013;

  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 18px 40px -16px rgba(0,0,0,.7);
}
:root[data-theme="dark"] [data-subject="matematica"] { --accent:#8f97ff; --accent-ink:#adb3ff; --accent-soft:#1d2044; }
:root[data-theme="dark"] [data-subject="biologia"]   { --accent:#57c793; --accent-ink:#7ad6ac; --accent-soft:#123024; }
:root[data-theme="dark"] [data-subject="chimica"]    { --accent:#3fc2bf; --accent-ink:#69d3d1; --accent-soft:#0f2e2e; }
:root[data-theme="dark"] [data-subject="fisica"]     { --accent:#6aaef0; --accent-ink:#8fc3f5; --accent-soft:#122539; }
:root[data-theme="dark"] [data-subject="esame"]      { --accent:#c08cea; --accent-ink:#d1abf1; --accent-soft:#251938; }

/* ---------- Base ---------- */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
p { margin: 0 0 .85em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 650; }
code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface-2); padding: .1em .38em;
  border-radius: 5px; border: 1px solid var(--line);
}
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(14px, 4vw, 28px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .home {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .9rem; font-weight: 600; color: var(--ink-soft);
  white-space: nowrap;
}
.topbar .home:hover { color: var(--accent-ink); text-decoration: none; }
.topbar .sep { color: var(--ink-faint); }
.topbar .where {
  font-size: .9rem; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun  { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .sun  { display: none; }
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 28px clamp(14px, 4vw, 28px) 96px; }
.wrap-wide { max-width: 1060px; }

/* ---------- Intestazione documento ---------- */
.doc-head { margin: 8px 0 26px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .74rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 5px 11px; border-radius: 999px; margin-bottom: 14px;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
h1 {
  font-size: clamp(1.7rem, 5vw, 2.3rem); line-height: 1.15;
  letter-spacing: -.022em; font-weight: 750; margin: 0 0 10px;
}
.doc-sub { color: var(--ink-soft); font-size: 1.02rem; margin: 0 0 14px; }
.doc-meta {
  display: flex; flex-wrap: wrap; gap: 7px;
  font-size: .82rem; color: var(--ink-soft); margin: 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.chip b { color: var(--ink); font-weight: 650; }

/* ---------- Indice ---------- */
.toc {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 6px 4px; margin: 26px 0 34px;
}
.toc > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; font-weight: 650; font-size: .95rem;
}
.toc > summary::-webkit-details-marker { display: none; }
.toc > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--ink-faint); border-bottom: 2px solid var(--ink-faint);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .2s;
}
.toc[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.toc ol { list-style: none; margin: 0; padding: 0 8px 10px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc li a {
  display: flex; align-items: baseline; gap: 12px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--ink); font-size: .94rem;
}
.toc li a::before {
  content: counter(toc); flex: none; min-width: 1.5em;
  font-size: .8rem; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.toc li a:hover { background: var(--surface-2); text-decoration: none; }
.toc li.extra a::before { content: "\203A"; font-size: 1rem; line-height: 1; }

/* ---------- Sezioni ---------- */
.mod { margin: 0 0 8px; padding: 34px 0 6px; border-top: 1px solid var(--line); }
.mod:first-of-type { border-top: 0; padding-top: 8px; }

h2 {
  font-size: clamp(1.24rem, 3.6vw, 1.5rem); line-height: 1.25;
  letter-spacing: -.015em; font-weight: 700;
  margin: 0 0 16px; display: flex; align-items: center; gap: 12px;
}
h2 .num {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 2rem; padding: 0 .45rem;
  font-size: .88rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: #fff; background: var(--accent); border-radius: 9px;
}
:root[data-theme="dark"] h2 .num,
:root:not([data-theme="light"]) h2 .num { color: var(--bg); }
h3 {
  font-size: 1.02rem; font-weight: 700; letter-spacing: -.005em;
  margin: 28px 0 8px; color: var(--ink);
}
h4 {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--accent-ink); margin: 20px 0 6px;
}
.lead { color: var(--ink-soft); }

ul, ol { margin: 0 0 .9em; padding-left: 1.3em; }
li { margin: 5px 0; }
li > ul, li > ol { margin-bottom: .2em; }

/* ---------- Callout ---------- */
.callout {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 14px 18px; margin: 16px 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout .tag {
  display: block; font-size: .7rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 7px;
}
.callout.def { background: var(--accent-soft); border-left-color: var(--accent); border-color: transparent; }
.callout.formula { background: var(--accent-soft); border-color: transparent; }
.callout.formula .row { margin: 7px 0; }
.callout.formula .where { font-size: .87rem; color: var(--ink-soft); margin-top: 9px; line-height: 1.55; }
.callout.example { background: var(--surface); box-shadow: var(--shadow); border-left-color: var(--accent); }
.callout.example .step { margin: 5px 0; }
.callout.example .res {
  margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line-strong); font-weight: 600;
}
.callout.warn { background: var(--warn-soft); border-left-color: var(--warn); border-color: transparent; }
.callout.warn .tag { color: var(--warn); }
.callout.warn ul { margin-bottom: 0; }
.callout.warn li { font-size: .96rem; }

.flag {
  font-size: .88rem; color: var(--ink-soft); font-style: italic;
  border-left: 2px solid var(--line-strong); padding-left: 13px; margin: 16px 0;
}
.note { font-size: .9rem; color: var(--ink-soft); }

/* ---------- Formulario ---------- */
.formulario {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 4px 20px; margin: 16px 0;
}
.frow { padding: 11px 0; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.frow .name {
  display: block; font-size: .76rem; font-weight: 650;
  letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 4px;
}
.frow .expr { font-size: 1.02rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 34px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Tabelle ---------- */
.tw { overflow-x: auto; margin: 16px 0; -webkit-overflow-scrolling: touch; border-radius: var(--radius-s); }
.tw table { margin: 0; }
table {
  width: 100%; border-collapse: collapse; font-size: .93rem;
  background: var(--surface); margin: 16px 0;
}
th, td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 650; font-size: .85rem; }
table.center th, table.center td { text-align: center; }
table.center td.lbl, table.center th.lbl { text-align: left; font-weight: 650; }

/* ---------- Figure ---------- */
figure { margin: 22px 0; text-align: center; }
figure .plate {
  background: var(--fig-plate); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 10px; overflow-x: auto;
}
figure svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figcaption { font-size: .82rem; color: var(--ink-soft); margin-top: 9px; line-height: 1.5; }

/* ---------- KaTeX ---------- */
.katex { font-size: 1.03em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; margin: 1em 0; }

/* =========================================================================
   QUIZ
   ========================================================================= */
.quiz-head {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin: 20px 0 24px;
}
.quiz-head .title { font-weight: 700; font-size: 1.02rem; margin: 0 0 4px; }
.quiz-head .desc { font-size: .89rem; color: var(--ink-soft); margin: 0 0 14px; }
.quiz-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.segmented {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px;
}
.segmented button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 14px; border-radius: 7px;
  font-size: .84rem; font-weight: 600; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 17px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: .88rem; font-weight: 600;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #10131a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #10131a; } }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.quiz-progress {
  margin-left: auto; font-size: .82rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* --- singolo quesito --- */
.qcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin: 0 0 14px; scroll-margin-top: 76px;
}
.qcard .qhead {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  font-size: .74rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.qcard .qhead .qsub {
  margin-left: auto; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  letter-spacing: .05em;
}
.qcard .stem { font-weight: 600; margin: 0 0 12px; line-height: 1.5; }
.qcard .stem p { margin: 0; }

.opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 11px; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: .96rem; line-height: 1.45;
  transition: border-color .12s, background .12s;
}
.opt:hover:not([disabled]) { border-color: var(--accent); background: var(--surface-2); }
.opt .lab {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-soft);
  transition: background .12s, color .12s, border-color .12s;
}
.opt .txt { flex: 1; padding-top: 1px; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt[aria-pressed="true"] .lab { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .opt[aria-pressed="true"] .lab { color: #10131a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .opt[aria-pressed="true"] .lab { color: #10131a; }
}
.opt.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-correct .lab { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--ko); background: var(--ko-soft); }
.opt.is-wrong .lab { background: var(--ko); border-color: var(--ko); color: #fff; }
:root[data-theme="dark"] .opt.is-correct .lab,
:root[data-theme="dark"] .opt.is-wrong .lab { color: #10131a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .opt.is-correct .lab,
  :root:not([data-theme="light"]) .opt.is-wrong .lab { color: #10131a; }
}
.opt[disabled] { cursor: default; }

.expl {
  margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-s);
  background: var(--surface-2); border-left: 3px solid var(--ok); font-size: .93rem;
}
.expl .verdict {
  display: block; font-size: .72rem; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; margin-bottom: 5px; color: var(--ok);
}
.expl.miss .verdict { color: var(--ko); }
.expl.miss { border-left-color: var(--ko); }
.expl .body > :last-child { margin-bottom: 0; }
.expl .review { display: block; margin-top: 8px; font-size: .85rem; }

/* --- esito --- */
.result {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 22px; margin: 22px 0 0; scroll-margin-top: 76px;
}
.result .score-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.score-ring { flex: none; width: 92px; height: 92px; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.24rem; font-weight: 750; font-variant-numeric: tabular-nums;
}
.result .headline { font-size: 1.1rem; font-weight: 700; margin: 0 0 4px; }
.result .sub { font-size: .9rem; color: var(--ink-soft); margin: 0; }
.verdict-pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; margin-bottom: 8px;
}
.verdict-pill.pass { background: var(--ok-soft); color: var(--ok); }
.verdict-pill.fail { background: var(--ko-soft); color: var(--ko); }
.result .breakdown { margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
.result .breakdown h4 { margin-top: 0; }
.result .breakdown ul { margin: 0; padding-left: 1.2em; font-size: .92rem; }
.subject-status {
  display: inline-block; margin-left: 5px; padding: 1px 7px;
  border-radius: 999px; font-size: .7rem; font-weight: 700;
}
.subject-status.pass { color: var(--ok); background: var(--ok-soft); }
.subject-status.fail { color: var(--ko); background: var(--ko-soft); }
.result .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* --- barra di avanzamento --- */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s; }

/* =========================================================================
   HOME
   ========================================================================= */
.hero { padding: 40px 0 12px; }
.hero h1 { font-size: clamp(2rem, 6.5vw, 3rem); margin-bottom: 14px; }
.hero .tagline { font-size: clamp(1.02rem, 2.6vw, 1.15rem); color: var(--ink-soft); max-width: 60ch; }

.factstrip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin: 30px 0 40px;
}
.factstrip .f { background: var(--surface); padding: 16px 18px; }
.factstrip .f .k { font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.factstrip .f .v { font-size: .82rem; color: var(--ink-soft); margin-top: 3px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; color: inherit;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: var(--shadow-lg); border-color: var(--accent);
}
.card .kicker {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 14px;
}
.card h3 { font-size: 1.22rem; margin: 0 0 8px; letter-spacing: -.015em; }
.card p { font-size: .92rem; color: var(--ink-soft); margin: 0 0 16px; }
.card .card-foot { margin-top: auto; }
.card .stats {
  display: flex; gap: 14px; font-size: .78rem; color: var(--ink-soft);
  padding-top: 12px; border-top: 1px solid var(--line); margin-bottom: 10px;
}
.card .stats b { color: var(--ink); font-weight: 650; }
.card .prog-label {
  display: flex; justify-content: space-between; font-size: .74rem;
  color: var(--ink-faint); margin-bottom: 5px;
}

.cta {
  display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin: 34px 0 0;
}
.cta h3 { margin: 0 0 6px; font-size: 1.15rem; }
.cta p { margin: 0; font-size: .92rem; color: var(--ink-soft); }
@media (max-width: 560px) { .cta { grid-template-columns: 1fr; } }

.site-foot {
  margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line);
  font-size: .84rem; color: var(--ink-faint);
}
.site-foot p { margin: 0 0 .5em; }

/* --- timer simulazione --- */
.exam-bar {
  position: sticky; top: var(--bar-h); z-index: 40;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; margin: 0 0 22px;
}
.exam-bar .clock {
  font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 700;
  letter-spacing: .01em;
}
.exam-bar .clock.low { color: var(--ko); }
.exam-bar .meta { font-size: .82rem; color: var(--ink-soft); }
.exam-bar select {
  font: inherit; font-size: .85rem; padding: 6px 10px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.exam-bar .spacer { flex: 1; }
.exam-setup {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: end; gap: 24px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin: 20px 0;
}
.exam-setup label {
  display: block; font-size: .78rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 7px;
}
.exam-setup select {
  width: min(100%, 260px); font: inherit; font-size: .92rem;
  padding: 9px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.exam-setup .note { margin: 9px 0 0; max-width: 540px; }

/* ---------- Utility ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.backtop { font-size: .82rem; margin: 26px 0 0; }
.backtop a { color: var(--ink-soft); }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .wrap { padding-top: 20px; }
  .qcard, .quiz-head, .result { padding: 15px; }
  .topbar .where { font-size: .84rem; }
  .quiz-controls { gap: 8px; }
  .quiz-progress { margin-left: 0; width: 100%; }
  .hero { padding: 26px 0 4px; }
  .exam-setup { grid-template-columns: 1fr; align-items: stretch; gap: 16px; }
  .exam-setup select { width: 100%; }
  .exam-setup .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- Stampa ---------- */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #eee;
    --ink: #000; --ink-soft: #333; --ink-faint: #555;
    --line: #bbb; --line-strong: #999; --fig-plate: #fff;
    --accent: #333; --accent-ink: #000; --accent-soft: #f2f2f2;
    --shadow: none; --shadow-lg: none;
  }
  [data-subject] {
    --accent: #333 !important; --accent-ink: #000 !important;
    --accent-soft: #f2f2f2 !important;
  }
  body { font-size: 10.8pt; line-height: 1.45; background: #fff; }
  @page { margin: 16mm; }
  .topbar, .icon-btn, .quiz-controls, .backtop, .result .actions,
  .exam-bar, .no-print { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .toc { break-after: page; box-shadow: none; }
  .toc > summary::after { display: none; }
  .card, .qcard, .callout, .formulario, .quiz-head, .result { box-shadow: none; break-inside: avoid; }
  h2, h3, h4 { break-after: avoid; }
  figure, table, .frow, .expl { break-inside: avoid; }
  .mod { break-inside: auto; }
  a { color: #000; text-decoration: none; }
  .opt { break-inside: avoid; }
  .expl { background: #f6f6f6; }
  /* in stampa il quiz è sempre completo di chiave */
  .print-key { display: block !important; }
}
