:root {
  --red: #d93a2b;
  --red-dark: #b02a1e;
  --red-soft: #fde8e4;
  --gold: #ffc83d;
  --gold-soft: #fff4d3;
  --green: #2f9e5b;
  --green-soft: #e3f5ea;
  --blue: #2f6fd6;
  --blue-soft: #e5eefc;
  --ink: #2a2321;
  --muted: #7a6f6a;
  --line: #eee3d8;
  --bg: #fffaf3;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(42, 35, 33, .06), 0 8px 24px rgba(42, 35, 33, .06);
  --fs: 16px;
  --han: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs)/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.kid { --fs: 18px; }
a { color: var(--blue); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.han { font-family: var(--han); }
.boot { display: grid; place-items: center; height: 100vh; font: 700 72px var(--han); color: var(--red); }

/* ---------- layout ---------- */
.shell { max-width: 880px; margin: 0 auto; padding: 0 16px 110px; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(255, 250, 243, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.me-chip { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px; border-radius: 14px; min-width: 0; }
.me-chip .av { font-size: 30px; line-height: 1; }
.me-chip .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
.pill.fire { color: #c2410c; background: #fff1e6; border-color: #fed7aa; }
.pill.xp { color: #8a5a00; background: var(--gold-soft); border-color: #ffe39a; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { max-width: 880px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav button {
  background: none; border: 0; padding: 8px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12.5px; color: var(--muted); font-weight: 600;
}
.nav button .ic { font-size: 24px; line-height: 1.1; filter: grayscale(.6); transition: transform .15s; }
.nav button.on { color: var(--red); }
.nav button.on .ic { filter: none; transform: translateY(-2px) scale(1.1); }

h1 { font-size: 1.6em; margin: 20px 0 6px; line-height: 1.25; }
h2 { font-size: 1.2em; margin: 26px 0 10px; }
h3 { font-size: 1.05em; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: .88em; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 12px 0; border: 1px solid var(--line); }
.card.hero { background: linear-gradient(135deg, var(--red) 0%, #e85d3f 100%); color: #fff; border: 0; }
.card.hero .muted, .card.hero .sub { color: rgba(255, 255, 255, .85); }
.card.hero a { color: #fff; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 14px; border: 0; background: var(--red); color: #fff; font-weight: 700; font-size: 1em;
  box-shadow: 0 3px 0 var(--red-dark); transition: transform .08s, box-shadow .08s; text-decoration: none;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.gold { background: var(--gold); color: #4a3200; box-shadow: 0 3px 0 #d9a21a; }
.btn.green { background: var(--green); box-shadow: 0 3px 0 #217543; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 6px 14px; font-size: .92em; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--blue); padding: 6px; text-decoration: underline; }

/* ---------- forms ---------- */
label.f { display: block; font-weight: 700; margin: 14px 0 6px; }
input.t, select.t {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
}
input.t:focus, select.t:focus { outline: none; border-color: var(--red); }
.err { color: var(--red-dark); font-weight: 600; min-height: 1.5em; margin: 8px 0 0; }

/* ---------- profile picker ---------- */
.center { max-width: 520px; margin: 0 auto; padding: 32px 18px 60px; text-align: center; }
.logo { font: 700 64px/1 var(--han); color: var(--red); margin: 8px 0; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; margin: 22px 0; }
.prof {
  background: #fff; border: 2px solid var(--line); border-radius: 22px; padding: 18px 8px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700;
}
.prof:hover, .prof:focus-visible { border-color: var(--red); }
.prof .av { font-size: 52px; line-height: 1.1; }
.prof .ag { font-size: 12px; color: var(--muted); font-weight: 600; }
.prof.add { border-style: dashed; color: var(--muted); }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button { font-size: 30px; padding: 8px 0; background: #fff; border: 2px solid var(--line); border-radius: 14px; }
.avatars button.on { border-color: var(--red); background: var(--red-soft); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choices button { padding: 12px 6px; border: 2px solid var(--line); background: #fff; border-radius: 14px; font-weight: 700; }
.choices button small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.choices button.on { border-color: var(--red); background: var(--red-soft); }

.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--red); border-color: var(--red); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin: 16px 0; }
.pad button {
  height: 64px; border-radius: 20px; border: 1px solid var(--line); background: #fff; font-size: 26px; font-weight: 700;
  box-shadow: 0 3px 0 var(--line);
}
.pad button:active { transform: translateY(2px); box-shadow: none; }
.pad button.fn { font-size: 18px; color: var(--muted); }

/* ---------- today ---------- */
.week-tag { display: inline-block; background: rgba(255, 255, 255, .22); padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: .85em; }
.check {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; border: 2px solid var(--line);
  background: #fff; width: 100%; text-align: left; margin: 8px 0;
}
.check .box {
  flex: 0 0 30px; height: 30px; border-radius: 10px; border: 2px solid #cfc3b8; display: grid; place-items: center;
  font-size: 18px; color: #fff; transition: all .15s;
}
.check.done { border-color: #b6e3c6; background: var(--green-soft); }
.check.done .box { background: var(--green); border-color: var(--green); }
.check .tx { flex: 1; min-width: 0; }
.check .tx b { display: block; }
.check .tx span { color: var(--muted); font-size: .9em; }
.check .ic { font-size: 26px; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f3ece5; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.chip.Pronunciation { background: var(--blue-soft); color: var(--blue); }
.chip.Grammar { background: #efe6fb; color: #6b3fb5; }
.chip.Practice { background: var(--green-soft); color: var(--green); }
.chip.Vocab { background: #e0f4f4; color: #187575; }
.chip.Characters { background: #ffeedd; color: #b45d0b; }
.chip.Review { background: #eeeeee; color: #666; }
.res-list { list-style: none; padding: 0; margin: 8px 0 0; }
.res-list li { margin: 8px 0; }
.res-list a { font-weight: 700; }
.bar { height: 10px; border-radius: 999px; background: #f0e6dc; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9f1c); border-radius: 999px; transition: width .4s; }
.card.hero .bar { background: rgba(255, 255, 255, .3); }
.card.hero .bar > i { background: var(--gold); }
.big-cta { display: flex; align-items: center; gap: 14px; }
.big-cta .num { font-size: 40px; font-weight: 800; color: var(--red); line-height: 1; }

/* ---------- tabs ---------- */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 4px; background: #f3ece5; border-radius: 16px; margin: 12px 0; scrollbar-width: none; }
.seg button { flex: 1 0 auto; border: 0; background: none; padding: 10px 14px; border-radius: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #fff; color: var(--red); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }

/* ---------- roadmap ---------- */
.wk { border: 1px solid var(--line); border-radius: 16px; background: #fff; margin: 10px 0; overflow: hidden; }
.wk.cur { border: 2px solid var(--red); }
.wk-h { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; background: none; border: 0; text-align: left; }
.wk-n { flex: 0 0 auto; min-width: 54px; text-align: center; font-weight: 800; color: var(--red); }
.wk-n small { display: block; font-weight: 600; color: var(--muted); font-size: 11px; }
.wk-t { flex: 1; min-width: 0; }
.wk-t b { display: block; overflow: hidden; text-overflow: ellipsis; }
.wk-b { padding: 0 14px 14px; border-top: 1px dashed var(--line); }
.done-mark { font-size: 22px; }
.phase { font-size: 12px; font-weight: 700; color: var(--muted); }
.lesson { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f5ede5; }
.lesson:last-child { border-bottom: 0; }
.lesson .no { width: 28px; color: var(--muted); font-size: .85em; text-align: right; }
.lesson .ttl { flex: 1; }
.lesson.done .ttl { color: var(--muted); text-decoration: line-through; }
.tick {
  flex: 0 0 34px; height: 34px; border-radius: 10px; border: 2px solid #cfc3b8; background: #fff; display: grid; place-items: center;
  color: #fff; font-size: 18px;
}
.tick.on { background: var(--green); border-color: var(--green); }
table.lv { width: 100%; border-collapse: collapse; font-size: .92em; }
table.lv th, table.lv td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.lv th { color: var(--muted); font-size: .85em; }
.scroll-x { overflow-x: auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .9em; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- flashcards ---------- */
.flash {
  min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: #fff; border-radius: 26px; border: 2px solid var(--line); box-shadow: var(--shadow); padding: 26px 18px; cursor: pointer;
  user-select: none;
}
.flash .hz { font: 700 clamp(56px, 16vw, 96px)/1.1 var(--han); }
.flash .py { font-size: 1.4em; color: var(--red); font-weight: 700; margin-top: 8px; }
.flash .mn { font-size: 1.25em; font-weight: 700; margin-top: 6px; }
.flash .hv { color: var(--muted); margin-top: 4px; }
.flash .hint { color: var(--muted); margin-top: 16px; font-size: .9em; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.grades button {
  border: 0; border-radius: 16px; padding: 10px 4px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.grades button .e { font-size: 28px; }
.grades button small { font-weight: 500; opacity: .8; font-size: 11px; }
.g0 { background: #fde2e1; color: #9b1c1c; }
.g1 { background: #ffedd5; color: #9a3412; }
.g2 { background: var(--green-soft); color: #166534; }
.g3 { background: var(--blue-soft); color: #1e40af; }
.speak { border: 0; background: var(--gold-soft); border-radius: 999px; width: 52px; height: 52px; font-size: 24px; }
.cardlist { list-style: none; padding: 0; margin: 0; }
.cardlist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cardlist .hz { font: 700 26px var(--han); min-width: 64px; }
.cardlist .info { flex: 1; min-width: 0; }
.cardlist .info b { color: var(--red); }

/* ---------- pronunciation ---------- */
.tone-q { text-align: center; }
.play-big {
  width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 48px;
  box-shadow: 0 6px 0 var(--red-dark); margin: 10px auto 14px; display: grid; place-items: center;
}
.play-big:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--red-dark); }
.tones { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tones button { padding: 14px 4px; border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 1.3em; }
.tones button small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.tones button.right { background: var(--green-soft); border-color: var(--green); }
.tones button.wrong { background: #fde2e1; border-color: #f19a96; }
.sounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.sound { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px; text-align: left; }
.sound:active { border-color: var(--red); }
.sound .k { font-weight: 800; color: var(--red); font-size: 1.2em; }
.sound .hz { font: 700 28px var(--han); float: right; }
.sound .d { display: block; color: var(--muted); font-size: .82em; margin-top: 4px; clear: both; }

/* ---------- me ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.7em; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .85em; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.badge { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 6px; text-align: center; }
.badge .e { font-size: 36px; display: block; }
.badge b { display: block; font-size: .85em; line-height: 1.25; }
.badge span { display: block; font-size: .72em; color: var(--muted); margin-top: 2px; }
.badge.off { opacity: .45; filter: grayscale(1); }
.heat { display: grid; grid-template-rows: repeat(7, 14px); grid-auto-flow: column; grid-auto-columns: 14px; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { border-radius: 3px; background: #f0e6dc; }
.heat i.l1 { background: #ffe0a3; } .heat i.l2 { background: #ffbf5b; } .heat i.l3 { background: #f08a24; } .heat i.l4 { background: var(--red); }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: pop .25s ease-out; }
.toast.gold { background: var(--gold); color: #4a3200; }
.toast.badge-t { background: linear-gradient(135deg, #7c3aed, #db2777); }
@keyframes pop { from { transform: translateY(-10px) scale(.9); opacity: 0; } }
.burst { position: fixed; z-index: 99; pointer-events: none; font-size: 26px; animation: fly 1.1s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

.notice { background: var(--gold-soft); border: 1px solid #ffe39a; padding: 12px 14px; border-radius: 14px; font-size: .92em; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .e { font-size: 56px; display: block; }

@media (min-width: 760px) {
  .nav { left: 50%; right: auto; bottom: 16px; transform: translateX(-50%); width: 600px; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 10px 30px rgba(42, 35, 33, .12); padding-bottom: 0; }
  .nav button { flex-direction: row; justify-content: center; gap: 6px; font-size: 14px; padding: 12px 6px; }
  .nav button .ic { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
