:root {
  --bg: #fff8ef; --card: #fff; --ink: #2b2a33; --muted: #6f6a75;
  --accent: #f26b1d; --accent2: #2a8f82; --line: #f0e4d6; --star: #ffc531;
  --radius: 22px; color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 18px; line-height: 1.45; }
#app { max-width: 980px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px calc(110px + env(safe-area-inset-bottom)); }
h1 { font-size: 30px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 22px; margin: 28px 0 12px; }
a { color: inherit; text-decoration: none; }

/* Trang chủ */
.hero { background: linear-gradient(135deg, #ffe2c7, #ffd6e4); border-radius: 28px; padding: 24px; display: grid; gap: 16px; }
.hero p { margin: 0; color: #5b4b55; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: #ffffffa8; border-radius: 18px; padding: 10px 16px; display: grid; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--muted); }
.goal { height: 14px; background: #ffffff90; border-radius: 99px; overflow: hidden; }
.goal div { height: 100%; background: var(--accent2); border-radius: 99px; transition: width .4s; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 6px; align-content: start; transition: transform .15s; }
.card:active { transform: scale(.97); }
.card .emoji { font-size: 44px; line-height: 1; }
.card .title { font-weight: 700; font-size: 20px; }
.card .sub { color: var(--muted); font-size: 15px; }
.card .meta { font-size: 14px; color: var(--muted); }
.card.full { border-color: var(--star); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--star); }

/* Thanh điều hướng */
#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fffdf9ee;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 5; }
#nav a { flex: 0 1 200px; text-align: center; padding: 12px 8px; border-radius: 16px; font-size: 16px; color: var(--muted); font-weight: 600; }
#nav a.on { background: #ffe7d4; color: var(--ink); }
#nav.hide { display: none; }

/* Bài học */
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.topbar h1 { font-size: 24px; margin: 0; }
.back { padding: 12px 16px; background: #fff; border: 2px solid var(--line); border-radius: 16px; font-weight: 700; white-space: nowrap; }
.lesson { display: grid; gap: 16px; }
.yt { position: relative; aspect-ratio: 16 / 9; border-radius: 20px; overflow: hidden; background: #000; }
.yt iframe, .yt > div { position: absolute; inset: 0; width: 100%; height: 100%; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.bigemoji { font-size: 84px; text-align: center; line-height: 1.1; }
.sentence { background: #fff; border: 2px solid var(--line); border-radius: 26px; padding: 22px 24px; text-align: center; }
.count { font-size: 15px; color: var(--muted); font-weight: 600; }
.en { font-size: 34px; font-weight: 700; margin: 10px 0; line-height: 1.35; }
.w { border-radius: 8px; padding: 0 2px; cursor: pointer; }
.w:active, .w.hl { background: #ffe0c7; }
.vi { font-size: 22px; color: #3f6a64; margin: 6px 0; }
.tip { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn { font: inherit; font-weight: 700; font-size: 20px; min-height: 60px; min-width: 72px; padding: 0 20px;
  border-radius: 18px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { min-width: 180px; font-size: 24px; }
.btn.rec.on { background: #e5484d; border-color: #e5484d; color: #fff; animation: pulse 1s infinite; }
.btn.star.on { background: var(--star); border-color: var(--star); }
@keyframes pulse { 50% { opacity: .7; } }
.toggles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.toggles label { background: #fff; border: 2px solid var(--line); border-radius: 99px; padding: 10px 16px; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.toggles input { width: 22px; height: 22px; accent-color: var(--accent2); margin: 0; }
.list { padding: 0; margin: 0; list-style: none; display: grid; gap: 8px; counter-reset: c; }
.list li { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px 44px 12px 52px; position: relative; cursor: pointer; counter-increment: c; }
.list li::before { content: counter(c); position: absolute; left: 18px; color: var(--muted); font-weight: 700; }
.list li.cur { border-color: var(--accent); }
.list li.done::after { content: "⭐"; position: absolute; right: 14px; }
.list li small { display: block; color: var(--muted); font-size: 15px; }

/* Bảng chọn từ */
.sheet { position: fixed; inset: 0; background: #0006; display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheetbox { background: #fff; border-radius: 28px 28px 0 0; padding: 24px 24px calc(28px + env(safe-area-inset-bottom)); width: min(560px, 100%); display: grid; gap: 12px; position: relative; }
.word { font-size: 40px; font-weight: 800; margin: 0; text-align: center; }
.x { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 24px; color: var(--muted); padding: 10px; }
input, textarea, select { font: inherit; font-size: 18px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; width: 100%; background: #fff; color: var(--ink); }
textarea { min-height: 160px; resize: vertical; }
label.f { display: grid; gap: 6px; font-weight: 600; }
.ok { text-align: center; color: var(--accent2); font-weight: 700; margin: 0; }

/* Sổ từ, phụ huynh */
.pagehead p { margin: 0; color: var(--muted); }
.words { list-style: none; padding: 0; display: grid; gap: 10px; }
.words li { background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px; display: flex; gap: 12px; align-items: center; }
.words li div { flex: 1; display: grid; }
.words b { font-size: 22px; }
.words small { color: var(--muted); }
.say, .del { font-size: 22px; border: 0; background: #fff1e4; border-radius: 14px; width: 52px; height: 52px; flex: none; }
.del { background: none; color: var(--muted); }
.empty { color: var(--muted); background: #fff; border: 2px dashed var(--line); border-radius: 20px; padding: 24px; text-align: center; }
.panel { background: #fff; border: 2px solid var(--line); border-radius: 22px; padding: 20px; display: grid; gap: 12px; margin-top: 16px; }
.panel h2 { margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.chart { display: flex; gap: 8px; align-items: flex-end; height: 140px; }
.chart div { flex: 1; display: grid; justify-items: center; align-content: end; gap: 4px; font-size: 13px; color: var(--muted); height: 100%; }
.chart i { display: block; width: 100%; background: var(--accent2); border-radius: 8px 8px 4px 4px; min-height: 3px; }
.note { font-size: 15px; color: var(--muted); margin: 0; }
.note ol { margin: 6px 0; padding-left: 22px; }
.preview { font-size: 15px; background: var(--bg); border-radius: 14px; padding: 12px; max-height: 280px; overflow: auto; }
.preview p { margin: 0 0 8px; }
.err { color: #c62828; font-weight: 600; }
.mylist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.mylist li { display: flex; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 14px; }
.mylist li span { flex: 1; }
.party { position: fixed; inset: 0; display: grid; place-items: center; background: #fff9; font-size: 40px; font-weight: 800; z-index: 20; text-align: center; animation: fade 2.4s forwards; pointer-events: none; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); width: min(620px, calc(100% - 32px));
  background: #2b2a33; color: #fff; border-radius: 18px; padding: 16px 48px 16px 18px; font-size: 16px; z-index: 30; box-shadow: 0 8px 30px #0003; }
.toast button { position: absolute; right: 8px; top: 8px; border: 0; background: none; color: #fff; font-size: 20px; padding: 8px; }
.gate { display: grid; gap: 12px; max-width: 360px; margin-top: 20px; }
@media (max-width: 600px) { .en { font-size: 26px; } .btn.big { min-width: 140px; } h1 { font-size: 26px; } }
