/* CorsiDrive — "sala di proiezione": nero caldo, grana di pellicola,
   un solo accento arancio, dispense color carta. */

:root {
  --ink: #0e0d0b;
  --ink-2: #151311;
  --ink-3: #1b1815;
  --ink-4: #24201c;
  --line: rgba(239, 230, 214, .075);
  --line-2: rgba(239, 230, 214, .14);
  --text: #f0e8db;
  --text-2: #cbc1b2;
  --muted: #8f8677;
  --dim: rgba(239, 230, 214, .16);
  --accent: #ff5b2e;
  --accent-2: #ff8b5e;
  --accent-ink: #1a0a04;
  --accent-soft: rgba(255, 91, 46, .14);
  --accent-glow: rgba(255, 91, 46, .26);
  --paper: #f4ede1;
  --paper-2: #ebe3d4;
  --paper-ink: #1d1914;
  --paper-muted: #7b705f;
  --paper-line: rgba(29, 25, 20, .12);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-text: "Newsreader", Charter, Georgia, serif;
  --font-ui: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --topbar: 64px;
  --sidebar: 340px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 var(--font-ui);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 620px at 78% -12%, rgba(255, 91, 46, .085), transparent 62%),
    radial-gradient(900px 520px at -8% 112%, rgba(255, 170, 110, .05), transparent 60%),
    var(--ink);
  overflow: hidden;
}

/* grana di pellicola */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .95  0 0 0 0 .9  0 0 0 .6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }

.mono { font-family: var(--font-mono); font-feature-settings: "zero"; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: relative;
  z-index: 30;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 22px;
  background: rgba(14, 13, 11, .72);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: -.02em;
  line-height: 1;
}
.brand em { font-style: italic; font-weight: 400; }
.brand b { font-weight: 600; }
.rec {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 91, 46, .16), 0 0 18px var(--accent);
}

.course-tabs {
  display: flex;
  align-self: stretch;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.course-tabs::-webkit-scrollbar { display: none; }

.course-tab {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 160ms ease;
}
.course-tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  transform: scaleX(0);
  transition: transform 240ms var(--ease-out);
}
.course-tab.active { color: var(--text); }
.course-tab.active::after { transform: scaleX(1); }

.top-actions { display: flex; gap: 4px; }
.top-actions .ico {
  display: none;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- bottoni */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: rgba(239, 230, 214, .025);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 28px -10px var(--accent-glow);
}
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.paper { border-color: var(--paper-line); background: transparent; color: var(--paper-ink); }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: rgba(239, 230, 214, .07); border-color: rgba(239, 230, 214, .22); }
  .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
  .btn.ghost:hover { background: rgba(239, 230, 214, .06); color: var(--text); }
  .btn.paper:hover { background: rgba(29, 25, 20, .06); border-color: rgba(29, 25, 20, .25); }
  .course-tab:hover { color: var(--text-2); }
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.menu-btn { display: none; }

/* ---------------------------------------------------------------- layout */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: calc(100vh - var(--topbar));
  height: calc(100dvh - var(--topbar)); /* iPhone e iPad: esclude la barra di Safari */
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(21, 19, 17, .62);
  border-right: 1px solid var(--line);
}

.main {
  overflow-y: auto;
  padding: 44px 52px 110px;
  min-width: 0;
}

.scrim { display: none; }

body.setup .layout { grid-template-columns: minmax(0, 1fr); }
body.setup .sidebar,
body.setup .course-tabs,
body.setup .top-actions,
body.setup .menu-btn { display: none; }

/* ------------------------------------------------------------ sidebar */

.side-head { padding: 22px 20px 10px; }
.side-label {
  display: flex;
  justify-content: space-between;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-count {
  margin: 10px 0 12px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.02em;
}
.side-count small { font-size: 17px; color: var(--muted); font-style: italic; }

.line-bar { height: 3px; border-radius: 3px; background: var(--dim); overflow: hidden; }
.line-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px var(--accent-glow);
  transform-origin: left;
}

.search { position: relative; padding: 10px 14px 10px; }
.search svg {
  position: absolute;
  left: 27px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  stroke: var(--muted);
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(239, 230, 214, .035);
  outline: none;
  font-size: 14px;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: rgba(255, 91, 46, .55); background: rgba(239, 230, 214, .05); }

.tree { flex: 1; overflow-y: auto; padding: 4px 10px 40px; }

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { margin-left: 15px; padding-left: 8px; border-left: 1px solid var(--line); }

.branch-row,
.lesson-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.35;
  transition: background-color 140ms ease, color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .lesson-row:hover, .branch-row:hover { background: rgba(239, 230, 214, .04); color: var(--text); }
}
.lesson-row.active, .branch-row.active {
  background: linear-gradient(90deg, rgba(255, 91, 46, .16), rgba(255, 91, 46, .02) 85%);
  color: var(--text);
}
.lesson-row.active::before, .branch-row.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.branch-row {
  margin-top: 6px;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.branch-label {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  letter-spacing: inherit;
  text-transform: inherit;
}

.chev {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: transform 200ms var(--ease-out), color 140ms ease;
}
.chev svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.2; fill: none; }
.chev[aria-expanded="true"] { transform: rotate(90deg); color: var(--accent); }

