*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",sans-serif;color:#20242e;background:#f6f7f9}
header{background:linear-gradient(120deg,#6d28d9 0%,#9333ea 55%,#db2777 100%);color:#fff;padding:14px 12px 12px;text-align:center;box-shadow:0 2px 10px rgba(109,40,217,.25)}
header h1{margin:0;font-size:21px;text-shadow:0 1px 3px rgba(0,0,0,.25)}
.sub{opacity:.95;margin:4px 0;font-size:13px}
.badge,.sync{font-size:12.5px;background:rgba(255,255,255,.25);display:inline-block;padding:3px 11px;border-radius:999px;font-weight:600}
main{max-width:760px;margin:0 auto;padding:12px}
.panel{background:#fff;border-radius:16px;padding:16px;margin-top:12px;box-shadow:0 1px 4px rgba(16,24,40,.06);border:1px solid #e4e7ec}
.panel h2{margin-top:0;font-size:17px;color:#20242e;border-bottom:2px solid #eef0f3;padding-bottom:6px}
.panel h3{font-size:15px;margin-bottom:6px;color:#20242e}
.fund-panel{background:#fff}
label{display:block;margin:10px 0;font-size:14px;color:#20242e;font-weight:600}
input,select{width:100%;padding:10px;border:1.5px solid #d3d8e0;border-radius:10px;font-size:16px;margin-top:4px;background:#fff;font-weight:400;color:#20242e}
input:focus,select:focus{outline:2px solid #7c3aed;border-color:#7c3aed}
.primary{width:100%;padding:13px;border:0;border-radius:12px;background:linear-gradient(120deg,#6d28d9,#7c3aed);color:#fff;font-size:16px;font-weight:700;margin-top:8px;box-shadow:0 3px 8px rgba(109,40,217,.3);cursor:pointer}
.primary:active{transform:scale(.99)}
.hint{font-size:13px;color:#5b6472}
.hidden{display:none!important}
button{font-family:inherit}
.userbar{margin-top:8px;display:flex;gap:10px;align-items:center;justify-content:center;flex-wrap:wrap;font-size:13px}
.userbar button{padding:5px 12px;border-radius:999px;border:1px solid rgba(255,255,255,.8);background:rgba(255,255,255,.18);color:#fff;cursor:pointer;font-size:13px;font-weight:600}
.linkbtn{display:block;margin:10px auto 0;border:0;background:none;color:#6d28d9;font-size:14px;cursor:pointer;text-decoration:underline;font-weight:600}
.authcard{max-width:760px;margin:12px auto 0}
footer{text-align:center;font-size:12px;color:#5b6472;padding:18px}
.meta{font-size:13px;color:#5b6472}
.stats-line{font-size:14.5px;line-height:1.65;color:#20242e}
.learn-bar{height:10px;background:#e9ebef;border-radius:999px;margin-top:10px;overflow:hidden}
.learn-bar>div{height:100%;background:#7c3aed;border-radius:999px;transition:width .4s}
/* --- Ô mục học (trang chính cấp 1) --- */
.tile-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.cat-tile{display:flex;flex-direction:column;align-items:flex-start;gap:3px;text-align:left;background:#fff;border:1.5px solid #e4e7ec;border-left:6px solid var(--tc,#7c3aed);border-radius:14px;padding:14px 14px 12px;cursor:pointer;box-shadow:0 1px 3px rgba(16,24,40,.05)}
.cat-tile:active{transform:scale(.99)}
.tile-icon{font-size:26px;line-height:1.1}
.tile-name{font-size:16px;font-weight:800;color:#20242e}
.tile-meta{font-size:12.5px;color:#5b6472}
/* --- Danh sách bộ thẻ trong mục (cấp 2) --- */
.deck-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px;margin:10px 0;background:#fff;border:1px solid #e4e7ec;border-radius:12px}
.deck-row .grow{flex:1;min-width:0}
.deck-title{font-size:15.5px;font-weight:700;color:#20242e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.deck-desc{font-size:13px;color:#5b6472;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.deck-btns{display:flex;flex-direction:column;gap:6px;flex-shrink:0}
.btn-study{padding:9px 13px;border-radius:9px;border:0;background:#6d28d9;color:#fff;font-size:13.5px;font-weight:700;cursor:pointer;white-space:nowrap}
.btn-view{padding:8px 13px;border-radius:9px;border:1.5px solid #c9cfd8;background:#fff;color:#20242e;font-size:13.5px;font-weight:600;cursor:pointer;white-space:nowrap}
.list{list-style:none;padding:0;margin:10px 0}
.list li{padding:10px 6px;border-bottom:1px solid #eef0f3;color:#20242e}
.list .row{display:flex;justify-content:space-between;gap:10px}
.list .grow{flex:1}
.list button{padding:6px 10px;border-radius:8px;border:1.5px solid #c9cfd8;background:#fff;color:#20242e;cursor:pointer}
.boxchip{display:inline-block;padding:2px 10px;border-radius:999px;color:#fff;font-size:12px;font-weight:700;margin-right:6px}
.boxchip.bnew{background:#94a3b8}
.boxchip.b0{background:#ef4444}
.boxchip.b1{background:#f97316}
.boxchip.b2{background:#eab308;color:#713f12}
.boxchip.b3{background:#22c55e}
.boxchip.b4{background:#06b6d4}
.boxchip.b5{background:#8b5cf6}
/* --- Thẻ ôn tập --- */
.bigcard{background:#fff;border:2px solid #e4e7ec;border-radius:18px;padding:28px 20px;text-align:center;cursor:pointer;min-height:280px;display:flex;flex-direction:column;justify-content:center;gap:14px;margin:10px 0;box-shadow:0 2px 8px rgba(16,24,40,.06)}
.bigcard .jp,.type-back .jp{font-size:42px;font-weight:800;color:#20242e;line-height:1.4}
.bigcard .jp.kanji-big{font-size:118px;line-height:1.15;color:#20242e}
.bigcard .rd,.type-back .rd{font-size:19px;color:#5b6472;font-style:italic}
.bigcard .vn,.type-back .vn{font-size:26px;font-weight:700;color:#20242e;line-height:1.4}
.bigcard .words,.type-back .words{background:#f6f7f9;border:1.5px dashed #b6bdc9;border-radius:12px;padding:10px 12px;font-size:17px;color:#20242e;line-height:1.6}
.bigcard .ex,.type-back .ex{font-size:19px;color:#20242e;line-height:1.5;border-top:1px dashed #d3d8e0;padding-top:12px}
.bigcard .exvn,.type-back .exvn{font-size:16px;color:#5b6472;margin-top:-8px}
.bigcard .tap{color:#5b6472;font-size:15px;font-weight:600}
.words-sm{background:#f6f7f9;border:1.5px dashed #b6bdc9;border-radius:10px;padding:6px 10px;font-size:14px;color:#20242e;margin-top:5px;line-height:1.6}
.exvn-sm{color:#5b6472!important}
.review-btns{display:flex;gap:10px;margin-top:12px}
.review-btns button{flex:1;padding:16px;font-size:17px;font-weight:700;border-radius:12px;cursor:pointer}
.btn-know{background:linear-gradient(120deg,#16a34a,#22c55e)!important;color:#fff!important;border:0!important;box-shadow:0 3px 8px rgba(34,197,94,.35)}
.btn-dunno{background:#fff!important;color:#dc2626!important;border:2px solid #dc2626!important}
.btn-dunno.suggest{box-shadow:0 0 0 4px rgba(245,158,11,.55);background:#fff7ed!important}
.speak-btn{align-self:center;font-size:19px;padding:8px 18px;border-radius:999px;border:1.5px solid #c9cfd8;background:#fff;color:#20242e;cursor:pointer}
.progress-note{font-size:14px;color:#5b6472;text-align:center;font-weight:600}
#btnQuitReview,#btnQuitBrowse,#btnBackHome{padding:10px 14px;border-radius:10px;border:2px solid #7c3aed;background:#fff;color:#6d28d9;font-weight:700;cursor:pointer;margin-top:10px}
/* --- Chuyển chế độ học --- */
.mode-bar{display:flex;gap:8px;margin:4px 0 2px}
.mode-bar button{flex:1;padding:10px;border-radius:999px;border:1.5px solid #c9cfd8;background:#fff;color:#20242e;font-size:14.5px;font-weight:700;cursor:pointer}
.mode-bar button.on{background:#6d28d9;border-color:#6d28d9;color:#fff}
/* --- Ô gõ cách đọc --- */
.type-box{margin-top:6px}
.type-row{display:flex;gap:8px}
.type-row button{flex:1;padding:12px 14px;border-radius:10px;font-size:15.5px;font-weight:700;cursor:pointer;white-space:nowrap}
#btnCheck{border:0;background:#6d28d9;color:#fff}
#btnHint{border:1.5px solid #c9cfd8;background:#fff;color:#20242e}
#btnHint:disabled{opacity:.45;cursor:default}
.type-feedback{margin-top:10px;font-size:16px;font-weight:700;min-height:22px}
.type-feedback.ok{color:#15803d}
.type-feedback.bad{color:#dc2626}
.type-hint{margin-top:2px;font-size:15px;color:#5b6472;min-height:20px}
.type-back{margin-top:12px;border:1px solid #e4e7ec;border-radius:14px;background:#fff;padding:16px;text-align:center;display:flex;flex-direction:column;gap:10px}
.hint-note{background:#fefce8;border:1px solid #fde68a;color:#713f12;border-radius:10px;padding:8px 10px;font-size:13.5px;line-height:1.45}
.shake{animation:shk .3s ease}
@keyframes shk{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
/* --- Ô gõ cách đọc ngay dưới từng chữ (trong thẻ) --- */
.front-grid{display:flex;gap:6px;justify-content:center;align-items:flex-start;width:100%;margin:0 auto}
.fcol{flex:1 1 0;min-width:0;display:flex;flex-direction:column;align-items:center;gap:7px}
.fchar{font-weight:800;color:#20242e;line-height:1.25}
.rcell{width:100%;margin-top:0;padding:8px 2px;text-align:center;font-size:18px;border:1.5px solid #d3d8e0;border-radius:10px;background:#fff;color:#20242e}
.rcell:focus{outline:2px solid #7c3aed;border-color:#7c3aed}
.rcell.locked{background:#eef0f3;border-color:#e4e7ec;color:#5b6472;font-weight:700;-webkit-text-fill-color:#5b6472}
.front-single{width:100%}
.rcell.wide{display:block;max-width:340px;margin:0 auto}
.speak-btn.speak-sm{font-size:14.5px;padding:5px 14px}
/* --- Lưới kanji (màn Xem) --- */
.kanji-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:10px}
.kanji-grid li{border:1.5px solid #e4e7ec;background:#fff;border-radius:14px;padding:10px 6px;text-align:center;cursor:pointer}
.kanji-grid .kchar{font-size:46px;font-weight:800;color:#20242e;line-height:1.15}
.kanji-grid .krd{font-size:12px;color:#5b6472;margin:2px 0}
.kanji-grid .kvn{font-size:12.5px;color:#20242e;line-height:1.35;margin-bottom:5px}
.kanji-grid .boxchip{margin-right:0;font-size:10.5px;padding:1px 7px}
/* --- Ô luyện viết --- */
.pad-panel{margin-top:14px}
.pad-toggle{width:100%;padding:11px;border-radius:12px;border:2px dashed #c4b5fd;background:#faf9ff;color:#6d28d9;font-size:15px;font-weight:700;cursor:pointer}
.pad-toggle:active{transform:scale(.99)}
.pad-body{margin-top:10px}
.pad-label{font-size:13.5px;color:#5b6472;font-weight:600;margin:2px 0 8px;line-height:1.45}
.pad-wrap{position:relative;width:100%;max-width:420px;margin:0 auto;aspect-ratio:1/1;background:#fff;border:2px solid #e4e7ec;border-radius:16px;overflow:hidden;background-image:linear-gradient(90deg,transparent calc(50% - 1px),#ececf1 calc(50% - 1px),#ececf1 calc(50% + 1px),transparent calc(50% + 1px)),linear-gradient(transparent calc(50% - 1px),#ececf1 calc(50% - 1px),#ececf1 calc(50% + 1px),transparent calc(50% + 1px))}
.pad-guide{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#e7e4f5;font-weight:800;pointer-events:none;line-height:1.1;text-align:center;padding:6px}
.pad-canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:none;cursor:crosshair;display:block}
.pad-btns{display:flex;gap:10px;justify-content:center;margin-top:10px;flex-wrap:wrap}
.pad-btns button{padding:9px 16px;border-radius:999px;border:1.5px solid #c4b5fd;background:#fff;color:#6d28d9;font-weight:700;cursor:pointer;font-size:14px}
