/* =========================================================================
   Il Circolo delle Quinte — foglio di stile
   Idea guida: ogni tonalità ha un colore, e quel colore accompagna chi legge
   in tutta la pagina. La tinta viva è riservata alla tonalità scelta;
   tutto il resto resta inchiostro su carta.
   ========================================================================= */

/* ---------- 1. Token ---------------------------------------------------- */

:root {
  /* carta fredda, non panna: lascia respirare i 12 colori */
  --paper:    oklch(97.6% 0.006 285);
  --paper-2:  oklch(94.6% 0.011 285);
  --card:     oklch(100% 0 0);
  --ink:      oklch(23% 0.028 285);
  --ink-2:    oklch(47% 0.022 285);
  --ink-3:    oklch(64% 0.016 285);
  --rule:     oklch(89.5% 0.012 285);
  --rule-2:   oklch(83% 0.016 285);

  /* la tonalità corrente: cambia --h e cambia tutta la pagina */
  --h: 25;
  --key:      oklch(57% 0.165 var(--h));
  --key-deep: oklch(40% 0.13 var(--h));
  --key-soft: oklch(92.5% 0.055 var(--h));
  --key-tint: oklch(97% 0.022 var(--h));
  --key-line: oklch(78% 0.11 var(--h));

  --ok:   oklch(58% 0.14 150);
  --no:   oklch(58% 0.17 25);

  --display: 'Alterazioni', 'Bricolage Grotesque', system-ui, sans-serif;
  --body:    'Alterazioni', 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --mono:    'Alterazioni', 'Martian Mono', ui-monospace, 'Cascadia Mono', monospace;
  --music:   'Noto Music', 'Segoe UI Symbol', serif;

  --r:  14px;
  --r-s: 9px;
  --shadow: 0 1px 2px oklch(30% 0.03 285 / .06), 0 8px 24px -12px oklch(30% 0.03 285 / .18);
  --ease: cubic-bezier(.2, .8, .25, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--key-soft); }

:focus-visible {
  outline: 2.5px solid var(--key);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- 2. Tipografia ---------------------------------------------- */

h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -.015em; }

h1 { font-size: clamp(2.4rem, 6vw, 3.9rem); line-height: 1.08; margin: 0 0 .5em; }
h1 .swap {
  color: var(--key-deep);
  font-variation-settings: 'wdth' 79;   /* stretta: e' un asse vero del font */
  font-weight: 700;
  transition: color .5s var(--ease);
}
h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  line-height: 1.12;
  margin: 2.1em 0 .5em;
}
h2:first-child { margin-top: 0; }
h3 {
  font-size: 1.24rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 2.1em 0 .5em;
  font-family: var(--body);
  letter-spacing: -.01em;
}

