:root {
  --bg: #f6f7fb;
  --card: #fff;
  --ink: #1f2430;
  --muted: #646b7a;
  --line: #e3e6ee;
  --brand: #4f46e5;
  --mastered: #2e9e5b;
  --review: #3b82f6;
  --learning: #e9a800;
  --gap: #e05252;
  --untested: #aab1bd;
  --radius: 14px;
}
* { box-sizing: border-box; }
/* Thanh trên cùng dính ở đầu màn hình: khi cuộn tới gợi ý, bước nhỏ hay kết quả thì chừa chỗ để không bị che. */
html { scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.subjects { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.subjects a { padding: 4px 14px; border-radius: 999px; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap; }
.subjects a.on { background: var(--brand); color: #fff; }
.overall { font-size: 15px; font-weight: 600; white-space: nowrap; text-decoration: none; }
main { max-width: 760px; margin: 0 auto; padding: 16px 14px 60px; }
h1 { font-size: 26px; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-size: 21px; margin: 24px 0 10px; }
h3 { font-size: 17px; margin: 18px 0 8px; color: var(--muted); }
p { margin: 8px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.plan-card { border: 2px solid var(--brand); }
.plan { margin: 8px 0 0; padding-left: 22px; }
.plan > li { margin: 10px 0; }
.plan > li.later { color: var(--muted); }
.plan > li.now::marker { color: var(--brand); font-weight: 700; }
.relearn { margin-top: 12px; }
.fold { margin: 12px 0; }
.fold > summary { cursor: pointer; font-size: 21px; font-weight: 700; padding: 8px 0; }
.relearn ul { margin: 6px 0 0; padding-left: 20px; }
.bell-top {
  margin-left: auto; padding: 2px 10px; border-radius: 999px; background: #fff3cd;
  font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; animation: ring 2.5s ease-in-out infinite;
}
.bell-top[hidden] { display: none; }
.bell { margin-left: 6px; display: inline-block; animation: ring 2.5s ease-in-out infinite; }
@keyframes ring { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(14deg); } 85% { transform: rotate(-12deg); } 95% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .bell, .bell-top { animation: none; } }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.spacer { flex: 1; }
.row.nav { flex-wrap: nowrap; }

button, .btn {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px;
  padding: 12px 18px; background: var(--brand); color: #fff; font-weight: 600;
  text-decoration: none; display: inline-block;
}
button:disabled { opacity: .45; cursor: default; }
.btn-light { background: #eef0ff; color: var(--brand); }
.btn-ghost { background: transparent; color: var(--muted); padding: 10px 6px; font-weight: 500; text-decoration: underline; }
.btn-big { font-size: 20px; padding: 16px 24px; }
.btn-dontknow { background: #fff6e0; color: #8a5a00; }
.btn-flag { background: transparent; color: var(--muted); padding: 10px 4px; font-size: 14px; font-weight: 500; }
.flag-row { text-align: right; margin-top: 4px; }
.flagged { display: inline-block; padding: 10px 4px; }

/* Câu hỏi */
.qtext { font-size: 20px; margin: 4px 0 14px; }
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; background: #fff; color: var(--ink); font-weight: 500;
  border: 2px solid var(--line); padding: 12px 14px; display: flex; gap: 12px; align-items: center;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt .letter {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #eef0ff; color: var(--brand); font-weight: 700;
}
.opt.right { border-color: var(--mastered); background: #ecf8f0; }
.opt.right .letter { background: var(--mastered); color: #fff; }
.opt.wrong { border-color: var(--gap); background: #fdeeee; }
.opt.wrong .letter { background: var(--gap); color: #fff; }
.opt:disabled { opacity: 1; }
.feedback { border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; }
.feedback.good { background: #ecf8f0; border: 1px solid #b9e4c8; }
.feedback.bad { background: #fff4f4; border: 1px solid #f3c4c4; }
.next-note { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius); background: #eef2ff; border: 1px solid #c7d2fe; font-size: 16px; }
.done-note { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius); background: #ecfdf5; border: 1px solid #a7f3d0; font-size: 16px; text-align: center; }
.feedback.info { background: #fff8e6; border: 1px solid #f1dca3; }
.feedback .title { font-weight: 700; font-size: 19px; }
.hint { background: #eef4ff; border-left: 4px solid var(--review); padding: 8px 12px; border-radius: 8px; margin: 10px 0 4px; }
.hint.retry { background: #fff8e6; border-left-color: var(--learning); }
.hint.retry p { margin: 6px 0 0; }
.walk { margin-top: 10px; }
.step { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.step p { margin: 0 0 6px; }
.step-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.step-opt { background: #fff; color: var(--ink); font-weight: 500; border: 2px solid var(--line); padding: 8px 12px; }
.step-opt.right { border-color: var(--mastered); background: #ecf8f0; }
.step-opt.wrong { border-color: var(--gap); background: #fdeeee; }
.step-fb { font-size: 16px; }
.step-done { font-weight: 700; margin-top: 10px; }
.solution { margin-top: 8px; }
.solution p { margin: 4px 0; }
/* Phân số trong lời giải, gợi ý cao hơn chữ thường: giãn dòng để các dòng không chạm nhau. */
.feedback p, .solution, .hint { line-height: 2.1; }

/* Bài giảng */
.remember { background: #fff8e6; border-left: 4px solid var(--learning); padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-weight: 500; }
.steps { display: flex; gap: 6px; margin: 4px 0 10px; }
.steps span { height: 6px; flex: 1; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--brand); }
.fig { display: block; width: 100%; max-width: 340px; margin: 12px auto; }
.fig.wide { max-width: 520px; }
.fig .axis { stroke: #8b93a3; stroke-width: 1.5; }
.fig .grid { stroke: #e3e6ee; stroke-width: 1; stroke-dasharray: 4 4; }
.fig .ring { fill: none; stroke: var(--brand); stroke-width: 2.5; }
.fig .ray { stroke: var(--ink); stroke-width: 2; }
.fig .dash { stroke: #8b93a3; stroke-width: 1.5; stroke-dasharray: 5 4; }
.fig .cosbar { stroke: var(--review); stroke-width: 5; }
.fig .sinbar { stroke: var(--gap); stroke-width: 5; }
.fig .arcmark { fill: none; stroke: var(--learning); stroke-width: 2; }
.fig .arcbold { fill: none; stroke: var(--gap); stroke-width: 6; }
.fig .arrowhead { fill: var(--learning); }
.fig .curve { fill: none; stroke: var(--brand); stroke-width: 3; }
.fig .curve2 { fill: none; stroke: var(--review); stroke-width: 3; stroke-dasharray: 9 5; }
.fig .pt { fill: var(--gap); }
.fig .pt2 { fill: var(--review); }
.fig .lbl { font-size: 14px; fill: var(--ink); }
.fig .lbl.small { font-size: 11px; fill: var(--muted); }
.fig .lbl.big { font-size: 20px; font-weight: 700; fill: var(--brand); }
.fig .lbl.cos { fill: var(--review); font-weight: 600; }
.fig .lbl.sin { fill: var(--gap); font-weight: 600; }
.valtable { border-collapse: collapse; margin: 12px auto; font-size: 16px; }
.valtable th, .valtable td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
.valtable th { background: #f1f2f8; }

/* Bản đồ kiến thức */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); }
.legend i, .chip i, .path i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.s-mastered { --c: var(--mastered); }
.s-review { --c: var(--review); }
.s-learning { --c: var(--learning); }
.s-gap { --c: var(--gap); }
.s-untested { --c: var(--untested); }
.legend i, .chip i, .path i { background: var(--c); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #fff; color: var(--ink); font-weight: 500; font-size: 16px;
  border: 2px solid var(--c); border-left-width: 8px; padding: 8px 12px; border-radius: 10px;
  text-decoration: none;
}
.chip.s-mastered { background: #ecf8f0; }
.chip.s-gap { background: #fdeeee; }
.chip.s-learning { background: #fff8e6; }
.chip.s-review { background: #eef4ff; }
.path { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.path li { counter-increment: step; }
.path a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; border: 1px solid transparent;
}
.path a::before { content: counter(step); width: 26px; text-align: right; color: var(--muted); font-size: 14px; }
.path a:hover { background: #fff; border-color: var(--line); }
.path .current a { background: #eef0ff; border-color: #c9ccff; font-weight: 600; }
.path .tag { margin-left: auto; white-space: nowrap; padding-left: 8px; font-size: 13px; color: var(--muted); }
.kinds { list-style: none; padding: 0; margin: 8px 0 0; font-size: 15px; display: grid; gap: 4px; }
.kinds li { display: flex; gap: 8px; align-items: baseline; }
.kinds li > b { flex: none; width: 1.4em; text-align: center; }
.kinds .k-ok { color: var(--mastered); }
.kinds .k-fix { color: var(--gap); }
.kinds .k-new { color: var(--muted); }
.kinds small { color: var(--muted); }
.kinds-total { font-size: 14px; color: var(--muted); margin-top: 2px; }
.big-emoji { font-size: 56px; text-align: center; margin: 10px 0 0; }
.center { text-align: center; }
.loading { color: var(--muted); }
.katex { font-size: 1.08em; }
@media (max-width: 480px) {
  body { font-size: 17px; }
  h1 { font-size: 23px; }
  .qtext { font-size: 19px; }
}

/* Tổng kết */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.stat small, .stat span { display: block; color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 18px; margin: 2px 0; }
.card h2 { margin-top: 0; font-size: 18px; }
.days, .watch { list-style: none; padding: 0; margin: 0; }
.days li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.days li:last-child { border-bottom: 0; }
.day-head { display: flex; justify-content: space-between; }
.watch li { padding: 6px 0; }
strong .katex { font-weight: bold; -webkit-text-stroke: 0.04em currentColor; }
.report { width: 100%; min-height: 220px; font: 14px/1.4 inherit; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }

/* Thuật ngữ bấm được, thẻ giải nghĩa, "Em chưa hiểu" */
button.term { all: unset; cursor: pointer; color: inherit; text-decoration: underline dotted var(--brand) 2px; text-underline-offset: 3px; }
button.term:hover, button.term:focus-visible { color: var(--brand); background: #eef0ff; border-radius: 4px; }
button.term.chip { text-decoration: none; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; }
.term-card { border: 0; border-radius: var(--radius); padding: 18px 20px; width: min(92vw, 480px); box-shadow: 0 12px 40px #0003; color: var(--ink); }
.term-card::backdrop { background: #1f243066; }
.term-card h2 { margin: 0 0 8px; }
.term-card .eg { background: #f2fbf5; border-left: 4px solid var(--mastered); padding: 8px 12px; border-radius: 8px; }
.easier { background: #f2fbf5; border-left: 4px solid var(--mastered); padding: 10px 14px; border-radius: 8px; margin: 12px 0 0; }
.easier .title { font-weight: 700; margin-bottom: 4px; }
.rest-note {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; max-width: 560px; margin: 0 auto;
  display: flex; gap: 12px; align-items: center; padding: 12px 14px;
  background: #fff8e6; border: 1px solid #f2d27a; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
}
.rest-note p { margin: 0; flex: 1; font-size: 16px; }
body:has(.rest-note) { padding-bottom: 170px; } /* cuộn được để lời nhắc không che nút */

/* Thẻ cách làm */
.method { background: #f7f6ff; border: 2px solid #d9d6ff; border-radius: 12px; padding: 12px 14px; margin: 12px 0; line-height: 1.9; }
.m-name { font-weight: 700; font-size: 19px; }
.m-when { color: var(--muted); font-size: 16px; margin-top: 2px; }
.m-steps { margin: 8px 0; padding-left: 26px; }
.m-steps li { margin: 6px 0; }
.m-steps li > b { display: inline-block; background: var(--brand); color: #fff; border-radius: 6px; padding: 0 8px; margin-right: 4px; }
.m-write { font-size: 16px; color: #3d3a7a; background: #fff; border: 1px dashed #c9c5f5; border-radius: 6px; padding: 2px 8px; margin-top: 4px; }
.m-why, .m-trap, .m-eg { font-size: 16px; margin-top: 6px; }
.m-trap { color: #8a4b00; }
.card-box .method { margin-top: 10px; }
.mk { display: inline-block; background: var(--brand); color: #fff; border-radius: 6px; padding: 0 8px; font-weight: 700; font-size: 15px; }

/* Bản đồ hành trình (trang chủ) */
.journey { padding: 16px 12px; }
.jhead { display: flex; gap: 14px; align-items: center; margin: 0 4px 10px; }
.jhead h2 { margin: 0 0 2px; }
.jhead p { margin: 0; }
.ring {
  flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--mastered) calc(var(--p) * 1%), var(--line) 0);
}
.ring span { width: 50px; height: 50px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--mastered); }
.chap { border-radius: 14px; margin: 10px 0; border: 1px solid var(--line); background: #f6f7fb; }
.chap > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.chap > summary::-webkit-details-marker { display: none; }
.chap > summary small { font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }
.chap-here { border-color: #c7d2fe; background: #fff; }
.chap-done > summary small { color: var(--mastered); }
.chap[open] > summary .dots { display: none; }
.chap > .stage { margin: 8px 8px; }
.stage { border-radius: 12px; margin: 8px 0; background: #fafbfe; border: 1px solid var(--line); }
.stage[open] { background: #fff; }
.stage-here { border-color: #c7d2fe; background: linear-gradient(#f4f5ff, #fff 90px); }
.stage summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.stage summary::-webkit-details-marker { display: none; }
.badge { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; background: var(--line); color: var(--muted); }
.stage-here .badge { background: var(--brand); color: #fff; }
.stage-done .badge { background: #e3f5ea; }
.stitle { flex: 1; min-width: 0; line-height: 1.3; }
.stitle small { display: block; font-size: 13px; color: var(--muted); }
.stitle b { font-size: 16px; }
.stage-done .stitle b { color: var(--mastered); }
.count { flex: none; font-size: 14px; font-weight: 700; color: var(--muted); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--untested)); opacity: .9; }
.stage[open] .dots { display: none; }
.trail { position: relative; margin: 0 8px 8px 4px; }
.road { position: absolute; left: 0; top: 0; }
.road path { fill: none; stroke: #c9cfe0; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1 12; }
.road path.lit { stroke: #9ad8b2; stroke-dasharray: none; }
.jrow { position: absolute; left: 0; right: 0; height: 72px; display: flex; align-items: center; text-decoration: none; color: var(--ink); }
.jrow .stop {
  position: absolute; left: var(--x); width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  background: #fff; border: 3px solid var(--c, var(--untested)); color: var(--muted);
  box-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.jrow.s-mastered .stop { background: var(--mastered); color: #fff; box-shadow: 0 3px 0 #23784a; }
.jrow.s-review .stop { background: #eef4ff; }
.jrow.s-learning .stop { background: #fff8e6; color: #8a6400; }
.jrow.s-gap .stop { background: #fdeeee; color: var(--gap); }
.jrow.here .stop { border-color: var(--brand); background: #eef0ff; font-size: 22px; box-shadow: 0 0 0 4px #c7d2fe; animation: pulse 1.8s ease-in-out infinite; }
.jrow .bell { position: absolute; top: -8px; right: -8px; font-size: 13px; animation: none; }
.jlabel { margin-left: 104px; min-width: 0; line-height: 1.25; padding: 6px 10px; border-radius: 10px; }
.jname { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; font-weight: 600; }
.jlabel small { display: block; font-size: 12.5px; color: var(--c, var(--muted)); font-weight: 600; margin-top: 1px; }
.jrow.s-untested .jname { color: var(--muted); font-weight: 500; }
.jrow.here .jlabel { background: #eef0ff; }
.jrow.here small { color: var(--brand); }
.journey .legend { margin: 10px 4px 0; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px #e0e7ff; } }

/* Đăng nhập và tài khoản */
.sign-in { display: grid; gap: 14px; max-width: 360px; margin: 16px auto; text-align: left; }
.sign-in label { display: grid; gap: 6px; font-weight: 600; }
.sign-in input { font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: inherit; }
.sign-in-error { color: #b42318; margin: 0; }
.account { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; max-width: 760px; margin: 0 auto; padding: 0 14px 24px; }
.account .btn-ghost { padding: 4px 6px; }

/* Trang phụ huynh */
.parent-report { white-space: pre-wrap; font: inherit; line-height: 1.6; margin: 0; padding: 0; border: 0; background: none; }
.parent-report .alarm { color: #93370d; font-weight: 600; }
.card.alarm { border: 2px solid #fdb022; background: #fffaeb; }
