/* ============================================================
   STUDIO — sistema grafico "Manifesto + ritagli"
   Carta chiara, colori primari pieni, titoli grotesk in maiuscolo.
   Ogni colore ha un ruolo: blu = azioni, rosso = avvisi,
   senape = crediti e attese, verde = fatto.
   ============================================================ */

/* ── Font (ospitati qui: nessuna richiesta a Google) ── */
@font-face { font-family: 'League Spartan'; src: url('../fonts/league-spartan-v2.woff2') format('woff2'); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('../fonts/hanken-grotesk.woff2') format('woff2'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Hanken Grotesk'; src: url('../fonts/hanken-grotesk-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Permanent Marker'; src: url('../fonts/permanent-marker.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

/* ── Token ── */
:root {
  --carta:       #F5EFE3;
  --foglio:      #FFFDF8;
  --foglio-2:    #F0E9DA;
  --inchiostro:  #1A1712;
  --grafite:     #5E574B;
  --riga:        #DDD3C1;
  --riga-forte:  #1A1712;

  --blu:         #2340B8;
  --blu-testo:   #2340B8;
  --blu-tinta:   #E3E7F6;
  --rosso:       #E3452F;
  --rosso-testo: #C9361F;
  --rosso-tinta: #FBE3DE;
  --senape:      #EBAE2C;
  --senape-tinta:#FAEBC8;
  --verde:       #2E7A4B;
  --verde-tinta: #DDEEE2;
  --rosa:        #F1A6B5;
  --su-colore:   #FFFFFF;
  --ombra:       0 10px 30px rgba(26, 23, 18, .12);

  /* alias usati nel codice esistente */
  --bg: var(--carta); --surface: var(--foglio); --surface2: var(--foglio-2); --border: var(--riga);
  --text: var(--inchiostro); --text-dim: var(--grafite); --text-mid: var(--grafite);
  --gold: var(--blu-testo); --danger: var(--rosso-testo); --success: var(--verde);

  --f-display: 'League Spartan', 'Futura', 'Avenir Next', system-ui, sans-serif;
  --f-testo:   'Hanken Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --f-mano:    'Permanent Marker', 'Marker Felt', 'Comic Sans MS', cursive;
  --font-sans: var(--f-testo); --font-serif: var(--f-display);
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --radius:    4px;
  --radius-lg: 6px;
  --tap:       44px;
  --sidebar-w: 252px;
  --tabbar-h:  64px;
  --transition: 160ms cubic-bezier(.4, 0, .2, 1);
  color-scheme: light;
}
/* Tema scuro: automatico dal sistema, oppure scelto a mano (data-theme su <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --carta: #15182B; --foglio: #1E2238; --foglio-2: #262B45; --inchiostro: #F2EBDD; --grafite: #A9A293;
    --riga: #343957; --riga-forte: #F2EBDD;
    --blu: #3A57D6; --blu-testo: #9DB0FF; --blu-tinta: #232C5C;
    --rosso-testo: #FF8A6E; --rosso-tinta: #4A2530;
    --senape-tinta: #4A3E22; --verde: #6FCB8F; --verde-tinta: #1F3A31;
    --ombra: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --carta: #15182B; --foglio: #1E2238; --foglio-2: #262B45; --inchiostro: #F2EBDD; --grafite: #A9A293;
  --riga: #343957; --riga-forte: #F2EBDD;
  --blu: #3A57D6; --blu-testo: #9DB0FF; --blu-tinta: #232C5C;
  --rosso-testo: #FF8A6E; --rosso-tinta: #4A2530;
  --senape-tinta: #4A3E22; --verde: #6FCB8F; --verde-tinta: #1F3A31;
  --ombra: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  background: var(--carta);
  color: var(--inchiostro);
  font: 400 1rem/1.6 var(--f-testo);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
body::after { /* grana della carta */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 2000; opacity: .06;
  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='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
a { color: var(--blu-testo); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
strong, b { font-weight: 700; }
:focus-visible { outline: 3px solid var(--blu-testo); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--senape); color: #1A1712; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Tipografia ── */
h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.01em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.4rem, 7vw, 4.5rem); font-weight: 900; text-transform: uppercase; }
h2 { font-size: clamp(1.9rem, 5vw, 2.8rem); font-weight: 900; text-transform: uppercase; }
h3 { font-size: 1.3rem; line-height: 1.15; }
h4 { font-size: 1.05rem; line-height: 1.2; }
p { max-width: 70ch; }
.mono  { font-family: var(--font-mono); font-size: .85em; }
.tnum  { font-variant-numeric: tabular-nums; }
.dim   { color: var(--grafite); }
.mid   { color: var(--grafite); }
.gold  { color: var(--blu-testo); }
.small { font-size: .85rem; }
.label, .eyebrow {
  display: block;
  font: 700 .75rem/1.2 var(--f-testo);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--grafite);
}
.mano { font-family: var(--f-mano); font-weight: 400; letter-spacing: .01em; }
.nota-mano { font-family: var(--f-mano); color: var(--rosso-testo); font-size: 1.1rem; display: inline-block; transform: rotate(-2deg); }

