.book-hero{min-height:30vh;display:flex;align-items:center;padding-top:56px}
.book-hero h1{font-family:var(--sans);font-size:clamp(1.8rem,5vw,3.2rem);color:var(--hi);letter-spacing:-1px;margin-bottom:.8rem}
.book-hero .lead{font-size:15px;color:var(--mid);max-width:680px;line-height:1.8}
.back-link{display:inline-flex;align-items:center;gap:.5rem;margin-bottom:1.5rem;color:var(--c1);font-size:13px;text-decoration:none}
.back-link:hover{text-decoration:underline}

.wrap-wide{max-width:1260px}

.wip-banner{
  background:rgba(191,90,242,.06);border:1px solid rgba(191,90,242,.25);border-radius:10px;
  padding:1.2rem 1.5rem;margin:0 0 2.5rem;font-size:13px;color:var(--mid);line-height:1.8;max-width:760px;
}
.wip-banner strong{color:var(--hi)}

.content-section h2{font-family:var(--sans);font-size:1.3rem;color:var(--hi);margin-bottom:1rem}

.book-toc{list-style:none;display:flex;flex-direction:column;gap:.2rem;max-width:640px;margin:0 0 3rem;padding:0}
.book-toc li a{
  display:flex;justify-content:space-between;gap:1rem;padding:.85rem 0;
  border-bottom:1px solid rgba(255,255,255,.05);color:var(--mid);font-size:14px;text-decoration:none;
}
.book-toc li a:hover{color:var(--hi)}
.book-toc .toc-status{font-family:var(--mono);font-size:10px;letter-spacing:1px;text-transform:uppercase;color:var(--c1);opacity:.75;flex-shrink:0}

/* ── Layout a due colonne: testo + indice laterale sticky ── */
.book-layout{display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:3rem;align-items:start}
.chapter-body{max-width:760px;min-width:0}
.chapter-body-solo{max-width:760px}

.book-toc-side{
  position:sticky;top:88px;max-height:calc(100vh - 110px);overflow-y:auto;
  padding:0 .6rem 2rem 0;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,.16) transparent;
}
.book-toc-side::-webkit-scrollbar{width:6px}
.book-toc-side::-webkit-scrollbar-thumb{background:rgba(255,255,255,.14);border-radius:3px}
.book-toc-side .toc-title{font-family:var(--mono);font-size:10.5px;letter-spacing:2px;text-transform:uppercase;color:var(--c1);opacity:.85;margin-bottom:1.1rem}
.book-toc-side ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.book-toc-side li a{
  display:block;padding:.55rem 0 .55rem 1rem;color:var(--fg);text-decoration:none;font-size:13px;line-height:1.5;
  border-left:2px solid rgba(255,255,255,.07);transition:color .15s,border-color .15s;
}
.book-toc-side li a:hover{color:var(--hi);border-left-color:var(--c1)}
.book-toc-side li.lvl1{margin-top:1.15rem}
.book-toc-side li.lvl1:first-child{margin-top:0}
.book-toc-side li.lvl1 a{font-weight:600;color:var(--mid)}
.book-toc-side li.lvl2 a{padding-left:1.7rem;font-size:12.5px;opacity:.92}
.book-toc-side li.lvl3 a{padding-left:2.5rem;font-size:12px;opacity:.75}

/* ── Corpo del capitolo ── */
.chapter-body p{color:var(--mid);line-height:1.9;margin-bottom:1.1rem}
.chapter-body ul,.chapter-body ol{color:var(--mid);line-height:1.85;margin:0 0 1.1rem 1.4rem}
.chapter-body li{margin-bottom:.35rem}
.chapter-body strong{color:var(--hi);font-weight:600}
.chapter-body img{max-width:100%;height:auto;border-radius:8px;border:1px solid rgba(255,255,255,.06);margin:.5rem 0 1.2rem;display:block}
.chapter-body .cite{font-size:.85em;color:var(--fg);opacity:.65}
.chapter-body a{color:var(--c1);overflow-wrap:break-word}

