:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #1d1f24;
  --muted: #6c6f78;
  --line: #ebe6dd;
  --green: #0f8a5f;
  --green-soft: #e3f4ec;
  --red: #c8372d;
  --red-soft: #fbe9e7;
  --amber: #a86400;
  --amber-soft: #fdf1dc;
  --accent: #0f8a5f;
  --shadow: 0 1px 2px rgba(30, 25, 15, .05), 0 6px 20px rgba(30, 25, 15, .06);
  --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121411; --card: #1b1e1b; --text: #eef0ec; --muted: #9ca39b; --line: #2b302b;
    --green: #3ccf8e; --green-soft: #143327; --red: #ff7a6e; --red-soft: #3a1c19; --amber: #f5b74a; --amber-soft: #352a12;
    --accent: #2fb67b; --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
h1, h2, .amount, .brand { font-family: Fraunces, Georgia, serif; letter-spacing: -.01em; }
h1 { font-size: 30px; line-height: 1.15; margin: 8px 0 14px; }
h2 { font-size: 22px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 10px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13.5px; }
.err { color: var(--red); font-size: 14px; }

.demo-banner { background: var(--amber-soft); color: var(--amber); font-size: 13px; text-align: center; padding: 6px 16px; font-weight: 600; }

/* intestazione */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-in { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 19px; margin-right: auto; white-space: nowrap; }
.logo { font-size: 22px; }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a { text-decoration: none; color: var(--muted); padding: 7px 10px; border-radius: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.nav a.active { color: var(--accent); background: var(--green-soft); }
.lang { width: auto !important; margin: 0 !important; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 4px !important; font-size: 13px !important; font-weight: 600; }
@media (max-width: 640px) {
  .nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; justify-content: space-around; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .nav.tabs a { display: flex; flex-direction: column; align-items: center; padding: 4px 8px; gap: 1px; font-size: 20px; line-height: 1.1; }
  .nav.tabs a span { font-size: 11px; }
  body.has-tabs { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .top { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
}

.view { max-width: 820px; margin: 0 auto; padding: 16px 16px 40px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.center { text-align: center; }
.sec { margin: 30px 2px 12px; }

/* pulsanti */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 650; cursor: pointer; text-decoration: none; background: var(--green-soft); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.big { padding: 15px 24px; font-size: 17px; }
.btn.small { padding: 6px 11px; font-size: 13.5px; }
.btn.full { width: 100%; margin-top: 8px; }
.btn.bad { background: var(--red-soft); color: var(--red); }
.btn.good { background: var(--green); color: #fff; }
.btn:disabled { opacity: .5; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row-btns .btn { flex: 1 1 160px; }

/* landing */
.hero { text-align: center; padding: 36px 4px 18px; }
.hero h1 { font-size: clamp(32px, 7vw, 48px); max-width: 640px; margin: 18px auto 12px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 18px; }
.flag { display: inline-flex; border-radius: 6px; overflow: hidden; height: 10px; width: 54px; }
.flag i { flex: 1; } .flag i:nth-child(1) { background: #009246; } .flag i:nth-child(2) { background: #f1f2f1; } .flag i:nth-child(3) { background: #ce2b37; }
.cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0 10px; }
.feats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.feat { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.feat h3 { margin: 6px 0 4px; } .feat p { margin: 0; color: var(--muted); font-size: 15px; }
.ficon { font-size: 26px; }
.price { text-align: center; padding: 28px 18px; }
.amount { font-size: 42px; font-weight: 700; margin: 6px 0; }
.amount span { font-size: 17px; color: var(--muted); font-family: Inter, sans-serif; font-weight: 500; margin-left: 4px; }
.faq details summary { cursor: pointer; font-weight: 650; }
.faq details p { margin: 10px 0 0; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin: 40px 0 10px; }

/* auth */
.auth { max-width: 420px; margin: 30px auto; }
.auth label, .editor label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
input:not([type=checkbox]), select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font-size: 16px; margin-top: 5px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* corso */
.hello { margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; text-align: center; text-decoration: none; color: var(--text); }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 12.5px; color: var(--muted); }
.next { display: flex; gap: 14px; align-items: center; justify-content: space-between; text-decoration: none; color: var(--text); border: 2px solid var(--green-soft); }
.next h2 { margin: 2px 0; } .next p { margin: 0; }
@media (max-width: 520px) { .next { flex-direction: column; align-items: stretch; } }
.level { margin-top: 26px; }
.levelh { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.levelh h2 { margin: 0; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.row:last-child { border-bottom: 0; }
.row.locked { opacity: .6; }
.num { width: 38px; height: 38px; flex: none; border-radius: 12px; background: var(--green-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; text-align: center; line-height: 1.1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.title { font-weight: 650; }
.sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.free { background: var(--amber-soft); color: var(--amber); }
.badge.lock { background: transparent; font-size: 16px; }
.paywall { text-align: center; border: 2px solid var(--green-soft); }
.lock { font-size: 34px; }
.pad { padding: 16px; }

/* lezione */
.back { display: inline-block; margin: 4px 0 6px; text-decoration: none; font-weight: 600; }
.lesson-h { margin-bottom: 18px; }
.lesson-h h1 { margin: 4px 0 6px; font-size: 34px; }
.block { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.prose p { margin: 0 0 8px; } .prose ul { margin: 6px 0; padding-left: 22px; } .prose li { margin: 3px 0; }
.trans { margin-top: 10px; } .trans summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.trans div { margin-top: 8px; padding: 10px 12px; background: var(--bg); border-radius: 12px; color: var(--muted); font-size: 15px; }
.trans p { margin: 0 0 6px; }
.tipbox { border-left: 4px solid var(--amber); padding-left: 12px; }
.tiph { font-weight: 700; color: var(--amber); margin-bottom: 6px; }
.speak { border: 0; background: var(--green-soft); border-radius: 50%; width: 32px; height: 32px; flex: none; cursor: pointer; font-size: 14px; }
.vocab { list-style: none; padding: 0; margin: 0; }
.vocab li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vocab li:last-child { border-bottom: 0; }
.vocab .it { font-weight: 650; flex: 1; } .vocab .tr { color: var(--muted); text-align: right; font-size: 15px; }
.block-dialogue h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg { display: flex; flex-direction: column; gap: 10px; }
.line { display: flex; flex-direction: column; max-width: 88%; }
.line.r { align-self: flex-end; align-items: flex-end; }
.who { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 6px 2px; }
.bubble { background: var(--bg); border-radius: 16px; padding: 9px 12px; display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; }
.line.r .bubble { background: var(--green-soft); }
.bubble .speak { width: 28px; height: 28px; font-size: 12px; background: var(--card); }
.ltr { grid-column: 2; font-size: 13.5px; color: var(--muted); }
.hide-tr .ltr { display: none; }
.switch { display: flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.exh { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 6px; }
.q { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.opts { display: grid; gap: 8px; margin-top: 10px; }
.opt { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500; }
.opt.right, .gapin.right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.opt.wrongopt, .gapin.wrongopt { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.opt.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.gapline { line-height: 2.2; }
.gapin { display: inline-block; width: auto !important; min-width: 70px; padding: 4px 8px !important; margin: 0 4px !important; text-align: center; font-weight: 650; border: 1.5px solid var(--line) !important; }
.row { flex-wrap: nowrap; }
.block .row { padding: 0; border: 0; gap: 8px; margin-top: 10px; }
.fb { margin-top: 10px; font-weight: 650; min-height: 1px; }
.fb.good { color: var(--green); } .fb.bad { color: var(--red); }
.explain { font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 15px; }
.answerline { min-height: 50px; border-bottom: 2px dashed var(--line); padding: 6px 0; margin: 8px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 550; }
.chip.on { background: var(--green-soft); border-color: var(--green); }
.solved .answerline .chip { cursor: default; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.match .opt { text-align: center; padding: 11px 8px; }
.video { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
audio { width: 100%; }
.done { text-align: center; }
.big-emoji { font-size: 46px; }

/* ripasso */
.flash { text-align: center; padding: 30px 18px; }
.flash .box { color: var(--green); letter-spacing: 3px; font-size: 12px; }
.flash .front { font-family: Fraunces, Georgia, serif; font-size: 32px; font-weight: 700; margin: 18px 0; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.flash .back { font-size: 20px; color: var(--muted); margin-bottom: 14px; }

/* account */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.kv:last-of-type { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }
.kv select { width: auto; margin: 0; }
.status.ok { color: var(--green); } .status.warn { color: var(--amber); } .status.off { color: var(--red); }
.card.demo { background: var(--amber-soft); box-shadow: none; }

/* insegnante */
.editor .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 10px; }
.checks label { display: flex; gap: 6px; align-items: center; color: var(--text); font-weight: 500; margin: 0; }
.tpl { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; min-height: 380px; line-height: 1.45; }
.table-wrap { overflow-x: auto; padding: 6px 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-size: 12.5px; }

/* modale, toast, spinner */
.modal { position: fixed; inset: 0; background: rgba(10, 12, 10, .5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 420px; text-align: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); background: #1f2420; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 20px auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* offerta */
.promo-badge { display: inline-block; background: #1d1f24; color: #fff; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; padding: 5px 12px; border-radius: 999px; }
.amount s.old { color: var(--muted); font-size: 24px; font-weight: 600; margin-right: 4px; }
.promo-note { font-weight: 650; color: var(--red); margin: 4px 0; }
.promo-strip { display: inline-block; background: #1d1f24; color: #fff; border-radius: 12px; padding: 8px 14px; font-weight: 650; font-size: 14.5px; margin-top: 6px; }
.promo-bonus { background: var(--amber-soft); color: var(--amber); border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 14.5px; margin: 10px 0; }
.promo-strip { line-height: 1.5; max-width: 560px; }

/* test di livello */
.pl-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pl .q { font-size: 19px; margin: 14px 0 4px; }
.blank { display: inline-block; min-width: 64px; border-bottom: 2px solid var(--muted); margin: 0 3px; }
.opt.idk { color: var(--muted); border-style: dashed; }
.passage { background: var(--bg); border-radius: 12px; padding: 4px 14px; margin-top: 12px; }
details.passage summary { padding: 10px 0; cursor: pointer; }
.pl-level { font-size: 64px; font-weight: 800; color: var(--green); line-height: 1.1; }
.pl-fix { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 10px; }