/* ── Logo a ritagli ── */
.logo-cut { display: inline-flex; gap: 2px; align-items: flex-end; text-decoration: none; }
.logo-cut:hover { text-decoration: none; }
.logo-cut b {
  font: 900 1.6rem/1 var(--f-display);
  text-transform: uppercase;
  padding: .2em .1em .02em;
  color: #FFFFFF;
  display: inline-block;
}
.logo-cut b:nth-of-type(1) { background: #2340B8; transform: rotate(-4deg); }
.logo-cut b:nth-of-type(2) { background: #E3452F; transform: rotate(3deg) translateY(-2px); }
.logo-cut b:nth-of-type(3) { background: #EBAE2C; color: #1A1712; transform: rotate(-1deg); }
.logo-cut b:nth-of-type(4) { background: #2E7A4B; transform: rotate(3deg) translateY(1px); }
.logo-cut b:nth-of-type(5) { background: #1A1712; transform: rotate(-2deg); }
.logo-cut b:nth-of-type(6) { background: #F1A6B5; color: #1A1712; transform: rotate(2deg) translateY(-1px); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-cut b:nth-of-type(5) { background: #F2EBDD; color: #1A1712; } }
:root[data-theme="dark"] .logo-cut b:nth-of-type(5) { background: #F2EBDD; color: #1A1712; }
/* quadrato del logo personale: alto quanto un ritaglio (1em + padding) */
.logo-cut .logo-mark { font-size: 1.6rem; width: 1.15em; height: 1.15em; flex-shrink: 0; margin-right: .3em; align-self: center; }
.logo-cut.lg b, .logo-cut.lg .logo-mark { font-size: clamp(3.2rem, 14vw, 7rem); }
.logo-cut.lg b { padding: .16em .08em 0; }
.logo-cut.md b, .logo-cut.md .logo-mark { font-size: 2.4rem; }

/* ══════════════════════════════════════════════
   STRUTTURA APP
   ══════════════════════════════════════════════ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  background: var(--foglio);
  border-right: 2px solid var(--riga-forte);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-logo { padding: 1.5rem 1.25rem 1.25rem; display: grid; gap: .6rem; }
.sidebar-logo p { font: 700 .72rem/1 var(--f-testo); letter-spacing: .12em; text-transform: uppercase; color: var(--grafite); }
.sidebar-nav { padding: .25rem .75rem 1rem; flex: 1; display: grid; align-content: start; gap: 2px; }
.nav-label {
  font: 700 .7rem/1 var(--f-testo);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--grafite);
  padding: 1.1rem .75rem .45rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 40px;
  padding: .45rem .75rem;
  color: var(--inchiostro);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: var(--foglio-2); text-decoration: none; }
.nav-link.active { background: var(--inchiostro); color: var(--carta); font-weight: 700; }
.nav-link .badge, .badge {
  margin-left: auto;
  background: var(--rosso);
  color: #FFFFFF;
  font: 700 .72rem/1 var(--f-testo);
  min-width: 22px;
  padding: .3rem .45rem;
  border-radius: 99px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-footer { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid var(--riga); display: grid; gap: .6rem; }
.user-chip { display: flex; align-items: center; gap: .7rem; min-width: 0; color: inherit; text-decoration: none; }
.user-chip:hover { text-decoration: none; }
.avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--senape); color: #1A1712;
  font: 900 1.05rem/1 var(--f-display);
  padding-top: 3px;
  transform: rotate(-4deg);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { min-width: 0; }
.user-info p { font-size: .9rem; font-weight: 700; line-height: 1.2; }
.user-info span { display: block; font-size: .75rem; color: var(--grafite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .link-row { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .85rem; }
.sidebar-footer .link-row a, .sidebar-footer .link-row button { color: var(--grafite); background: none; border: 0; font: inherit; cursor: pointer; padding: .35rem 0; text-decoration: underline; text-underline-offset: 3px; }

.main {
  padding: 2.5rem clamp(1.25rem, 4vw, 3.5rem) 4rem;
  max-width: 1180px;
  width: 100%;
  min-width: 0;
}

/* Barra superiore e tab da telefono */
.mobile-bar, .tabbar, .sheet-close { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    position: sticky; top: 0; z-index: 850;
    min-height: 56px;
    padding: calc(.5rem + env(safe-area-inset-top, 0px)) 1rem .5rem;
    background: var(--foglio);
    border-bottom: 2px solid var(--riga-forte);
  }
  .mobile-bar .logo-cut b, .mobile-bar .logo-cut .logo-mark { font-size: 1.25rem; }
  .mobile-bar-back {
    display: inline-flex; align-items: center; gap: .35rem; min-height: var(--tap);
    font-weight: 700; color: var(--inchiostro); text-decoration: none; min-width: 0;
  }
  .mobile-bar-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bar-back svg { width: 20px; height: 20px; flex-shrink: 0; }
  .mobile-bar .avatar { width: 34px; height: 34px; }

  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed; inset: 0; z-index: 1500;
    height: auto; border-right: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheetIn .2s ease;
  }
  .sheet-close {
    display: inline-flex; position: absolute; top: calc(.9rem + env(safe-area-inset-top, 0px)); right: 1rem;
    width: var(--tap); height: var(--tap); align-items: center; justify-content: center;
    background: var(--carta); border: 2px solid var(--riga-forte); border-radius: 50%;
    color: var(--inchiostro); font-size: 1.4rem; cursor: pointer;
  }
  .sidebar-logo { padding-top: calc(1.5rem + env(safe-area-inset-top, 0px)); }
  .nav-link { min-height: var(--tap); font-size: 1.02rem; }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    background: var(--foglio);
    border-top: 2px solid var(--riga-forte);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tab {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: var(--tabbar-h);
    color: var(--grafite); text-decoration: none;
    font: 700 .68rem/1 var(--f-testo); letter-spacing: .02em;
    background: none; border: 0; cursor: pointer;
  }
  .tab svg { width: 24px; height: 24px; }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--inchiostro); }
  .tab.active::before { content: ""; position: absolute; top: -2px; left: 22%; right: 22%; height: 5px; background: var(--rosso); transform: rotate(-1.5deg); }
  .tab .badge { position: absolute; top: 7px; left: calc(50% + 6px); margin: 0; font-size: .65rem; min-width: 18px; padding: .2rem .35rem; }

  .main { padding: 1.5rem 1rem calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
}
@keyframes sheetIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Intestazione pagina ── */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap;
  margin-bottom: 2rem;
}
.page-header > div:first-child, .page-header-text { min-width: 0; max-width: 100%; }
.page-header h2 { margin-bottom: .45rem; overflow-wrap: anywhere; }
.page-header p { color: var(--grafite); font-size: 1.02rem; }
.page-header .eyebrow { margin-bottom: .6rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back-link {
  display: inline-flex; align-items: center; gap: .35rem;
  font-weight: 700; font-size: .92rem; color: var(--inchiostro);
  margin-bottom: 1.25rem; min-height: 32px;
}
.back-link svg { width: 18px; height: 18px; }
@media (max-width: 900px) {
  .back-link { display: none; } /* sostituito dalla freccia nella barra in alto */
  .page-header { margin-bottom: 1.5rem; }
}

.section-title {
  font: 800 1.15rem/1.1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: .01em;
  margin: 2.25rem 0 .9rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.section-title:first-child { margin-top: 0; }

/* ── Card ── */
.card {
  background: var(--foglio);
  border: 1px solid var(--riga);
  border-radius: var(--radius-lg);
  padding: clamp(1.1rem, 3vw, 1.6rem);
  position: relative;
  min-width: 0;
}
.card + .card { margin-top: 1rem; }
.card > h3:first-child, .card-head { margin-bottom: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.card-tab {
  position: absolute; top: -11px; left: 16px;
  padding: .3rem .6rem .2rem;
  font: 800 .72rem/1 var(--f-display); letter-spacing: .06em; text-transform: uppercase;
  color: #FFFFFF; background: #C9361F;
  transform: rotate(-2deg);
}
.card-tab.blu { background: var(--blu); }
.card-tab.senape { background: var(--senape); color: #1A1712; }
.card.flat { background: transparent; border-style: dashed; }
.card.link-card { display: block; color: inherit; text-decoration: none; transition: transform var(--transition), border-color var(--transition); }
.card.link-card:hover { border-color: var(--riga-forte); transform: rotate(-.4deg); text-decoration: none; }

.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: .5rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.divider { border: 0; border-top: 1px solid var(--riga); margin: 1.5rem 0; }

/* ── Griglie ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.grid-2 > .card, .grid-3 > .card, .grid-auto > .card, .split > .card, .stack > .card, .summary > .card { margin: 0; }
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ── Numeri ── */
.stat-card {
  background: var(--foglio);
  border: 1px solid var(--riga);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: grid; gap: .35rem; align-content: start;
  color: inherit; text-decoration: none; min-width: 0;
}
a.stat-card:hover { border-color: var(--riga-forte); text-decoration: none; }
.stat-card .label { margin: 0; }
.stat-card .value { font: 900 2.6rem/.9 var(--f-display); font-variant-numeric: tabular-nums; color: var(--inchiostro); }
.stat-card .value.gold, .stat-card.alert-stat .value { color: var(--rosso-testo); }
.stat-card .hint { font-size: .85rem; color: var(--grafite); }
.stat-card.senape { background: var(--senape); border-color: var(--senape); color: #1A1712; }
.stat-card.senape .label, .stat-card.senape .value, .stat-card.senape .hint { color: #1A1712; }
.stat-card.blu { background: var(--blu); border-color: var(--blu); color: #FFFFFF; }
.stat-card.blu .label, .stat-card.blu .value, .stat-card.blu .hint { color: #FFFFFF; }
.stat-card.blu a { color: #FFFFFF; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 1rem; margin-bottom: 2rem; }

/* ── Bottoni ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap);
  padding: .6rem 1.15rem;
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius);
  background: var(--foglio);
  color: var(--inchiostro);
  font: 700 .95rem/1.1 var(--f-testo);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: rotate(-1.2deg) translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--blu); border-color: var(--blu); color: #FFFFFF; }
.btn-accent  { background: var(--senape); border-color: var(--senape); color: #1A1712; }
.btn-ghost   { background: transparent; }
.btn-ghost:hover { background: var(--foglio); }
.btn-danger  { background: transparent; border-color: var(--rosso-testo); color: var(--rosso-testo); }
.btn-danger:hover { background: var(--rosso-testo); color: #FFFFFF; }
.btn-link    { border-color: transparent; background: transparent; color: var(--blu-testo); padding-inline: .25rem; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { transform: none; }
.btn-sm { min-height: 36px; padding: .4rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: .8rem 1.4rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
@media (max-width: 900px) { .btn-sm { min-height: 40px; } }
@media (prefers-reduced-motion: reduce) { .btn, .card.link-card { transition: none; } .btn:hover, .card.link-card:hover { transform: none; } }

/* ── Form ── */
.form-group { margin-bottom: 1.1rem; min-width: 0; }
label, .field-label {
  display: block;
  font: 700 .88rem/1.3 var(--f-testo);
  color: var(--inchiostro);
  margin-bottom: .4rem;
}
.hint, .form-hint { display: block; font-size: .8rem; color: var(--grafite); margin-top: .35rem; font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], input[type="url"], input[type="tel"],
select, textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--foglio);
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius);
  color: var(--inchiostro);
  font: 400 1rem/1.35 var(--f-testo);  /* 16px: niente zoom automatico su iPhone */
  padding: .55rem .8rem;
  transition: box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
select {
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' fill='none' stroke='%235E574B' stroke-width='2.2'/></svg>");
  background-repeat: no-repeat; background-position: right .85rem center;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--blu-tinta), 0 0 0 5px var(--blu-testo); }
input::placeholder, textarea::placeholder { color: var(--grafite); opacity: .75; }
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input[type="color"] { width: 100%; height: var(--tap); padding: .2rem; border: 2px solid var(--riga-forte); border-radius: var(--radius); background: var(--foglio); cursor: pointer; }
input[type="file"] { font: inherit; font-size: .9rem; color: var(--grafite); max-width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--blu); width: 20px; height: 20px; flex-shrink: 0; }
.check {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 500; font-size: .95rem; margin: 0;
  min-height: var(--tap); cursor: pointer;
}
.check-row { display: flex; gap: .25rem 1.25rem; flex-wrap: wrap; }
.choice-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.choice {
  display: inline-flex; align-items: center; gap: .5rem; margin: 0;
  min-height: var(--tap); padding: .45rem .85rem;
  border: 2px solid var(--riga); border-radius: var(--radius);
  font-weight: 600; font-size: .92rem; cursor: pointer; background: var(--foglio);
}
.choice:has(input:checked) { border-color: var(--riga-forte); background: var(--carta); }
.choice input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1.25rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 0 1rem; }

/* ── Tabelle ── */
.table-wrap { overflow-x: auto; margin: 0 -.25rem; padding: 0 .25rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th {
  text-align: left;
  font: 700 .72rem/1.2 var(--f-testo);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--grafite);
  padding: .6rem .75rem;
  border-bottom: 2px solid var(--riga-forte);
  white-space: nowrap;
}
td { padding: .8rem .75rem; border-bottom: 1px solid var(--riga); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--carta) 60%, transparent); }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .row { justify-content: flex-end; flex-wrap: nowrap; }
.table-empty { text-align: center; padding: 2rem; color: var(--grafite); }
/* Tabelle che su telefono diventano schede */
@media (max-width: 760px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: .9rem 0; border-bottom: 1px solid var(--riga); }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards tbody tr:hover td { background: none; }
  .table-cards td { border: 0; padding: .2rem 0; display: flex; gap: .75rem; justify-content: space-between; align-items: center; text-align: right; }
  .table-cards td::before { content: attr(data-label); font: 700 .72rem/1.2 var(--f-testo); letter-spacing: .08em; text-transform: uppercase; color: var(--grafite); text-align: left; flex-shrink: 0; }
  .table-cards td[data-label=""]::before, .table-cards td:not([data-label])::before { content: none; }
  .table-cards td.cell-title { font-size: 1.05rem; font-weight: 700; text-align: left; justify-content: flex-start; padding-bottom: .35rem; }
  .table-cards td.actions { justify-content: flex-start; padding-top: .6rem; }
  .table-cards td.actions .row { justify-content: flex-start; flex-wrap: wrap; }
  .table-cards td.table-empty { justify-content: center; }
  .table-wrap:has(.table-cards) { overflow: visible; }
}

/* ── Etichette di stato ── */
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .32rem .6rem .28rem;
  border-radius: 2px;
  font: 700 .72rem/1.1 var(--f-testo);
  letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap;
  border: 0;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.no-dot::before { content: none; }
.pill-yellow { background: var(--senape-tinta); color: var(--inchiostro); }
.pill-yellow::before { background: var(--senape); }
.pill-gold   { background: var(--blu-tinta); color: var(--blu-testo); }
.pill-green  { background: var(--verde-tinta); color: var(--verde); }
.pill-red    { background: var(--rosso-tinta); color: var(--rosso-testo); }
.pill-gray   { background: transparent; color: var(--grafite); box-shadow: inset 0 0 0 1.5px var(--riga); }
.pill-course { background: transparent; color: var(--inchiostro); box-shadow: inset 0 0 0 1.5px var(--riga); }
.pill-course::before { background: var(--c, var(--blu)); border-radius: 1px; transform: rotate(45deg); }
button.pill { cursor: pointer; min-height: 32px; }
button.pill:hover { box-shadow: inset 0 0 0 1.5px var(--riga-forte); }

/* ── Avvisi ── */
.alert {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .95rem;
  margin-bottom: 1.25rem;
  border-left: 6px solid;
  background: var(--foglio);
  transition: opacity .4s ease;
}
.alert-error   { border-color: var(--rosso); background: var(--rosso-tinta); color: var(--inchiostro); }
.alert-success { border-color: var(--verde); background: var(--verde-tinta); color: var(--inchiostro); }
.alert-info    { border-color: var(--blu); background: var(--blu-tinta); color: var(--inchiostro); }
.alert .alert-close { margin-left: auto; background: none; border: 0; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .25rem; opacity: .6; }

/* ── Stati vuoti con ritaglio ── */
.empty {
  display: grid; justify-items: center; text-align: center; gap: .6rem;
  padding: 2.5rem 1.25rem;
  background: var(--foglio); border: 1px dashed var(--riga); border-radius: var(--radius-lg);
  color: var(--grafite);
}
.empty img { width: 110px; height: auto; transform: rotate(-6deg); margin-bottom: .25rem; }
.empty h3 { color: var(--inchiostro); text-transform: uppercase; }
.empty p { max-width: 42ch; }

/* ── Chat ── */
.chat-wrap {
  display: flex; flex-direction: column;
  height: min(520px, 70vh);
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--foglio);
}
.chat-messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem;
  background: var(--carta);
}
.msg { max-width: 82%; padding: .6rem .9rem; font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere; }
.msg-them { background: var(--foglio); border: 1px solid var(--riga); align-self: flex-start; border-radius: 14px 14px 14px 3px; }
.msg-me   { background: var(--blu); color: #FFFFFF; align-self: flex-end; border-radius: 14px 14px 3px 14px; }
.msg-meta { font-size: .72rem; opacity: .75; margin-top: .3rem; }
.chat-empty { margin: auto; text-align: center; color: var(--grafite); font-size: .92rem; display: grid; gap: .5rem; justify-items: center; }
.chat-empty img { width: 72px; transform: rotate(8deg); }
.chat-form {
  display: flex; gap: .5rem; align-items: flex-end;
  padding: .6rem;
  background: var(--foglio);
  border-top: 2px solid var(--riga-forte);
}
.chat-form input, .chat-form textarea { flex: 1; min-width: 0; min-height: var(--tap); }
.chat-form textarea { min-height: var(--tap); max-height: 140px; height: var(--tap); resize: none; }
.chat-new { position: sticky; bottom: 0; align-self: center; }

.convo-list { display: grid; }
.jump-back { display: none; font-weight: 700; margin-bottom: .35rem; }
@media (max-width: 900px) { .jump-back { display: inline-block; } }
.convo {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--riga);
  color: inherit; text-decoration: none;
}
.convo:last-child { border-bottom: 0; }
.convo:hover { background: var(--carta); text-decoration: none; }
.convo.active { background: var(--carta); box-shadow: inset 5px 0 0 var(--rosso); }
.convo strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo .sub { grid-column: 1; font-size: .85rem; color: var(--grafite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo .when { grid-column: 2; grid-row: 1; font-size: .75rem; color: var(--grafite); font-variant-numeric: tabular-nums; }
.convo .badge { grid-column: 2; grid-row: 2; justify-self: end; margin: 0; }

.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.chat-layout > .card { padding: 0; overflow: hidden; }
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-layout.has-selection .convo-pane { display: none; }
  .chat-layout:not(.has-selection) .chat-pane { display: none; }
  .chat-layout .chat-wrap { height: calc(100dvh - 56px - var(--tabbar-h) - 9rem); min-height: 360px; }
}

/* ── Caricamento file ── */
.drop-zone {
  display: grid; justify-items: center; gap: .6rem;
  border: 2px dashed var(--riga-forte);
  border-radius: var(--radius-lg);
  padding: 2rem 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--carta);
  transition: background var(--transition), transform var(--transition);
  margin: 0;
  font-weight: 400;
}
.drop-zone:hover, .drop-zone.drag-over { background: var(--senape-tinta); }
.drop-zone:focus-within { outline: 3px solid var(--blu-testo); outline-offset: 2px; }
.drop-zone svg { width: 40px; height: 40px; color: var(--blu-testo); }
.drop-zone p { color: var(--inchiostro); font-size: .98rem; font-weight: 600; }
.drop-zone .hint { margin: 0; }
.drop-zone.has-file { border-style: solid; background: var(--verde-tinta); }
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ── Toast ── */
#toast-container {
  position: fixed; z-index: 3000;
  right: 1.25rem; bottom: 1.25rem;
  display: flex; flex-direction: column; gap: .5rem;
  max-width: calc(100vw - 2rem);
}
.toast {
  background: var(--inchiostro); color: var(--carta);
  border-left: 6px solid var(--verde);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  font-size: .92rem; font-weight: 500;
  min-width: 240px;
  box-shadow: var(--ombra);
  animation: slideIn .25s ease;
}
.toast.toast-error { border-left-color: var(--rosso); }
@media (max-width: 900px) { #toast-container { left: 1rem; right: 1rem; bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom, 0px)); } }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Finestre (dialog) ── */
dialog.modal {
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius-lg);
  background: var(--foglio); color: var(--inchiostro);
  padding: 1.5rem;
  width: min(440px, calc(100vw - 2rem));
  margin: auto;
  box-shadow: var(--ombra);
}
dialog.modal::backdrop { background: rgba(21, 24, 43, .55); }
dialog.modal h3 { margin-bottom: .75rem; padding-right: 2rem; }
dialog.modal .modal-close { position: absolute; top: .75rem; right: .75rem; width: 40px; height: 40px; border: 0; background: none; font-size: 1.5rem; color: var(--grafite); cursor: pointer; }
@media (max-width: 600px) {
  dialog.modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 12px 12px 0 0; border-width: 2px 0 0; padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
}

/* ══════════════════════════════════════════════
   STUDENTE: percorsi ed esercizi
   ══════════════════════════════════════════════ */
.hello { display: grid; gap: .3rem; margin-bottom: 1.75rem; }
.hello h2 { font-size: clamp(2.2rem, 8vw, 3.6rem); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.summary .stat-card { position: relative; overflow: hidden; }
.summary .stat-card .value.sm { font-size: 1.55rem; line-height: 1; text-transform: uppercase; }
.summary .stat-card .btn { justify-self: start; margin-top: .4rem; }
.summary .blob { position: absolute; width: 86px; height: 86px; right: -20px; bottom: -24px; background: var(--rosso); border-radius: 58% 42% 55% 45% / 45% 55% 45% 55%; pointer-events: none; }

.course-card {
  background: var(--foglio);
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 2rem;
}
.course-card-header {
  padding: 1.35rem 1.4rem 1.1rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap;
  border-top: 0;
}
.course-card-header h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.course-card-header p { font-size: .95rem; color: var(--grafite); margin-top: .4rem; }
.course-card-meta { font: 700 .72rem/1.2 var(--f-testo); letter-spacing: .08em; text-transform: uppercase; color: var(--grafite); text-align: right; }
.course-card-meta strong { display: block; font: 900 2.2rem/1 var(--f-display); letter-spacing: 0; color: var(--inchiostro); font-variant-numeric: tabular-nums; }

.progress-bar { height: 10px; background: var(--foglio-2); border-top: 1px solid var(--riga); border-bottom: 1px solid var(--riga); }
.progress-bar-fill { height: 100%; background: var(--verde); transition: width .5s ease; }
.progress-steps { display: flex; gap: 3px; padding: 0 1.4rem 1rem; }
.progress-steps i { flex: 1; height: 10px; background: var(--foglio-2); box-shadow: inset 0 0 0 1px var(--riga); display: block; }
.progress-steps i.done { background: var(--verde); box-shadow: none; }
.progress-steps i.wait { background: var(--senape); box-shadow: none; }
.progress-steps i.fix  { background: var(--rosso); box-shadow: none; }

.exercise-track { border-top: 1px solid var(--riga); }
.exercise-row {
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto auto; align-items: center; gap: .5rem .9rem;
  padding: .8rem 1.4rem;
  min-height: 60px;
  border-top: 1px solid var(--riga);
  color: var(--inchiostro); text-decoration: none;
  transition: background var(--transition);
}
.exercise-row:first-child { border-top: 0; }
.exercise-row:hover { background: var(--carta); text-decoration: none; }
.exercise-row .ex-num { font: 900 1.35rem/1 var(--f-display); color: var(--grafite); font-variant-numeric: tabular-nums; padding-top: 3px; }
.exercise-row .ex-title { font-weight: 700; font-size: 1rem; min-width: 0; }
.exercise-row .ex-title small { display: block; font-weight: 400; font-size: .8rem; color: var(--grafite); }
.exercise-row .ex-msgs { font: 700 .72rem/1 var(--f-testo); color: #FFFFFF; background: var(--rosso); padding: .3rem .5rem; border-radius: 99px; white-space: nowrap; }
.exercise-row .ex-arrow { color: var(--grafite); font-size: 1.1rem; }
.exercise-row.is-next { background: var(--senape-tinta); }
.exercise-row.is-locked { color: var(--grafite); cursor: not-allowed; grid-template-columns: 2.4rem minmax(0, 1fr) auto; }
.exercise-row.is-locked:hover { background: none; }
.exercise-row.is-locked .ex-title { font-weight: 400; }
@media (max-width: 600px) {
  .exercise-row { grid-template-columns: 2.1rem minmax(0, 1fr) auto; padding: .8rem 1rem; }
  .exercise-row .ex-arrow { display: none; }
  .exercise-row .pill { grid-column: 2; justify-self: start; }
  .exercise-row .ex-msgs { grid-column: 3; grid-row: 1; }
}

.course-strip { margin-bottom: 1.75rem; display: grid; gap: .5rem; }
.course-strip h2 { font-size: clamp(2rem, 7vw, 3.4rem); overflow-wrap: anywhere; }
.course-strip .row a { font-weight: 700; font-size: .9rem; }
@media (min-width: 1101px) { .jump-chat { display: none; } }

.ex-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 1.5rem; align-items: start; }
.ex-layout > div { min-width: 0; display: grid; gap: 1rem; align-content: start; }
.ex-layout .card + .card { margin-top: 0; }
.ex-side { position: sticky; top: 1.5rem; }
@media (max-width: 1100px) { .ex-layout { grid-template-columns: minmax(0, 1fr); } .ex-side { position: static; } }
.brief-text { white-space: pre-wrap; line-height: 1.75; font-size: 1rem; }
.file-list { display: grid; gap: .5rem; }
.file-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .9rem; min-height: var(--tap);
  border: 2px solid var(--riga-forte); border-radius: var(--radius);
  color: var(--inchiostro); text-decoration: none; font-weight: 600;
  background: var(--foglio);
}
.file-link:hover { background: var(--carta); text-decoration: none; }
.file-link svg { width: 20px; height: 20px; color: var(--blu-testo); flex-shrink: 0; }
.file-link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-item { padding: .9rem 0; border-top: 1px solid var(--riga); display: grid; gap: .6rem; }
.sub-item:first-of-type { border-top: 0; padding-top: 0; }
.sub-item .note { font-size: .9rem; color: var(--grafite); }
.exercise-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 2px solid var(--riga-forte); flex-wrap: wrap; }

