/* GrammarOn — giao dien "vo o li": nen luoi o nhat co duong le do, mau but da cua mindmap. */
:root {
  --paper: #fbfcff;
  --grid: #e4e7f6;
  --margin: #f2a7ad;
  --ink: #1f2a56;
  --ink-soft: #5a6488;
  --line: #d5daef;
  --blue: #2f6feb;
  --green: #23a046;
  --purple: #8a3fc7;
  --orange: #ef8a1f;
  --red: #e0414b;
  --yellow: #e9b600;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(31, 42, 86, .06), 0 8px 24px -12px rgba(31, 42, 86, .25);
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --hand: 'Patrick Hand', 'Nunito', cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* Luoi o li 24px + duong le do ben trai */
  background-image:
    linear-gradient(90deg, transparent 47px, var(--margin) 47px, var(--margin) 49px, transparent 49px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px, 24px 24px;
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--blue); }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 880px; margin: 0 auto; padding: 20px 16px 64px 64px; }
@media (max-width: 600px) { .wrap { padding-left: 60px; padding-right: 14px; } }

/* ---------- Thanh tren ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -.5px; text-decoration: none; color: var(--ink); }
.brand b { color: var(--orange); }
.topbar nav { display: flex; gap: 8px; align-items: center; }

/* ---------- Chu ---------- */
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 6vw, 42px); font-weight: 800; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 19px; font-weight: 700; }
.muted { color: var(--ink-soft); }
.hand { font-family: var(--hand); font-size: 1.15em; }
.en { font-weight: 700; }

/* ---------- The ---------- */
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.section { margin-top: 32px; }
.section > h2 { display: flex; align-items: baseline; gap: 10px; }
.section > h2 .count { font-family: var(--body); font-size: 15px; font-weight: 700; color: var(--ink-soft); }

