
    :root{
      --bg:#f7f8ff;--surface:#fff;--surface2:#f0f2ff;--ink:#1f2440;--muted:#69708f;--line:#e2e5f2;
      --accent:#6657d9;--accent2:#8d7cf4;--ok:#238b63;--warn:#b56c00;--bad:#b74455;--shadow:0 14px 35px rgba(35,39,79,.10);
      --radius:22px;--tap:48px;--safe-top:env(safe-area-inset-top);--safe-bottom:env(safe-area-inset-bottom);
    }
    *{box-sizing:border-box}html{background:var(--bg);color:var(--ink);font-family:Inter,ui-rounded,"SF Pro Rounded","SF Pro Display",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
    body{margin:0;min-height:100vh;background:radial-gradient(circle at 10% -10%,#e6e3ff 0,transparent 35%),var(--bg)}
    button,input,select{font:inherit}button{cursor:pointer}.hidden{display:none!important}.muted{color:var(--muted)}.small{font-size:.86rem}.tiny{font-size:.78rem}.strong{font-weight:800}
    .shell{min-height:100vh;padding-top:var(--safe-top);padding-bottom:calc(84px + var(--safe-bottom))}
    .topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px;background:rgba(247,248,255,.88);backdrop-filter:blur(16px);border-bottom:1px solid rgba(226,229,242,.8)}
    .brand{display:flex;align-items:center;gap:10px;min-width:0}.brandmark{width:42px;height:42px;border-radius:14px;display:grid;place-items:center;background:linear-gradient(135deg,var(--accent),var(--accent2));color:white;font-weight:900;box-shadow:0 8px 18px rgba(102,87,217,.25)}
    .brandtext{min-width:0}.brandtitle{font-weight:900;white-space:nowrap}.brandsub{font-size:.75rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
    .profile-pill{border:1px solid var(--line);background:var(--surface);min-height:44px;padding:8px 11px;border-radius:15px;display:flex;align-items:center;gap:8px;color:var(--ink);font-weight:750}
    main{width:min(1120px,100%);margin:0 auto;padding:18px 16px 42px}
    h1,h2,h3,p{margin-top:0}h1{font-size:clamp(1.65rem,6vw,2.8rem);letter-spacing:-.04em;margin-bottom:8px}h2{font-size:1.3rem;letter-spacing:-.02em;margin-bottom:12px}h3{font-size:1rem;margin-bottom:6px}.lead{font-size:1.04rem;line-height:1.5;color:var(--muted)}
    .hero{padding:22px;border-radius:28px;background:linear-gradient(145deg,#fff,#f1efff);border:1px solid #e5e1ff;box-shadow:var(--shadow);margin-bottom:18px}.hero-row{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;flex-wrap:wrap}.hero-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
    .btn{min-height:var(--tap);border:0;border-radius:16px;padding:11px 16px;font-weight:850;display:inline-flex;align-items:center;justify-content:center;gap:8px}.btn.primary{background:var(--accent);color:#fff;box-shadow:0 8px 18px rgba(102,87,217,.22)}.btn.secondary{background:var(--surface2);color:var(--ink)}.btn.ghost{background:transparent;border:1px solid var(--line);color:var(--ink)}.btn.danger{background:#fff0f2;color:var(--bad)}.btn:focus-visible,.choice:focus-visible,.navbtn:focus-visible{outline:3px solid rgba(102,87,217,.35);outline-offset:2px}
    .grid{display:grid;grid-template-columns:1fr;gap:14px}.grid.two{grid-template-columns:1fr}.grid.cards{grid-template-columns:repeat(2,minmax(0,1fr))}
    .card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:0 7px 20px rgba(35,39,79,.05)}
    .subject-card{min-height:132px;display:flex;flex-direction:column;justify-content:space-between;position:relative;overflow:hidden}.subject-card::after{content:"";position:absolute;right:-30px;top:-32px;width:90px;height:90px;border-radius:50%;background:var(--subject-soft,#eef0ff)}.subject-icon{font-size:1.7rem;position:relative;z-index:1}.subject-name{font-weight:900;position:relative;z-index:1}.subject-meta{color:var(--muted);font-size:.82rem;position:relative;z-index:1}.subject-btn{all:unset;cursor:pointer;display:block}.subject-btn:focus-visible{outline:3px solid rgba(102,87,217,.35);border-radius:var(--radius)}
    .stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.stat{padding:12px;border-radius:16px;background:var(--surface2);text-align:center}.stat b{display:block;font-size:1.25rem}.stat span{font-size:.73rem;color:var(--muted)}
    .progress{height:10px;background:#eceef8;border-radius:999px;overflow:hidden}.progress>i{display:block;height:100%;background:linear-gradient(90deg,var(--accent),var(--accent2));border-radius:inherit}
    .row{display:flex;align-items:center;justify-content:space-between;gap:12px}.row.wrap{flex-wrap:wrap}.stack{display:flex;flex-direction:column;gap:12px}.chips{display:flex;flex-wrap:wrap;gap:8px}.chip{padding:7px 10px;border-radius:999px;background:var(--surface2);font-size:.8rem;font-weight:750}.chip.ok{background:#e8f7f1;color:var(--ok)}.chip.warn{background:#fff4e5;color:var(--warn)}
    .bottomnav{position:fixed;z-index:30;left:0;right:0;bottom:0;padding:8px 8px calc(8px + var(--safe-bottom));display:grid;grid-template-columns:repeat(5,1fr);gap:4px;background:rgba(255,255,255,.94);border-top:1px solid var(--line);backdrop-filter:blur(18px)}.navbtn{border:0;background:transparent;min-height:58px;border-radius:15px;color:var(--muted);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-size:.68rem;font-weight:780}.navbtn .ico{font-size:1.23rem}.navbtn.active{background:var(--surface2);color:var(--accent)}
    .screen{display:none}.screen.active{display:block}
    .exercise-wrap{max-width:760px;margin:0 auto}.exercise-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}.exercise-card{background:var(--surface);border:1px solid var(--line);border-radius:28px;padding:20px;box-shadow:var(--shadow)}.kicker{font-size:.8rem;font-weight:850;color:var(--accent);text-transform:uppercase;letter-spacing:.06em}.question{font-size:clamp(1.35rem,5vw,2rem);font-weight:900;line-height:1.25;letter-spacing:-.02em;margin:12px 0 18px}.context{padding:13px;border-radius:16px;background:#f6f7fc;color:#424865;line-height:1.55;margin-bottom:14px}.choices{display:grid;grid-template-columns:1fr;gap:10px}.choice{border:1px solid var(--line);background:white;min-height:58px;border-radius:17px;padding:12px 14px;text-align:left;font-weight:760;color:var(--ink)}.choice:hover{background:#f9f8ff}.choice.selected{border-color:var(--accent);background:#f1efff}.choice.correct{border-color:#83c9ad;background:#eaf8f2;color:#176749}.choice.wrong{border-color:#e5a1ac;background:#fff0f2;color:#8f3141}
    .answerbox{display:flex;gap:10px}.answerbox input{width:100%;min-height:56px;border:1px solid var(--line);border-radius:16px;padding:12px 14px;background:#fff;color:var(--ink);font-size:1.1rem}.feedback{margin-top:15px;border-radius:18px;padding:14px;line-height:1.45}.feedback.good{background:#eaf8f2;color:#176749}.feedback.bad{background:#fff2f3;color:#873746}.feedback b{display:block;margin-bottom:4px}.exercise-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:15px}.mission-dots{display:flex;gap:6px;flex:1}.mission-dot{height:8px;border-radius:999px;background:#e5e7f2;flex:1}.mission-dot.done{background:var(--accent)}
    .profile-grid{display:grid;grid-template-columns:1fr;gap:12px}.profile-card{border:1px solid var(--line);background:var(--surface);border-radius:20px;padding:16px;display:flex;justify-content:space-between;align-items:center;gap:12px}.avatar{width:48px;height:48px;border-radius:16px;background:var(--surface2);display:grid;place-items:center;font-size:1.35rem;font-weight:900;color:var(--accent)}
    .modal{position:fixed;inset:0;z-index:60;background:rgba(20,23,45,.52);display:grid;place-items:end center;padding:14px}.sheet{width:min(640px,100%);max-height:90vh;overflow:auto;background:var(--surface);border-radius:26px;padding:20px;box-shadow:0 24px 80px rgba(0,0,0,.25)}.field{display:flex;flex-direction:column;gap:7px;margin-bottom:13px}.field label{font-size:.82rem;font-weight:820}.field input,.field select{min-height:50px;border:1px solid var(--line);border-radius:14px;padding:10px 12px;background:#fff;color:var(--ink)}
    .table{width:100%;border-collapse:collapse;font-size:.88rem}.table th,.table td{text-align:left;padding:10px 8px;border-bottom:1px solid var(--line)}.table th{color:var(--muted);font-size:.76rem;text-transform:uppercase;letter-spacing:.04em}.mastery{font-weight:800}.mastery.m0{color:#8b91a9}.mastery.m1{color:#7c6dbe}.mastery.m2{color:#5c64be}.mastery.m3{color:#35839b}.mastery.m4{color:var(--ok)}
    .empty{padding:28px 18px;text-align:center;border:1px dashed #cfd3e6;border-radius:22px;background:rgba(255,255,255,.55)}
    .toast{position:fixed;z-index:80;left:50%;transform:translateX(-50%);bottom:calc(92px + var(--safe-bottom));background:#20243d;color:#fff;padding:10px 14px;border-radius:13px;font-size:.88rem;box-shadow:var(--shadow)}
    .footer-note{margin-top:20px;font-size:.76rem;line-height:1.45;color:var(--muted)}
    @media(min-width:720px){main{padding:28px 24px 56px}.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}.grid.cards{grid-template-columns:repeat(4,minmax(0,1fr))}.profile-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.choices{grid-template-columns:repeat(2,minmax(0,1fr))}.bottomnav{left:50%;right:auto;transform:translateX(-50%);width:min(680px,96%);bottom:12px;border:1px solid var(--line);border-radius:22px;padding:7px;box-shadow:var(--shadow)}.shell{padding-bottom:110px}.modal{place-items:center}.sheet{border-radius:28px}.hero{padding:30px}}
    @media(min-width:1000px){.grid.cards{grid-template-columns:repeat(7,minmax(0,1fr))}.subject-card{min-height:148px}.subject-name{font-size:.94rem}}
    @media(prefers-reduced-motion:no-preference){.screen.active{animation:fade .18s ease}.card,.btn,.choice{transition:.16s ease}.btn:active,.choice:active{transform:scale(.985)}@keyframes fade{from{opacity:.65;transform:translateY(3px)}to{opacity:1;transform:none}}}
  /* Responsive extensions preserve the V1 visual identity. */
select,input{max-width:100%;min-height:48px;border:1px solid var(--line);border-radius:12px;padding:10px;background:white;color:var(--ink);font-size:1rem}button:disabled{cursor:default}.sudoku{display:grid;grid-template-columns:repeat(4,1fr);gap:0;width:min(280px,100%);border:3px solid var(--ink);margin:18px 0}.sudoku>*{width:100%;min-width:0;height:58px;border:1px solid var(--line);border-radius:0;text-align:center;font-size:1.15rem}.sudoku>*:nth-child(4n+2){border-right:3px solid var(--ink)}.sudoku>*:nth-child(n+5):nth-child(-n+8){border-bottom:3px solid var(--ink)}.sudoku .given{display:grid;place-items:center;background:var(--surface2);font-weight:800}.memory{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.memory .choice{text-align:center;font-size:2rem;min-height:80px}.matchrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);align-items:center;gap:12px}.matchrow select{width:100%}#validateExtra{margin-top:16px}.context{white-space:pre-line}details{margin:12px 0}summary{cursor:pointer;padding:12px;border-radius:12px;background:var(--surface2);font-weight:700}button:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible{outline:3px solid #8070e8;outline-offset:3px}.brandsub{font-size:.8rem}.navbtn{font-size:.78rem}.stat span,.subject-meta,.footer-note{font-size:.875rem}.tiny{font-size:.8rem}.table{table-layout:fixed;overflow-wrap:anywhere}.table th,.table td{padding:10px 5px}.row>*{min-width:0}.row{flex-wrap:wrap}.topbar .row{flex-wrap:nowrap}.profile-pill{max-width:42%;overflow-wrap:anywhere}.brandtitle{white-space:normal}.brandsub{white-space:normal}.brandmark{flex-shrink:0}.subject-name{overflow-wrap:normal}.subject-card{min-height:160px}.answerbox{flex-wrap:wrap}.answerbox input{flex:1;min-width:140px}.exercise-card{padding:18px}.btn[hidden]{display:none}.grid.cards{grid-template-columns:repeat(2,minmax(0,1fr))}@media(min-width:720px){.grid.cards{grid-template-columns:repeat(4,minmax(0,1fr))}.table{table-layout:auto}}@media(min-width:1000px){.grid.cards{grid-template-columns:repeat(4,minmax(0,1fr))}.subject-card{min-height:140px}.hero h1{max-width:650px}}@media(max-width:380px){.brandmark{display:none}.topbar{gap:8px;padding:12px}.profile-pill{font-size:.85rem}.navbtn{font-size:.72rem}.card{padding:13px}.hero{padding:18px}.table{font-size:.78rem}.table th{font-size:.72rem}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

/* V2: exact learning diagrams and touch-safe layouts. */
.learning-figure{margin:16px 0;padding:14px;border:1px solid var(--line);border-radius:16px;background:var(--surface2)}
.learning-figure figcaption{font-size:.875rem;line-height:1.5;margin:8px 0}
.fraction-bar{display:grid;min-height:56px;border:2px solid var(--ink)}.fraction-bar span{border-right:1px solid var(--ink);background:white}.fraction-bar span:last-child{border-right:0}.fraction-bar .filled{background:var(--accent)}
.learning-grid{display:grid;gap:4px}.learning-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}.learning-row>div{padding:12px 4px;border:1px solid var(--line);background:white;text-align:center;overflow-wrap:anywhere;font-weight:700}.matrix .learning-row>div{font-size:1.8rem}.map .learning-row>div{font-size:.875rem;min-height:55px;display:grid;place-items:center}
.exercise-head{flex-wrap:wrap}.mission-dots{min-width:80px}.context,.question,.choice,.chip{overflow-wrap:anywhere}.sheet{max-height:calc(100dvh - 28px - env(safe-area-inset-bottom));padding-bottom:calc(20px + env(safe-area-inset-bottom))}.topbar{padding-top:calc(14px + env(safe-area-inset-top))}.shell{padding-top:0}.toast{max-width:calc(100vw - 24px);width:max-content}.profile-card{flex-wrap:wrap}.profile-card .avatar{flex-shrink:0}.matchrow select{min-width:0}.matchrow input[type=checkbox]{width:28px;height:28px;min-height:28px;justify-self:end}.matchrow:has(input[type=checkbox]){min-height:48px}.table a{overflow-wrap:anywhere}li{margin-bottom:8px}.navbtn{font-size:.875rem}.kicker,.field label,.subject-meta{font-size:.875rem}
@media(max-width:430px){.matchrow{grid-template-columns:1fr}.matchrow:has(input[type=checkbox]){grid-template-columns:minmax(0,1fr) 36px}.hero .stats{width:100%}.exercise-head .btn{padding-inline:10px}.navbtn{font-size:.8rem}.table{font-size:.875rem}.table th{font-size:.8rem}.brandtitle{font-size:.95rem}.brandsub{font-size:.75rem}.learning-figure{padding:8px}.learning-row>div{padding:10px 2px}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
