:root{--olive:#5f6f1f;--olive-d:#4a5717;--olive-l:#eef1df;--ink:#111;--bg:#f4f4ef;--line:#dcdccf;--red:#b42318;--green:#16794a;--safe-t:env(safe-area-inset-top);--safe-b:env(safe-area-inset-bottom)}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%}
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink);font-size:17px;line-height:1.45}
button{font:inherit;cursor:pointer}
.center{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
.spinner{width:36px;height:36px;border:4px solid var(--line);border-top-color:var(--olive);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.page{max-width:720px;margin:0 auto;padding:calc(16px + var(--safe-t)) 16px calc(24px + var(--safe-b))}
.brand{display:flex;align-items:center;gap:12px;margin-bottom:18px}
.brand img{width:48px;height:48px;border-radius:12px}.brand h1{font-size:21px;margin:0}.brand small{display:block;color:#666;font-size:13px;font-weight:400}
.card{background:#fff;border:1px solid var(--line);border-radius:16px;padding:18px;margin-bottom:14px}
label{display:block;font-weight:600;font-size:15px;margin-bottom:14px}
input{display:block;width:100%;margin-top:6px;padding:13px 14px;border:1px solid #bfbfb0;border-radius:10px;font:inherit;font-size:17px;background:#fff}
input:focus{outline:2px solid var(--olive);border-color:var(--olive)}
.btn{display:block;width:100%;background:var(--olive);color:#fff;border:0;border-radius:12px;padding:15px;font-weight:700;font-size:17px;text-align:center}
.btn:active{background:var(--olive-d)}.btn:disabled{opacity:.5}
.btn.ghost{background:#fff;color:var(--olive-d);border:1.5px solid var(--olive)}
.btn.dark{background:#111}
.btn+.btn{margin-top:10px}
.err{background:#fde8e7;color:var(--red);padding:10px 12px;border-radius:10px;margin-bottom:14px;font-size:15px}
.muted{color:#666;font-size:14px}
.hero{background:#111;color:#fff;border-radius:18px;padding:20px;margin-bottom:14px}
.hero h2{margin:0 0 6px;font-size:20px}.hero p{margin:0 0 16px;color:#cfd3c0;font-size:15px}
.secrow{display:flex;gap:8px;margin-bottom:16px}.secrow div{flex:1;background:#1f1f1f;border-radius:10px;padding:8px;font-size:12px;color:#bbb}
.secrow b{display:block;color:#fff;font-size:18px}
.list{list-style:none;margin:0;padding:0}
.list li{display:flex;justify-content:space-between;align-items:center;padding:12px 0;border-bottom:1px solid #eee;gap:8px}
.list li:last-child{border:0}.list li button{background:none;border:0;color:var(--olive-d);font-weight:600;padding:4px}
.pill{display:inline-block;padding:3px 10px;border-radius:20px;font-size:13px;font-weight:700}
.pill.pass{background:#e6f4ea;color:var(--green)}.pill.fail{background:#fde8e7;color:var(--red)}
.links{display:flex;justify-content:center;gap:22px;margin-top:8px}.links button{background:none;border:0;color:#555;text-decoration:underline;font-size:15px}

/* test screen */
.test{display:flex;flex-direction:column;min-height:100vh;max-width:760px;margin:0 auto}
.tbar{position:sticky;top:0;z-index:5;background:#111;color:#fff;padding:calc(10px + var(--safe-t)) 14px 10px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.tbar .sec{font-size:13px;color:#cfd3c0}.tbar .count{font-weight:700}
.timer{font-variant-numeric:tabular-nums;font-weight:700;background:#2a2a2a;padding:6px 10px;border-radius:8px}
.timer.low{background:var(--red)}
.prog{height:4px;background:#2a2a2a}.prog i{display:block;height:100%;background:#a3b34a;transition:width .2s}
.qbody{flex:1;padding:18px 16px}
.qtext{font-size:19px;font-weight:600;margin:0 0 14px}
.qimg{display:flex;justify-content:center;margin:0 0 16px}.qimg img{max-width:min(240px,70vw);max-height:240px;background:#fff;border-radius:10px}
.qimg img.wide{max-width:100%;max-height:none}
.opts{display:flex;flex-direction:column;gap:10px}
.opt{display:flex;gap:12px;align-items:flex-start;text-align:left;background:#fff;border:2px solid var(--line);border-radius:14px;padding:14px;font-size:17px;color:var(--ink)}
.opt b{flex:0 0 30px;height:30px;border-radius:50%;background:var(--olive-l);color:var(--olive-d);display:flex;align-items:center;justify-content:center;font-size:15px}
.opt.sel{border-color:var(--olive);background:var(--olive-l)}.opt.sel b{background:var(--olive);color:#fff}
.tfoot{position:sticky;bottom:0;background:#fff;border-top:1px solid var(--line);padding:10px 12px calc(10px + var(--safe-b));display:grid;grid-template-columns:1fr auto 1fr;gap:8px}
.tfoot button{border-radius:12px;padding:13px 10px;font-weight:700;border:1.5px solid var(--olive);background:#fff;color:var(--olive-d)}
.tfoot .next{background:var(--olive);color:#fff}.tfoot .flag.on{background:#fff4d6;border-color:#d4a200;color:#7a4b00}
.tfoot button:disabled{opacity:.35}

/* modal */
.modal{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:20;display:flex;align-items:flex-end;justify-content:center}
.modal[hidden]{display:none}
.sheet{background:#fff;width:100%;max-width:640px;border-radius:20px 20px 0 0;padding:18px 16px calc(18px + var(--safe-b));max-height:88vh;overflow:auto}
.sheet h3{margin:0 0 6px}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(44px,1fr));gap:6px;margin:12px 0}
.grid button{aspect-ratio:1;border-radius:9px;border:1.5px solid var(--line);background:#fff;font-weight:700;font-size:14px;position:relative}
.grid button.ans{background:var(--olive-l);border-color:var(--olive);color:var(--olive-d)}
.grid button.cur{outline:3px solid #111}
.grid button.flg::after{content:"";position:absolute;top:3px;right:3px;width:8px;height:8px;border-radius:50%;background:#e0a800}
.gridsec{font-size:13px;font-weight:700;color:#555;margin-top:10px}
.legend{display:flex;gap:14px;font-size:13px;color:#555;flex-wrap:wrap}
.legend i{display:inline-block;width:12px;height:12px;border-radius:3px;margin-right:4px;vertical-align:-1px;border:1.5px solid var(--line)}
.legend .a{background:var(--olive-l);border-color:var(--olive)}.legend .f{background:#e0a800;border-color:#e0a800;border-radius:50%}

/* results */
.verdict{text-align:center;border-radius:18px;padding:26px 16px;margin-bottom:14px;color:#fff}
.verdict.pass{background:var(--green)}.verdict.fail{background:var(--red)}
.verdict h2{font-size:32px;margin:0}.verdict p{margin:6px 0 0;opacity:.9}
.secres{margin-bottom:14px}.secres .top{display:flex;justify-content:space-between;font-weight:600;margin-bottom:6px;gap:10px}
.bar{position:relative;height:12px;background:#eee;border-radius:6px;overflow:hidden}
.bar i{display:block;height:100%;border-radius:6px}.bar i.ok{background:var(--green)}.bar i.no{background:var(--red)}
.bar s{position:absolute;top:-2px;bottom:-2px;width:2px;background:#111}
.secres small{color:#666}
.rev{border-left:5px solid var(--green)}.rev.wrong{border-left-color:var(--red)}
.rev .opt{cursor:default;padding:10px 12px;font-size:16px}.rev .opt.right{border-color:var(--green);background:#e6f4ea}
.rev .opt.mine{border-color:var(--red);background:#fde8e7}
.rev .ex{margin-top:10px;font-size:15px;color:#444;background:#f6f6f0;padding:10px;border-radius:10px}
.toggle{display:flex;gap:6px;margin-bottom:12px}.toggle button{flex:1;padding:10px;border-radius:10px;border:1.5px solid var(--olive);background:#fff;color:var(--olive-d);font-weight:600}
.toggle button.on{background:var(--olive);color:#fff}
.offline{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(84px + var(--safe-b));background:#111;color:#fff;padding:8px 14px;border-radius:20px;font-size:14px;z-index:30}