p { margin: 0 0 1.05em; max-width: 66ch; }
a { color: var(--key-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.eyebrow {
  font-family: var(--mono);
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 .9em;
  display: block;
}

.lead { font-size: 1.16rem; color: var(--ink-2); max-width: 58ch; }

strong { font-weight: 650; color: var(--ink); }
em { font-style: italic; }

/* nome di nota / accordo dentro al testo */
.n {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.06em;
  padding: 0 .12em;
  color: var(--key-deep);
  white-space: nowrap;
}
.n-plain { color: inherit; }

code, .kbd {
  font-family: var(--mono);
  font-size: .82em;
  background: var(--paper-2);
  padding: .15em .42em;
  border-radius: 5px;
}

ul, ol { max-width: 64ch; padding-left: 1.25em; margin: 0 0 1.15em; }
li { margin-bottom: .42em; }
li::marker { color: var(--key); }

/* ---------- 3. Impalcatura ---------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 2rem);
  height: 58px;
  background: oklch(97.6% 0.006 285 / .84);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -.02em;
  text-decoration: none;
  color: var(--ink);
  display: flex; align-items: center; gap: .55rem;
}
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--key);
  box-shadow: 0 0 0 3px var(--key-soft);
  transition: background .5s var(--ease), box-shadow .5s var(--ease);
}

.topbar-spacer { flex: 1; }

.keychip {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: .34rem .7rem;
  border-radius: 100px;
  background: var(--key-soft);
  color: var(--key-deep);
  border: 1px solid var(--key-line);
  transition: background .5s var(--ease), color .5s var(--ease), border-color .5s var(--ease);
}

.layout {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem) 7rem;
}

/* ---------- 4. Sommario laterale ---------------------------------------- */

.rail {
  position: sticky; top: 58px;
  align-self: start;
  max-height: calc(100vh - 58px);
  overflow-y: auto;
  padding: 2.2rem 0 2rem;
}
.rail-title {
  font-family: var(--mono);
  font-size: .6rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 1rem .1rem;
}
.rail-title + .rail-title { margin-top: 2rem; }

.rail nav { display: flex; flex-direction: column; }

.step {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: baseline;
  gap: .55rem;
  padding: .48rem .55rem .48rem .1rem;
  border: 0; background: none;
  font: inherit; font-size: .93rem;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-s);
  position: relative;
  transition: color .18s, background .18s;
}
.step:hover { color: var(--ink); background: var(--paper-2); }
.step-num {
  font-family: var(--mono);
  font-size: .62rem; font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .02em;
}
.step.is-on { color: var(--ink); font-weight: 600; }
.step.is-on .step-num { color: var(--key); }
.step.is-on::before {
  content: ''; position: absolute; left: -12px; top: 50%;
  width: 3px; height: 18px; margin-top: -9px;
  border-radius: 3px; background: var(--key);
}
.step.is-done::after {
  content: '✓'; position: absolute; right: .55rem; top: 50%;
  transform: translateY(-50%); font-size: .72rem; color: var(--ok);
}

/* ---------- 5. Contenuto ------------------------------------------------ */

.main { padding-top: 2.6rem; min-width: 0; }

.pane { animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.pane-head { margin-bottom: 2.2rem; }

.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 4.5rem; padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}
.pager .btn { max-width: 46%; }
.pager .btn span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 6. Bottoni e controlli -------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .58rem 1.05rem;
  border-radius: 100px;
  border: 1px solid var(--rule-2);
  background: var(--card);
  color: var(--ink);
  font: inherit; font-size: .9rem; font-weight: 550;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s var(--ease), color .18s;
}
.btn:hover { border-color: var(--key-line); background: var(--key-tint); }
.btn:active { transform: translateY(1px); }
.btn.is-primary {
  background: var(--key); border-color: var(--key); color: oklch(99% 0 0);
}
.btn.is-primary:hover { background: var(--key-deep); border-color: var(--key-deep); }
.btn.is-ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.is-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-ico { font-size: 1.05em; line-height: 1; }

.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: .55rem;
  margin: 1.1rem 0 0;
}

.switch {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .84rem; color: var(--ink-2); cursor: pointer;
  padding: .4rem .2rem;
}
.switch input { position: absolute; opacity: 0; width: 0; }
.switch-track {
  width: 34px; height: 19px; border-radius: 100px;
  background: var(--rule-2); position: relative;
  transition: background .22s var(--ease);
  flex: none;
}
.switch-track::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 2px oklch(30% 0 0 / .3);
  transition: transform .22s var(--ease);
}
.switch input:checked + .switch-track { background: var(--key); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch input:focus-visible + .switch-track { outline: 2.5px solid var(--key); outline-offset: 3px; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--paper-2); border-radius: 100px;
}
.segmented button {
  border: 0; background: none; font: inherit; font-size: .84rem;
  padding: .32rem .85rem; border-radius: 100px; cursor: pointer;
  color: var(--ink-2); transition: background .18s, color .18s;
}
.segmented button.is-on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px oklch(30% 0 0 / .09); }