/* ---------- Nut ---------- */
.btn {
  font: 800 17px/1 var(--body); border: 0; cursor: pointer; border-radius: 999px;
  padding: 13px 22px; background: var(--blue); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 3px 0 #1d4fb8;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d4fb8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.green { background: var(--green); box-shadow: 0 3px 0 #17732f; }
.btn.orange { background: var(--orange); box-shadow: 0 3px 0 #b8650e; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); padding: 9px 16px; font-size: 15px; }
.btn.small { padding: 9px 16px; font-size: 15px; }

/* ---------- Form ---------- */
label { display: block; font-weight: 700; margin: 14px 0 6px; }
input[type=text], input[type=password], textarea {
  width: 100%; font: 600 18px/1.3 var(--body); color: var(--ink);
  padding: 11px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
select { font: 700 17px/1.3 var(--body); color: var(--ink); padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); outline: none; }
.error { color: var(--red); font-weight: 700; min-height: 1.4em; margin: 10px 0 0; }

/* ---------- Cham level: 6 cham, da qua level nao to xanh level do ---------- */
.dots { display: inline-flex; gap: 4px; vertical-align: middle; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--grid); border: 1.5px solid var(--line); }
.dots i.on { background: var(--green); border-color: #17732f; }
.star { color: var(--yellow); font-size: 18px; }

/* ---------- Danh sach bai ---------- */
.task { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.task .num {
  flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font: 800 22px var(--display); color: #fff; background: var(--blue);
}
.task .num.review { background: var(--orange); }
.task .num { line-height: 1; grid-auto-flow: row; align-content: center; gap: 2px; }
.task .num small { font: 700 11px var(--body, inherit); opacity: .85; }
.task .body .book-tag { font-size: 12px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.book-group + .book-group { margin-top: 18px; }
.book-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font: 800 18px var(--display); }
.task .body { flex: 1; min-width: 0; }
.task .body .title { font-weight: 800; }
.task .body .vi { color: var(--ink-soft); font-size: 15px; }
.task .go { flex: none; font: 800 24px var(--display); color: var(--ink-soft); }

.path { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.path a {
  display: block; text-decoration: none; color: inherit; background: #fff; border: 2px solid var(--line);
  border-radius: 14px; padding: 10px 12px; min-height: 92px;
}
.path a.locked { opacity: .5; }
.path a.next { border-color: var(--blue); border-style: dashed; }
.path a.due { border-color: var(--orange); }
.path .n { font: 800 15px var(--display); color: var(--ink-soft); }
.path .t { font-weight: 700; font-size: 14px; line-height: 1.3; margin: 2px 0 6px; }

.empty { text-align: center; padding: 28px 16px; }
.empty .hand { font-size: 24px; color: var(--green); }

/* ---------- Trang bai hoc ---------- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; flex-wrap: wrap; }
.steps span { font-weight: 800; font-size: 14px; padding: 6px 12px; border-radius: 999px; background: #fff; border: 2px solid var(--line); color: var(--ink-soft); }
.steps span.now { border-color: var(--blue); color: var(--blue); }
.steps span.done { background: var(--green); border-color: var(--green); color: #fff; }

.mindmap { width: 100%; border-radius: 14px; border: 2px solid var(--line); background: #fff; display: block; }
.theory { margin-top: 14px; }
.theory summary { cursor: pointer; font-weight: 800; color: var(--blue); }
.theory .rule { margin: 12px 0 0; padding-left: 12px; border-left: 4px solid var(--blue); }
.theory .rule .vi { margin-top: 4px; padding: 6px 10px; border-radius: 10px; background: #eef6ff; color: var(--ink); font-size: 15px; }
.theory .rule .vi::before { content: 'Tiếng Việt'; display: block; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--blue); margin-bottom: 2px; }
.theory .rule ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-soft); }

.upload-box { border: 3px dashed var(--line); border-radius: 16px; padding: 22px; text-align: center; background: #fff; }
.upload-box img { max-width: 100%; max-height: 360px; border-radius: 10px; margin-top: 12px; }

/* ---------- Bai tap ---------- */
.ex h3 { margin-bottom: 2px; }
.ex .instr { color: var(--ink-soft); margin: 0 0 12px; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { font: 700 16px var(--body); padding: 6px 14px; border-radius: 999px; border: 2px solid var(--purple); color: var(--purple); background: #fff; cursor: pointer; }
.example { background: #f4f0fb; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 15px; }
.example b { color: var(--purple); }

.item { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px 0; border-top: 1px dashed var(--line); }
.item:first-of-type { border-top: 0; }
.item.has-img { grid-template-columns: 34px 1fr auto; align-items: start; }
.thumb { border: 0; padding: 4px; background: #fff; border-radius: 10px; cursor: zoom-in; box-shadow: inset 0 0 0 2px var(--line); }
.thumb img { display: block; width: 116px; max-height: 130px; object-fit: contain; }
@media (max-width: 600px) { .thumb img { width: 84px; max-height: 100px; } }
dialog.zoom { border: 0; border-radius: 16px; padding: 12px; background: #fff; max-width: 92vw; cursor: zoom-out; }
dialog.zoom::backdrop { background: rgba(31, 42, 86, .55); }
dialog.zoom img { display: block; max-width: 86vw; max-height: 80vh; width: 340px; object-fit: contain; }
.item .no { font: 800 18px var(--display); color: var(--ink-soft); padding-top: 4px; }
.item .pic { font-size: 14px; color: var(--ink-soft); font-style: italic; margin-bottom: 4px; }
.item .q { font-size: 18px; }
.blank {
  display: inline-block; width: 8.5em; max-width: 100%; font: 700 18px var(--body); color: var(--blue);
  border: 0; border-bottom: 2.5px solid var(--ink-soft); background: transparent; padding: 2px 4px; margin: 0 2px; text-align: center;
}
.blank:focus { outline: none; border-bottom-color: var(--blue); background: #eef3ff; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.opt { font: 700 17px var(--body); padding: 8px 16px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-align: left; }
.opt.picked { border-color: var(--blue); background: #eef3ff; color: var(--blue); }
.lines textarea { margin-top: 8px; min-height: 48px; resize: vertical; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tile { font: 700 17px var(--body); padding: 6px 12px; border-radius: 10px; border: 2px solid var(--orange); background: #fff7ee; color: var(--ink); cursor: pointer; }
.tile:disabled { opacity: .3; cursor: default; }
.built { min-height: 44px; border-bottom: 2.5px solid var(--ink-soft); padding: 6px 2px; font-weight: 700; color: var(--blue); font-size: 18px; }

/* Ket qua cham */
.item.right .no::after { content: ' ✓'; color: var(--green); }
.item.wrong .no::after { content: ' ✗'; color: var(--red); }
.item.right input, .item.right textarea, .item.right button { pointer-events: none; }
.item.right .blank, .item.right .built { color: var(--green); border-bottom-color: var(--green); }
.item.wrong .blank, .item.wrong .built, .item.wrong textarea { border-color: var(--red); }
.hint { font-family: var(--hand); font-size: 19px; color: var(--red); margin-top: 6px; }

.submitbar { position: sticky; bottom: 12px; display: flex; justify-content: center; margin-top: 20px; }
.feedback { font-family: var(--hand); font-size: 22px; text-align: center; margin: 12px 0 0; }
.feedback.good { color: var(--green); }
.feedback.bad { color: var(--red); }

.result { text-align: center; }
.result .big { font: 800 56px/1 var(--display); color: var(--green); margin: 8px 0; }

/* ---------- Trang phu huynh ---------- */
.small { font-size: 14px; }
.back { display: inline-block; font-weight: 800; text-decoration: none; margin-bottom: 8px; }
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 20px; }
.kids .card + .card { margin-top: 0; }
.kid { display: block; text-decoration: none; color: inherit; }
.kid:hover { border-color: var(--blue); }
.kid-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kid-head h3 { margin: 0; }
.badge { flex: none; font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.badge.warn { background: #fdecd8; color: #a3540a; }
.badge.ok { background: #e2f5e7; color: #17732f; }
.bar { height: 10px; border-radius: 999px; background: var(--grid); margin: 12px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }

.settings { display: grid; grid-template-columns: 1fr 180px; gap: 14px; }
@media (max-width: 600px) { .settings { grid-template-columns: 1fr; } }
.row-btns { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.cred { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: #fff8e1; border: 2px dashed var(--yellow); font-size: 18px; }
.cred b { font-family: ui-monospace, Menlo, monospace; letter-spacing: .5px; }

.path .tile-lesson { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; min-height: 92px; }
.path .tile-lesson.locked { opacity: .5; }
.path .tile-lesson.due { border-color: var(--orange); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.shot { border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 6px; cursor: zoom-in; text-align: left; font: 600 13px/1.35 var(--body); color: var(--ink-soft); }
.shot img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; margin-bottom: 6px; background: var(--grid); }
.shot b { color: var(--ink); }

.history { padding: 6px 16px; }
.hitem { border-top: 1px dashed var(--line); }
.hitem:first-child { border-top: 0; }
.hitem summary { list-style: none; cursor: pointer; }
.hitem summary::-webkit-details-marker { display: none; }
.hrow { display: grid; grid-template-columns: 92px 1fr auto 86px 56px; gap: 10px; align-items: center; padding: 10px 0; font-size: 15px; }
.hitem summary .hrow .htitle::after { content: ' ▾'; color: var(--ink-soft); }
.hday { color: var(--ink-soft); font-weight: 700; }
.htitle { font-weight: 700; min-width: 0; }
.hlevel { color: var(--ink-soft); font-weight: 700; text-align: right; }
.hscore { font-weight: 800; text-align: right; }
.hscore.good { color: var(--green); }
.hscore.bad { color: var(--red); }
.chip-kind { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: #e8efff; color: var(--blue); }
.chip-kind.review { background: #fdecd8; color: #a3540a; }
.wrong-list { margin: 0 0 12px; padding-left: 20px; font-size: 15px; }
.wrong-list li { margin: 4px 0; }
.wrong-list .ans { color: var(--green); font-weight: 800; }
@media (max-width: 600px) {
  .hrow { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .hday { grid-column: 1 / -1; font-size: 13px; }
  .hlevel { text-align: left; }
}

dialog.sheet { border: 0; border-radius: var(--radius); padding: 22px; width: min(460px, 92vw); box-shadow: var(--shadow); }
dialog.sheet::backdrop { background: rgba(31, 42, 86, .55); }

/* Dang nhap */
.login { max-width: 420px; margin: 8vh auto 0; }
.login h1 { margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Che do xem thu */
.preview-note { background: #fff8e1; border: 2px dashed var(--yellow); border-radius: 12px; padding: 10px 14px; font-weight: 700; font-size: 15px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Hoc thu ---------- */
.trial-link { display: block; margin-top: 14px; text-decoration: none; color: inherit; border-color: var(--orange); }
.trial-link span { display: block; color: var(--orange); font-weight: 800; margin-top: 2px; }
.steps-explain { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.steps-explain .card { margin: 0; }
.steps-explain p { margin: 4px 0 0; color: var(--ink-soft); font-size: 15px; }
#list .card + .card { margin-top: 10px; }
.trial-cta { margin-top: 16px; padding-top: 14px; border-top: 2px dashed var(--line); }
.trial-cta p { margin: 0 0 10px; }
.contact { margin: 12px 0; padding: 14px; border-radius: 14px; background: #fff4e8; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.contact p { margin: 0; flex-basis: 100%; }
