*{box-sizing:border-box}body{margin:0;font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#1a2e43;background:#f6f8fc}button,input,select{font:inherit}button{cursor:pointer}h1{font-size:clamp(26px,3.3vw,42px);letter-spacing:-1px;margin:12px 0 16px}h2{font-size:23px}h3{font-size:17px}.layout{display:flex;min-height:100vh}.sidebar{width:252px;flex-shrink:0;background:#112b48;color:#fff;padding:30px 17px;position:sticky;top:0;height:100vh;display:flex;flex-direction:column}.brand{display:flex;gap:11px;align-items:center;margin-bottom:47px;padding:0 12px}.brand strong{font-size:20px}.brand small,.side-bottom small{display:block;font-size:12px;opacity:.65;margin-top:3px}.brand-mark{background:#d6e7ff;color:#1a3457;border-radius:12px;font-size:27px;padding:5px 12px}.sidebar nav{display:grid;gap:7px}.sidebar nav button{background:none;border:0;color:#d1dce8;text-align:left;padding:13px;border-radius:10px}.sidebar nav button:hover,.sidebar nav button.active{background:#284a6e;color:#fff}.side-bottom{margin-top:auto;background:#1c3959;padding:14px;border-radius:12px;font-size:13px;line-height:1.6}.main{flex:1;min-width:0}.main header{background:white;border-bottom:1px solid #e7edf5;padding:22px max(35px,5vw);display:flex;justify-content:space-between;gap:10px}.main header span{font-size:13px;color:#718096}.content{max-width:1120px;margin:0 auto;padding:35px 32px 80px}.eyebrow{font-size:11px;letter-spacing:2px;color:#5278a5;font-weight:800}.hero{background:linear-gradient(115deg,#213d68,#5167ad);padding:55px;color:white;border-radius:22px;margin-bottom:22px}.hero .eyebrow{color:#c7d9ff}.hero p{max-width:480px;line-height:1.8;color:#e2eaff}.primary{background:#4c61d6;border:0;border-radius:10px;color:white;padding:13px 22px;font-weight:700}.primary:hover{background:#384fbd}.primary:disabled{opacity:.4;cursor:default}.secondary{background:#edf2ff;border:0;border-radius:9px;color:#344ca4;padding:11px 16px}.link{background:none;border:0;color:#4961c4;padding:8px 0}.stats,.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin:20px 0 35px}.card{background:white;padding:24px;border-radius:16px;border:1px solid #e6ebf2;box-shadow:0 5px 20px #192b4706;margin-bottom:16px}.stats .card{display:grid;gap:5px}.stats strong{font-size:30px}.card span,.card p,section>p{color:#6c7b8d}.navcard,.chapter{text-align:left;display:flex;flex-direction:column;gap:12px}.navcard b{font-size:19px}.chapter{min-height:195px}.chapter-icon{font-size:27px;color:#566ec7}.chapter small{color:#64748b}.theory{background:white;border:1px solid #e6ebf2;border-radius:13px;display:flex;gap:17px;padding:22px;margin:18px 0}.theory p{line-height:1.8}.number{background:#e8edfd;color:#455cbd;border-radius:50%;width:35px;height:35px;display:grid;place-items:center;flex-shrink:0;font-weight:bold}.toolbar{display:flex;justify-content:space-between;align-items:center;margin:20px 0;gap:15px}.toolbar label{display:flex;gap:10px;align-items:center}.toolbar select{padding:9px;border:1px solid #ced7e3;border-radius:8px;max-width:260px}.exercise{padding:32px}.exercise h2{line-height:1.5}.answer{display:grid;gap:11px;margin:25px 0}.answer input{padding:14px;border:1px solid #cbd4e0;border-radius:9px;width:100%;max-width:460px}.symbols{display:flex;flex-wrap:wrap;gap:7px}.symbols button{border:1px solid #d9e2ee;background:#f4f7fc;border-radius:7px;padding:7px 13px}.choices{display:grid;gap:10px;margin:20px 0}.choices label{padding:14px;border:1px solid #dce3ed;border-radius:9px;cursor:pointer}.workspace{margin:24px 0}.workspace-heading{display:flex;justify-content:space-between;align-items:center}.workspace canvas{display:block;width:100%;height:auto;background:#fff;border:1px solid #d7e1ed;border-radius:10px;touch-action:none}.workspace small{color:#7c8b9c}.feedback{padding:17px;border-radius:12px;margin:18px 0}.correct{background:#e7f8ef;color:#176947}.incorrect{background:#fff0ed;color:#a83e33}.feedback li{margin:8px 0}.actions{margin-top:22px}.result{text-align:center;padding:60px}.score{font-size:80px;font-weight:800;color:#5367d3}.source-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:16px;margin-top:30px}.source-grid a{display:grid;color:#304366;text-decoration:none;background:white;border:1px solid #e8edf5;padding:9px;border-radius:12px;gap:8px}.source-grid img{width:100%;height:180px;object-fit:cover;border-radius:7px}.alert{padding:16px;background:#ffedea;border:1px solid #ecc7bb;margin-bottom:15px;border-radius:9px}.import{cursor:pointer;display:inline-flex;margin-left:20px;color:#435ba9;align-items:center;gap:10px}.import input{max-width:190px;font-size:12px}@media(max-width:800px){.layout{display:block}.sidebar{width:auto;height:auto;position:static;padding:14px}.brand{margin:0 0 12px}.sidebar nav{display:flex;overflow-x:auto;gap:4px}.sidebar nav button{flex-shrink:0}.side-bottom{display:none}.content{padding:24px 16px}.main header{padding:16px}.stats,.cards{grid-template-columns:repeat(2,minmax(0,1fr))}.hero{padding:34px 24px}.toolbar{flex-wrap:wrap}}@media(max-width:520px){.stats,.cards{grid-template-columns:1fr}.main header span{display:none}.exercise{padding:18px}.import{margin:15px 0 0}}

/* Minimal login screen; existing study layout unchanged. */
.login-page{min-height:100vh;display:flex;align-items:center;justify-content:center;background:#f4f7fc;padding:24px}
.login-card{width:min(100%,430px);background:white;border:1px solid #dde6f1;border-radius:20px;padding:36px;box-shadow:0 15px 35px rgba(16,42,75,.08);display:flex;flex-direction:column;gap:13px}
.login-card h1{font-size:26px;line-height:1.2;color:#132d4e;margin:6px 0}.login-card p{color:#64748b;margin:0 0 12px}.login-card label{font-weight:600;color:#132d4e}
.login-card input{width:100%;box-sizing:border-box;padding:13px;border:1px solid #ccd8e6;border-radius:9px;font:inherit}
.login-card .primary{margin-top:12px}.login-mark{width:54px;height:54px;border-radius:14px;background:#d8eaff;color:#132d4e;font-size:32px;display:grid;place-items:center}

/* Imported lessons: reuse existing card treatment; preserve newline-separated teaching steps. */
.imported-lesson { margin: 18px 0; text-align: left; }
.imported-lesson .lesson-text { white-space: pre-line; line-height: 1.9; overflow-wrap: anywhere; }
.lesson-notice { color: #a23b3b; }

/* Reusable, data-driven lesson renderer: percent, algebra, geometry and future chapters. */
.guided-lesson{margin:24px 0;padding:30px;border-radius:20px;overflow:hidden}
.guided-lesson h2{line-height:1.3;margin:14px 0 22px}
.lesson-meter{display:flex;gap:5px;margin:15px 0 10px}.lesson-meter span{height:8px;flex:1;background:#e8edf5;border-radius:30px}.lesson-meter span.seen{background:#526ce1}
.guided-counter{font-size:13px;font-weight:700;color:#5266a3;margin-bottom:17px}
.lesson-step{padding:28px;background:#f4f7ff;border:1px solid #dfe7ff;border-radius:18px;min-height:180px;display:flex;flex-direction:column;justify-content:center}
.lesson-step h3{font-size:22px;color:#253d72;margin:0 0 18px}
.lesson-step .math-copy{font-size:20px;line-height:1.8;color:#22344c;white-space:pre-wrap;margin:0}
.math-value{display:inline-block;color:#2c51ca;background:#e5ebff;border-radius:6px;padding:0 4px;font-weight:800}
.step-highlight{background:#eaf8ef;border-color:#bce6c9}.step-highlight h3{color:#176849}.step-highlight .math-value{color:#12633f;background:#d3f3dd}
.step-formula{background:#edf3ff}.step-comparison{background:#fff8eb;border-color:#f5dfa9}.step-comparison .math-value{background:#fff0c7;color:#825a0c}
.step-hundreds{background:#f0f6ff}.hundred-row{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin-top:22px}
.hundred-cell{border-radius:12px;background:white;border:1px solid #ccdaf6;display:grid;gap:9px;padding:14px 7px;text-align:center}.hundred-cell b{font-size:22px;color:#2454bf}.hundred-cell small{font-size:12px;color:#b04c3d}.hundred-cell strong{color:#21734b;font-size:14px}
.big-equation{font-size:clamp(24px,3vw,40px);font-weight:800;letter-spacing:.3px;color:#274caf;background:white;padding:18px;border-radius:12px;margin-top:20px;text-align:center}
.big-result{color:#176644;background:#daf5e5;border-radius:12px;font-weight:800;padding:18px;font-size:27px;margin-top:15px;text-align:center}
.lesson-items{display:grid;gap:10px;margin-top:18px}.lesson-items>div{background:white;border:1px solid #dfe6f6;padding:12px;border-radius:10px;font-weight:600}
.geometry-drawing{background:white;border-radius:14px;margin-top:15px;text-align:center}.geometry-drawing svg{width:min(100%,400px)}.geometry-drawing text{fill:#274caf;font-size:15px;font-weight:700}
.lesson-controls{display:flex;gap:12px;justify-content:space-between;align-items:center;margin-top:19px}.lesson-controls button:disabled{opacity:.35;cursor:default}
@media(max-width:650px){.guided-lesson{padding:18px}.lesson-step{padding:18px}.lesson-step .math-copy{font-size:17px}.hundred-row{grid-template-columns:repeat(2,minmax(0,1fr))}.lesson-controls{flex-wrap:wrap}}

/* Compact visual pages: related explanations remain visible together. */
.lesson-page{display:grid;gap:13px}
.lesson-page .lesson-step{min-height:0;padding:20px 24px}
.lesson-page .lesson-step h3{font-size:19px;margin-bottom:10px}
.lesson-page .lesson-step .math-copy{font-size:18px;line-height:1.65}
.lesson-page .hundred-row{margin-top:16px}
@media(max-width:650px){.lesson-page .lesson-step{padding:16px}.lesson-page .lesson-step .math-copy{font-size:16px}}

/* Chemistry: lesson cards mimic the PDF with a clear blue heading and green rules. */
.guided-lesson .lesson-step { border-left:4px solid #2b63aa; padding:18px 20px; margin:18px 0; background:#f8fbff; border-radius:10px; }
.guided-lesson .lesson-step h3 {color:#17518e; font-size:1.14rem; line-height:1.4;}
.guided-lesson .lesson-step.step-highlight {border-left-color:#178354;background:#eef9f0;}
.guided-lesson .lesson-step .lesson-items > div {margin-top:10px; padding:9px 12px; background:#e8f6ed; border-radius:6px; color:#17613b; font-weight:600;}
.guided-lesson .big-equation {font-size:clamp(1.05rem,2.25vw,1.4rem); overflow-wrap:anywhere;white-space:normal;background:#eef3ff;padding:15px;border-radius:8px;color:#173c7c;}
.guided-lesson .math-copy {line-height:1.75;white-space:pre-line;}
.guided-lesson .guided-counter {color:#ad621b;font-weight:700;}

.chem-keyword {color:#ad6019; font-weight:750;}

/* Imported HTML lessons: formatted headings and paragraphs, not raw tags. */
.guided-lesson .math-copy h2,.guided-lesson .math-copy h3{color:#20509a;line-height:1.35;margin:0 0 12px;font-size:1.25rem}
.guided-lesson .math-copy p{margin:0 0 12px;white-space:normal}
.guided-lesson .math-copy p:last-child{margin-bottom:0}
.guided-lesson .lesson-step.step-highlight .math-copy{color:#237248;font-weight:600}
.guided-lesson .math-copy ul,.guided-lesson .math-copy ol{padding-left:1.4em}

/* Login migliorato: form più largo, leggibile e centrato. */
.login-page{min-height:100vh;padding:32px 18px;background:linear-gradient(135deg,#e9f1ff 0%,#f7f9fe 50%,#e5edff 100%)}
.login-card{width:min(100%,560px);padding:clamp(30px,5vw,58px);border-radius:24px;gap:17px;box-shadow:0 22px 65px rgba(18,43,76,.13)}
.login-mark{width:70px;height:70px;font-size:40px;border-radius:18px}
.login-card h1{font-size:clamp(29px,3.2vw,37px);margin:5px 0 0;line-height:1.18}
.login-card p{font-size:16px;margin:0 0 12px;line-height:1.5}
.login-card label{font-size:15px}
.login-card input{min-height:56px;border-radius:12px;padding:15px 16px;font-size:17px;background:#fbfdff}
.login-card input:focus{outline:3px solid #bccafa;border-color:#516ad8}
.login-card .primary{min-height:56px;margin-top:14px;font-size:17px;border-radius:12px}
.login-card .alert{margin:0}
@media(max-width:520px){.login-card{padding:30px 24px}}

/* Quiz: grouped exam questions */
.chapter-buttons{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}.chapter-action{padding:9px 14px;border-radius:9px;background:#e8efff;color:#20509a;font-weight:700}.chapter-action:last-child{background:#4d61dd;color:white}.chapter-actions{justify-content:flex-start;margin:10px 0 24px}.exam-stem{white-space:pre-line;line-height:1.6}.exam-subquestion{padding:22px 0;border-top:1px solid #e1e8f0}.exam-subquestion h3{font-size:1.08rem;white-space:pre-line}.exam-subquestion input.group-answer{display:block;width:100%;max-width:580px;padding:12px 14px;margin:10px 0;border:1px solid #cbd5e1;border-radius:9px;font-size:1rem}.exam-subquestion .feedback{margin:12px 0}.exam-subquestion button{margin-top:10px}

/* Quiz with a single exercise and free-answer subquestions */
.quiz-symbols{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:12px;margin:16px 0 22px;background:#f1f5ff;border-radius:12px}.quiz-symbol-title{font-weight:700;margin-right:8px}.quiz-symbols button{min-width:36px;padding:7px 9px;border-radius:7px;cursor:pointer}.grouped-exercise .exam-subquestion{padding:18px 0;border-top:1px solid #e2e8f0}.grouped-exercise .group-answer{width:100%;max-width:100%;box-sizing:border-box;padding:14px 16px;font-size:1.05rem;margin-top:8px;border:1px solid #cbd5e1;border-radius:10px}.grouped-exercise .exam-stem{white-space:pre-line;line-height:1.6}

/* User greeting, logout action, and chapter statistics */
.main header{align-items:center;flex-wrap:wrap}
.header-user{display:flex;align-items:center;justify-content:flex-end;gap:16px;flex-wrap:wrap}
.main header .header-user span{font-size:15px;color:#253b5a;font-weight:700}
.logout-btn{border:1px solid #d4ddf2;background:#eef2ff;color:#29459d;padding:12px 19px;border-radius:11px;font-weight:700;transition:background .15s,transform .15s}
.logout-btn:hover{background:#dce5ff;transform:translateY(-1px)}
.logout-btn:focus-visible{outline:3px solid #92aaf7;outline-offset:2px}
.logout-btn:disabled{opacity:.5}
.overall-performance{margin-bottom:22px}
.overall-performance h2{margin:0 0 15px;font-size:20px}
.performance-summary{display:grid;gap:9px;width:100%}
.performance-top{display:flex;gap:12px;justify-content:space-between;align-items:center;flex-wrap:wrap}
.performance-top strong{font-size:27px;color:#2f4fa8}
.performance-top span{font-size:13px;color:#50627b}
.performance-track{height:10px;border-radius:50px;background:#e5eaf4;overflow:hidden}
.performance-track>span{display:block;height:100%;background:linear-gradient(90deg,#4359cb,#54ae83);border-radius:50px}
.performance-summary small{font-size:12px;color:#64748b;line-height:1.55}
.chapter .performance-summary{margin-top:2px}
.chapter .performance-top strong{font-size:21px}
@media(max-width:560px){.header-user{width:100%;justify-content:space-between}.main header{gap:15px}}