/* ---------- 7. Contenitori ---------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: clamp(1.1rem, 2.4vw, 1.7rem);
  margin: 1.8rem 0;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.card-title {
  font-family: var(--mono);
  font-size: .62rem; font-weight: 700; letter-spacing: .15em;
  text-transform: uppercase; color: var(--ink-3);
}

/* nota a margine: la voce dell'insegnante */
.aside {
  border-left: 3px solid var(--key-line);
  background: var(--key-tint);
  padding: 1rem 1.2rem;
  border-radius: 0 var(--r-s) var(--r-s) 0;
  margin: 1.8rem 0;
  font-size: .97rem;
}
.aside > :last-child { margin-bottom: 0; }
.aside-label {
  font-family: var(--mono);
  font-size: .58rem; font-weight: 700; letter-spacing: .15em;
  text-transform: uppercase; color: var(--key-deep);
  display: block; margin-bottom: .45em;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }

/* ---------- 8. La ruota -------------------------------------------------- */

.wheel-host {
  position: relative;
  width: min(100%, 520px);
  margin-inline: auto;
  aspect-ratio: 1;
}
.wheel { width: 100%; height: 100%; display: block; overflow: visible; }

.wh-dial { transition: transform .95s var(--ease); }
@media (prefers-reduced-motion: reduce) { .wh-dial, .wh-spin { transition: none !important; } }
.wh-dial { transform-box: view-box; transform-origin: 300px 300px; }
.wh-spin { transform-box: view-box; transition: transform .95s var(--ease); }

.wh-sector { cursor: pointer; }
.wh-out, .wh-inn {
  fill: oklch(97% 0.018 var(--h));
  stroke: oklch(89% 0.03 var(--h));
  stroke-width: 1;
  transition: fill .4s var(--ease), stroke .4s var(--ease);
}
.wh-inn { fill: oklch(98.4% 0.008 var(--h)); }
.wh-sector:hover .wh-out { fill: oklch(90% 0.075 var(--h)); }
.wh-sector:hover .wh-inn { fill: oklch(95% 0.035 var(--h)); }
.wh-sector.is-on .wh-out { fill: oklch(70% 0.145 var(--h)); stroke: oklch(58% 0.16 var(--h)); }
.wh-sector.is-on .wh-inn { fill: oklch(89% 0.08 var(--h)); stroke: oklch(74% 0.12 var(--h)); }
.wh-sector.is-v .wh-out, .wh-sector.is-iv .wh-out { fill: oklch(94% 0.045 var(--h)); }
.wh-sector:focus { outline: none; }
.wh-sector:focus-visible .wh-out { stroke: var(--ink); stroke-width: 2.5; }

.wh-labels { pointer-events: none; }
.wh-major {
  font-family: var(--display); font-size: 30px; font-weight: 600;
  fill: var(--ink); text-anchor: middle; dominant-baseline: middle;
  transition: fill .4s var(--ease);
}
.wh-alt {
  font-family: var(--display); font-size: 17px;
  fill: var(--ink-3); text-anchor: middle; dominant-baseline: middle;
}
.wh-minor {
  font-family: var(--body); font-size: 15px; font-weight: 500;
  fill: var(--ink-2); text-anchor: middle; dominant-baseline: middle;
}
.wh-sig {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  fill: var(--ink-3); text-anchor: middle; dominant-baseline: middle;
  letter-spacing: -.03em;
}
.wh-labels.is-on .wh-major { fill: oklch(24% 0.06 var(--h)); }
.wh-labels.is-on .wh-minor { fill: oklch(34% 0.07 var(--h)); font-weight: 650; }
.wh-labels.is-on .wh-sig   { fill: oklch(45% 0.13 var(--h)); }

.wh-hole { fill: var(--paper); stroke: var(--rule); stroke-width: 1; }

.wh-relations { opacity: 0; transition: opacity .4s var(--ease); }
.wheel-host.is-rotating .wh-relations { opacity: 1; }
.wh-rel {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  fill: var(--ink-3); text-anchor: middle; dominant-baseline: middle;
}
.wh-relsub {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .09em;
  text-transform: uppercase; fill: var(--ink-3);
  text-anchor: middle; dominant-baseline: middle;
}

