@font-face { font-family: "Newsreader"; src: url("/web/fonts/newsreader-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; }
@font-face { font-family: "Newsreader"; src: url("/web/fonts/newsreader-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; }
@font-face { font-family: "Newsreader"; src: url("/web/fonts/newsreader-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; }
@font-face { font-family: "Inter"; src: url("/web/fonts/inter-latin-400-normal.woff2") format("woff2"); font-weight: 400; }
@font-face { font-family: "Inter"; src: url("/web/fonts/inter-latin-600-normal.woff2") format("woff2"); font-weight: 600; }

:root {
  --paper: #f7f7f9;
  --sheet: #ffffff;
  --ink: #1b1c22;
  --ink-2: #4a4c57;
  --ink-3: #7b7e8a;
  --rule: #e3e3ea;
  --violet: #5b45c2;
  --violet-soft: #efecfb;
  --amber: #8a5a00;
  --amber-soft: #fff4dc;
  --mint-soft: #e6f6f1;
  --mint: #1d6b55;
  --pearl: linear-gradient(115deg, #c9b8ff 0%, #ffc9a8 55%, #9fe3da 100%);
  --serif: "Newsreader", ui-serif, Georgia, serif;
  --sans: "Inter", -apple-system, system-ui, sans-serif;
  --measure: 68ch;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--violet); text-decoration-thickness: 1px; text-underline-offset: 3px; }
kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0 0.4em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--sheet);
  font: 600 0.82em/1.6 var(--sans);
  text-align: center;
  color: var(--ink-2);
}
code { font: 0.9em/1 ui-monospace, "SF Mono", Menlo, monospace; padding: 0.1em 0.35em; border-radius: 4px; background: #eeeef3; }
b, strong { font-weight: 600; }

/* ---------- impaginazione ---------- */

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1180px; margin: 0 auto; }
.toc {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 36px 20px 40px 28px;
  border-right: 1px solid var(--rule);
  font-size: 13.5px;
}
.toc .toc-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; font: 500 20px/1 var(--serif); color: var(--ink); text-decoration: none; }
.toc-brand img { display: inline-block; width: 26px; height: 26px; }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: cap; }
.toc > nav > ol > li { counter-increment: cap; margin: 0 0 2px; }
.toc a { display: block; padding: 5px 8px; border-radius: 7px; color: var(--ink-2); text-decoration: none; }
.toc > nav > ol > li > a::before { content: counter(cap) ". "; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.toc a:hover { background: #ececf2; color: var(--ink); }
.toc a.attivo { background: var(--violet-soft); color: var(--violet); }
.toc ol ol { margin: 2px 0 8px 18px; font-size: 12.5px; }
.toc ol ol a { padding: 3px 8px; }
.toc-pdf { display: inline-flex; align-items: center; gap: 8px; margin-top: 22px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 9px; background: var(--sheet); color: var(--ink); font-weight: 600; text-decoration: none; }

main { padding: 0 56px 120px; min-width: 0; }
.doc { max-width: var(--measure); }

/* ---------- copertina ---------- */

.cover { position: relative; padding: 72px 0 56px; }
.cover-mark { width: 54px; height: 54px; margin-bottom: 30px; }
.cover h1 { margin: 0; font: 400 clamp(46px, 7vw, 76px)/0.98 var(--serif); letter-spacing: -0.02em; }
.cover .sub { max-width: 34ch; margin: 18px 0 0; font: 400 22px/1.4 var(--serif); color: var(--ink-2); }
.cover-strip { display: grid; grid-template-columns: 1.5fr 1fr 0.75fr 1fr; gap: 6px; margin: 44px 0 18px; }
.cover-strip img { width: 100%; height: 190px; object-fit: cover; border-radius: 6px; }
.cover-strip figcaption { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); }
.pearl-rule { height: 3px; width: 120px; margin: 28px 0 0; border: 0; border-radius: 3px; background: var(--pearl); }
.cover-meta { margin: 14px 0 0; font-size: 13px; color: var(--ink-3); }

/* ---------- capitoli ---------- */

.chapter { padding-top: 56px; }
.chapter + .chapter { border-top: 1px solid var(--rule); margin-top: 56px; }
.chapter-num { margin: 0 0 6px; font: 400 15px/1 var(--serif); font-style: italic; color: var(--violet); }
h2 { margin: 0 0 14px; font: 400 38px/1.1 var(--serif); letter-spacing: -0.01em; }
h3 { margin: 40px 0 10px; font: 500 23px/1.25 var(--serif); }
h4 { margin: 26px 0 6px; font: 600 15px/1.4 var(--sans); }
p { margin: 0 0 14px; }
.lead { font: 400 19px/1.55 var(--serif); color: var(--ink-2); }
ul, ol { margin: 0 0 16px; padding-left: 1.3em; }
li { margin: 0 0 6px; }
li::marker { color: var(--ink-3); }

.steps { list-style: none; padding: 0; counter-reset: passo; }
.steps > li { position: relative; padding-left: 40px; margin-bottom: 14px; counter-increment: passo; }
.steps > li::before {
  content: counter(passo);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font: 600 13px/26px var(--sans);
  text-align: center;
}

/* ---------- figure ---------- */

figure { margin: 26px 0 28px; }
.shot { border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: #15161a; box-shadow: 0 18px 40px -26px rgba(20, 20, 40, 0.45); }
.wide { width: min(100%, 900px); max-width: none; }
figcaption { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-3); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair img, .trio img { width: 100%; border-radius: 8px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.label-img { position: relative; }
.label-img span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(20, 20, 26, 0.75);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.checker { padding: 18px; border-radius: 8px; background-color: #fff; background-image: conic-gradient(#ececf0 25%, transparent 0 50%, #ececf0 0 75%, transparent 0); background-size: 18px 18px; }

/* mappa numerata sopra uno screenshot */
.map { position: relative; }
.pin {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
  font: 600 12.5px/22px var(--sans);
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.legend { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; font-size: 14.5px; }
.legend li { display: flex; gap: 10px; align-items: baseline; margin: 0; }
.legend b.n {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
  font: 600 12px/22px var(--sans);
  text-align: center;
}

/* ---------- box ---------- */

.note, .tip-box, .warn {
  margin: 20px 0;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.6;
}
.note { background: var(--violet-soft); }
.tip-box { background: var(--mint-soft); }
.warn { background: var(--amber-soft); }
.note > b:first-child, .tip-box > b:first-child, .warn > b:first-child { display: block; margin-bottom: 2px; }
.tip-box > b:first-child { color: var(--mint); }
.warn > b:first-child { color: var(--amber); }
.note > b:first-child { color: var(--violet); }
.note p:last-child, .tip-box p:last-child, .warn p:last-child { margin: 0; }

/* ---------- tabelle ---------- */

table { width: 100%; margin: 18px 0 24px; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: 13px; }
td:first-child { white-space: nowrap; font-weight: 600; }

/* ---------- chat con Claude ---------- */

.chat { margin: 24px 0 30px; padding: 22px; border-radius: 14px; background: #1c1d22; color: #ececef; font-size: 14.5px; }
.chat .u, .chat .c { max-width: 92%; margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; line-height: 1.55; }
.chat .u { margin-left: auto; background: #34313f; }
.chat .c { background: transparent; padding-left: 0; color: #d9d9df; }
.chat code { background: #2c2d35; color: #e6e6ea; }
.chat .tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 5px 10px;
  border: 1px solid #3a3b44;
  border-radius: 8px;
  color: #a9abb6;
  font: 12.5px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
}
.chat .tool::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7fd8a6; }
.chat img { width: 220px; margin: 2px 0 12px; border-radius: 8px; }
.chat .row { display: flex; gap: 8px; flex-wrap: wrap; }
.chat .row img { width: 150px; }

.prompts { list-style: none; padding: 0; display: grid; gap: 8px; }
.prompts li { margin: 0; padding: 10px 14px; border-left: 3px solid var(--violet); background: var(--sheet); border-radius: 0 8px 8px 0; font: italic 400 16.5px/1.5 var(--serif); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }

/* evidenziazione dopo un salto dall'infobox */
.flash { animation: flash 1.6s ease-out; border-radius: 8px; }
@keyframes flash { 0%, 30% { background: var(--violet-soft); box-shadow: 0 0 0 10px var(--violet-soft); } 100% { background: transparent; box-shadow: 0 0 0 10px transparent; } }

/* ---------- dentro la dashboard ---------- */

body.incorporata .layout { display: block; }
body.incorporata .toc { display: none; }
body.incorporata main { padding: 0 26px 80px; }
body.incorporata .cover { padding-top: 34px; }
body.incorporata .cover h1 { font-size: 44px; }
body.incorporata .cover-strip img { height: 110px; }
body.incorporata h2 { font-size: 31px; }
body.incorporata .legend, body.incorporata .cols { grid-template-columns: 1fr; }

@media (max-width: 900px) {
  .layout { display: block; }
  .toc { display: none; }
  main { padding: 0 22px 80px; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .flash { animation: none; } }

/* ---------- stampa (PDF) ---------- */

@page { size: A4; margin: 18mm 17mm 20mm; }
@media print {
  html { scroll-behavior: auto; }
  body { background: #fff; font-size: 10.6pt; line-height: 1.55; }
  .layout { display: block; max-width: none; }
  .toc { display: none; }
  main { padding: 0; }
  .doc { max-width: none; }
  .cover { min-height: 255mm; padding: 26mm 4mm 0; break-after: page; }
  .cover h1 { font-size: 84pt; }
  .cover .sub { font-size: 18pt; }
  .cover-strip { margin-top: 22mm; }
  .cover-strip img { height: 78mm; }
  .print-toc { display: block; break-after: page; }
  .chapter { padding-top: 10mm; margin-top: 10mm; }
  .chapter + .chapter { margin-top: 8mm; border-top: 0.6pt solid var(--rule); }
  .print-toc + .chapter { border-top: 0; margin-top: 0; padding-top: 0; }
  #claude-mcp { break-before: page; border-top: 0; }
  .chapter-num, h2, h3, .lead { break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  h2 { font-size: 28pt; }
  h3 { font-size: 15pt; break-after: avoid; }
  h4 { break-after: avoid; }
  figure, table, .chat, .note, .tip-box, .warn, .legend { break-inside: avoid; }
  .chat { background: #1c1d22 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pin, .legend b.n, .steps > li::before, .note, .tip-box, .warn, .shot, .pearl-rule, .checker, kbd, code, .prompts li { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shot { box-shadow: none; }
  figure img { max-height: 105mm; width: auto; margin: 0 auto; }
  figure img.shot { max-height: 84mm; }
  figcaption { font-size: 9pt; }
  .pair img, .trio img { max-height: 70mm; object-fit: contain; }
  .wide { width: 100%; }
  .map img { max-height: none; width: 100%; }
  .chat img { max-height: 45mm; width: auto; }
  .cover-strip img { max-height: none; width: 100%; }
  a { color: inherit; text-decoration: none; }
  .no-print { display: none !important; }
}
@media screen { .print-toc { display: none; } }
.print-toc h2 { margin-top: 0; }
.print-toc ol { list-style: none; margin: 3mm 0 0; padding: 0; counter-reset: voce; }
.print-toc li { display: flex; align-items: baseline; gap: 8px; margin: 0; break-inside: avoid; }
.print-toc li::after { content: ""; order: 1; flex: 1; border-bottom: 0.6pt dotted #b9bbc6; transform: translateY(-3px); }
.print-toc li span { order: 2; min-width: 2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.print-toc li.cap { counter-increment: voce; margin-top: 1.6mm; font-weight: 600; font-size: 10.4pt; }
.print-toc li.cap a::before { content: counter(voce) ".  "; color: var(--violet); }
.print-toc li.sub { padding-left: 7mm; font-size: 9pt; color: var(--ink-2); line-height: 1.38; }
.print-toc a { color: inherit; text-decoration: none; }
.print-toc .note { margin-top: 5mm; font-size: 9.4pt; padding: 10px 14px; }
.pmark { position: absolute; top: 0; right: 0; font-size: 2px; line-height: 1; color: #fff; }
@media print { .nuova-pagina { break-before: page; } }

/* posizioni dei numeri sulla mappa dello Studio */
.p-viste { left: 39.4%; top: 3%; }
.p-stato { left: 72.3%; top: 3%; }
.p-azioni { left: 37.4%; top: 73.6%; }
.p-modi { left: 2.2%; top: 80.4%; }
.p-prompt { left: 59.5%; top: 87.8%; }
.p-pillole { left: 41.8%; top: 95%; }
.p-genera { left: 58%; top: 95%; }
.p-stili { left: 89.6%; top: 9.4%; }
.p-sessione { left: 7.2%; top: 14%; }

.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 26px; }
.gallery-grid figure { margin: 0; }
.gallery-grid img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; }
.gallery-grid.four img { aspect-ratio: 1; }
.gallery-grid .label-img span { left: 6px; bottom: 6px; font-size: 11px; padding: 2px 7px; }
body.incorporata .gallery-grid { grid-template-columns: repeat(2, 1fr); }
@media print { .gallery-grid img { max-height: none; } .gallery-grid { break-inside: avoid; } }

.side { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 22px; align-items: start; margin: 18px 0 22px; }
.side > img { width: 100%; border-radius: 8px; }
.side .poster-final { box-shadow: 0 18px 40px -22px rgba(20, 20, 40, 0.55); }
.quote { font: italic 400 16px/1.5 var(--serif); color: var(--ink-2); }
body.incorporata .side { grid-template-columns: 1fr; }
@media print { .side { break-inside: avoid; } .side > img { max-height: 120mm; width: auto; } }