.row-num {
  flex: none;
  min-width: 24px;
  color: var(--muted);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
}
.row-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-meta {
  flex: none;
  color: var(--muted);
  font: 400 10.5px/1 var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
}

.search-hit { display: block; }
.search-path {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font: 400 10.5px/1.3 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.empty-search { color: var(--muted); padding: 14px; font-size: 14px; }

/* icone di stato */
.st { flex: none; width: 18px; height: 18px; }
.st svg { width: 18px; height: 18px; }
.st .trk { fill: none; stroke: var(--dim); stroke-width: 1.8; }
.st-done circle { fill: var(--text); }
.st-done path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.st-partial .arc { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; filter: drop-shadow(0 0 3px rgba(255, 91, 46, .5)); }
.st-doc path, .st-doc rect { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

/* ---------------------------------------------------------------- pagina */

.page { max-width: 1480px; margin: 0 auto; }
.page-enter > * { animation: rise 320ms var(--ease-out) both; }
.page-enter > *:nth-child(2) { animation-delay: 40ms; }
.page-enter > *:nth-child(3) { animation-delay: 80ms; }
.page-enter > *:nth-child(4) { animation-delay: 120ms; }
.page-enter > *:nth-child(5) { animation-delay: 160ms; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.display {
  margin: 18px 0 0;
  font-family: var(--font-display);
  font-weight: 380;
  font-size: clamp(46px, 6.4vw, 104px);
  line-height: .92;
  letter-spacing: -.035em;
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}
.display em { font-style: italic; font-weight: 300; color: var(--accent); }

.section-label {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 56px 0 18px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  letter-spacing: -.02em;
}
.section-label .mono { font-size: 12px; color: var(--muted); letter-spacing: .08em; }

.muted { color: var(--muted); }

/* ------------------------------------------------------------ home corso */

.hero { position: relative; padding: 6px 0 4px; }
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 46px;
  margin: 34px 0 26px;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -.02em;
}
.stat b em { font-style: italic; color: var(--accent); }
.stat > span {
  display: block;
  margin-top: 8px;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* pellicola: un fotogramma per video */
.filmstrip {
  position: relative;
  display: flex;
  gap: 3px;
  height: 52px;
  padding: 13px 12px;
  border-radius: 10px;
  background: #090807;
  box-shadow: inset 0 0 0 1px var(--line), 0 24px 50px -30px rgba(0, 0, 0, .9);
}
.filmstrip::before,
.filmstrip::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 4px;
  border-radius: 1px;
  background: repeating-linear-gradient(90deg, rgba(239, 230, 214, .16) 0 7px, transparent 7px 15px);
}
.filmstrip::before { top: 4px; }
.filmstrip::after { bottom: 4px; }
.frame {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: rgba(239, 230, 214, .09);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.frame.done { background: var(--text); }
.frame.partial { background: linear-gradient(90deg, var(--accent) var(--p, 50%), rgba(239, 230, 214, .09) var(--p, 50%)); }
@media (hover: hover) and (pointer: fine) {
  .frame:hover { transform: scaleY(1.28); background-color: rgba(239, 230, 214, .3); }
  .frame.done:hover { background-color: #fff; }
}
.filmstrip.mini { height: 30px; padding: 8px 8px; gap: 2px; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--line); }
.filmstrip.mini::before, .filmstrip.mini::after { left: 8px; right: 8px; height: 2px; }
.filmstrip.mini::before { top: 3px; }
.filmstrip.mini::after { bottom: 3px; }
.filmstrip.mini .frame { pointer-events: none; }

.strip-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  font: 400 11px/1 var(--font-mono);
  color: var(--muted);
}
.strip-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* continua a guardare */
.reel {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  margin-top: 40px;
  padding: 24px 28px;
  border-radius: 20px;
  text-decoration: none;
  overflow: hidden;
  background:
    radial-gradient(420px 220px at 0% 50%, rgba(255, 91, 46, .22), transparent 70%),
    linear-gradient(180deg, rgba(239, 230, 214, .035), rgba(239, 230, 214, .01)),
    var(--ink-3);
  border: 1px solid var(--line-2);
  box-shadow: 0 40px 70px -40px rgba(0, 0, 0, .9);
  transition: border-color 200ms ease, transform 200ms var(--ease-out);
}
.reel:active { transform: scale(.995); }
.play-disc {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 10px rgba(255, 91, 46, .12), 0 16px 40px -8px var(--accent-glow);
  transition: transform 220ms var(--ease-out);
}
.play-disc svg { width: 26px; height: 26px; fill: var(--accent-ink); margin-left: 4px; }
@media (hover: hover) and (pointer: fine) {
  .reel:hover { border-color: rgba(255, 91, 46, .45); }
  .reel:hover .play-disc { transform: scale(1.06); }
}
.reel-title {
  margin: 10px 0 12px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: -.02em;
  overflow-wrap: anywhere;
}
.reel-title .num { color: var(--accent); font-style: italic; margin-right: 10px; }
.reel-time {
  display: flex;
  align-items: center;
  gap: 14px;
  font: 400 12px/1 var(--font-mono);
  color: var(--text-2);
}
.reel-time .line-bar { flex: 1; max-width: 360px; }
.reel-cta {
  font: 600 11.5px/1 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}
.reel-cta svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .reel:hover .reel-cta svg { transform: translateX(4px); } }

/* sezioni */
.sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.section-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 190px;
  padding: 22px 22px 20px;
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  background: linear-gradient(180deg, rgba(239, 230, 214, .03), rgba(239, 230, 214, 0)), var(--ink-2);
  border: 1px solid var(--line);
  animation: rise 360ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms + 120ms);
  transition: border-color 200ms ease, transform 200ms var(--ease-out);
}
.section-card:active { transform: scale(.985); }
.section-card .ghost {
  position: absolute;
  right: -4px;
  top: -30px;
  font: italic 300 150px/1 var(--font-display);
  color: transparent;
  -webkit-text-stroke: 1px rgba(239, 230, 214, .11);
  letter-spacing: -.05em;
  pointer-events: none;
  user-select: none;
  transition: -webkit-text-stroke-color 220ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .section-card:hover { border-color: rgba(255, 91, 46, .38); transform: translateY(-2px); }
  .section-card:hover .ghost { -webkit-text-stroke-color: rgba(255, 91, 46, .45); }
}
.section-card .section-title {
  position: relative;
  max-width: 82%;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: -.015em;
  flex: 1;
}
.section-meta {
  position: relative;
  display: flex;
  justify-content: space-between;
  font: 400 11px/1 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-meta b { color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------- lezione */

.lesson-head { position: relative; margin-bottom: 30px; padding-top: 8px; }
.lesson-head .ghost-num {
  position: absolute;
  left: -14px;
  top: -64px;
  z-index: 0;
  font: italic 300 210px/1 var(--font-display);
  letter-spacing: -.06em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 91, 46, .22);
  pointer-events: none;
  user-select: none;
}
.crumbs {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font: 500 10.5px/1.4 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.crumbs a { text-decoration: none; transition: color 140ms ease; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .45; }
.lesson-title {
  position: relative;
  margin: 14px 0 0;
  max-width: 980px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 3.4vw, 54px);
  line-height: 1.02;
  letter-spacing: -.03em;
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}

.lesson-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas: "top side" "mat mat";
  column-gap: 30px;
  align-items: start;
}
.lesson-top { grid-area: top; min-width: 0; }
.lesson-mat { grid-area: mat; min-width: 0; }
.lesson-side {
  grid-area: side;
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--line-2),
    0 50px 90px -45px rgba(0, 0, 0, .95),
    0 0 140px -40px var(--accent-glow);
}
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--text);
  background: radial-gradient(circle at 50% 45%, rgba(26, 22, 18, .82), rgba(8, 7, 6, .94));
  backdrop-filter: blur(6px);
  transition: opacity 260ms var(--ease-out);
}
@starting-style { .overlay { opacity: 0; } }
.overlay[hidden] { display: none; }
.overlay .big { font-family: var(--font-display); font-size: 30px; letter-spacing: -.02em; }
.overlay .big em { color: var(--accent); }
.overlay .sub { color: var(--text-2); max-width: 520px; }
.overlay .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.resume-banner {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 7px 7px 14px;
  border-radius: 999px;
  background: rgba(10, 9, 8, .72);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-2);
  font: 500 12px/1 var(--font-mono);
  color: var(--text);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
}
@starting-style { .resume-banner { opacity: 0; transform: translateY(-6px); } }
.resume-banner[hidden] { display: none; }
.resume-banner b { color: var(--accent); font-weight: 500; }
.resume-banner button {
  border: 0;
  border-radius: 999px;
  padding: 6px 11px;
  background: rgba(239, 230, 214, .12);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms var(--ease-out);
}
.resume-banner button:hover { background: rgba(239, 230, 214, .2); }
.resume-banner button:active { transform: scale(.96); }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 18px 0 30px;
}
.actions .spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.pill.done { color: var(--ink); background: var(--text); border-color: var(--text); }
.pill.done::before { background: var(--ink); }
.pill.partial { color: var(--accent); border-color: rgba(255, 91, 46, .4); background: var(--accent-soft); }
.pill.partial::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.speed {
  appearance: none;
  padding: 7px 30px 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: rgba(239, 230, 214, .03) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' fill='none' stroke='%238f8677' stroke-width='1.8' stroke-linecap='round'/></svg>") no-repeat right 9px center / 13px;
  font: 500 12px/1.2 var(--font-mono);
  cursor: pointer;
}
.speed option { background: var(--ink-3); }