.wh-center {
  position: absolute; inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 33%; text-align: center; pointer-events: none;
}
.whc-eyebrow {
  font-family: var(--mono); font-size: .5rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
}
.whc-name {
  font-family: var(--display); font-size: clamp(2rem, 8vw, 2.9rem);
  font-weight: 600; line-height: 1.05; margin: .12em 0 .04em;
  color: var(--key-deep); transition: color .5s var(--ease);
}
.whc-it { font-size: .82rem; color: var(--ink-2); line-height: 1.25; }
.whc-sig {
  font-family: var(--mono); font-size: .55rem; letter-spacing: .06em;
  color: var(--ink-3); margin-top: .5em;
}

/* ---------- 9. Il pentagramma -------------------------------------------- */

.staff-box {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: .4rem clamp(.6rem, 2vw, 1.2rem);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.staff { display: block; min-width: 420px; }

.st-line   { stroke: var(--ink); stroke-width: 1.05; opacity: .5; }
.st-ledger { stroke: var(--ink); stroke-width: 1.05; opacity: .5; }
.st-bar    { stroke: var(--ink); stroke-width: 1.2; opacity: .35; }
.st-clef   { font-family: var(--music); fill: var(--ink); }
.st-head   { fill: var(--ink); transition: fill .16s, transform .16s var(--ease); }
.st-stem   { stroke: var(--ink); stroke-width: 1.35; transition: stroke .16s; }
.st-acc    { fill: var(--ink); }
.st-sig    { fill: var(--key); transition: fill .5s var(--ease); }

.st-note { transform-box: fill-box; transform-origin: center; }
.st-note.is-on .st-head { fill: var(--key); }
.st-note.is-on .st-stem { stroke: var(--key); }
.st-note.is-dim .st-head, .st-note.is-dim .st-stem { opacity: .22; }

.st-label {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: -.02em;
  fill: var(--ink-2); text-anchor: middle;
  transition: fill .16s;
}
.st-label.is-on { fill: var(--key); font-weight: 700; }
.st-degree {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em; fill: var(--ink-3); text-anchor: middle;
}
.st-bracket { fill: none; stroke: var(--rule-2); stroke-width: 1.1; }
.st-bracket.is-semi { stroke: var(--key-line); stroke-width: 1.8; }
.st-brackettext {
  font-family: var(--mono); font-size: 7px; letter-spacing: .04em;
  fill: var(--ink-3); text-anchor: middle;
}
.st-brackettext.is-semi { fill: var(--key-deep); font-weight: 700; }

/* ---------- 10. Widget vari ---------------------------------------------- */

/* catena delle quinte */
.chain { display: flex; flex-wrap: wrap; align-items: stretch; gap: .3rem; }
.chain-link {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  min-width: 62px; padding: .55rem .3rem;
  border-radius: var(--r-s);
  border: 1px solid transparent;
  background: oklch(97% 0.018 var(--lh));
  cursor: pointer; font: inherit;
  transition: background .3s var(--ease), transform .2s var(--ease), border-color .2s;
}
.chain-link:hover { background: oklch(92% 0.06 var(--lh)); }
.chain-link.is-on { background: oklch(76% 0.13 var(--lh)); border-color: oklch(62% 0.15 var(--lh)); }
.chain-link.is-past { background: oklch(94% 0.04 var(--lh)); }
.chain-link.is-future { opacity: .38; }
.chain-name { font-family: var(--display); font-size: 1.2rem; font-weight: 600; line-height: 1; }
.chain-sig { font-family: var(--mono); font-size: .55rem; color: var(--ink-2); letter-spacing: -.02em; }
.chain-arrow { align-self: center; color: var(--ink-3); font-size: .8rem; }

/* accordi della tonalità */
.chords { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.chord {
  display: flex; flex-direction: column; align-items: center; gap: .18rem;
  padding: .75rem .25rem .6rem;
  border-radius: var(--r-s);
  border: 1px solid var(--rule);
  background: var(--card);
  cursor: pointer; font: inherit;
  transition: background .2s, border-color .2s, transform .16s var(--ease);
}
.chord:hover { background: var(--key-tint); border-color: var(--key-line); }
.chord.is-on { background: var(--key-soft); border-color: var(--key); }
.chord.is-playing { transform: translateY(-4px); background: var(--key-soft); border-color: var(--key); }
.chord-roman {
  font-family: var(--display); font-size: 1.05rem; font-weight: 600;
  color: var(--key-deep); line-height: 1;
}
.chord-sym { font-family: var(--display); font-size: 1.15rem; font-weight: 500; line-height: 1.1; }
.chord-fn { font-size: .6rem; color: var(--ink-3); text-align: center; line-height: 1.2; }
.chord.is-pillar { border-color: var(--key-line); background: var(--key-tint); }

/* tastiera */
.piano { position: relative; display: flex; height: 116px; user-select: none; }
.pk {
  position: relative; flex: 1;
  border: 1px solid var(--rule-2); border-radius: 0 0 6px 6px;
  background: var(--card); cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: .45rem;
  font-family: var(--mono); font-size: .55rem; color: var(--ink-3);
  transition: background .16s;
}
.pk:hover { background: var(--key-tint); }
.pk.is-in { background: var(--key-soft); color: var(--key-deep); font-weight: 700; }
.pk.is-root { background: var(--key); color: oklch(99% 0 0); }
.pk.is-playing { background: var(--key-deep); color: oklch(99% 0 0); }
.pk-black {
  position: absolute; top: 0; width: 7.4%; height: 62%;
  transform: translateX(-50%); z-index: 2;
  background: var(--ink); border: 1px solid var(--ink);
  border-radius: 0 0 5px 5px; color: oklch(80% 0 0);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: .3rem; font-family: var(--mono); font-size: .5rem;
  cursor: pointer;
}
.pk-black.is-in { background: var(--key-deep); border-color: var(--key-deep); color: oklch(95% 0 0); }
.pk-black.is-root { background: var(--key); border-color: var(--key); color: oklch(99% 0 0); }
.pk-black.is-playing { background: var(--key-line); border-color: var(--key-line); color: var(--ink); }

/* tabella armature */
.sigtable-wrap { overflow-x: auto; }
.sigtable { width: 100%; min-width: 430px; border-collapse: collapse; font-size: .9rem; }
.sigtable th {
  font-family: var(--mono); font-size: .55rem; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
  text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--rule-2);
}
.sigtable td { padding: .45rem .6rem; border-bottom: 1px solid var(--rule); }
.sigtable tr { cursor: pointer; transition: background .15s; }
.sigtable tbody tr:hover { background: var(--paper-2); }
.sigtable tr.is-on { background: var(--key-tint); }
.sigtable .c-name { font-family: var(--display); font-size: 1.1rem; font-weight: 600; }
.sigtable .c-acc { font-family: var(--display); color: var(--key-deep); letter-spacing: .1em; }
.sigtable .c-n { font-family: var(--mono); font-size: .75rem; color: var(--ink-2); }

.ivrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: .4rem; }
.ivrow .chord-fn { display: block; }        /* i semitoni servono anche su schermo stretto */

