:root{
  --paper:#F5F1E8; --ink:#172036; --muted:#5B6275; --line:#E3DCCB; --card:#FFFFFF;
  --chip:#EDE8DA; --red:#B83A26; --red-bg:#F6E1DB; --gold:#E0B04C; --green:#1E6B52; --green-bg:#E1F0E8;
  --navy-soft:#B7BDD0; --navy-line:#2C3856;
  --serif:'Lora',Georgia,'Times New Roman',serif; --sans:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--sans);-webkit-text-size-adjust:100%}
body{min-height:100vh;min-height:100dvh}
a{color:inherit;text-decoration:none}
button{font-family:inherit;color:inherit}
a:focus-visible,button:focus-visible,input:focus-visible{outline:2px solid var(--red);outline-offset:2px}
h1,h2,h3{margin:0}
.shell{max-width:480px;margin:0 auto;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column}
.page{flex:1;padding:20px 20px 16px;display:flex;flex-direction:column;gap:14px}
.title{font-family:var(--serif);font-weight:700;font-size:28px;line-height:36px}
.h2{font-family:var(--serif);font-weight:700;font-size:17px}
.muted{color:var(--muted)}
.small{font-size:12px}

/* tab bar */
.tabs{position:sticky;bottom:0;display:flex;background:var(--card);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
.tabs a{flex:1;height:64px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:11px;font-weight:600;color:var(--muted)}
.tabs a[aria-current=page]{color:var(--red)}
.tabs svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* generic */
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px}
.btn{display:flex;align-items:center;justify-content:center;gap:8px;height:52px;border-radius:16px;border:0;background:var(--red);color:#fff;font-size:16px;font-weight:600;cursor:pointer;width:100%}
.btn:disabled{background:var(--line);color:var(--muted);cursor:default}
.btn.ghost{background:var(--card);color:var(--ink);border:1px solid var(--line)}
.btn.small{height:38px;font-size:14px;border-radius:12px;width:auto;padding:0 16px}
.btn.outline{background:transparent;border:1.5px solid var(--red);color:var(--red)}
.btn.outline-light{background:transparent;border:1.5px solid var(--paper);color:var(--paper)}
.link{font-size:14px;font-weight:600;background:none;border:0;cursor:pointer;height:40px;color:var(--ink)}
.chip{font-size:12px;font-weight:700;border-radius:8px;padding:4px 8px;flex:none;white-space:nowrap}
.chip.progress{background:var(--red-bg);color:var(--red)}
.chip.new{background:var(--green-bg);color:var(--green)}
.chip.done{background:var(--chip);color:var(--ink)}
.chip.vip{background:var(--ink);color:var(--gold)}
.chip.lock{background:var(--ink);color:var(--gold)}
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.stat{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:10px 12px;text-align:center}
.stat b{display:block;font-family:var(--serif);font-size:20px}
.stat span{font-size:11px;color:var(--muted)}
.row-between{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.bar{height:6px;border-radius:3px;background:var(--line)}
.bar i{display:block;height:6px;border-radius:3px;background:var(--red)}
.empty{padding:32px 0;text-align:center;font-size:14px;color:var(--muted)}
.skeleton{height:64px;border-radius:16px;background:linear-gradient(90deg,#ece6d6,#f3eee1,#ece6d6);background-size:200% 100%;animation:sk 1.2s infinite}
@keyframes sk{to{background-position:-200% 0}}

/* home */
.top{display:flex;align-items:center;justify-content:space-between}
.word{font-family:var(--serif);font-weight:700;font-size:14px;letter-spacing:.14em}
.hello{font-family:var(--serif);font-weight:700;font-size:26px;line-height:32px}
.avatar{width:40px;height:40px;border-radius:20px;background:var(--ink);color:var(--gold);display:flex;align-items:center;justify-content:center;font-family:var(--serif);font-weight:700;font-size:17px;flex:none}
.hero{background:var(--ink);color:var(--paper);border-radius:20px;padding:18px 20px;display:flex;flex-direction:column;gap:6px}
.hero .eyebrow{font-size:11px;font-weight:700;letter-spacing:.1em;color:var(--gold)}
.hero .name{font-family:var(--serif);font-weight:600;font-size:21px;line-height:27px}
.hero .bar{background:var(--navy-line);margin:6px 0 4px}
.hero .bar i{background:var(--gold)}
.hero .cnt{font-size:12px;color:var(--navy-soft)}
.hero .btn{background:var(--red);height:48px;margin-top:8px}
.premium-banner{background:var(--ink);color:var(--paper);border-radius:16px;padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:12px}
.premium-banner b{font-family:var(--serif);font-size:16px;display:block}
.premium-banner span{font-size:12px;color:var(--navy-soft)}
.premium-banner .btn{background:var(--gold);color:var(--ink);height:38px;width:auto;padding:0 14px;font-size:14px;border-radius:12px;flex:none}

/* test list */
.search{display:flex;align-items:center;gap:10px;height:48px;padding:0 14px;background:var(--card);border:1px solid var(--line);border-radius:14px}
.search input{flex:1;min-width:0;border:0;outline:0;background:transparent;font:inherit;font-size:15px;color:var(--ink)}
.search svg{width:20px;height:20px;fill:none;stroke:var(--muted);stroke-width:1.8;stroke-linecap:round;flex:none}
.filters{display:flex;gap:8px}
.filters button{height:40px;padding:0 18px;border-radius:20px;font-size:14px;font-weight:600;cursor:pointer;background:var(--card);border:1px solid var(--line)}
.filters button[aria-pressed=true]{background:var(--ink);color:var(--paper);border-color:var(--ink)}
.list{display:flex;flex-direction:column;gap:10px}
.item{display:flex;align-items:center;gap:12px;width:100%;text-align:left;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px;cursor:pointer}
.tile{width:44px;height:44px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:13px;flex:none;background:var(--red-bg);color:var(--red);overflow:hidden}
.tile.vip{background:var(--ink);color:var(--gold)}
.item .meta{flex:1;min-width:0}
.item .t{font-size:15px;font-weight:600;overflow-wrap:anywhere}
.item .s{font-size:12px;color:var(--muted);margin-top:2px}

/* quiz */
.quiz{padding:12px 20px 20px;gap:8px}
.qbar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;height:44px}
.iconbtn{width:44px;height:44px;margin-left:-10px;display:flex;align-items:center;justify-content:center;background:none;border:0;cursor:pointer}
.iconbtn svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.counter{font-family:var(--serif);font-weight:700;font-size:17px}
.timer{justify-self:end;display:flex;align-items:center;gap:6px;height:34px;padding:0 12px;border-radius:17px;background:var(--card);border:1px solid var(--line);font-size:14px;font-weight:600;font-variant-numeric:tabular-nums}
.timer svg{width:16px;height:16px;fill:none;stroke:var(--red);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.timer.low{border-color:var(--red);color:var(--red)}
.qtitle{font-size:12px;font-weight:600;letter-spacing:.04em;color:var(--muted);margin-top:4px}
.qtext{font-family:var(--serif);font-weight:600;font-size:19px;line-height:26px;overflow-wrap:anywhere}
.qimg{position:relative;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:10px;margin-top:4px;cursor:zoom-in;text-align:center}
.qimg img{max-width:100%;max-height:300px;border-radius:8px;display:block;margin:0 auto;object-fit:contain}
.qimg .hint{display:flex;justify-content:flex-end;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--muted);margin-top:8px}
.qimg .hint svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.opts{display:flex;flex-direction:column;gap:8px;margin-top:6px}
.opt{width:100%;min-height:52px;display:flex;align-items:center;gap:12px;padding:10px 16px;border-radius:14px;font-size:15px;font-weight:600;cursor:pointer;background:var(--card);border:1px solid var(--line);text-align:left;overflow-wrap:anywhere}
.opt .mark{width:22px;height:22px;border-radius:11px;border:2px solid #C9C1AE;flex:none;display:flex;align-items:center;justify-content:center}
.opt .mark svg{width:14px;height:14px;fill:none;stroke:#fff;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
.opt.correct{background:var(--green-bg);border:2px solid var(--green)}
.opt.correct .mark{background:var(--green);border-color:var(--green)}
.opt.wrong{background:var(--red-bg);border:2px solid var(--red)}
.opt.wrong .mark{background:var(--red);border-color:var(--red)}
.opt.dim{color:var(--muted)}
.opt:disabled{cursor:default}
.qfoot{margin-top:auto;padding-top:10px}

/* result */
.ringwrap{display:flex;flex-direction:column;align-items:center;gap:6px}
.ring{position:relative;width:168px;height:168px}
.ring svg{transform:rotate(-90deg)}
.ring .c{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.ring .c b{font-family:var(--serif);font-size:42px;line-height:46px}
.ring .c span{font-size:13px;color:var(--muted)}
.cert{display:flex;align-items:center;gap:14px}
.cert .thumb{width:88px;height:62px;background:#FBF7EC;border:1px solid #C9B27A;padding:4px;flex:none}
.cert .thumb div{height:100%;border:1px solid #C9B27A;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-family:var(--serif);font-weight:700;font-size:8px;letter-spacing:.12em}
.cert .thumb i{display:block;width:40px;height:3px;background:#C9B27A}
.wrongitem{display:flex;gap:12px;align-items:flex-start;background:var(--card);border:1px solid var(--line);border-radius:14px;padding:10px 14px}
.wrongitem .x{width:26px;height:26px;border-radius:13px;background:var(--red-bg);display:flex;align-items:center;justify-content:center;flex:none;font-size:12px;font-weight:700;color:var(--red)}
.wrongitem .q{font-size:13px;font-weight:600;overflow-wrap:anywhere}
.wrongitem .a{font-size:12px;color:var(--green);margin-top:3px;overflow-wrap:anywhere}
.wrongitem .b{font-size:12px;color:var(--red);margin-top:2px;overflow-wrap:anywhere}

/* rating */
.seg{display:flex;gap:4px;padding:4px;background:var(--chip);border-radius:14px}
.seg button{flex:1;height:40px;border:0;border-radius:10px;font-size:14px;font-weight:600;cursor:pointer;background:transparent;color:#4A5164}
.seg button[aria-pressed=true]{background:#fff;color:var(--ink)}
.podium{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;align-items:end;margin-top:4px}
.pcol{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:0}
.pav{border-radius:50%;display:flex;align-items:center;justify-content:center;font-family:var(--serif);font-weight:700}
.pname{font-size:13px;font-weight:600;margin-top:4px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pval{font-size:12px;color:var(--muted)}
.pstep{width:100%;margin-top:6px;border-radius:12px 12px 0 0;display:flex;align-items:center;justify-content:center;font-family:var(--serif);font-weight:700}
.rrow{display:flex;align-items:center;gap:12px;height:52px;padding:0 14px;background:var(--card);border:1px solid var(--line);border-radius:14px}
.rrow.me{border-color:var(--red)}
.rrow .rk{width:22px;font-family:var(--serif);font-weight:700;font-size:16px;color:var(--muted)}
.rrow .av{width:34px;height:34px;border-radius:17px;background:var(--chip);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;flex:none}
.rrow .nm{flex:1;min-width:0;font-size:15px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rrow .vl{font-size:14px;font-weight:600}
.mebar{margin-top:auto;position:sticky;bottom:calc(72px + env(safe-area-inset-bottom));background:var(--ink);color:var(--paper);border-radius:16px;padding:0 16px;height:60px;display:flex;align-items:center;gap:12px}
.mebar .rk{min-width:30px;font-family:var(--serif);font-weight:700;font-size:20px;color:var(--gold)}
.mebar .av{width:36px;height:36px;border-radius:18px;background:var(--red);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;flex:none}
.mebar .who{flex:1;min-width:0}
.mebar .who b{display:block;font-size:15px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.mebar .who span{font-size:11px;color:var(--navy-soft)}
.mebar .val{font-size:15px;font-weight:700;color:var(--gold)}

/* profile */
.phead{display:flex;align-items:center;gap:14px}
.phead .avatar{width:64px;height:64px;border-radius:32px;font-size:26px}
.badge{display:inline-block;margin-top:4px;font-size:11px;font-weight:700;letter-spacing:.08em;background:var(--ink);color:var(--gold);border-radius:8px;padding:3px 8px}
.badge.free{background:var(--chip);color:var(--muted)}
.pcard{background:var(--ink);color:var(--paper);border-radius:20px;padding:18px 20px;display:flex;flex-direction:column;gap:6px}
.pcard .big{font-family:var(--serif);font-weight:600;font-size:22px}
.pcard .bar{background:var(--navy-line);margin:4px 0 8px}
.pcard .bar i{background:var(--gold)}
.pcard .sub{font-size:12px;color:var(--navy-soft)}
.reflink{flex:1;min-width:0;height:44px;padding:0 12px;background:var(--paper);border-radius:12px;display:flex;align-items:center;font-size:13px;color:var(--muted);overflow:hidden;white-space:nowrap}
.copybtn{height:44px;padding:0 14px;border-radius:12px;display:flex;align-items:center;gap:6px;font-size:14px;font-weight:600;cursor:pointer;border:0;background:var(--red);color:#fff}
.copybtn.ok{background:var(--green)}
.copybtn svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.menu{background:var(--card);border:1px solid var(--line);border-radius:16px;overflow:hidden}
.menu>*{display:flex;align-items:center;justify-content:space-between;width:100%;min-height:50px;padding:8px 16px;border:0;border-bottom:1px solid var(--line);background:none;font-size:15px;font-weight:600;text-align:left;cursor:pointer}
.menu>*:last-child{border-bottom:0}
.menu svg{width:18px;height:18px;fill:none;stroke:var(--muted);stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.lang{display:flex;gap:4px;padding:3px;background:var(--chip);border-radius:10px}
.lang button{height:34px;padding:0 12px;border:0;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;background:transparent;color:#4A5164}
.lang button[aria-pressed=true]{background:#fff;color:var(--ink)}
.back{display:flex;align-items:center;gap:6px;height:44px;margin-left:-6px;font-size:14px;font-weight:600;background:none;border:0;cursor:pointer}
.back svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* modal / overlay */
#overlay{position:fixed;inset:0;z-index:50;background:rgba(23,32,54,.55);display:flex;align-items:flex-end;justify-content:center}
#overlay[hidden]{display:none}
.sheet{width:100%;max-width:480px;max-height:88vh;overflow:auto;background:var(--paper);border-radius:20px 20px 0 0;padding:20px 20px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px}
.sheet input{height:48px;border-radius:12px;border:1px solid var(--line);padding:0 14px;font:inherit;font-size:16px;background:#fff;color:var(--ink);width:100%}
.sheet pre{white-space:pre-wrap;font-family:var(--sans);font-size:14px;line-height:20px;margin:0}
.zoom{position:fixed;inset:0;z-index:60;background:#0e1424;overflow:auto;touch-action:pinch-zoom pan-x pan-y}
.zoom img{display:block;min-width:100%;width:180%;max-width:none;margin:60px auto 40px;background:#fff}
.zoom button{position:fixed;top:12px;right:12px;width:44px;height:44px;border-radius:22px;border:0;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center}
.zoom button svg{width:20px;height:20px;fill:none;stroke:var(--ink);stroke-width:2;stroke-linecap:round}
.err{padding:40px 20px;text-align:center;display:flex;flex-direction:column;gap:12px;align-items:center}
@media (prefers-reduced-motion:reduce){.skeleton{animation:none}}

.wthumb{display:block;max-width:100%;max-height:96px;margin-top:6px;border-radius:8px;border:1px solid var(--line);background:#fff;cursor:zoom-in}