.nav-pair { display: inline-flex; gap: 6px; }

/* interruttore Autoplay */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(239, 230, 214, .03);
  color: var(--muted);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms var(--ease-out);
}
.switch:active { transform: scale(.97); }
.switch-track {
  position: relative;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: var(--dim);
  transition: background-color 200ms ease;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 220ms var(--ease-out), background-color 200ms ease;
}
.switch[aria-checked="true"] { color: var(--text); border-color: rgba(255, 91, 46, .4); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(12px); background: #fff; }
@media (hover: hover) and (pointer: fine) { .switch:hover { border-color: rgba(239, 230, 214, .26); } }

/* conto alla rovescia dell'autoplay */
.go-next { position: relative; overflow: hidden; isolation: isolate; }
.go-next > span { position: relative; z-index: 1; }
.go-next.counting::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(255, 255, 255, .34);
  transform-origin: left;
  transform: scaleX(0);
  animation: count-fill var(--count, 5s) linear forwards;
}
@keyframes count-fill { to { transform: scaleX(1); } }
.countdown {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 18px;
  margin-top: 4px;
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: .08em;
  color: var(--text-2);
}
.countdown b { color: var(--accent-2); font-weight: 600; }
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 140ms ease;
}
.link-btn:hover { color: var(--text); }
.overlay .sub b { color: var(--text); font-weight: 600; }