/* ---------- 11. Quiz ----------------------------------------------------- */

.quiz-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap;
}
.quiz-progress { flex: 1; min-width: 140px; height: 5px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.quiz-progress i { display: block; height: 100%; background: var(--key); transition: width .4s var(--ease); }
.quiz-score { font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; color: var(--ink-2); }

.quiz-q {
  font-family: var(--display); font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.22; margin: 0 0 1.3rem; max-width: 30ch;
}
.quiz-answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .55rem; }
.answer {
  padding: .85rem 1rem; border-radius: var(--r-s);
  border: 1.5px solid var(--rule-2); background: var(--card);
  font: inherit; font-size: 1rem; cursor: pointer; text-align: left;
  transition: background .18s, border-color .18s, transform .12s var(--ease);
}
.answer:hover:not([disabled]) { border-color: var(--key-line); background: var(--key-tint); }
.answer .a-main { font-family: var(--display); font-size: 1.2rem; font-weight: 600; display: block; }
.answer .a-sub { font-size: .76rem; color: var(--ink-3); }
.answer.is-right { border-color: var(--ok); background: oklch(96% 0.05 150); }
.answer.is-wrong { border-color: var(--no); background: oklch(96% 0.04 25); }
.answer[disabled] { cursor: default; }
.answer.is-right .a-main { color: oklch(38% 0.12 150); }
.answer.is-wrong .a-main { color: oklch(42% 0.15 25); }

