:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --ink: #2a2622;
  --muted: #8a8178;
  --line: #e7e0d6;
  --brand: #b5562f;
  --brand-soft: #f3e6dd;
  --es: #d2402c;
  --zh: #2f8f6b;
  --again: #d2402c;
  --hard: #d98a2b;
  --good: #2f8f6b;
  --easy: #3b7dd8;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(40,30,20,.08), 0 6px 20px rgba(40,30,20,.05);
  --accent: var(--brand);
}
.view.es { --accent: var(--es); }
.view.zh { --accent: var(--zh); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.cjk { font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif; }

#app { max-width: 600px; margin: 0 auto; padding: 16px 16px 64px; }
.view { display: flex; flex-direction: column; gap: 14px; }

/* ---- hero / home ---- */
.hero { text-align: center; padding: 28px 8px 8px; }
.brand { font-size: 34px; font-weight: 800; letter-spacing: -.5px; display: inline-flex; align-items: center; gap: 10px; }
.logo {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  background: var(--brand); color: #fff; border-radius: 12px; font-size: 26px; font-weight: 800;
  transform: rotate(-4deg);
}
.tagline { font-size: 18px; font-weight: 600; margin: 14px 0 6px; }
.sub { color: var(--muted); margin: 0; }

.lang-grid { display: flex; flex-direction: column; gap: 12px; }
.lang-card {
  display: block; text-decoration: none; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  border-left: 5px solid var(--brand); transition: transform .08s ease;
}
.lang-card:active { transform: scale(.99); }
.lang-card.es { border-left-color: var(--es); }
.lang-card.zh { border-left-color: var(--zh); }
.lang-flag { font-size: 26px; font-weight: 700; }
.lang-card.zh .lang-flag { font-family: "PingFang SC","Noto Sans CJK SC",sans-serif; }
.lang-name { font-size: 20px; font-weight: 700; margin-top: 2px; }
.lang-blurb { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.lang-stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.lang-stats b { color: var(--ink); font-size: 16px; }

.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }
.foot a { color: var(--brand); }

/* ---- nav ---- */
.nav, .rev-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav-title { font-weight: 700; font-size: 18px; }
.back {
  text-decoration: none; color: var(--ink); font-size: 22px; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
}

/* ---- stat strip ---- */
.strip { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--muted); }

/* ---- buttons ---- */
.btn {
  display: block; text-align: center; text-decoration: none; cursor: pointer; border: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; font-family: inherit;
  padding: 14px 18px; border-radius: 12px; width: 100%; box-shadow: var(--shadow);
}
.btn:active { transform: scale(.99); }
.btn.big { padding: 18px; font-size: 17px; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost.danger { color: var(--again); }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---- generic card ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.muted { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

/* ---- weeks list ---- */
.weeks h3 { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; margin: 8px 2px; }
.week-row {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.week-row.done { background: linear-gradient(0deg, var(--brand-soft), var(--surface)); }
.wk-num { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
.wk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wk-body b { font-size: 15px; }
.wk-sent { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-badge { font-size: 11px; color: var(--muted); flex: none; }

/* ---- lesson ---- */
.lesson-theme { margin: 4px 2px; font-size: 22px; }
.sentence-card .target { font-size: 24px; font-weight: 700; line-height: 1.4; }
.sentence-card .target.cjk { font-size: 26px; }
.pinyin { color: var(--zh); margin-top: 8px; font-size: 15px; }
.gloss { margin-top: 10px; font-size: 16px; }
.literal { margin-top: 6px; color: var(--muted); font-size: 13px; font-style: italic; }

.gram { padding: 10px 0; border-top: 1px solid var(--line); }
.gram:first-of-type { border-top: none; }
.gram b { color: var(--accent); }
.gram p { margin: 4px 0 0; font-size: 14px; }

.conj { margin-bottom: 14px; }
.conj-head { margin-bottom: 6px; }
.conj-head b { font-size: 17px; }
.conj-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.conj-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.conj-table .pron { color: var(--muted); width: 42%; }
.conj-table .form { font-weight: 600; }
.conj-table .form.cjk, .v-word.cjk { font-size: 17px; }

.vocab-table { width: 100%; border-collapse: collapse; }
.vocab-table tr { border-bottom: 1px solid var(--line); }
.vocab-table tr:last-child { border-bottom: none; }
.vocab-table td { padding: 9px 4px; vertical-align: top; }
.v-word { font-weight: 700; font-size: 16px; white-space: nowrap; }
.v-read { display: block; color: var(--zh); font-weight: 500; font-size: 13px; }
.v-gloss { width: 99%; font-size: 14px; }
.v-pos { color: var(--muted); font-size: 12px; margin-left: 6px; }
.v-rank { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }

/* ---- review ---- */
.rev-head { margin-bottom: 6px; }
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); transition: width .25s ease; }
.rev-count { font-weight: 700; color: var(--muted); min-width: 24px; text-align: right; }

.flash { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 20px; text-align: center; min-height: 220px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.prompt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.q { font-size: 38px; font-weight: 800; line-height: 1.25; }
.q.cjk { font-size: 56px; }
.q.q-sent { font-size: 22px; font-weight: 700; }
.q-sub { color: var(--muted); font-size: 15px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.a { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1.3; }
.a.cjk { font-size: 34px; }
.a-sub { color: var(--muted); margin-top: 6px; font-size: 15px; }

.rate { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.rate-btn { border: none; border-radius: 12px; padding: 14px 4px; color: #fff; font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.rate-btn span { font-size: 11px; font-weight: 500; opacity: .9; }
.rate-btn.again { background: var(--again); }
.rate-btn.hard { background: var(--hard); }
.rate-btn.good { background: var(--good); }
.rate-btn.easy { background: var(--easy); }
.rate-btn:active { transform: scale(.97); }

/* ---- done / stats ---- */
.done-card { text-align: center; }
.big-emoji { font-size: 40px; font-weight: 800; color: var(--accent); }
.done-card h2 { margin: 6px 0; }
.done-card p { color: var(--muted); }
.done-card .btn { margin-top: 12px; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bar { flex: 1; background: var(--bg); border-radius: 4px 4px 0 0; display: flex; align-items: flex-end; height: 100%; }
.bar-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.maturity .mat-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.maturity .mat-row:first-of-type { border-top: none; }

/* ---- about modal ---- */
.modal { position: fixed; inset: 0; background: rgba(30,22,16,.5); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-body { max-width: 520px; }
.how { padding-left: 18px; }
.how li { margin-bottom: 10px; font-size: 14px; }

/* ---- audio (speaker buttons) ---- */
.speak-btn {
  border: none; background: transparent; cursor: pointer; padding: 0 6px;
  font-size: 18px; line-height: 1; opacity: .65; vertical-align: middle;
  filter: grayscale(1);
}
.speak-btn:hover, .speak-btn:active { opacity: 1; filter: none; }
.speak-btn.inline { margin-left: 10px; font-size: .6em; }
.speak-btn.mini { font-size: 15px; padding: 0 4px; margin-left: 6px; }
.v-word { white-space: nowrap; }

/* ---- coverage meter ---- */
.coverage .cov-pct { font-size: 16px; margin-bottom: 10px; }
.coverage .cov-pct b { font-size: 26px; color: var(--accent); }
.cov-bar { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.cov-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s ease; }
.cov-note { color: var(--muted); font-size: 12px; margin-top: 8px; }

@media (min-width: 620px) {
  .lang-grid { flex-direction: row; }
  .lang-card { flex: 1; }
}