/* scene (più video nella stessa lezione) */
.playlist {
  margin: -8px 0 30px;
  padding: 8px;
  border-radius: 16px;
  background: var(--ink-2);
  border: 1px solid var(--line);
}
.playlist-label {
  padding: 8px 10px 10px;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.playlist-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 14px;
  color: var(--text-2);
  transition: background-color 140ms ease;
}
.playlist-item .idx { font: 500 11px/1 var(--font-mono); color: var(--muted); min-width: 20px; }
@media (hover: hover) and (pointer: fine) { .playlist-item:hover { background: rgba(239, 230, 214, .04); color: var(--text); } }
.playlist-item.active { background: var(--accent-soft); color: var(--text); }
.playlist-item.active .idx { color: var(--accent); }
.playlist-item .row-meta { margin-left: auto; }

/* ---------------------------------------------------------------- dispense
   Ogni dispensa è un foglio stampato: colonna di lettura centrata,
   serif da lettura, titoli editoriali, schede per codice/prompt/azioni. */

.mat-label {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 8px 0 20px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  letter-spacing: -.02em;
}
.mat-label em { font-style: italic; color: var(--accent); }
.mat-label .mono { font-size: 11.5px; color: var(--muted); letter-spacing: .1em; }

.materials { display: flex; flex-direction: column; gap: 30px; }

.material {
  --measure: 690px;
  --gutter: 58px;
  --rust: #b8420f;
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  color: var(--paper-ink);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .36  0 0 0 0 .24  0 0 0 .07 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>"),
    linear-gradient(180deg, #f8f2e7 0%, #f2eadc 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .75),
    0 0 0 1px rgba(0, 0, 0, .28),
    0 2px 0 rgba(0, 0, 0, .25),
    0 50px 90px -48px rgba(0, 0, 0, .95);
}

.material-head { border-bottom: 1px solid var(--paper-line); }
.head-inner {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 30px var(--gutter) 22px;
}
.material-head .titles { flex: 1; min-width: 0; }
.material-head .kind {
  display: block;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--paper-muted);
}
.material-head .kind b { color: var(--rust); font-weight: 600; }
.material-head h3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 11px 0 0;
  font: 500 29px/1.12 var(--font-display);
  letter-spacing: -.022em;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}
.material-head .acts { display: flex; gap: 6px; flex: none; padding-bottom: 2px; }
.btn.paper {
  padding: 6px 11px;
  border-color: rgba(29, 25, 20, .14);
  background: rgba(255, 255, 255, .45);
  color: var(--paper-ink);
  font-size: 12px;
}

.material-body { padding: 22px var(--gutter); }
.material-body.flush { padding: 0; }
.material-body.note {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 26px var(--gutter) 30px;
  color: var(--paper-muted);
  font: italic 17px/1.6 var(--font-text);
}
.pdf-frame { width: 100%; height: 82vh; border: 0; display: block; background: var(--paper-2); }
.material-body img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 10px; }
.material-body audio { width: 100%; }
.paper-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 30px var(--gutter);
  color: var(--paper-muted);
  font: 12px var(--font-mono);
}

/* ---- il testo della dispensa */

.doc {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 42px var(--gutter) 58px;
  color: #221c16;
  font: 400 18px/1.76 var(--font-text);
  font-variation-settings: "opsz" 16;
  font-feature-settings: "kern", "liga", "onum";
  overflow-wrap: break-word;
  hanging-punctuation: first;
}
.doc > :first-child { margin-top: 0; }
.doc > :last-child { margin-bottom: 0; }
.doc p { margin: 0 0 1.05em; text-wrap: pretty; }
.doc p.indent { padding-left: 1.2em; border-left: 2px solid rgba(29, 25, 20, .14); }
.doc p.lead { font: italic 400 21px/1.55 var(--font-display); color: var(--paper-muted); }
.doc .doc-empty { color: var(--paper-muted); font-style: italic; }
.doc .plain-text { white-space: pre-wrap; }

