:root {
  --sw: 262px; --hh: 54px;
  --bg: #FFF8F0; --card: #fff; --text: #2D2D3A; --muted: #9090A8;
  --math: #FF6B6B; --eng: #6C63FF; --green: #22C55E;
  --sh: 0 4px 18px rgba(0,0,0,.07);
  --r: 16px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Nunito", sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; }

/* ── HEADER ── */
.hdr {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hh); z-index: 300;
  background: white; box-shadow: 0 1px 10px rgba(0,0,0,.08);
  display: flex; align-items: center; padding: 0 14px; gap: 10px;
}
.hdr-burger { background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 6px; border-radius: 8px; transition: .15s; }
.hdr-burger:hover { background: #F0EDFF; }
.hdr-logo { font-family: "Baloo 2", cursive; font-size: 1.3rem; font-weight: 800;
  background: linear-gradient(135deg, #FF6B6B, #6C63FF);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; white-space: nowrap; }
.hdr-gap { flex: 1; }
.hdr-av { width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #FF6B6B, #6C63FF);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.hdr-nm { font-weight: 700; font-size: .82rem; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-btn { border: none; border-radius: 9px; padding: 5px 11px; font-family: "Nunito", sans-serif;
  font-size: .76rem; font-weight: 700; cursor: pointer; transition: .15s; white-space: nowrap; }
.hdr-btn.rpt { background: #F0FDF4; color: #166534; }
.hdr-btn.rpt:hover { background: #DCFCE7; }
.hdr-btn.rpt.on { background: #22C55E; color: white; }

/* ── LAYOUT ── */
.layout { display: flex; padding-top: var(--hh); min-height: 100vh; }

/* ── SIDEBAR ── */
.sb {
  position: fixed; top: var(--hh); left: 0; bottom: 0; width: var(--sw);
  background: white; box-shadow: 2px 0 14px rgba(0,0,0,.06);
  display: flex; flex-direction: column; z-index: 200;
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}
.sb.closed { transform: translateX(calc(-1 * var(--sw))); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 10px 8px 4px; }
.sb-scroll::-webkit-scrollbar { width: 4px; }
.sb-scroll::-webkit-scrollbar-thumb { background: #DDD; border-radius: 2px; }

.sb-sec-lbl {
  display: block; font-size: .63rem; font-weight: 800; letter-spacing: .9px;
  text-transform: uppercase; color: var(--muted); padding: 10px 8px 4px;
}

/* Accordion rows */
.acc-row {
  width: 100%; border: none; background: none;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 8px; border-radius: 11px; cursor: pointer;
  font-family: "Nunito", sans-serif; transition: .15s; text-align: left;
  color: var(--text);
}
.acc-row:hover { background: #F5F3FF; }

.acc-grade { font-size: .88rem; font-weight: 800; }
.acc-grade .lbl { flex: 1; }
.acc-grade .pct { font-size: .7rem; font-weight: 800; opacity: .75; }
.acc-grade .arr { font-size: .65rem; color: var(--muted); transition: transform .22s; flex-shrink: 0; }
.acc-grade.open .arr { transform: rotate(90deg); }

.g-pbar { height: 3px; background: #EEE; border-radius: 2px; margin: 1px 8px 4px; }
.g-pfill { height: 100%; border-radius: 2px; transition: width .5s; }

.acc-subj { font-size: .82rem; font-weight: 700; padding-left: 14px; }
.acc-subj .lbl { flex: 1; }
.acc-subj .cnt { font-size: .7rem; opacity: .65; }
.acc-subj .arr { font-size: .6rem; color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.acc-subj.open .arr { transform: rotate(90deg); }
.acc-subj.sel { color: white; font-weight: 800; }

.acc-lesson { font-size: .78rem; font-weight: 600; padding: 5px 8px 5px 22px; border-radius: 9px; color: var(--muted); }
.acc-lesson:hover { background: #F5F3FF; color: var(--text); }
.acc-lesson.active { background: #EDE9FF; color: var(--eng); font-weight: 700; }
.acc-lesson.done { color: #22C55E; }
.acc-lesson.done.active { background: #DCFCE7; color: #15803D; }
.ll-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; margin-top: 1px; }
.ll-txt { flex: 1; text-align: left; line-height: 1.35; }
.ll-chk { font-size: .65rem; flex-shrink: 0; }

/* Collapsible */
.acc-body { overflow: hidden; transition: max-height .28s ease; max-height: 0; }
.acc-body.open { max-height: 9999px; }

/* Sidebar footer */
.sb-foot { border-top: 1.5px solid #F2F2F5; padding: 8px; }
.sb-foot-btn {
  width: 100%; border: none; background: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 11px; cursor: pointer; font-family: "Nunito", sans-serif;
  font-size: .83rem; font-weight: 700; color: var(--muted); transition: .15s; text-align: left;
}
.sb-foot-btn:hover { background: #F5F3FF; color: var(--text); }
.sb-foot-btn.active { background: #EDE9FF; color: var(--eng); }

/* Overlay (mobile) */
.sb-ov { display: none; position: fixed; inset: 0; top: var(--hh); background: rgba(0,0,0,.35); z-index: 199; }
.sb-ov.show { display: block; }

/* ── MAIN ── */
.main { flex: 1; margin-left: var(--sw); min-width: 0; transition: margin-left .26s cubic-bezier(.4,0,.2,1); }
.main.full { margin-left: 0; }
.main-in { max-width: 800px; margin: 0 auto; padding: 22px 18px 80px; }

/* ── WELCOME ── */
.welcome { text-align: center; padding: 50px 20px 30px; animation: fadeUp .4s ease; }
.w-emoji { font-size: 3.5rem; margin-bottom: 10px; }
.w-title { font-family: "Baloo 2", cursive; font-size: 1.9rem; font-weight: 800;
  background: linear-gradient(135deg, #FF6B6B, #FF8E53, #6C63FF);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 6px; }
.w-sub { color: var(--muted); font-size: .92rem; font-weight: 600; }
.stat-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.stat-chip { background: white; border-radius: 14px; padding: 13px 18px; box-shadow: var(--sh);
  display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: .87rem; }
.sv { font-family: "Baloo 2", cursive; font-size: 1.35rem; font-weight: 800; }
.sl { font-size: .7rem; color: var(--muted); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── LESSON ── */
.lesson-view { animation: fadeUp .3s ease; }
.ld-hero { border-radius: var(--r); padding: 18px 22px; color: white; margin-bottom: 16px; position: relative; overflow: hidden; }
.ld-hero::after { content: ""; position: absolute; right: -16px; top: -16px; width: 100px; height: 100px; border-radius: 50%; background: rgba(255,255,255,.1); }
.ld-cat { font-size: .7rem; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; opacity: .85; margin-bottom: 4px; }
.ld-title { font-family: "Baloo 2", cursive; font-size: 1.35rem; font-weight: 800; line-height: 1.25; }
.ld-bar { height: 5px; background: rgba(255,255,255,.3); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.ld-bar-fill { height: 100%; background: white; border-radius: 3px; transition: width .5s; }
.ld-bar-lbl { font-size: .73rem; margin-top: 4px; opacity: .9; }

.sec-card { background: white; border-radius: var(--r); padding: 18px; box-shadow: var(--sh); margin-bottom: 14px; }
.sc-hd { font-family: "Baloo 2", cursive; font-size: .93rem; font-weight: 700; margin-bottom: 11px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sc-badge { border-radius: 50px; padding: 2px 10px; font-size: .76rem; font-weight: 800; }

.sum-box { background: linear-gradient(135deg, #FFFBF0, #FFF5E0); border-left: 4px solid #FFB347;
  border-radius: 11px; padding: 12px 15px; font-size: .88rem; line-height: 1.75; }
.ex-box { background: #F8F9FF; border-radius: 10px; padding: 10px 13px; margin-bottom: 7px; border: 1.5px solid #EEF0FF; }
.ex-lbl { font-weight: 700; font-size: .8rem; margin-bottom: 5px; }
.ex-step { font-size: .83rem; padding: 2px 0 2px 16px; line-height: 1.6; position: relative; }
.ex-step::before { content: "→"; position: absolute; left: 0; color: #CCC; }

/* Quiz */
.qz-item { margin-bottom: 15px; }
.qz-q { background: linear-gradient(135deg, #F3F0FF, #EBF5FF); border-radius: 11px;
  padding: 11px 14px; font-weight: 700; font-size: .88rem; margin-bottom: 8px;
  display: flex; gap: 8px; align-items: flex-start; }
.qz-n { border-radius: 50%; width: 21px; height: 21px; display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 800; color: white; flex-shrink: 0; margin-top: 1px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.opt { border: 2px solid #E8E8F0; background: white; border-radius: 10px; padding: 8px 11px;
  font-family: "Nunito", sans-serif; font-size: .83rem; font-weight: 600; cursor: pointer;
  transition: all .15s; text-align: left; color: var(--text); }
.opt:hover:not([disabled]) { border-color: #6C63FF; background: #F3F0FF; transform: scale(1.012); }
.opt.ok { border-color: #22C55E; background: #DCFCE7; color: #166534; }
.opt.no { border-color: #EF4444; background: #FEE2E2; color: #991B1B; }
.opt[disabled] { cursor: default; }
.exp { background: #F0FFF4; border: 2px solid #86EFAC; border-radius: 10px;
  padding: 10px 14px; margin-top: 7px; font-size: .83rem; line-height: 1.7; display: none; }
.exp.show { display: block; animation: popIn .22s ease; }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.exp-h { font-weight: 800; color: #166534; margin-bottom: 3px; font-size: .77rem; }
.exp-s::before { content: "✔ "; color: #22C55E; }

/* Lesson nav */
.ln-row { display: flex; gap: 9px; justify-content: space-between; margin-top: 18px; }
.ln-btn { border: 2px solid #E8E8F0; background: white; border-radius: 11px; padding: 9px 16px;
  font-family: "Nunito", sans-serif; font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: .15s; display: flex; align-items: center; gap: 5px; color: var(--text); }
.ln-btn:hover { border-color: #6C63FF; background: #F3F0FF; color: #6C63FF; }
.ln-btn[disabled] { opacity: .3; cursor: not-allowed; pointer-events: none; }
.ln-btn.pri { background: #6C63FF; color: white; border-color: #6C63FF; }
.ln-btn.pri:hover { background: #5750D9; }

/* ── REVIEW QUIZ ── */
.rv-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.rv-opt { border: 2px solid #E0DAFF; background: white; border-radius: 10px; padding: 8px 11px;
  font-family: "Nunito", sans-serif; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: all .15s; text-align: left; color: var(--text); width: 100%; }
.rv-opt:hover:not([disabled]) { border-color: #6C63FF; background: #F3F0FF; transform: scale(1.01); }
.rv-opt.ok { border-color: #22C55E; background: #DCFCE7; color: #166534; font-weight: 700; }
.rv-opt.no { border-color: #EF4444; background: #FEE2E2; color: #991B1B; }
.rv-opt[disabled] { cursor: default; }

/* ── REPORT ── */
.rpt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 11px; margin-bottom: 22px; }
.rc { background: white; border-radius: var(--r); padding: 16px 14px; box-shadow: var(--sh); text-align: center; }
.rc-ico { font-size: 1.9rem; margin-bottom: 5px; }
.rc-val { font-family: "Baloo 2", cursive; font-size: 1.7rem; font-weight: 800; }
.rc-lbl { font-size: .72rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.rpt-sec { font-family: "Baloo 2", cursive; font-size: .95rem; font-weight: 800; margin: 20px 0 9px; display: flex; align-items: center; gap: 6px; }
.lr { background: white; border-radius: 12px; padding: 12px 15px; box-shadow: var(--sh); margin-bottom: 7px; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.lr-ico { font-size: 1.4rem; flex-shrink: 0; }
.lr-inf { flex: 1; min-width: 120px; }
.lr-ttl { font-weight: 800; font-size: .85rem; }
.lr-met { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.lr-sc { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.sp { padding: 3px 9px; border-radius: 50px; font-weight: 800; font-size: .75rem; }
.sp.full { background: #DCFCE7; color: #166534; }
.sp.part { background: #FEF9C3; color: #854D0E; }
.sp.none { background: #F1F5F9; color: #64748B; }
.lr-pb { width: 90px; height: 4px; background: #F0F0F5; border-radius: 50px; overflow: hidden; }
.lr-pf { height: 100%; border-radius: 50px; }

/* ── KB VIEW ── */
.kb-hero { border-radius: var(--r); padding: 18px 22px; margin-bottom: 16px; }
.kb-card { background: white; border-radius: var(--r); box-shadow: var(--sh); margin-bottom: 12px; overflow: hidden; }
.kb-card-hdr { display: flex; align-items: center; gap: 9px; padding: 13px 16px; cursor: pointer; user-select: none; }
.kb-card-hdr:hover { background: #FAFAFA; }
.kb-card-icon { font-size: 1.5rem; flex-shrink: 0; }
.kb-card-info { flex: 1; }
.kb-card-cat { font-size: .67rem; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; opacity: .7; }
.kb-card-title { font-family: "Baloo 2", cursive; font-size: .97rem; font-weight: 800; }
.kb-card-arr { font-size: .65rem; color: var(--muted); transition: transform .22s; }
.kb-card-hdr.open .kb-card-arr { transform: rotate(90deg); }
.kb-card-body { padding: 14px 16px; display: none; border-top: 2px solid #F5F5FA; }
.kb-card-hdr.open + .kb-card-body { display: block; }

.kb-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.kb-table tr { border-bottom: 1px solid #F5F5FA; }
.kb-table tr:last-child { border-bottom: none; }
.kb-table td { padding: 7px 8px; vertical-align: top; line-height: 1.6; }
.kbt-lbl { font-weight: 800; color: #666; width: 120px; font-size: .8rem; }
.kbt-note { font-size: .74rem; color: var(--muted); font-style: italic; margin-top: 2px; }

.gr-row { display: grid; grid-template-columns: 140px 1fr; gap: 6px; padding: 6px 0; border-bottom: 1px solid #F5F5FA; font-size: .83rem; line-height: 1.6; }
.gr-row:last-child { border-bottom: none; }
.gr-subj { font-weight: 700; color: #6C63FF; }
.gr-tag { border-radius: 8px; padding: 6px 10px; font-size: .8rem; margin-top: 6px; }
.gr-tag.sig { background: #FFF8E1; }
.gr-tag.neg { background: #FEF2F2; }
.gr-tag.hl { background: linear-gradient(135deg, #F3F0FF, #EBF5FF); font-weight: 700; color: #6C63FF; }

.vc-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid #F5F5FA; align-items: start; }
.vc-row:last-child { border-bottom: none; }
.vc-word { font-weight: 800; font-size: .9rem; }
.vc-ipa { font-size: .73rem; color: var(--muted); margin-top: 1px; font-style: italic; }
.vc-vi { font-weight: 700; font-size: .83rem; color: #FF6B6B; }
.vc-ex { font-size: .78rem; color: var(--muted); line-height: 1.5; margin-top: 1px; }
.vc-ex u { color: #6C63FF; text-decoration-color: #6C63FF; }

/* Confetti */
.cc { position: fixed; font-size: 1.8rem; pointer-events: none; animation: fall 1.5s ease-in forwards; z-index: 9999; }
@keyframes fall { 0% { transform: translateY(-60px) rotate(0); opacity: 1; } 100% { transform: translateY(100vh) rotate(360deg); opacity: 0; } }

/* Responsive */
@media (max-width: 768px) {
  .sb { transform: translateX(calc(-1 * var(--sw))); }
  .sb.mob-open { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .opts, .rv-opts { grid-template-columns: 1fr; }
  .hdr-nm { display: none; }
}
@media (min-width: 769px) {
  .sb-ov, .hdr-burger { display: none !important; }
}

.kb-q-label {
  font-size: .68rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Ẩn label trên màn hình nhỏ */
@media (max-width: 600px) {
  .kb-q-label { display: none; }
}