/* ══════════════════════════════════════════════
   ANNOTATORE (correzioni sulle tavole)
   ══════════════════════════════════════════════ */
.annotator { border: 2px solid var(--riga-forte); border-radius: var(--radius-lg); overflow: clip; background: var(--foglio-2); }
.annot-toolbar {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  padding: .55rem .65rem;
  background: var(--foglio);
  border-bottom: 2px solid var(--riga-forte);
  position: sticky; top: 0; z-index: 5;
}
@media (max-width: 900px) { .annot-toolbar { top: 56px; } }
.annot-tool, .annot-zoom-btn, .annot-size {
  min-width: 38px; height: 38px; padding: 0 .4rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--riga); border-radius: var(--radius);
  background: var(--foglio); color: var(--inchiostro);
  cursor: pointer; font: 700 .95rem/1 var(--f-testo);
  transition: background var(--transition);
}
.annot-tool:hover, .annot-zoom-btn:hover, .annot-size:hover { border-color: var(--riga-forte); }
.annot-tool.active, .annot-size.active { background: var(--inchiostro); color: var(--carta); border-color: var(--inchiostro); }
.annot-size { min-width: 32px; height: 32px; font-size: .8rem; }
.annot-tool-ic { pointer-events: none; }
.annot-sep { width: 2px; height: 24px; background: var(--riga); margin: 0 .2rem; }
.annot-swatches, .annot-sizes { display: flex; gap: .3rem; }
.annot-swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--foglio); cursor: pointer; padding: 0; box-shadow: 0 0 0 1.5px var(--riga); transition: transform var(--transition); }
.annot-swatch:hover { transform: scale(1.1); }
.annot-swatch.active { box-shadow: 0 0 0 2.5px var(--inchiostro); }
.annot-zoom { display: flex; align-items: center; gap: .25rem; }
.annot-zoom-label { min-width: 46px; text-align: center; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--grafite); }
.annot-toolbar-view { justify-content: flex-end; }
.annot-zoom-hint { font-size: .8rem; color: var(--grafite); margin-right: auto; }
.annot-pages { max-height: 76vh; overflow: auto; padding: 1rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.annot-page { position: relative; width: 100%; max-width: 900px; line-height: 0; box-shadow: 0 2px 14px rgba(26, 23, 18, .18); background: #fff; }
.annot-canvas { display: block; width: 100%; height: auto; }
.annot-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; }
.annotator[data-mode="edit"] .annot-svg { pointer-events: auto; }
.annotator[data-mode="edit"][data-active-tool="arrow"] .annot-svg,
.annotator[data-mode="edit"][data-active-tool="pen"] .annot-svg,
.annotator[data-mode="edit"][data-active-tool="comment"] .annot-svg,
.annotator[data-mode="edit"][data-active-tool="histo"] .annot-svg { cursor: crosshair; }
.annot-histo {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .65rem .75rem; background: var(--foglio); border-bottom: 2px solid var(--riga);
}
.annot-histo[hidden] { display: none; }
.annot-histo-graph { flex: 0 0 auto; width: min(300px, 100%); line-height: 0; }
.annot-histo-graph svg { width: 100%; height: auto; }
.annot-histo-info { flex: 1 1 200px; display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.annot-histo-title { font-weight: 700; font-size: .95rem; }
.annot-histo-hint { font-size: .85rem; color: var(--grafite); line-height: 1.45; }
.annot-el { pointer-events: none; }
.annotator[data-mode="edit"][data-active-tool="select"] .annot-el { pointer-events: auto; cursor: pointer; }
.annotator[data-mode="view"] .annot-pin { pointer-events: auto; cursor: pointer; }
.annotator[data-mode="view"] .annot-histo-box { pointer-events: auto; cursor: help; }
.annot-pin { cursor: pointer; }
.annot-shape.selected { filter: drop-shadow(0 0 3px #1A1712); }
.annot-pin.selected circle { stroke: #1A1712; }
.annot-preview { opacity: .8; }
.annot-status { padding: 1.25rem; text-align: center; font-size: .9rem; }
.annot-unsupported { padding: 2.5rem 1.5rem; text-align: center; color: var(--grafite); display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.annot-popover {
  position: absolute; transform: translate(12px, -8px); z-index: 20;
  width: min(240px, 70vw);
  background: var(--foglio); color: var(--inchiostro);
  border: 2px solid var(--riga-forte); border-left: 6px solid var(--rosso);
  border-radius: var(--radius);
  padding: .7rem; box-shadow: var(--ombra); line-height: 1.5;
}
.annot-popover textarea { min-height: 70px; font-size: 1rem; }
.annot-popover p { font-size: .9rem; white-space: pre-wrap; margin-bottom: .5rem; }
.annot-popover-actions { display: flex; gap: .4rem; justify-content: flex-end; margin-top: .5rem; }
@media (max-width: 900px) { .annot-pages { max-height: 65vh; padding: .5rem; } }

/* ── Sessione di correzione ── */
.review-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.review-progress { font: 700 .85rem/1 var(--f-testo); color: var(--grafite); letter-spacing: .04em; text-transform: uppercase; }
.review-progress strong { font: 900 1.6rem/1 var(--f-display); color: var(--inchiostro); }
.review-meta { font-size: .95rem; }
.review-meta strong { font-weight: 700; }
.review-done { text-align: center; padding: 3.5rem 1.5rem; display: grid; justify-items: center; gap: .6rem; }
.review-done img { width: 140px; transform: rotate(-8deg); margin-bottom: .5rem; }
.review-note { background: var(--senape-tinta); padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .9rem; font-size: .92rem; }
.review-note .label { color: var(--inchiostro); margin-bottom: .2rem; }
details.review-chat { margin-bottom: .9rem; }
details.review-chat > summary { cursor: pointer; font-weight: 700; font-size: .9rem; min-height: 36px; display: flex; align-items: center; }
details.review-chat .chat-messages { max-height: 280px; margin-top: .5rem; border-radius: var(--radius); }

/* ══════════════════════════════════════════════
   ACCESSO E LANDING
   ══════════════════════════════════════════════ */
.public { background: var(--carta); }
.public-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(1rem + env(safe-area-inset-top, 0px)) clamp(1rem, 4vw, 3rem) 1rem;
  max-width: 1240px; margin: 0 auto;
}
.public-header .logo-cut b, .public-header .logo-cut .logo-mark { font-size: clamp(1.3rem, 3.5vw, 1.8rem); }
.public-main { max-width: 1240px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem) 4rem; }

.auth-card {
  background: var(--foglio);
  border: 2px solid var(--riga-forte);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 4vw, 2rem);
  display: grid; gap: 1rem; align-content: start;
  position: relative;
  scroll-margin-top: 1.5rem;
}
.auth-card h2 { font-size: 2.2rem; }
.auth-card .form-group { margin: 0; }
.auth-card details > summary {
  cursor: pointer; font-weight: 700; color: var(--blu-testo); min-height: var(--tap);
  display: flex; align-items: center; gap: .4rem; text-decoration: underline; text-underline-offset: 3px;
}
.auth-card details[open] > summary { margin-bottom: .75rem; }
.auth-card .fine { font-size: .82rem; color: var(--grafite); }
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.auth-center { display: grid; place-items: center; padding: 1rem 1rem 4rem; }
.auth-center .auth-card { width: min(440px, 100%); }

/* Landing */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.5rem clamp(1.5rem, 4vw, 3rem);
  grid-template-areas: "text auth" "collage auth";
  align-items: start; padding: clamp(1rem, 4vw, 3rem) 0 2rem;
}
.hero > .hero-text { grid-area: text; }
.hero > .auth-card { grid-area: auth; }
.hero > .collage { grid-area: collage; }
.hero-text { display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
.hero h1 { font-size: clamp(2.9rem, 9vw, 6.4rem); line-height: .86; }
.hero h1 .hl { color: var(--blu-testo); }
.hero-lead { font-size: clamp(1.05rem, 2.2vw, 1.3rem); max-width: 36ch; }
.hero-cta { display: flex; gap: .6rem; flex-wrap: wrap; }
@media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "auth" "collage"; } }

.collage { position: relative; aspect-ratio: 16 / 9; max-width: 100%; margin: 1rem 0 0; min-height: 220px; }
.collage > * { position: absolute; display: block; }
.collage img { filter: drop-shadow(2px 3px 0 rgba(26, 23, 18, .12)); }
.shape-blu    { background: var(--blu); }
.shape-rosso  { background: var(--rosso); }
.shape-senape { background: var(--senape); }
.shape-verde  { background: var(--verde); }
.shape-rosa   { background: var(--rosa); }
.cut-a { clip-path: polygon(1% 4%, 98% 0, 100% 93%, 3% 100%); }
.cut-b { clip-path: polygon(0 2%, 95% 0, 100% 100%, 5% 96%); }
.cut-c { clip-path: polygon(3% 0, 100% 5%, 97% 100%, 0 94%); }
.blob  { border-radius: 58% 42% 55% 45% / 45% 55% 45% 55%; }
.riso  {
  background: var(--blu);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='12'><rect x='3' y='1' width='2.2' height='7' rx='1'/></svg>") 0 0 / 8px 12px;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='12'><rect x='3' y='1' width='2.2' height='7' rx='1'/></svg>") 0 0 / 8px 12px;
}
@media (prefers-reduced-motion: no-preference) {
  .float { animation: floaty 7s ease-in-out infinite; }
  .float.d2 { animation-delay: -2.5s; animation-duration: 8s; }
  .float.d3 { animation-delay: -4s; animation-duration: 9s; }
}
@keyframes floaty { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

.band { padding: clamp(2.5rem, 7vw, 5rem) 0 0; display: grid; gap: 1.5rem; }
.band-head { display: grid; gap: .75rem; max-width: 760px; }
.band-head p { font-size: 1.08rem; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; counter-reset: step; }
@media (max-width: 860px) { .steps { grid-template-columns: minmax(0, 1fr); } }
.step { background: var(--foglio); border: 2px solid var(--riga-forte); border-radius: var(--radius-lg); padding: 1.4rem; display: grid; gap: .6rem; align-content: start; position: relative; overflow: hidden; }
.step::before { counter-increment: step; content: counter(step); font: 900 3.4rem/.8 var(--f-display); color: var(--rosso-testo); }
.step img { position: absolute; right: -14px; top: -10px; width: 90px; transform: rotate(12deg); opacity: .95; }
.ex-cloud { display: flex; flex-wrap: wrap; gap: .5rem; }
.ex-tag {
  display: inline-flex; gap: .5rem; align-items: baseline;
  padding: .55rem .8rem .45rem; background: var(--foglio); border: 2px solid var(--riga-forte);
  font: 800 1rem/1 var(--f-display); text-transform: uppercase; letter-spacing: .01em;
}
.ex-tag span { font: 700 .75rem/1 var(--f-testo); color: var(--grafite); font-variant-numeric: tabular-nums; }
.ex-tag:nth-child(3n+1) { transform: rotate(-1.5deg); }
.ex-tag:nth-child(4n+2) { transform: rotate(1.2deg); background: var(--senape); color: #1A1712; border-color: var(--senape); }
.ex-tag:nth-child(4n+2) span { color: #1A1712; }
.ex-tag:nth-child(5n+3) { background: var(--blu); color: #FFFFFF; border-color: var(--blu); }
.ex-tag:nth-child(5n+3) span { color: #FFFFFF; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; }
@media (max-width: 860px) { .split { grid-template-columns: minmax(0, 1fr); } }
.price-list { list-style: none; display: grid; }
.price-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: .8rem 0; border-bottom: 1px solid var(--riga); font-size: 1.02rem; }
.price-list li:last-child { border-bottom: 0; }
.price-list strong { font: 900 1.5rem/1 var(--f-display); white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-list .dim { font: 400 .85rem var(--f-testo); }
.price-list li.free { background: var(--senape); color: #1A1712; margin: 0 -.75rem; padding: .8rem .75rem; border: 2px solid #1A1712; border-radius: var(--radius); }
.free-badge { justify-self: start; display: inline-flex; align-items: center; gap: .4rem; background: var(--senape); color: #1A1712; border: 2px solid #1A1712; border-radius: 999px; padding: .5rem 1rem; font: 800 1rem/1 var(--f-display); text-transform: uppercase; letter-spacing: .02em; text-decoration: none; transform: rotate(-2deg); box-shadow: 3px 3px 0 #1A1712; transition: transform var(--transition); }
.free-badge:hover { transform: rotate(0) translateY(-2px); }
.public-footer { max-width: 1240px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 3rem) calc(2rem + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .88rem; color: var(--grafite); border-top: 2px solid var(--riga-forte); }
.public-footer a { color: inherit; }

/* Pagina testo (privacy) */
.prose { max-width: 720px; margin: 0 auto; display: grid; gap: .9rem; padding-bottom: 2rem; }
.prose h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); margin-bottom: .25rem; }
.prose h2 { font-size: 1.3rem; margin-top: 1.25rem; }
.prose ul { padding-left: 1.2rem; display: grid; gap: .35rem; }

/* ── Barra di scorrimento discreta ── */
@media (hover: hover) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--riga); border-radius: 99px; }
}

/* <details> usati come pulsanti */
details > summary { list-style: none; }
summary svg { width: 20px; height: 20px; flex-shrink: 0; }
details > summary::-webkit-details-marker { display: none; }

/* ── Selettore del tema (automatico → chiaro → scuro) ── */
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 38px; height: 38px; padding: 0; cursor: pointer;
  background: var(--foglio); color: var(--inchiostro);
  border: 2px solid var(--riga-forte); border-radius: 50%;
}
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn:hover { background: var(--foglio-2); }
.header-tools { display: flex; align-items: center; gap: .6rem; }
.mobile-bar .theme-btn { width: 34px; height: 34px; }
.user-chip .theme-btn { margin-left: auto; }

/* Percorsi: elenco esercizi come lista ordinata, modifica percorso */
ol.ex-cloud { list-style: none; padding: 0; margin: 0; }
details.course-edit > summary { cursor: pointer; font-weight: 700; font-size: .9rem; min-height: var(--tap); display: inline-flex; align-items: center; }

/* Anteprima studente: Sascia vede Studio come "Pinco Pallino" */
.hello-tools { grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .75rem 1rem; }
@media (max-width: 560px) { .hello-tools { grid-template-columns: minmax(0, 1fr); } .hello-tools .btn { justify-self: start; } }
.av-modal fieldset { border: 0; padding: 0; margin: 0 0 1.1rem; min-width: 0; }
.av-modal fieldset[hidden], .av-modal [hidden] { display: none; }
.av-modal .check { min-height: 40px; }
.av-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rosso); margin-right: .45rem; vertical-align: 1px; flex-shrink: 0; animation: avPulse 2s ease-in-out infinite; }
@keyframes avPulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .av-dot { animation: none; } }
.av-box { margin: 0 .75rem 1rem; padding: .75rem; border: 2px dashed var(--rosso-testo); border-radius: var(--radius); background: var(--rosso-tinta); }
.av-box p { margin: 0 0 .55rem; font-size: .88rem; color: var(--inchiostro); }
.av-box .btn { background: var(--foglio); }
.av-chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: .3rem .7rem;
  border: 2px dashed var(--rosso-testo); border-radius: 999px; background: var(--rosso-tinta);
  color: var(--inchiostro); font: 700 .78rem/1 var(--f-testo); cursor: pointer; white-space: nowrap;
}
.av-chip .av-dot { width: 8px; height: 8px; margin-right: .35rem; }
.av-chip:hover { background: var(--foglio); border-style: solid; }
.av-modal { overscroll-behavior: contain; }
