:root {
  --red: #c1272d; --red-dark: #9c1d22; --gold: #f4c430; --ink: #1f2430; --muted: #6b7280;
  --bg: #fff8f0; --card: #ffffff; --line: #efe4d6; --soft: #fbf1e6;
  --ok: #1e8e3e; --ok-bg: #e7f6ec; --bad: #d93025; --bad-bg: #fdecea; --blue: #1d4ed8;
  --t1: #d32f2f; --t2: #2e7d32; --t3: #1565c0; --t4: #6a1b9a; --t5: #757575;
  --radius: 16px; --shadow: 0 2px 10px rgba(60, 30, 10, .07);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --zh: 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Noto Sans CJK SC', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #f1efe9; --muted: #a3a8b3; --bg: #15171c; --card: #1f2229; --line: #2c303a; --soft: #262a33; --ok-bg: #16351f; --bad-bg: #3d1a17; --shadow: 0 2px 10px rgba(0,0,0,.35); --gold: #f6cd4c; --red: #e8555b; --red-dark: #c1272d; --blue: #7aa2ff; --ok: #4cc26a; --bad: #ff6b60; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--red); text-decoration: none; }
h1, h2, h3 { margin: .2em 0 .4em; line-height: 1.2; }
h1 { font-size: 1.5rem; font-weight: 800; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .4em 0; }
ul { padding-left: 1.2em; margin: .4em 0; }
small, .small { font-size: .85rem; } .muted { color: var(--muted); } .center { text-align: center; } .r { text-align: right; }
.zh { font-family: var(--zh); }
.tap { cursor: pointer; }
.ok-text { color: var(--ok); } .bad-text { color: var(--bad); }
[hidden] { display: none !important; }

#app { max-width: 720px; margin: 0 auto; padding: 0 12px calc(84px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; background: var(--bg); }
.brand { font-weight: 800; color: var(--ink); font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 600; color: var(--muted); font-size: .75rem; }
.brand-zh { font-family: var(--zh); background: var(--red); color: #fff; border-radius: 10px; width: 34px; height: 34px; display: inline-grid; place-items: center; font-size: 1.2rem; }
.top-right { display: flex; align-items: center; gap: 8px; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.25rem; color: var(--muted); min-width: 56px; padding: 2px 6px; border-radius: 10px; }
.nav a span { font-size: .68rem; font-weight: 700; }
.nav a.active { color: var(--red); background: var(--soft); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 12px 0; border: 1px solid var(--line); }
.card.cta { display: flex; align-items: center; gap: 14px; color: var(--ink); border: 2px solid var(--red); }
.card.cta .arrow { margin-left: auto; font-size: 2rem; color: var(--red); }
.card.action { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; color: var(--ink); margin: 0; }
.card.action span { font-size: 1.6rem; } .card.action small { color: var(--muted); }
.card.action.disabled { opacity: .5; pointer-events: none; }
.card.tip { background: var(--soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.row { display: flex; align-items: center; gap: 8px; margin: 8px 0; } .row.wrap { flex-wrap: wrap; } .row.center { justify-content: center; } .row.between { justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; } .chips.center { justify-content: center; }
.pill { display: inline-block; background: var(--soft); border-radius: 999px; padding: 3px 10px; font-size: .85rem; font-weight: 700; }
.badge { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.lock { background: transparent; }
.emoji { font-size: 1.8rem; line-height: 1; } .emoji.big { font-size: 2.6rem; }
.bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; background: var(--red); border-radius: 999px; transition: width .4s; }
.bar.gold > div { background: var(--gold); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; transition: transform .05s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.big { font-size: 1.1rem; padding: 14px 22px; }
.btn.speak { font-family: var(--zh); }
.btn:disabled { opacity: .55; cursor: default; }
.ico { font: inherit; border: none; background: var(--soft); border-radius: 10px; width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1.05rem; color: var(--ink); }
.ico.mic:disabled { opacity: .5; }
.inp, .sel { font: inherit; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); min-width: 0; }
.inp { flex: 1; width: 100%; } .inp.ok { border-color: var(--ok); } .inp.bad { border-color: var(--bad); }
.sel.wide { width: 100%; }
label { display: block; margin: 10px 0; font-weight: 600; }
label > .inp, label > .sel, label > input[type=range] { display: block; width: 100%; margin-top: 4px; }
.switch { display: flex; align-items: center; gap: 8px; }
.switch input { width: 20px; height: 20px; }
details summary { cursor: pointer; font-weight: 700; }

/* início */
.hero { text-align: center; background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; border: none; }
.hero .muted { color: rgba(255,255,255,.85); } .hero h1 { color: #fff; }
.hero-zh { font-family: var(--zh); font-size: 2.2rem; font-weight: 700; cursor: pointer; }
.hero-zh small { font-size: 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat .n { font-weight: 800; font-size: 1.1rem; } .stat .l { font-size: .68rem; color: var(--muted); }
.word-day .wd { display: flex; align-items: center; gap: 14px; }
.week { display: flex; gap: 6px; align-items: flex-end; height: 110px; }
.day { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.wcol-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; background: var(--soft); border-radius: 8px; overflow: hidden; }
.wcol { width: 100%; background: var(--red); min-height: 3px; border-radius: 8px 8px 0 0; opacity: .8; }
.wcol.hit { background: var(--ok); }
.day .lbl { font-size: .7rem; color: var(--muted); margin-top: 4px; text-align: center; }

/* aulas */
.page-head { margin: 8px 0; } .back { display: inline-block; font-weight: 700; margin-bottom: 4px; }
.module h2 { margin-top: 18px; }
.lesson-card { display: flex; align-items: center; gap: 12px; color: var(--ink); margin: 8px 0; }
.lesson-card .lc-body { flex: 1; min-width: 0; } .lesson-card.locked { opacity: .55; }
.lesson-head h1 { font-size: 1.3rem; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 8px -12px; padding: 4px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 12px; font-size: 1.1rem; color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.tabs a span { font-size: .7rem; font-weight: 700; }
.tabs a.active { background: var(--card); color: var(--red); border-color: var(--line); box-shadow: var(--shadow); }
.objectives { margin: 4px 0 0; }
.vocab-list { display: flex; flex-direction: column; gap: 8px; }
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; transition: box-shadow .2s; }
.vcard.hl { box-shadow: 0 0 0 3px var(--gold); }
.v-main { display: flex; align-items: center; gap: 12px; }
.v-hanzi { font-family: var(--zh); font-size: 2rem; font-weight: 500; background: var(--soft); border: none; border-radius: 12px; padding: 4px 12px; cursor: pointer; color: var(--ink); min-width: 62px; }
.v-info { flex: 1; min-width: 0; }
.v-py { color: var(--red); font-weight: 700; } .v-pt { font-weight: 600; }
.pos { font-size: .7rem; color: var(--muted); font-weight: 600; border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; margin-left: 4px; }
.v-actions { display: flex; gap: 6px; }
.v-ex { margin-top: 8px; padding: 8px 10px; background: var(--soft); border-radius: 10px; font-size: .95rem; }
.v-ex .zh { font-size: 1.1rem; }
.v-tip { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.no-py .v-py { visibility: hidden; } .no-pt .v-pt, .no-pt .v-tip { visibility: hidden; }
.mic-result { margin-top: 4px; font-size: .9rem; }
.mic-result .fb { display: inline-block; padding: 6px 10px; margin: 4px 0 0; }
.gram p { white-space: normal; }
.examples { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ex { padding: 8px 10px; background: var(--soft); border-radius: 10px; } .ex .zh { font-size: 1.15rem; }
.culture { background: var(--soft); }
.dialogue { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.line { display: flex; flex-direction: column; max-width: 88%; }
.line.b { align-self: flex-end; align-items: flex-end; }
.line .who { font-size: .75rem; color: var(--muted); font-weight: 700; margin: 0 6px 2px; font-family: var(--zh); }
.bubble { background: var(--soft); border-radius: 16px; padding: 10px 14px; cursor: pointer; border: 2px solid transparent; }
.line.b .bubble { background: var(--red); color: #fff; }
.line.b .bubble .py, .line.b .bubble .pt { color: rgba(255,255,255,.85); }
.line.hl .bubble { border-color: var(--gold); }
.bubble .zh { font-size: 1.25rem; } .bubble .py { color: var(--red); font-size: .9rem; font-weight: 700; } .bubble .pt { font-size: .9rem; color: var(--muted); }
.listen-mode .bubble:not(.reveal) .zh, .listen-mode .bubble:not(.reveal) .py, .listen-mode .bubble:not(.reveal) .pt { filter: blur(7px); user-select: none; }

/* quiz */
.quiz { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-progress { flex: 1; height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.q-progress > div { height: 100%; background: var(--ok); transition: width .3s; }
.q-count, .q-timer { font-size: .85rem; font-weight: 700; color: var(--muted); }
.q-timer { color: var(--red); }
.q-q { font-size: 1.15rem; font-weight: 700; margin: 6px 0 12px; }
.big-zh { font-family: var(--zh); font-size: 2rem; text-align: center; margin: 8px 0; }
.blank { display: inline-block; min-width: 2.2em; border-bottom: 3px solid var(--red); text-align: center; color: var(--red); }
.blank.ok { color: var(--ok); border-color: var(--ok); } .blank.bad { color: var(--bad); border-color: var(--bad); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.opt { font: inherit; font-weight: 700; padding: 14px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-size: 1rem; min-height: 54px; }
.opt.zh { font-family: var(--zh); font-size: 1.35rem; font-weight: 500; }
.opt:not(:disabled):hover { border-color: var(--red); }
.opt.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); } .opt.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.opts.tones { grid-template-columns: 1fr 1fr 1fr; }
.opts.tones .opt:nth-child(5) { grid-column: span 3; }
.opt.tone-1 { border-color: var(--t1); } .opt.tone-2 { border-color: var(--t2); } .opt.tone-3 { border-color: var(--t3); } .opt.tone-4 { border-color: var(--t4); } .opt.tone-5 { border-color: var(--t5); }
.answer-bar { min-height: 56px; border: 2px dashed var(--line); border-radius: 12px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; font-size: 1.2rem; }
.answer-bar.ok { border-color: var(--ok); background: var(--ok-bg); } .answer-bar.bad { border-color: var(--bad); background: var(--bad-bg); }
.chip { font: inherit; font-weight: 700; padding: 8px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip.zh { font-family: var(--zh); font-size: 1.15rem; font-weight: 500; }
.chip.used { opacity: .25; pointer-events: none; } .chip.picked { background: var(--soft); }
.chip.disabled { opacity: .5; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 8px; background: none; min-height: 0; }
.mbtn { font: inherit; font-weight: 600; padding: 12px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.mbtn.zh { font-family: var(--zh); font-size: 1.3rem; font-weight: 500; }
.mbtn.sel { border-color: var(--blue); background: var(--soft); }
.mbtn.ok { background: var(--ok-bg); border-color: var(--ok); opacity: .7; } .mbtn.bad { background: var(--bad-bg); border-color: var(--bad); }
.fb { padding: 10px 12px; border-radius: 12px; margin: 10px 0; }
.fb.ok { background: var(--ok-bg); color: var(--ok); } .fb.bad { background: var(--bad-bg); color: var(--bad); }
.fb .explain, .fb .reveal { color: var(--ink); margin-top: 4px; font-weight: 500; }
.fb .zh { font-size: 1.15rem; }
.q-foot .next { width: 100%; }
.result .score { text-align: center; padding: 20px; border-radius: var(--radius); margin: 10px 0; background: var(--soft); }
.result .score.good { background: var(--ok-bg); color: var(--ok); } .result .score.meh { background: var(--bad-bg); color: var(--bad); }
.result .score .big { font-size: 3rem; font-weight: 800; line-height: 1; }
.wrong-list li { margin: 6px 0; }

/* flashcards */
.flashcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px 16px; text-align: center; box-shadow: var(--shadow); min-height: 300px; display: flex; flex-direction: column; justify-content: center; position: relative; }
.flashcard.new::before { content: 'novo'; position: absolute; top: 10px; right: 12px; background: var(--gold); color: #3b2a00; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.fc-tag { position: absolute; top: 10px; left: 12px; font-size: .7rem; color: var(--muted); font-weight: 700; }
.fc-hanzi { font-family: var(--zh); font-size: 3.2rem; margin: 10px 0; }
.fc-hanzi small { font-size: 1rem; }
.fc-py { color: var(--red); font-weight: 800; font-size: 1.3rem; } .fc-pt { font-weight: 700; font-size: 1.3rem; margin: 4px 0; }
.fc-back .v-ex { text-align: left; }
.fc-actions { margin-top: 16px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.grade { flex-direction: column; gap: 0; padding: 10px 4px; }
.grade small { font-weight: 600; color: var(--muted); font-size: .7rem; }
.grade.g1 { border-color: var(--bad); color: var(--bad); } .grade.g3 { border-color: #e69500; color: #b36b00; } .grade.g4 { border-color: var(--ok); color: var(--ok); } .grade.g5 { border-color: var(--blue); color: var(--blue); }

/* treinos */
.tone-chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.tc svg { width: 100%; height: 60px; } .tc { font-weight: 700; }
.tc.tone-1 { color: var(--t1); } .tc.tone-2 { color: var(--t2); } .tc.tone-3 { color: var(--t3); } .tc.tone-4 { color: var(--t4); }
.writer { display: flex; justify-content: center; margin: 12px auto; min-height: 120px; }
.writer svg { border: 1px dashed var(--line); border-radius: 12px; background: var(--card); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pcell { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--ink); cursor: pointer; }
.pcell b { font-size: 1.05rem; color: var(--red); } .pcell .zh { font-size: 1.3rem; } .pcell small { color: var(--muted); } .pcell em { font-size: .72rem; color: var(--muted); }
.vtable, .hist { width: 100%; border-collapse: collapse; }
.vtable td, .hist td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vtable .zh { font-size: 1.25rem; } .vtable tr.dim { opacity: .55; }

#toasts { position: fixed; bottom: 84px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 50; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem; opacity: 0; transform: translateY(10px); transition: all .25s; max-width: 92%; text-align: center; }
.toast.show { opacity: 1; transform: none; }

@media (min-width: 600px) { .stats .stat .l { font-size: .8rem; } .opts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 380px) { .stats { grid-template-columns: 1fr 1fr; } .grid2 { gap: 8px; } }