.quiz-feedback {
  margin-top: 1.3rem; padding: .95rem 1.15rem;
  border-radius: var(--r-s); font-size: .95rem;
  border-left: 3px solid var(--rule-2); background: var(--paper-2);
}
.quiz-feedback.is-right { border-color: var(--ok); background: oklch(97% 0.03 150); }
.quiz-feedback.is-wrong { border-color: var(--no); background: oklch(97% 0.025 25); }
.quiz-feedback b { font-weight: 650; }
.quiz-feedback > :last-child { margin-bottom: 0; }

.quiz-end { text-align: center; padding: 2rem 0; }
.quiz-end .big {
  font-family: var(--display); font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 600; line-height: 1; color: var(--key-deep);
}

.tally { display: flex; gap: 4px; flex-wrap: wrap; margin: 1rem 0 0; }
.tally i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule-2); }
.tally i.ok { background: var(--ok); }
.tally i.no { background: var(--no); }

/* ---------- 12. Copertina ------------------------------------------------ */

.hero {
  position: relative;
  padding: 1rem 0 0;
  margin-bottom: 3rem;
}
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center;
}
.hero h1 { margin-bottom: .35em; }

.hero-note {
  margin-top: 1.8rem; font-size: .92rem; color: var(--ink-3);
  display: flex; align-items: center; gap: .5rem;
}

/* ---------- 13. Adattamento agli schermi piccoli ------------------------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-bottom: 5rem; }
  .rail {
    position: sticky; top: 58px; z-index: 30;
    max-height: none; padding: .7rem 0;
    background: oklch(97.6% 0.006 285 / .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule);
    margin: 0 calc(-1 * clamp(1rem, 3vw, 2rem));
    padding-inline: clamp(1rem, 3vw, 2rem);
  }
  .rail-title { display: none; }
  .rail nav { flex-direction: row; overflow-x: auto; gap: .3rem; scrollbar-width: none; }
  .rail nav::-webkit-scrollbar { display: none; }
  .step {
    grid-template-columns: auto; white-space: nowrap;
    padding: .4rem .8rem; border: 1px solid var(--rule); border-radius: 100px;
    font-size: .84rem;
  }
  .step-num { display: none; }
  .step.is-on { background: var(--key-soft); border-color: var(--key-line); }
  .step.is-on::before { display: none; }
  .rail nav + .rail-title { display: none; }
  .main { padding-top: 1.8rem; }
  .hero-grid { grid-template-columns: 1fr; }
  .chords { grid-template-columns: repeat(4, 1fr); }
  .chord-fn { display: none; }
}

@media (max-width: 700px) {
  #modeswitch button { padding: .3rem .6rem; font-size: .78rem; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .topbar { gap: .5rem; }
  .brand { font-size: .92rem; }
  .chords { grid-template-columns: repeat(3, 1fr); }
  .piano { height: 92px; }
  .keychip { display: none; }
}

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

/* ---------- 14. Stampa --------------------------------------------------- */

@media print {
  .topbar, .rail, .pager, .controls { display: none; }
  .layout { grid-template-columns: 1fr; }
  .card, .staff-box { break-inside: avoid; box-shadow: none; }
}