/* attacco con capolettera */
.doc p.lead-in { font-size: 21px; line-height: 1.62; color: #1b1612; }
.doc p.lead-in::first-letter {
  float: left;
  margin: .08em .13em 0 -.03em;
  font: 400 4.25em/.8 var(--font-display);
  font-variation-settings: "opsz" 144;
  color: var(--rust);
}

/* frase breve in evidenza */
.doc p.punch {
  margin: 1.35em 0;
  padding-left: 20px;
  border-left: 2px solid var(--accent);
  font: italic 400 24px/1.38 var(--font-display);
  letter-spacing: -.01em;
  color: #1b1612;
}

.doc h2, .doc h3, .doc h4 { color: #1b1612; text-wrap: balance; }
.doc h2 {
  margin: 2.1em 0 .6em;
  font: 500 33px/1.1 var(--font-display);
  letter-spacing: -.025em;
  font-variation-settings: "opsz" 120;
}
.doc h2::before {
  content: "";
  display: block;
  width: 34px;
  height: 3px;
  margin-bottom: 20px;
  border-radius: 3px;
  background: var(--accent);
}
.doc h3 {
  margin: 1.8em 0 .5em;
  font: italic 500 25px/1.2 var(--font-display);
  letter-spacing: -.015em;
}
.doc h4 {
  margin: 2em 0 .55em;
  font: 600 12px/1.4 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rust);
}
.doc h2 + h3, .doc h2 + h4, .doc h3 + h4 { margin-top: .6em; }

.doc strong { font-weight: 650; color: #17120e; }
.doc em { font-style: italic; }
.doc a {
  color: var(--rust);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(184, 66, 15, .35);
  text-underline-offset: 3px;
  transition: text-decoration-color 140ms ease, color 140ms ease;
}
.doc a:hover { text-decoration-color: currentColor; }
.doc a.ext::after { content: "↗"; display: inline-block; margin-left: .15em; font-size: .72em; vertical-align: .18em; text-decoration: none; }

.doc ul, .doc ol { margin: 0 0 1.2em; padding-left: 1.35em; }
.doc li { margin: .38em 0; padding-left: .3em; }
.doc li > ul, .doc li > ol { margin: .3em 0 0; }
.doc ul { list-style: none; }
.doc ul > li { position: relative; }
.doc ul > li::before {
  content: "";
  position: absolute;
  left: -1.05em;
  top: .72em;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}
.doc ol > li::marker { font: 600 .8em var(--font-mono); color: var(--rust); }

.doc :not(pre) > code {
  padding: .1em .4em;
  border-radius: 6px;
  border: 1px solid rgba(29, 25, 20, .1);
  background: rgba(29, 25, 20, .055);
  font: 500 .8em/1.4 var(--font-mono);
  white-space: break-spaces;
}
.doc mark { padding: 0 .12em; border-radius: 2px; background: linear-gradient(transparent 52%, #ffd27f 52%); color: inherit; }
.doc hr {
  height: 20px;
  margin: 2.6em 0;
  border: 0;
  text-align: center;
  overflow: visible;
}
.doc hr::after {
  content: "✦   ✦   ✦";
  white-space: pre;
  font-size: 11px;
  letter-spacing: .3em;
  color: rgba(184, 66, 15, .55);
}
.doc img { display: block; max-width: 100%; height: auto; margin: 1.6em auto; border-radius: 12px; box-shadow: 0 22px 44px -28px rgba(0, 0, 0, .55); }
.doc blockquote {
  position: relative;
  margin: 1.5em 0;
  padding: .1em 0 .1em 1.3em;
  border-left: 2px solid var(--accent);
  font: italic 400 20px/1.55 var(--font-display);
  color: #3a3128;
}

.doc-table, .md-body table { margin: 1.6em 0; overflow-x: auto; border-radius: 12px; border: 1px solid var(--paper-line); background: rgba(255, 255, 255, .4); }
.doc table { width: 100%; border-collapse: collapse; font: 400 14.5px/1.55 var(--font-ui); }
.doc th, .doc td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--paper-line); }
.doc tr:last-child td { border-bottom: 0; }
.doc td + td, .doc th + th { border-left: 1px solid var(--paper-line); }
.doc th {
  background: rgba(29, 25, 20, .05);
  font: 600 11px/1.3 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--paper-muted);
}
.doc .md-body > :first-child { margin-top: 0; }
.doc .md-body h1 { margin: 0 0 .5em; font: 500 34px/1.1 var(--font-display); letter-spacing: -.025em; }

/* prompt dentro una frase */
.inline-prompt {
  padding: .08em .25em .08em .45em;
  border-radius: 8px;
  border: 1px solid rgba(184, 66, 15, .22);
  background: #fff4e3;
  font: 500 .88em/1.5 var(--font-ui);
  color: #2a2119;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.inline-prompt q { quotes: "“" "”"; }
.copy-mini {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  vertical-align: -5px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(184, 66, 15, .1);
  color: var(--rust);
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms var(--ease-out);
}
.copy-mini:hover { background: rgba(184, 66, 15, .18); }
.copy-mini:active { transform: scale(.92); }
.copy-mini svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.copy-mini.ok { background: #e4f0d6; color: #3f7d20; }

/* scheda "Azione" */
.action-card {
  margin: 2.2em 0;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(380px 160px at 0% 0%, rgba(255, 91, 46, .22), transparent 70%), #1c1814;
  color: #efe7da;
  box-shadow: 0 26px 50px -30px rgba(0, 0, 0, .8);
  transition: opacity 200ms ease;
}
.action-card header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 18px;
  align-items: center;
  padding: 20px 22px 18px 24px;
  border-bottom: 1px solid rgba(239, 230, 214, .08);
}
.action-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 10.5px/1 var(--font-mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #ff8b5e;
}
.action-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.action-card h3 {
  grid-column: 1;
  margin: 0;
  font: 500 25px/1.18 var(--font-display);
  letter-spacing: -.015em;
  color: #fff6e9;
  text-wrap: balance;
}
.action-done {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 9px;
  font: 500 10.5px/1 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #a89f91;
  cursor: pointer;
}
.action-check {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1.5px solid rgba(239, 230, 214, .32);
  background: transparent;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, transform 140ms var(--ease-out);
}
.action-check:active { transform: scale(.92); }
.action-check svg { width: 16px; height: 16px; fill: none; stroke: transparent; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; transition: stroke 180ms ease; }
.action-card.done .action-check { background: var(--accent); border-color: var(--accent); }
.action-card.done .action-check svg { stroke: #1a0a04; }
.action-card.done .action-done { color: #ff8b5e; }
.action-card.done h3 { text-decoration: line-through; text-decoration-color: rgba(255, 91, 46, .75); text-decoration-thickness: 2px; color: #cfc5b6; }
.action-body {
  padding: 18px 24px 22px;
  font: 400 16.5px/1.7 var(--font-text);
  color: #ddd3c4;
}
.action-body > :last-child { margin-bottom: 0; }
.action-body strong { color: #fff6e9; }
.action-body a { color: #ff8b5e; text-decoration-color: rgba(255, 139, 94, .4); }
.action-body p.punch { color: #fff6e9; font-size: 21px; }
.action-body :not(pre) > code { background: rgba(239, 230, 214, .08); border-color: rgba(239, 230, 214, .12); color: #fff6e9; }
.action-body .inline-prompt { background: rgba(255, 91, 46, .12); border-color: rgba(255, 91, 46, .3); color: #fff6e9; }
.action-body .copy-mini { background: rgba(255, 91, 46, .18); color: #ff8b5e; }
.action-body ul > li::before { background: var(--accent); }
.action-body .doc-empty { color: #a89f91; }

/* documento che contiene solo un link */
.doc-links { display: flex; flex-direction: column; gap: 12px; padding-top: 30px; padding-bottom: 34px; }
.link-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px 16px 16px;
  border-radius: 16px;
  border: 1px solid var(--paper-line);
  background: rgba(255, 255, 255, .55);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
  transition: border-color 180ms ease, transform 180ms var(--ease-out), box-shadow 180ms ease;
}
.link-card:active { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) {
  .link-card:hover { border-color: rgba(184, 66, 15, .45); transform: translateY(-1px); box-shadow: 0 18px 34px -24px rgba(0, 0, 0, .5); }
  .link-card:hover .link-go svg { transform: translateX(4px); }
}
.link-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--paper-line), 0 6px 14px -8px rgba(0, 0, 0, .35);
}
.link-icon { width: 28px; height: 28px; border-radius: 6px; }
.link-mono { font: italic 400 28px/1 var(--font-display); color: var(--rust); }
.link-text { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.link-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 24px/1.15 var(--font-display); letter-spacing: -.015em; color: #1b1612; }
.link-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 12px/1.3 var(--font-mono); color: var(--paper-muted); }
.link-go {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rust);
}
.link-go svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; transition: transform 200ms var(--ease-out); }

@media (max-width: 900px) {
  .material { --gutter: 22px; }
  .doc { font-size: 17px; padding-top: 30px; padding-bottom: 40px; }
  .doc p.lead-in { font-size: 19px; }
  .material-head h3 { font-size: 24px; }
  .head-inner { flex-direction: column; align-items: stretch; }
  .link-go { display: none; }
}

/* riquadro codice / terminale */
.code-block {
  position: relative;
  margin: 1.3em 0 1.5em;
  border-radius: 14px;
  background: #171411;
  color: #efe7da;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(239, 230, 214, .06), 0 22px 44px -26px rgba(0, 0, 0, .7);
}
.code-block figcaption {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid rgba(239, 230, 214, .07);
  background: rgba(239, 230, 214, .025);
}
.code-block .dots { display: flex; gap: 6px; }
.code-block .dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(239, 230, 214, .14); }
.code-block .dots i:first-child { background: #ff5b2e; }
.code-lang { font: 600 10.5px/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: #a89f91; }
.code-lines { font: 400 10.5px/1 var(--font-mono); color: #6f675c; }
.code-block .copy-btn { margin-left: auto; }
.code-block pre {
  margin: 0;
  padding: 18px 20px 20px;
  overflow-x: auto;
  font: 400 13.5px/1.7 var(--font-mono);
  tab-size: 2;
  white-space: pre;
}
.code-block code { font: inherit; background: none; border: 0; padding: 0; color: inherit; white-space: inherit; }
.code-block.collapsed pre { max-height: 440px; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent); mask-image: linear-gradient(to bottom, #000 72%, transparent); }
.expand-btn {
  display: block;
  width: 100%;
  padding: 11px;
  border: 0;
  border-top: 1px solid rgba(239, 230, 214, .07);
  background: rgba(239, 230, 214, .03);
  color: #ff8b5e;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 140ms ease;
}
.expand-btn:hover { background: rgba(239, 230, 214, .07); }

.copy-btn {
  flex: none;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(239, 230, 214, .16);
  background: rgba(239, 230, 214, .05);
  color: #efe7da;
  font: 500 11.5px/1 var(--font-mono);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms var(--ease-out);
}
.copy-btn:hover { background: rgba(239, 230, 214, .12); }
.copy-btn:active { transform: scale(.96); }
.copy-btn.ok { color: #c3d98c; border-color: rgba(195, 217, 140, .4); }
.copy-btn.light { border-color: var(--paper-line); background: rgba(255, 255, 255, .5); color: var(--paper-ink); }
.copy-btn.light:hover { background: #fff; border-color: rgba(29, 25, 20, .25); }
.copy-btn.light.ok { color: #3f7d20; border-color: rgba(63, 125, 32, .35); }

/* colori della sintassi (highlight.js) */
.code-block .hljs-comment, .code-block .hljs-quote { color: #857b6e; font-style: italic; }
.code-block .hljs-keyword, .code-block .hljs-selector-tag, .code-block .hljs-literal, .code-block .hljs-section, .code-block .hljs-doctag { color: #ff8b5e; }
.code-block .hljs-string, .code-block .hljs-regexp, .code-block .hljs-addition, .code-block .hljs-template-tag { color: #c3d98c; }
.code-block .hljs-number, .code-block .hljs-built_in, .code-block .hljs-type, .code-block .hljs-symbol, .code-block .hljs-bullet, .code-block .hljs-link { color: #e9b872; }
.code-block .hljs-title, .code-block .hljs-name, .code-block .hljs-selector-id, .code-block .hljs-selector-class { color: #fff6e9; font-weight: 600; }
.code-block .hljs-attr, .code-block .hljs-attribute, .code-block .hljs-variable, .code-block .hljs-template-variable, .code-block .hljs-params, .code-block .hljs-property { color: #9fcbdc; }
.code-block .hljs-meta, .code-block .hljs-subst { color: #c7b3e6; }
.code-block .hljs-deletion { color: #ff8a80; }
.code-block .hljs-emphasis { font-style: italic; }
.code-block .hljs-strong { font-weight: 700; }

/* prompt e Markdown */
.prompt-block, .md-block {
  margin: 1.3em 0 1.5em;
  border-radius: 14px;
  background: #fffaf2;
  border: 1px solid rgba(29, 25, 20, .12);
  box-shadow: 0 16px 34px -28px rgba(0, 0, 0, .55);
  overflow: hidden;
}
.prompt-block { border-left: 3px solid var(--accent); }
.prompt-block figcaption, .md-block figcaption {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 18px;
  border-bottom: 1px dashed rgba(29, 25, 20, .14);
}
.prompt-block figcaption .copy-btn, .md-block figcaption .copy-btn { margin-left: auto; }
.prompt-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 10.5px/1 var(--font-mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #c2410c;
}
.prompt-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.prompt-text {
  padding: 16px 20px 18px;
  white-space: pre-wrap;
  font: 400 15.5px/1.72 var(--font-ui);
  color: var(--paper-ink);
}
.note-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 1.3em 0 1.5em;
  padding: 16px 20px 17px;
  border-radius: 14px;
  background: var(--paper-2);
  border: 1px solid rgba(29, 25, 20, .08);
}
.note-block .prompt-label { color: var(--paper-muted); }
.note-block .prompt-label::before { background: var(--paper-muted); }
.note-body { white-space: pre-wrap; font-size: 15.5px; line-height: 1.7; }
.segmented { display: inline-flex; padding: 3px; border-radius: 9px; background: rgba(29, 25, 20, .06); }
.seg {
  padding: 5px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--paper-muted);
  font: 500 11.5px/1 var(--font-mono);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.seg.on { background: #fff; color: var(--paper-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.md-view { padding: 22px 24px 24px; }
.md-view[hidden], .md-source[hidden] { display: none; }
.md-source { padding: 0 14px 4px; }
.md-source .code-block { margin: 14px 0; }

.no-video {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 26px 28px;
  margin-bottom: 18px;
  border-radius: 18px;
  border: 1px dashed var(--line-2);
  color: var(--text-2);
}
.no-video svg { width: 30px; height: 30px; stroke: var(--accent); stroke-width: 1.4; fill: none; flex: none; }

/* taccuino */
.notes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 20px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(239, 230, 214, .03), transparent 40%), var(--ink-2);
  border: 1px solid var(--line);
  transition: border-color 200ms ease;
}
.notes:focus-within { border-color: rgba(255, 91, 46, .35); }
.notes-head { display: flex; align-items: center; gap: 10px; }
.notes-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -.02em;
}
.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 10px/1 var(--font-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.save-state.ok::before { background: var(--text); }
.save-state.busy::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.save-state:empty { display: none; }

.stamp-btn { gap: 5px; font-family: var(--font-mono); font-weight: 500; color: var(--accent); border-color: rgba(255, 91, 46, .35); }
.stamp-btn b { font-weight: 500; }

.notes textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  padding: 2px 2px;
  border: 0;
  outline: none;
  background:
    linear-gradient(transparent calc(1.8em - 1px), rgba(239, 230, 214, .075) 1px) 0 0 / 100% 1.8em local;
  font-size: 14.5px;
  line-height: 1.8em;
  color: var(--text);
  caret-color: var(--accent);
}
.notes textarea::placeholder { color: var(--muted); }

.stamps { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.stamps:empty { display: none; }
.stamp {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 140ms ease, transform 140ms var(--ease-out);
}
.stamp:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { .stamp:hover { background: rgba(239, 230, 214, .05); } }
.stamp b { color: var(--accent); font: 500 12px/1 var(--font-mono); }
.stamp span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font: 400 11px/1.4 var(--font-mono);
  color: var(--muted);
}
.shortcuts span { display: inline-flex; align-items: center; gap: 6px; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  font: 500 11px/1 var(--font-mono);
  color: var(--text);
}

/* pagina appunti */
.notes-page { max-width: 940px; }
.note-entry {
  position: relative;
  padding: 22px 26px 24px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  animation: rise 340ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.note-entry h3 { margin: 8px 0 12px; font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: -.015em; }
.note-entry h3 a { text-decoration: none; transition: color 140ms ease; }
.note-entry h3 a:hover { color: var(--accent); }
.note-entry h3 .num { color: var(--accent); font-style: italic; margin-right: 8px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); line-height: 1.7; }
.note-text .ts { color: var(--accent); font: 500 12.5px var(--font-mono); }
.empty-state {
  padding: 46px 30px;
  border-radius: 18px;
  border: 1px dashed var(--line-2);
  color: var(--text-2);
  text-align: center;
}

/* ---------------------------------------------------------------- setup */

.setup-wrap { max-width: 860px; margin: 4vh auto 0; }
.setup-wrap .display { font-size: clamp(44px, 6vw, 86px); }
.setup-lead { margin: 22px 0 36px; max-width: 620px; font-size: 17px; color: var(--text-2); }
.setup-lead code, .steps code {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(239, 230, 214, .07);
  font: 13px var(--font-mono);
  color: var(--text);
}
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; border-top: 1px solid var(--line); }
.steps li {
  counter-increment: s;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  animation: rise 360ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 50ms + 80ms);
}
.steps li::before {
  content: counter(s, decimal-leading-zero);
  font: italic 300 30px/1 var(--font-display);
  color: var(--accent);
}
.steps a { color: var(--text); text-decoration-color: rgba(255, 91, 46, .6); text-underline-offset: 3px; }
.steps b { color: var(--text); }
.setup-row { display: flex; gap: 10px; margin-top: 34px; flex-wrap: wrap; }
.callout {
  display: flex;
  gap: 14px;
  margin-top: 28px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 91, 46, .3);
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 14.5px;
}
.callout b { color: var(--text); }

/* ---------------------------------------------------------------- stati */

.loading {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18vh 0 0;
  justify-content: center;
  font: 500 12px/1.5 var(--font-mono);
  letter-spacing: .08em;
  color: var(--text-2);
  text-align: left;
}
.reel-spin {
  position: relative;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin 650ms linear infinite;
}
.reel-spin::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 2px dotted rgba(239, 230, 214, .35);
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--paper-line);
  border-top-color: var(--accent);
  animation: spin 650ms linear infinite;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px 12px 14px;
  border-radius: 14px;
  background: rgba(36, 32, 28, .92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-2);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .7);
  font-size: 14px;
  transform: translateX(-50%);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); flex: none; }
@starting-style { .toast { opacity: 0; transform: translate(-50%, 10px); } }
.toast[hidden] { display: none; }

/* ---------------------------------------------------------- responsive */

@media (max-width: 1280px) {
  .lesson-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "side" "mat"; }
  .lesson-side { position: static; margin-bottom: 34px; }
  .notes textarea { min-height: 180px; }
  .main { padding: 36px 36px 100px; }
}

@media (max-width: 900px) {
  :root { --topbar: 108px; }
  .topbar { flex-wrap: wrap; align-content: center; row-gap: 4px; column-gap: 12px; padding: 10px 14px 0; }
  .course-tabs { order: 3; flex-basis: 100%; height: 44px; align-self: auto; }
  .top-actions { margin-left: auto; }
  .top-actions .btn { padding: 8px 9px; }
  .menu-btn { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--topbar);
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(88vw, var(--sidebar));
    background: var(--ink-2);
    transform: translateX(-100%);
    transition: transform 320ms var(--ease-drawer);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 35;
    background: rgba(0, 0, 0, .5);
  }
  .main { padding: 26px 18px 80px; }
  .reel { grid-template-columns: auto minmax(0, 1fr); padding: 20px; gap: 18px; }
  .reel .reel-cta { display: none; }
  .play-disc { width: 56px; height: 56px; }
  .reel-title { font-size: 23px; }
  .hero-stats { gap: 18px 30px; }
  .stat b { font-size: 32px; }
  .lesson-head .ghost-num { font-size: 150px; top: -40px; }
  .material:nth-child(n) { transform: none; }
}

/* telefono: una sola riga in alto, azioni come icone */
@media (max-width: 640px) {
  :root { --topbar: 96px; }
  .topbar { padding: 6px 6px 0 4px; column-gap: 2px; row-gap: 2px; }
  .brand { font-size: 21px; gap: 9px; margin-left: 2px; }
  .top-actions { gap: 0; }
  .top-actions .btn { width: 42px; height: 42px; padding: 0; }
  .top-actions .ico { display: block; }
  .top-actions .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .course-tabs { height: 42px; gap: 0; margin: 0 -6px 0 -4px; padding: 0 4px; }
  .course-tab { padding: 0 12px; font-size: 13.5px; }
  .main { padding: 22px 14px 80px; }
  .material { --gutter: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .reel-spin, .spinner { animation-duration: 1.6s !important; }
}
