/* Servizio lezioni: stesso tema scuro della pagina degli appunti dell'AI Hub. Font di sistema, nessuna risorsa
   esterna (CSP 'self'). */
:root {
  color-scheme: dark;
  --bg: #0a0c11; --surface: #12151d; --surface-2: #1a1e29; --field: #0e1118; --text: #e8eaf0; --muted: #a3acbd;
  --border: #262b38; --border-strong: #343b4c;
  --accent: #9aa2ff; --accent-soft: rgba(154, 162, 255, .13);
  --primary-1: #5b5ff0; --primary-2: #8b4fe6;
  --ok: #5ee39a; --err: #ff8a80; --err-soft: rgba(255, 138, 128, .12);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px; --radius-sm: 10px; --control-h: 42px; --control-h-sm: 34px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  background: radial-gradient(1100px 520px at 50% -260px, rgba(91, 95, 240, .16), transparent 70%) no-repeat, var(--bg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 16px; margin: 6px 0 4px; }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-1), var(--primary-2)); font-size: 15px; box-shadow: var(--shadow); }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center;
  font-weight: 700; color: var(--text); font-size: 12px; text-transform: uppercase; }
a.avatar:hover { text-decoration: none; background: var(--accent-soft); color: var(--accent); }

main { max-width: 820px; margin: 0 auto; padding: 24px 20px 48px; }
@media (max-width: 720px) { main { padding: 16px 14px 40px; } .top { padding: 10px 16px; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 16px; }
.auth { max-width: 440px; margin: 6vh auto 16px; }
.auth.wide { max-width: 560px; margin-top: 3vh; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); background: var(--err-soft); padding: 8px 12px; border-radius: var(--radius-sm); }
.ok-text { color: var(--ok); }
.narrow-form { max-width: 420px; }
form.inline { display: inline; margin: 0; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
label .hint { font-weight: 400; color: var(--muted); }
input { font: inherit; font-size: 15px; color: var(--text); background: var(--field); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 12px; min-width: 0; }
input:not([type=checkbox]) { height: var(--control-h); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { accent-color: var(--primary-1); width: 18px; height: 18px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); }
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); padding: 5px 16px;
  min-height: var(--control-h); line-height: 1.35; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: linear-gradient(135deg, var(--primary-1), var(--primary-2)); color: #fff;
  border-color: transparent; box-shadow: 0 6px 18px rgba(91, 95, 240, .28); }
button.sm, .btn.sm { min-height: var(--control-h-sm); padding: 4px 12px; font-size: 13px; }
button.danger { color: var(--err); }
button.link { background: none; border: none; padding: 0; min-height: 0; color: var(--muted); font-weight: 500; }
button.link:hover { color: var(--text); }

/* cartelle e lezioni */
.percorso { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.percorso strong { color: var(--text); }
.elenco { display: grid; gap: 8px; margin-bottom: 16px; }
.voce { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.voce:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.voce .ic { font-size: 20px; }
.voce .t { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.voce .sub { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.voce .n { color: var(--muted); font-size: 13px; background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.chip { font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.sessioni { padding-left: 18px; margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.sessioni li { margin: 4px 0; overflow-wrap: anywhere; }

/* primo accesso: codice QR e chiave */
.qr-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr { border-radius: var(--radius-sm); border: 1px solid var(--border); max-width: 100%; height: auto; }
.chiave { display: block; margin-top: 4px; font-size: 15px; letter-spacing: .06em; color: var(--text);
  overflow-wrap: anywhere; }

/* pagina della lezione: come gli appunti dell'Hub */
.view-head { max-width: 760px; margin: 0 auto 12px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pdf-scelta { gap: 10px; margin: 0; }
.player { max-width: 760px; margin: 0 auto 12px; }
.player audio { width: 100%; }
.notes { line-height: 1.7; font-size: 16px; max-width: 760px; margin: 0 auto; padding: 28px 32px; }
@media (max-width: 720px) { .notes { padding: 20px 18px; } }
.notes h1 { font-size: 24px; margin: 0 0 10px; }
.notes h1 + p em { color: var(--muted); }
.notes h2 { font-size: 19px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.notes h3 { font-size: 15px; margin: 22px 0 6px; color: var(--accent); }
.notes h4 { font-size: 14px; margin: 16px 0 4px; color: var(--muted); }
.notes ul, .notes ol { padding-left: 22px; margin: 6px 0; }
.notes li { margin: 4px 0; }
.notes li::marker { color: var(--accent); }
.notes sub { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 6px; }
.notes hr { border: none; border-top: 1px solid var(--border); margin: 28px 0 10px; }
.notes p { margin: 8px 0; }
.notes code { font-size: 13px; }
.notes table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 14px; margin: 8px 0 14px; max-width: 100%; }
.notes th, .notes td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.notes th { background: var(--surface-2); font-weight: 600; }
