/* Bố cục: một cột hẹp như trang vở, thẻ bài rõ ràng, nút to cho ngón tay trẻ.
   Màu: xanh lá mít + vàng múi mít trên nền giấy xanh nhạt. */
:root {
  --bg: #f1f6ea; --card: #ffffff; --ink: #1d2a1b; --muted: #58684f; --line: #d6e2cb;
  --accent: #2e7a4b; --accent-ink: #1c5533; --warm: #e8a521; --hi: #fff2c8;
  --good: #23854d; --good-bg: #e2f5e8; --bad: #c8473f; --bad-bg: #fde8e5;
  --math: #2e6fb8; --math-bg: #e4eefa; --viet: #b0532c; --viet-bg: #fbeadf;
  --leaf: #3d8b4f; --fruit: #c9d86a; --fruit-edge: #7f9532; --blush: #f19a8c;
  --display: "Lexend", "Segoe UI", system-ui, sans-serif; --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121811; --card: #1b2419; --ink: #edf3e6; --muted: #a5b49c; --line: #2f3d2c;
    --accent: #6cc28b; --accent-ink: #bfeccb; --warm: #f2bd48; --hi: #3a3219;
    --good: #5fd08a; --good-bg: #183323; --bad: #f2837a; --bad-bg: #3b1d1a;
    --math: #7fb2ef; --math-bg: #192a3f; --viet: #f0a07a; --viet-bg: #3a2318;
    --leaf: #5fb06f; --fruit: #a9b955; --fruit-edge: #d3e07c; --blush: #e98a7c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121811; --card: #1b2419; --ink: #edf3e6; --muted: #a5b49c; --line: #2f3d2c;
  --accent: #6cc28b; --accent-ink: #bfeccb; --warm: #f2bd48; --hi: #3a3219;
  --good: #5fd08a; --good-bg: #183323; --bad: #f2837a; --bad-bg: #3b1d1a;
  --math: #7fb2ef; --math-bg: #192a3f; --viet: #f0a07a; --viet-bg: #3a2318;
  --leaf: #5fb06f; --fruit: #a9b955; --fruit-edge: #d3e07c; --blush: #e98a7c; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.25; text-wrap: balance; margin: 0 0 .4em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--warm); outline-offset: 2px; }
kbd { font-family: var(--display); font-size: .75rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 .4em; color: var(--muted); background: var(--bg); }
.wrap { max-width: 860px; margin: 0 auto; padding-block: 8px 48px; display: flex; flex-direction: column; gap: 18px; }
.wrap.narrow { max-width: 460px; }
.sub, .note { color: var(--muted); margin: 0; } .note { font-size: .9rem; } .center { text-align: center; justify-content: center; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; } .row.end { justify-content: flex-end; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.btn { background: var(--accent); color: var(--card); border: 0; border-radius: 999px; padding: .7em 1.4em; font-family: var(--display); font-weight: 600; font-size: 1rem; min-height: 48px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.soft { background: var(--hi); color: var(--ink); border: 1px solid var(--warm); }
.btn.danger { background: var(--bad); }
.ghost { background: transparent; border: 1.5px solid var(--line); border-radius: 999px; padding: .5em 1.1em; min-height: 44px; font-weight: 600; }
.ghost.small { min-height: 36px; padding: .3em .9em; font-size: .9rem; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; font-weight: 700; }
.back { background: none; border: 0; color: var(--muted); font-weight: 700; padding: 6px 0; align-self: flex-start; }

/* Thanh trên */
.top { max-width: 860px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font-family: var(--display); font-weight: 700; font-size: 1.2rem; color: var(--accent-ink); }
.top nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .3em .9em .3em .4em; font-weight: 700; min-height: 40px; }
.chip .av { font-size: 1.3rem; }
.mui { display: inline-flex; align-items: center; gap: 3px; font-family: var(--display); font-variant-numeric: tabular-nums; }
.mui b { font-weight: 600; }

/* Chào */
.hello { display: flex; gap: 16px; align-items: center; }
.hello h1 { margin-bottom: .2em; } .hello p { margin: 0; color: var(--muted); }
.goal { display: flex; gap: 6px; margin-top: 8px; } .goal span { opacity: .25; filter: grayscale(1); } .goal span.on { opacity: 1; filter: none; }
.tip { background: var(--hi); border-radius: var(--r); padding: 12px 16px; }

/* Hồ sơ */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.profile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 18px 10px; min-height: 170px; justify-content: center; }
.profile:hover { border-color: var(--accent); }
.profile.add { border-style: dashed; color: var(--muted); }
.profile kbd { position: absolute; top: 8px; left: 8px; }
.profile small { color: var(--muted); font-size: .85rem; text-align: center; }
.big-av { font-size: 3rem; line-height: 1; }
.add-form { display: flex; flex-direction: column; gap: 10px; max-width: 520px; }
.add-form input[type=text], .add-form input:not([type]), #pname, #gate { font: inherit; font-size: 1.1rem; padding: .6em .8em; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); }
.lbl { font-weight: 700; }
.av-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.av-pick label { position: relative; } .av-pick input { position: absolute; opacity: 0; }
.av-pick span { display: grid; place-items: center; font-size: 1.7rem; border: 2px solid var(--line); border-radius: 12px; aspect-ratio: 1; cursor: pointer; }
.av-pick input:checked + span { border-color: var(--accent); background: var(--good-bg); }
.av-pick input:focus-visible + span { outline: 3px solid var(--warm); }
@media (max-width: 480px) { .av-pick { grid-template-columns: repeat(4, 1fr); } }

/* Môn học */
.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .subjects { grid-template-columns: 1fr; } }
.subject { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 14px; text-align: left; border-radius: 18px; padding: 18px; border: 2px solid transparent; }
.subject.math { background: var(--math-bg); } .subject.viet { background: var(--viet-bg); }
.subject.math:hover { border-color: var(--math); } .subject.viet:hover { border-color: var(--viet); }
.s-ico { grid-row: 1 / 4; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--card); font-family: var(--display); font-size: 1.4rem; }
.math .s-ico { color: var(--math); } .viet .s-ico { color: var(--viet); }
.s-name { font-family: var(--display); font-weight: 700; font-size: 1.5rem; }
.s-meta { color: var(--muted); font-size: .9rem; }
.bar { display: block; height: 8px; border-radius: 8px; background: var(--card); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.block { display: flex; flex-direction: column; gap: 10px; }
.block .btn { align-self: flex-start; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.exam { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 12px; padding: 12px 14px; }
.exam.math { border-left-color: var(--math); } .exam.viet { border-left-color: var(--viet); }
.exam small { color: var(--muted); }

/* Danh sách bài */
.page-title.math { color: var(--math); } .page-title.viet { color: var(--viet); }
.topic-group h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 8px; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.topic { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.topic:hover { border-color: var(--accent); }
.t-name { font-weight: 800; } .t-sgk { color: var(--muted); font-size: .82rem; }
.t-stat { display: flex; align-items: center; gap: 8px; margin-top: 4px; } .t-stat small { color: var(--muted); font-size: .8rem; }
.stars i { font-style: normal; color: var(--line); font-size: 1.1rem; } .stars i.on { color: var(--warm); }

/* Làm bài */
.quiz-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qtitle { font-family: var(--display); font-weight: 600; flex: 1; min-width: 0; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots i { width: 22px; height: 8px; border-radius: 6px; background: var(--line); }
.dots i.cur { background: var(--warm); } .dots i.ok { background: var(--good); } .dots i.bad { background: var(--bad); } .dots i.done { background: var(--accent); }
.timer { color: var(--muted); font-variant-numeric: tabular-nums; } .timer.late { color: var(--bad); font-weight: 700; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 4vw, 28px); display: flex; flex-direction: column; gap: 16px; }
.qline { display: flex; gap: 10px; align-items: flex-start; }
.q { flex: 1; min-width: 0; font-size: clamp(1.2rem, 3.2vw, 1.55rem); font-weight: 600; margin: 0; }
.speak { border: 1.5px solid var(--line); background: var(--bg); border-radius: 50%; width: 44px; height: 44px; flex: none; }
.visual { display: flex; justify-content: center; overflow-x: auto; color: var(--ink); }
.fig { width: 100%; max-width: 380px; height: auto; color: var(--ink); }
.fig.small { max-width: 160px; } .fig.clock { max-width: 200px; }
.visual.small .fig { max-width: 220px; }
.passage { background: var(--hi); border-radius: 14px; padding: 14px 18px; }
.passage h3 { margin-bottom: .3em; } .passage p { margin: 0 0 8px; font-size: 1.08rem; line-height: 1.7; }
.column-calc { display: inline-grid; grid-template-columns: auto auto; column-gap: 8px; font-family: var(--display); font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: .12em; }
.column-calc .op { align-self: start; color: var(--accent); }
.column-calc .line { border-top: 3px solid var(--ink); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.options.few { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 520px) { .options:not(.pics) { grid-template-columns: 1fr; } }
.opt { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 56px; font-size: 1.1rem; font-weight: 600; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.right { background: var(--good-bg); border-color: var(--good); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt.picked { border-color: var(--accent); background: var(--hi); }
.options.pics .opt { justify-content: center; } .shape { width: 110px; height: 88px; color: var(--ink); }
.num-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.num-display { min-width: 160px; min-height: 64px; display: flex; align-items: baseline; justify-content: center; gap: 6px; font-family: var(--display); font-size: 2.2rem; font-weight: 700; border: 2.5px solid var(--line); border-radius: 14px; padding: 4px 16px; font-variant-numeric: tabular-nums; }
.num-display .ph { color: var(--line); } .num-display .unit { font-size: 1.1rem; color: var(--muted); }
.num-display.right { border-color: var(--good); background: var(--good-bg); } .num-display.wrong { border-color: var(--bad); background: var(--bad-bg); }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 8px; }
.keypad button { height: 56px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font-family: var(--display); font-size: 1.4rem; font-weight: 600; }
.keypad button.ok { background: var(--accent); color: var(--card); border: 0; font-size: 1.05rem; }
.keypad button:disabled { opacity: .45; }
.order { display: flex; flex-direction: column; gap: 12px; }
.sentence { min-height: 62px; border: 2.5px dashed var(--line); border-radius: 14px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sentence.right { border-style: solid; border-color: var(--good); background: var(--good-bg); } .sentence.wrong { border-style: solid; border-color: var(--bad); background: var(--bad-bg); }
.sentence .ph { color: var(--muted); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.w { border: 2px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 14px; font-size: 1.1rem; font-weight: 700; min-height: 44px; }
.w.on { background: var(--hi); border-color: var(--warm); }
.order .btn { align-self: flex-start; }
.spell .slots, .spell .bank { justify-content: center; }
.spell .tile { width: 52px; min-height: 56px; padding: 0; font-family: 'Lexend', sans-serif; font-size: 1.6rem; text-transform: none; display: inline-flex; align-items: center; justify-content: center; }
.spell .slot { width: 52px; height: 56px; border-bottom: 3px solid var(--muted); display: inline-block; }
.spell .tile.gone { visibility: hidden; border: 0; display: inline-block; }
.spell .row.center { justify-content: center; gap: 12px; }
@media (max-width: 420px) { .spell .tile, .spell .slot { width: 42px; height: 48px; min-height: 48px; font-size: 1.35rem; } }
.feedback { display: flex; gap: 12px; align-items: center; border-radius: 14px; padding: 12px 14px; }
.feedback.good { background: var(--good-bg); } .feedback.bad { background: var(--bad-bg); }
.feedback b { font-family: var(--display); }
.feedback .mascot { flex: none; }
@media (max-width: 560px) { .qtitle { order: 3; flex-basis: 100%; } .count { margin-left: auto; } }
.review .fig, .review .cal { max-width: 220px; } .review .shape { width: 70px; height: 56px; } .review .column-calc { font-size: 1.3rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }

/* Kết quả */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.result .big { font-size: 1.2rem; margin: 0; }
.review { display: flex; flex-direction: column; gap: 12px; padding-left: 1.2em; }
.review li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rq { font-weight: 800; } .rp, .rx { color: var(--muted); font-size: .92rem; }
.bad-t { color: var(--bad); font-weight: 700; } .good-t { color: var(--good); font-weight: 700; }
.mini svg { width: 60px; height: 48px; vertical-align: middle; }

/* Phiếu bài tập */
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; align-self: flex-start; }
.seg button { background: none; border: 0; padding: .5em 1.2em; font-weight: 700; min-height: 44px; }
.seg button.on { background: var(--accent); color: var(--card); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.checks label { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.checks input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); }
.checks span { display: flex; flex-direction: column; } .checks small { color: var(--muted); }
select { font: inherit; padding: .4em .6em; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); min-height: 44px; }
.sheet { background: #fff; color: #111; border-radius: 6px; padding: 28px; border: 1px solid var(--line); }
.sheet .fig, .sheet .shape, .sheet .visual { color: #111; }
.sheet-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 14px; font-size: .95rem; }
.sheet-q { display: flex; flex-direction: column; gap: 16px; padding-left: 1.4em; }
.pq { break-inside: avoid; } .pq .q { font-weight: 700; } .pq .visual { justify-content: flex-start; margin: 6px 0; }
.abcd { list-style: upper-alpha; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 24px; padding-left: 1.6em; margin: 6px 0 0; }
.blank { margin-top: 6px; } .order-print span { font-weight: 700; }
.passage.print { background: #f4f4f4; }
.answers { break-before: page; margin-top: 28px; border-top: 1px dashed #999; padding-top: 12px; }
.answers ol { columns: 3; padding-left: 1.4em; }

/* Phụ huynh */
.kid header { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; } .kid header small { color: var(--muted); }
.kid-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; } .kid-grid > div { min-width: 0; }
@media (max-width: 640px) { .kid-grid { grid-template-columns: 1fr; } }
.stat { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stat th, .stat td { text-align: left; border-bottom: 1px solid var(--line); padding: 5px 4px; vertical-align: top; }
.stat .num { font-variant-numeric: tabular-nums; }
.kid p { margin: 0 0 4px; } .h { font-size: .9rem; }
textarea { width: 100%; font: inherit; font-size: .8rem; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); padding: 8px; }
.err { color: var(--bad); font-weight: 700; }
.about p { color: var(--muted); }

/* Lịch */
.cal { width: 100%; max-width: 380px; } .cal-title { font-family: var(--display); font-weight: 700; text-align: center; margin-bottom: 4px; }
.cal table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cal th, .cal td { border: 1px solid var(--line); text-align: center; padding: 3px 0; font-size: .92rem; }
.cal th { background: var(--hi); font-size: .8rem; } .cal th:last-child { color: var(--bad); }

/* Tài khoản */
.acct { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.acct.card { align-items: stretch; text-align: left; }
.gbtn { display: inline-flex; align-items: center; gap: 10px; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px; padding: .6em 1.2em; font-weight: 700; min-height: 48px; align-self: center; }
.acct.card .gbtn { align-self: flex-start; }
.acct-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .acct-row > div { flex: 1; min-width: 160px; }
.acct-row img { width: 40px; height: 40px; border-radius: 50%; }
.acct-row small { color: var(--muted); }
.consent { max-width: 480px; text-align: left !important; align-items: stretch !important; }
.consent ul { margin: 0; padding-left: 1.2em; } .consent p { margin: 0; }
.ck { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; cursor: pointer; }
.ck input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin-top: 2px; }

/* Nghỉ mắt */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay .card { text-align: center; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.overlay .big { font-family: var(--display); font-size: 3rem; margin: 0; color: var(--accent); }

@media (prefers-reduced-motion: no-preference) {
  .opt, .topic, .profile, .subject { transition: border-color .15s, transform .15s; }
  .opt:active:not(:disabled), .profile:active, .subject:active { transform: scale(.98); }
  .feedback { animation: pop .25s ease-out; }
  @keyframes pop { from { transform: translateY(6px); } to { transform: none; } }
}
@media print {
  body { background: #fff; padding: 0; }
  .noprint, .top { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .sheet { border: 0; padding: 0; }
}

/* Thời khoá biểu trong câu hỏi Tiếng Việt */
.tkb { width: 100%; border-collapse: collapse; font-size: .85rem; margin: 8px 0; background: var(--card); table-layout: fixed; }
.tkb th, .tkb td { border: 1px solid var(--line); padding: 4px 3px; text-align: center; overflow-wrap: anywhere; }
.tkb th { background: var(--bg); font-family: var(--display); font-weight: 600; }
.tkb td:first-child, .tkb th:first-child { width: 2.6em; font-weight: 700; }
@media (max-width: 420px) { .tkb { font-size: .72rem; } .tkb th, .tkb td { padding: 3px 1px; } }
