:root {
  --bg: #f4f7f2; --card: #ffffff; --ink: #14231a; --muted: #5d6d62; --line: #dfe7dc;
  --brand: #15803d; --brand-ink: #ffffff; --brand-soft: #dcfce7; --accent: #facc15; --accent-ink: #3b2f00;
  --warn: #b45309; --bad: #b91c1c; --kid: #2563eb;
  --r: 18px; --shadow: 0 1px 2px rgba(20, 35, 26, .06), 0 6px 20px rgba(20, 35, 26, .06);
  --tabs: 66px; --safe-b: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1510; --card: #16211a; --ink: #e8f0ea; --muted: #9db0a3; --line: #263429; --brand: #22c55e; --brand-ink: #062611; --brand-soft: #173d24; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--tabs) + var(--safe-b) + 12px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13.5px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

#app { max-width: 640px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 16px 16px; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.top .grow { flex: 1; min-width: 0; }
.kidchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px 6px 6px; font-weight: 600; max-width: 100%; }
.kidchip .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 14px; flex: none; }
.kidchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.hero { background: linear-gradient(150deg, #166534, #15803d 55%, #22c55e); color: #fff; border: 0; }
.hero .muted { color: #d9f99d; }
.hero h1 { font-size: 22px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); }

.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 700; background: var(--brand); color: var(--brand-ink); min-height: 48px; }
.btn.block { width: 100%; }
.btn.big { font-size: 18px; min-height: 56px; }
.btn.alt { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 6px 0; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; text-align: left; width: 100%; }
.item .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 20px; flex: none; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tx span { font-size: 13px; color: var(--muted); }
.item.done .ic { background: var(--brand); color: #fff; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); }
.pill.y { background: #fef3c7; color: #78350f; }
.pill.b { background: #dbeafe; color: #1e3a8a; }

.weeks { display: grid; gap: 10px; }
.week h3 { display: flex; justify-content: space-between; gap: 8px; }
.dots { display: flex; gap: 6px; margin-top: 8px; }
.dots button { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 4px; font-size: 13px; font-weight: 600; min-height: 44px; }
.dots button.done { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.dots button.next { outline: 2px solid var(--accent); outline-offset: 1px; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filters button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-size: 14px; min-height: 38px; }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.diagram { width: 100%; height: auto; display: block; border-radius: 14px; }
.sec { margin-top: 14px; }
.sec h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sec ol, .sec ul { margin: 0; padding-left: 22px; }
.sec li { margin-bottom: 6px; }
.say { background: #ede9fe; color: #3b0764; border-radius: 14px; padding: 10px 12px; }
@media (prefers-color-scheme: dark) { .say { background: #2e1f4d; color: #e9d5ff; } }
.say li { list-style: "💬 "; }
.fix div { border-left: 3px solid var(--warn); padding: 4px 0 4px 10px; margin-bottom: 8px; }
.fix b { display: block; }

/* trình chạy buổi tập */
.player { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; padding: calc(10px + env(safe-area-inset-top)) 16px calc(20px + var(--safe-b)); }
.player .in { max-width: 640px; margin: 0 auto; }
.bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0 14px; }
.bar i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.timer { text-align: center; padding: 14px; }
.timer .t { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.timer .t.go { color: var(--brand); }
.timer .row { justify-content: center; margin-top: 10px; }
.num { display: flex; align-items: center; gap: 8px; }
.num input { flex: 1; min-width: 0; text-align: center; font-size: 26px; font-weight: 800; border: 2px solid var(--line); border-radius: 14px; padding: 8px; background: var(--card); }
.num button { width: 56px; height: 56px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 26px; font-weight: 700; flex: none; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate button { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 4px; font-weight: 700; min-height: 64px; }
.rate button b { display: block; font-size: 24px; }
.rate button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.foot { position: sticky; bottom: 0; padding: 12px 0 0; background: linear-gradient(transparent, var(--bg) 30%); display: flex; gap: 8px; }
.foot .btn { flex: 1; }
.celebrate { text-align: center; padding: 30px 10px; }
.celebrate .big { font-size: 72px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.badge { text-align: center; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; }
.badge b { display: block; font-size: 28px; }
.badge.off { opacity: .35; filter: grayscale(1); }

.chart { width: 100%; height: auto; display: block; }
form .f { display: grid; gap: 4px; margin-bottom: 12px; }
form label, .lbl { font-size: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px; min-height: 46px; }
textarea { min-height: 80px; resize: vertical; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 6px; min-height: 46px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }

#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
#tabs button { border: 0; background: none; height: var(--tabs); display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--muted); }
#tabs b { font-size: 21px; line-height: 1; font-weight: 400; }
#tabs span { font-size: 11.5px; font-weight: 600; }
#tabs button[aria-current="page"] { color: var(--brand); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs) + var(--safe-b) + 14px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; }
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet .card { width: min(640px, 100%); margin: 0; border-radius: 22px 22px 0 0; max-height: 88dvh; overflow-y: auto; padding-bottom: calc(18px + var(--safe-b)); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.illus { display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.illus:has(figure:only-child) { grid-auto-columns: 100%; }
.illus figure { margin: 0; scroll-snap-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.illus img { display: block; width: 100%; height: auto; aspect-ratio: 1; background: #3f9b4f; }
.illus figcaption { padding: 8px 12px 10px; font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; }
.illus figcaption b { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: inline-grid; place-items: center; font-size: 12.5px; }
.item .ic.th { overflow: hidden; background: #3f9b4f; }
.item .ic.th img { width: 100%; height: 100%; object-fit: cover; }
