:root {
  --bg: #fff6fa;
  --card: #ffffff;
  --ink: #2a2140;
  --muted: #7a7090;
  --line: #f0e2ea;
  --navy: #7b5cff;
  --gold: #ff6fa3;
  --gold-soft: #ffe3ee;
  --mint: #2fc4a0;
  --mint-soft: #dcf7ef;
  --sun: #ffc23d;
  --ok: #2f9e5b;
  --ok-soft: #e3f4ea;
  --bad: #d0453a;
  --bad-soft: #fbe6e3;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --r: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16121f;
    --card: #221c30;
    --ink: #f1ecf8;
    --muted: #a79fbb;
    --line: #342b47;
    --navy: #5a3fd6;
    --gold: #ff7fae;
    --gold-soft: #45233a;
    --mint: #3fd6b0;
    --mint-soft: #173a31;
    --sun: #ffcf5c;
    --ok: #4cc27c;
    --ok-soft: #173325;
    --bad: #f06a5e;
    --bad-soft: #3a1d1b;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

/* ---------- Thanh trên ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  background: var(--navy); color: #fff;
}
.top-title { flex: 1; font-weight: 700; font-size: 18px; padding-left: 4px; }
.top .bar { flex: 1; height: 10px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: hidden; }
.top .bar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .3s; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: transparent; display: grid; place-items: center; color: #fff;
}
.icon-btn:active { background: rgba(255,255,255,.12); }
[hidden] { display: none !important; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; }

/* ---------- Trang chủ ---------- */
.hello { margin: 4px 0 14px; }
.hello h1 { font-size: 22px; margin: 0; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.today { background: var(--navy); color: #fff; border: 0; }
.today .row { display: flex; gap: 10px; margin: 6px 0 14px; }
.today .stat { flex: 1; background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px; }
.today .stat b { display: block; font-size: 24px; line-height: 1.2; color: var(--gold); }
.today .stat span { font-size: 13px; opacity: .8; }
.today h2 { margin: 0; font-size: 17px; }
.today .sub { font-size: 13px; opacity: .75; margin-top: 2px; }
.btn {
  display: block; width: 100%; border: 0; border-radius: 14px;
  padding: 15px 16px; font-weight: 700; font-size: 17px;
  background: var(--gold); color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.btn.ghost { background: transparent; color: inherit; border: 1.5px solid var(--line); box-shadow: none; font-weight: 600; }
.btn.navy { background: var(--navy); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .45; }
.btn + .btn { margin-top: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile {
  text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; box-shadow: var(--shadow);
}
.tile .ic { font-size: 22px; }
.tile b { display: block; margin-top: 4px; }
.tile span { font-size: 13px; color: var(--muted); }
.tile:active { transform: scale(.98); }

.goal .meter { height: 10px; border-radius: 99px; background: var(--gold-soft); overflow: hidden; margin: 8px 0 6px; }
.goal .meter i { display: block; height: 100%; background: var(--gold); }
.goal .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.goal h3 { margin: 0; font-size: 15px; }

/* ---------- Thẻ học ---------- */
.q-label { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 4px 0 10px; }
.word-card { text-align: center; padding: 26px 16px 20px; }
.word { font-size: 34px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; word-break: break-word; }
.ipa { color: var(--muted); margin-top: 4px; font-size: 17px; }
.pos { display: inline-block; font-size: 12px; font-weight: 700; color: var(--gold); background: var(--gold-soft); border-radius: 6px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }
.meaning { font-size: 19px; font-weight: 600; margin-top: 12px; }
.ex { text-align: left; margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }
.ex .en { font-weight: 500; }
.ex .vi { color: var(--muted); font-size: 14px; margin-top: 2px; }
mark { background: var(--gold-soft); color: inherit; border-radius: 4px; padding: 0 2px; }
.ex mark { background: var(--gold-soft); color: inherit; border-radius: 4px; padding: 0 2px; }
.speak-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--gold-soft); color: var(--gold); vertical-align: middle;
}
.speak-btn.sm { width: 34px; height: 34px; float: right; margin: -2px -4px 0 8px; }
.big-listen { width: 96px; height: 96px; margin: 18px auto 6px; display: grid; }
.big-listen svg { width: 42px; height: 42px; }
.slow { font-size: 13px; border: 0; background: none; color: var(--muted); text-decoration: underline; }

.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 14px 16px; border-radius: 14px;
  background: var(--card); border: 2px solid var(--line); font-size: 17px; font-weight: 500;
  box-shadow: 0 2px 0 var(--line);
}
.opt:active { transform: translateY(1px); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opts.done .opt { pointer-events: none; }

.prompt-vi { font-size: 22px; font-weight: 700; text-align: center; margin: 6px 0 4px; }
.blank-ex { text-align: center; color: var(--muted); margin-bottom: 14px; }
.text-in {
  width: 100%; padding: 14px 16px; font-size: 19px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink); outline: none;
}
.text-in:focus { border-color: var(--gold); }

.mic {
  width: 104px; height: 104px; border-radius: 50%; border: 0; margin: 18px auto 10px;
  display: grid; place-items: center; background: var(--navy); color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.mic svg { width: 44px; height: 44px; }
.mic.on { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(208,69,58,.5)} 70%{box-shadow:0 0 0 18px rgba(208,69,58,0)} 100%{box-shadow:0 0 0 0 rgba(208,69,58,0)} }
.heard { text-align: center; min-height: 26px; color: var(--muted); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 8px; }

/* ---------- Thanh phản hồi dưới ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0,0,0,.08);
  animation: up .18s ease-out;
}
.sheet-in { max-width: 560px; margin: 0 auto; }
.sheet.ok { background: var(--ok-soft); }
.sheet.bad { background: var(--bad-soft); }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet.ok h3 { color: var(--ok); }
.sheet.bad h3 { color: var(--bad); }
.sheet .ans { margin-bottom: 12px; }
@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
.fixed-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.fixed-bottom > div { max-width: 560px; margin: 0 auto; }

/* ---------- Chấm câu nói/nghe ---------- */
.diff { font-size: 18px; line-height: 1.7; }
.diff .g { color: var(--ok); font-weight: 600; }
.diff .r { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.score { font-size: 40px; font-weight: 800; text-align: center; }

/* ---------- Tiến độ ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.kpi b { display: block; font-size: 24px; }
.kpi span { font-size: 12px; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; margin-top: 10px; }
.chart i { flex: 1; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .9; }
.chart i.zero { background: var(--line); }
.chart-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- Danh sách từ ---------- */
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.wl { list-style: none; margin: 0; padding: 0; }
.wl li { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.wl .t { flex: 1; min-width: 0; }
.wl .t b { display: block; }
.wl .t span { font-size: 14px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.dot.L { background: var(--bad); } .dot.R { background: var(--gold); } .dot.M { background: var(--ok); }

/* ---------- Cài đặt ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 22px; }
.stepper b { font-size: 22px; min-width: 40px; text-align: center; }
select.text-in { appearance: none; font-size: 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 50; font-size: 15px;
  max-width: calc(100% - 32px);
}
.done-hero { text-align: center; padding: 20px 0 10px; }
.done-hero .big { font-size: 56px; }
.done-hero h2 { margin: 4px 0; }

/* ---------- Helena ---------- */
.helena-hi { display: flex; align-items: flex-end; gap: 10px; margin: 2px 0 6px; }
.helena-hi img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; border: 3px solid var(--gold); background: var(--gold-soft); }
.bubble { position: relative; flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px 13px; font-size: 15px; box-shadow: var(--shadow); }
.bubble b { font-size: 17px; }
.streak { margin: 0 0 14px 74px; font-size: 13px; color: var(--muted); }
.helena-big { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 4px solid var(--gold); display: block; margin: 0 auto 8px; }

/* ---------- Kem ---------- */
.kem-hi { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 14px; }
.kem-hi img { width: 72px; height: 72px; flex: none; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
.kem-hi .bubble { flex: 1; background: var(--card); border: 2px solid var(--line); border-radius: 18px 18px 18px 4px; padding: 10px 13px; font-size: 15px; }
.kem-hi .bubble b { font-size: 18px; }
.chips-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pill { background: var(--card); border: 2px solid var(--line); border-radius: 99px; padding: 5px 12px; font-weight: 700; font-size: 14px; }
.today { background: linear-gradient(135deg, #7b5cff, #ff6fa3); }
.today .stat b { color: #fff; }
.today .btn { background: #fff; color: #7b5cff; }
h2.sec { font-size: 18px; margin: 18px 0 10px; }
.units { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.unit {
  text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  padding: 12px; position: relative; overflow: hidden; min-height: 108px;
}
.unit .n { font-size: 12px; font-weight: 800; color: var(--gold); letter-spacing: .04em; }
.unit b { display: block; font-size: 15px; line-height: 1.25; margin: 2px 0; }
.unit span { font-size: 12px; color: var(--muted); display: block; }
.unit .prog { height: 6px; border-radius: 99px; background: var(--gold-soft); margin-top: 8px; overflow: hidden; }
.unit .prog i { display: block; height: 100%; background: var(--mint); }
.unit.cur { border-color: var(--gold); }
.stars { color: var(--sun); letter-spacing: 1px; font-size: 14px; }
.stars .off { color: var(--line); }
.acts { display: grid; gap: 10px; }
.act { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 14px; }
.act .ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex: none; background: var(--gold-soft); }
.act .t { flex: 1; min-width: 0; }
.act .t b { display: block; }
.act .t span { font-size: 13px; color: var(--muted); }
.act:active, .unit:active { transform: scale(.98); }
.lesson li { margin-bottom: 6px; }
.lesson ul { padding-left: 20px; margin: 8px 0 0; }
.qtext { font-size: 19px; font-weight: 700; margin: 4px 0 16px; line-height: 1.45; }
.qtext u, .opt u { text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--gold); }
.qnum { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.big-score { text-align: center; padding: 10px 0; }
.big-score .s { font-size: 54px; font-weight: 900; color: var(--gold); line-height: 1; }
.big-score .stars { font-size: 34px; }
.review li { padding: 10px 0; border-bottom: 1px solid var(--line); list-style: none; }
.review { padding: 0; margin: 0; }
.review .wrongpick { color: var(--bad); }
.review .right { color: var(--ok); font-weight: 700; }
.sound-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 12px; }
.sound-btns .opt { text-align: center; font-size: 26px; font-weight: 800; padding: 22px 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 700; }
.pct-lo { color: var(--bad); font-weight: 700; } .pct-mid { color: var(--gold); font-weight: 700; } .pct-hi { color: var(--ok); font-weight: 700; }
.name-in { text-align: center; font-size: 22px; font-weight: 700; }
.kem-av { border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); background: var(--gold-soft); display: block; margin: 0 auto 8px; }
.kem-hi .kem-av { margin: 0; }

/* ---------- Nhiệm vụ · chuỗi · cấp · huy hiệu ---------- */
.lvl { padding: 14px 16px; }
.lvl-top { display: flex; align-items: center; gap: 8px; }
.lvl-top b { flex: 1; font-size: 17px; }
.lvl-n { background: var(--navy); color: #fff; font-weight: 800; font-size: 12px; border-radius: 99px; padding: 3px 9px; }
.lvl-xp { font-weight: 800; color: var(--gold); }
.lvl .meter { height: 12px; border-radius: 99px; background: var(--gold-soft); overflow: hidden; margin: 8px 0 6px; }
.lvl .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffa94d); border-radius: 99px; transition: width .4s; }
.streak-card .st-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.st-big { font-size: 26px; background: #fff1e0; border-radius: 16px; padding: 6px 12px; flex: none; }
.st-big b { font-size: 30px; color: #ff7a1a; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.day { text-align: center; }
.day i { display: grid; place-items: center; height: 36px; border-radius: 12px; background: var(--bg); border: 2px solid var(--line); font-style: normal; font-size: 18px; }
.day span { font-size: 11px; color: var(--muted); font-weight: 700; }
.day.on i { background: #fff1e0; border-color: #ffb36b; }
.day.ice i { background: #e3f3ff; border-color: #8cc8ff; }
.day.today i { border-style: dashed; border-color: var(--gold); }
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.q-head span { font-weight: 800; color: var(--gold); }
.quest { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.quest:last-of-type { border-bottom: 0; }
.quest .qi { font-size: 20px; }
.quest .qt { flex: 1; min-width: 0; font-weight: 600; }
.quest .qx { text-align: right; font-size: 12px; font-weight: 800; color: var(--muted); }
.quest .qx span { color: var(--gold); }
.quest.done .qt > div:first-child { text-decoration: line-through; color: var(--muted); }
.qbar { height: 8px; border-radius: 99px; background: var(--gold-soft); overflow: hidden; margin-top: 5px; }
.qbar i { display: block; height: 100%; background: var(--mint); border-radius: 99px; }
.btn.chest { margin-top: 10px; background: linear-gradient(135deg, #ffc23d, #ff6fa3); animation: wiggle 1.4s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 20% { transform: rotate(-2deg) } 40% { transform: rotate(2deg) } 60% { transform: rotate(-1deg) } }
.chest-done { margin-top: 8px; font-weight: 700; color: var(--mint); }
.mission-card { border-color: #c9b8ff; background: linear-gradient(180deg, #f4efff, var(--card)); }
.mission { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.mission:last-child { border-bottom: 0; }
.mission .mt { font-weight: 700; }
.mission.done .mt { color: var(--ok); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.grid3 .tile { padding: 12px 10px; }
.grid3 .tile b { font-size: 14px; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 12px 6px; text-align: center; filter: grayscale(1); opacity: .5; }
.badge.got { filter: none; opacity: 1; border-color: var(--sun); background: #fffaeb; }
.badge .bi { font-size: 30px; }
.badge b { display: block; font-size: 13px; line-height: 1.2; margin-top: 2px; }
.badge span { font-size: 11px; color: var(--muted); line-height: 1.2; display: block; margin-top: 2px; }
.kpis.k4 { grid-template-columns: 1fr 1fr; }
@media (prefers-color-scheme: dark) {
  .st-big, .day.on i { background: #3a2514; }
  .day.ice i { background: #16304a; }
  .mission-card { background: var(--card); }
  .badge.got { background: #3a3218; }
}
.ring { display: inline-block; width: 20px; height: 20px; border: 2.5px solid var(--line); border-radius: 50%; vertical-align: middle; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who-btn { background: var(--card); border: 2px solid var(--line); border-radius: 22px; padding: 22px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.who-btn span { font-size: 52px; line-height: 1.1; }
.who-btn b { font-size: 20px; }
.who-btn small { color: var(--muted); font-size: 13px; }
.who-btn:active { transform: scale(.97); border-color: var(--gold); }