.chapter-body h2,.chapter-body h3,.chapter-body h4,.chapter-body h5,.chapter-body h6{
  font-family:var(--sans);color:var(--hi);scroll-margin-top:88px;
}
.chapter-body .lvl1{font-size:1.35rem;font-weight:700;margin:3rem 0 1.1rem;padding-top:.5rem;border-top:1px solid rgba(255,255,255,.06)}
.chapter-body .lvl1:first-child{border-top:none;padding-top:0;margin-top:0}
.chapter-body .lvl2{font-size:1.15rem;font-weight:600;margin:2.4rem 0 1rem}
.chapter-body .lvl3{font-size:1.02rem;font-weight:600;margin:2rem 0 .9rem}
.chapter-body .lvl4{font-size:.92rem;font-weight:600;margin:1.7rem 0 .8rem;opacity:.95}
.chapter-body .lvl5{font-size:.85rem;font-weight:600;margin:1.5rem 0 .7rem;opacity:.85}
.chapter-body .lvl6{font-size:.8rem;font-weight:600;margin:1.3rem 0 .6rem;opacity:.7;text-transform:uppercase;letter-spacing:.4px}

.table-scroll{overflow-x:auto;margin:0 0 1.4rem;-webkit-overflow-scrolling:touch}
.chapter-body table{border-collapse:collapse;width:100%;min-width:480px;font-size:12.5px}
.chapter-body th,.chapter-body td{border:1px solid rgba(255,255,255,.08);padding:.6rem .8rem;text-align:left;vertical-align:top;color:var(--mid)}
.chapter-body th{color:var(--hi);background:rgba(255,255,255,.02);font-weight:600}

.stub-note{
  display:block;font-family:var(--mono);font-size:11px;letter-spacing:1px;color:var(--fg);
  opacity:.55;font-style:italic;margin:0 0 1.6rem;
}
.todo-note{
  background:rgba(0,240,255,.04);border-left:2px solid var(--c1);border-radius:0 6px 6px 0;
  padding:.7rem 1rem;margin:1rem 0 1.3rem;font-family:var(--mono);font-size:12px;color:var(--fg);
}
.todo-note::before{content:'nota di lavoro — ';color:var(--c1);text-transform:uppercase;letter-spacing:1px;font-size:10px}

.chapter-nav{display:flex;justify-content:space-between;gap:1rem;margin-top:4rem;padding-top:2rem;border-top:1px solid rgba(255,255,255,.06);font-size:13px}
.chapter-nav a{color:var(--c1);text-decoration:none}
.chapter-nav a:hover{text-decoration:underline}

.topics-list{list-style:none;columns:2;column-gap:2.5rem;max-width:900px;margin:1rem 0 0;padding:0}
.topics-list li{color:var(--mid);font-size:13px;line-height:2;break-inside:avoid;position:relative;padding-left:1rem}
.topics-list li::before{content:'—';position:absolute;left:0;color:var(--fg);opacity:.5}

/* ── Mobile: l'indice laterale scende sopra il testo, non più sticky ── */
@media(max-width:1000px){
  .book-layout{grid-template-columns:1fr;gap:0}
  .book-toc-side{
    position:static;max-height:none;order:-1;margin-bottom:2rem;padding:1.1rem 1.2rem 1.3rem;
    border:1px solid rgba(255,255,255,.07);border-radius:10px;background:rgba(255,255,255,.015);
  }
  .book-toc-side ul{max-height:38vh;overflow-y:auto}
}
@media(max-width:700px){
  .topics-list{columns:1}
  .book-hero .lead{font-size:14px}
  .chapter-body .lvl1{font-size:1.2rem}
  .chapter-body .lvl2{font-size:1.08rem}
  .chapter-body table{font-size:11.5px}
  .chapter-body th,.chapter-body td{padding:.45rem .6rem}
}
