:root{
  --bg:#f4f7fb;--card:#fff;--ink:#14202b;--muted:#52606d;--line:#d5dde6;
  --blue:#0b5fa5;--blue-d:#084a82;--orange:#c4500a;--green:#0a7a52;--red:#b3261e;--purple:#7b2d8e;
  --okbg:#e3f5ec;--badbg:#fdeceb;--infobg:#e8f1fa;--yel:#fff4d6;
  --r:16px;
}
*{box-sizing:border-box}
html{font-size:20px;-webkit-text-size-adjust:100%}
html[data-ts="normal"]{font-size:17px}
html[data-ts="large"]{font-size:20px}
html[data-ts="xlarge"]{font-size:23px}
body{margin:0;background:var(--bg);color:var(--ink);font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;line-height:1.5;-webkit-tap-highlight-color:transparent}
#app{max-width:640px;margin:0 auto;padding:0 16px 40px}
.page{padding-bottom:30px}
h1,h2,h3{line-height:1.25;margin:.3em 0}
h1{font-size:1.25rem}h2{font-size:1.15rem}h3{font-size:1rem}
p{margin:.5em 0}
.muted{color:var(--muted)}.small{font-size:.8rem}
.cb{color:var(--blue);font-weight:700}.co{color:var(--orange);font-weight:700}.cg{color:var(--green);font-weight:700}

.topbar{display:flex;align-items:center;gap:8px;position:sticky;top:0;z-index:5;background:var(--bg);padding:10px 0;border-bottom:1px solid var(--line);margin-bottom:12px}
.topbar h1{flex:1;text-align:center;margin:0;font-size:1.05rem}
.sp{width:48px}
.hero{text-align:center;padding:24px 0 8px}.logo{font-size:3rem}

.btn{font:inherit;font-weight:600;min-height:52px;padding:10px 18px;border-radius:14px;border:2px solid var(--line);background:#fff;color:var(--ink);cursor:pointer;touch-action:manipulation}
.btn:active{transform:scale(.98)}
.btn:disabled{opacity:.45;cursor:default}
.btn.primary{background:var(--blue);border-color:var(--blue);color:#fff}
.btn.primary:active{background:var(--blue-d)}
.btn.big{width:100%;min-height:58px;margin-top:10px}
.btn.round{width:48px;min-width:48px;height:48px;min-height:48px;padding:0;border-radius:50%;font-size:1.2rem}
.btn.ghost{background:transparent;border-color:transparent;color:var(--blue)}
.btn.sm{min-height:44px;padding:6px 12px;font-size:.85rem}
.btn.danger{color:var(--red);border-color:var(--red)}
.btn.on{background:var(--blue);color:#fff;border-color:var(--blue)}
.btn:focus-visible,.choice:focus-visible,.key:focus-visible,.field:focus-visible,.switch:focus-visible,.txt:focus-visible,.sel:focus-visible{outline:4px solid #ffbf47;outline-offset:2px}
.row2{display:flex;gap:10px;flex-wrap:wrap}
.row2>.btn{flex:1;min-width:140px}
.stack{display:flex;flex-direction:column;gap:2px}
.namebtn,.listbtn{text-align:left;font-size:1.05rem}
.lead{font-size:1.05rem;text-align:center}
.foot{text-align:center;margin-top:20px}

.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:16px;margin:12px 0;box-shadow:0 1px 3px rgba(20,32,43,.06)}
.topic{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;align-items:center}
.topic .row2{grid-column:1/3;margin-top:8px}
.ticon{font-size:2.2rem}
.topic h2{margin:0}.topic p{margin:0}
.tools .setrow{margin-top:8px}
.setrow{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:8px 0}
.seg{display:flex;gap:6px}.seg .btn{min-height:46px;padding:6px 12px}
.newst{margin-top:24px}
.txt{font:inherit;width:100%;min-height:54px;padding:10px 14px;border-radius:14px;border:2px solid var(--line);margin:8px 0}
.sel{font:inherit;min-height:48px;border-radius:12px;border:2px solid var(--line);padding:6px 10px;background:#fff;max-width:55%}

/* esercizio */
.extitle{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.chip{background:var(--infobg);color:var(--blue-d);font-weight:700;border-radius:999px;padding:4px 12px;font-size:.85rem}
.dots{display:flex;gap:6px}.dot{width:12px;height:12px;border-radius:50%;background:var(--line)}.dot.done{background:var(--green)}.dot.cur{background:var(--blue);transform:scale(1.25)}
.stmt{background:#fff;border:2px solid var(--blue);border-radius:var(--r);padding:12px 16px;margin:12px 0;font-size:1.05rem}
.figbox,.graphwrap{display:flex;justify-content:center;margin:10px 0}
.graph{background:#fff;border:1px solid var(--line);border-radius:12px;display:block;touch-action:manipulation}
.ring{animation:pulse 1s ease-in-out infinite;transform-origin:center;transform-box:fill-box}
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.5;transform:scale(1.25)}}
.stepcard{background:#fff;border:1px solid var(--line);border-radius:var(--r);padding:14px;margin-top:10px}
.sthead{display:flex;align-items:center;justify-content:space-between}
.stn{font-weight:700;color:var(--muted);font-size:.85rem;text-transform:uppercase;letter-spacing:.04em}
.q{font-size:1.1rem;margin:6px 0 10px}
.q2{font-weight:600;margin:6px 0}
.fb{margin:10px 0;border-radius:12px}
.fb.ok,.fb.bad,.fb.info{padding:10px 14px}
.fb.ok{background:var(--okbg);color:#064d33}.fb.bad{background:var(--badbg);color:#7d1913}.fb.info{background:var(--infobg);color:#083f6e}
.sol{margin-top:6px}
.hint{background:var(--yel);border-radius:12px;padding:8px 12px;margin:8px 0}
.actions{margin-top:8px}
.box{background:var(--infobg);border-left:6px solid var(--blue);border-radius:10px;padding:8px 14px;margin:10px 0}
.formula{background:#fff;border:2px dashed var(--blue);border-radius:12px;padding:8px 12px;margin:8px 0;text-align:center;font-size:1.1rem}
.live{background:#fff;border:2px solid var(--line);border-radius:12px;padding:10px 14px;margin:10px 0;min-height:3em}

/* scelte */
.choices{display:flex;flex-direction:column;gap:10px}
.choice{font:inherit;text-align:left;min-height:58px;padding:12px 16px;border-radius:14px;border:2px solid var(--line);background:#fff;color:var(--ink);cursor:pointer;font-size:1.1rem}
.choice.good{background:var(--okbg);border-color:var(--green)}
.choice.badc{background:var(--badbg);border-color:var(--red);text-decoration:line-through;opacity:.75}
.choice:disabled{cursor:default}

/* tastierino */
.fields{display:flex;gap:10px;justify-content:center;margin-bottom:10px}
.fwrap{flex:1;max-width:240px}
.flabel{display:block;font-weight:700;color:var(--muted);font-size:.85rem;margin-bottom:2px}
.field{width:100%;min-height:64px;border-radius:14px;border:3px solid var(--line);background:#fff;font:inherit;font-size:1.5rem;font-weight:700;text-align:center;color:var(--ink)}
.field.active{border-color:var(--blue);background:#f0f7fe}
.field .ph{color:#9aa6b2}
.keypad{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;max-width:360px;margin:0 auto}
.key{font:inherit;font-size:1.4rem;font-weight:700;min-height:58px;border-radius:14px;border:2px solid var(--line);background:#fff;color:var(--ink);touch-action:manipulation}
.key:active{background:var(--infobg)}
.key.k-back,.key.k-clear,.key.k-neg,.key.k-next,.key.k-ok{background:#eef2f6}
.key:disabled{opacity:.4}

/* frazioni */
.frac{display:inline-flex;flex-direction:column;vertical-align:middle;text-align:center;line-height:1.15;margin:0 .15em;font-size:.9em}
.frac>span:first-child{border-bottom:2px solid currentColor;padding:0 .2em}
.frac>span:last-child{padding:0 .2em}
sub{font-size:.7em}

/* fine */
.done{text-align:center}
.bigstars{font-size:2.6rem;color:#e0a200;letter-spacing:.1em}
.stars{color:#e0a200;white-space:nowrap}

/* lezione */
.lprog{display:flex;align-items:center;gap:10px;margin:6px 0}
.bar{flex:1;height:10px;border-radius:99px;background:var(--line);overflow:hidden}.bar span{display:block;height:100%;background:var(--green);transition:width .3s}
.lbody h2{display:flex;align-items:center;justify-content:space-between;gap:8px}
.ltext{font-size:1.05rem}
.ltext ul,.ltext ol{padding-left:1.3em}
.lfoot{display:flex;gap:10px;margin-top:10px}.lfoot .btn{flex:1}
.widget{margin-top:6px}
.ctlrow{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin:8px 0}
.stepper{display:flex;align-items:center;gap:8px;background:#fff;border:2px solid var(--line);border-radius:999px;padding:4px}
.stlabel{min-width:3.2em;text-align:center;font-weight:700}
.gatehint{text-align:center}

/* storico */
.histrow{display:flex;width:100%;align-items:center;justify-content:space-between;text-align:left;font:inherit;cursor:pointer;gap:10px}
.hl{display:flex;flex-direction:column}
.rstep{border-left:6px solid var(--line);padding:6px 12px;margin:10px 0;background:#fff;border-radius:10px}
.rstep.g{border-color:var(--green)}.rstep.y{border-color:#e0a200}.rstep.r{border-color:var(--red)}
.rhead{display:flex;justify-content:space-between;gap:8px;font-size:.85rem}
.badge{color:var(--muted)}

/* admin */
.swrow{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 0;border-bottom:1px solid #eef1f5}
.swl{display:flex;flex-direction:column}
.subs{padding-left:14px;border-left:3px solid var(--line);margin:0 0 8px 6px}
.switch{width:64px;min-width:64px;height:36px;border-radius:99px;border:none;background:#c3ccd6;position:relative;cursor:pointer;transition:background .2s}
.switch::after{content:"";position:absolute;top:4px;left:4px;width:28px;height:28px;border-radius:50%;background:#fff;transition:transform .2s}
.switch.on{background:var(--green)}.switch.on::after{transform:translateX(28px)}
.strow{display:flex;flex-direction:column;gap:6px;padding:8px 0;border-bottom:1px solid #eef1f5}
.savebar{position:fixed;left:0;right:0;bottom:0;background:#fff;border-top:2px solid var(--blue);padding:10px 16px;display:none;align-items:center;justify-content:space-between;gap:10px;z-index:9;padding-bottom:calc(10px + env(safe-area-inset-bottom))}
.toast{position:fixed;left:50%;bottom:80px;transform:translateX(-50%);background:#14202b;color:#fff;padding:12px 20px;border-radius:99px;z-index:20}

@media (prefers-reduced-motion:reduce){.ring{animation:none}*{transition:none!important}}
