/* Jom Mandarin! — design system */
:root {
  --brand: #EE6A10;
  --brand-deep: #C2540A;
  --brand-tint: #FFF1E6;
  --brand-ink: #B34A00;

  --ink: #1D2140;
  --ink-2: #4A4F72;
  --muted: #696E8D;
  --bg: #F6F6FA;
  --surface: #FFFFFF;
  --line: #E4E5EE;
  --line-2: #D3D5E2;

  --green: #24A353;  --green-deep: #1A7F40; --green-tint: #E4F8EA; --green-ink: #17793B;
  --red: #F0494F;    --red-deep: #C8323A;   --red-tint: #FFE8E8;   --red-ink: #B4232B;
  --blue: #1592D6;   --blue-deep: #0D72A8;  --blue-tint: #E2F4FD;  --blue-ink: #0A6E9F;
  --violet: #8B5CF6; --violet-deep: #6D3FD8; --violet-tint: #F0EAFF; --violet-ink: #5B2FC4;
  --gold: #FFC531;   --gold-deep: #E0A100;   --gold-tint: #FFF7DC;

  --zh: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-sm: 12px; --r: 16px; --r-lg: 22px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.175, 1);
  --shadow-1: 0 1px 2px rgba(29,33,64,.06), 0 4px 14px rgba(29,33,64,.06);
  --shadow-2: 0 2px 4px rgba(29,33,64,.06), 0 14px 40px rgba(29,33,64,.12);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--ui); font-weight: 600; font-size: 17px; line-height: 1.5;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; min-height: 100dvh;
}
::selection { background: #FFD9BC; color: var(--ink); }
img { max-width: 100%; display: block; }
a { color: var(--blue-ink); text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 900; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; text-wrap: pretty; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 10px; }
.zh { font-family: var(--zh); font-weight: 500; letter-spacing: 0.02em; }
.py { font-family: var(--ui); font-weight: 700; color: var(--muted); letter-spacing: 0; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.15em; height: 1.15em; flex: none; }
html { scrollbar-color: var(--line-2) transparent; }

/* ---------- buttons ---------- */
.btn {
  --c: var(--brand); --cd: var(--brand-deep); --tc: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: 0 22px; border: 0; border-radius: var(--r);
  background: var(--c); color: var(--tc); font-weight: 900; letter-spacing: .01em;
  box-shadow: 0 4px 0 var(--cd); cursor: pointer; text-decoration: none; user-select: none; font-size: 19px;
  transition: transform 110ms var(--ease-out), box-shadow 110ms var(--ease-out), background-color 150ms ease, opacity 150ms ease;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--cd); }
.btn:disabled { --c: #E4E5EE; --cd: #CFD1DE; --tc: #A3A7C0; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.green { --c: var(--green); --cd: var(--green-deep); }
.btn.red { --c: var(--red); --cd: var(--red-deep); }
.btn.blue { --c: var(--blue); --cd: var(--blue-deep); }
.btn.ghost { --c: var(--surface); --cd: var(--line-2); --tc: var(--ink-2); border: 2px solid var(--line-2); box-shadow: 0 3px 0 var(--line-2); }
.btn.small { min-height: 42px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn.small.blue { --c: var(--blue-deep); --cd: #0A5A85; }
.btn .sub { font-weight: 700; opacity: .85; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer; transition: background-color 150ms ease, color 150ms ease, transform 110ms var(--ease-out);
}
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: #EEEEF5; color: var(--ink); } }

.audio-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 0;
  background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-deep); cursor: pointer;
  transition: transform 110ms var(--ease-out), box-shadow 110ms var(--ease-out);
}
.audio-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--blue-deep); }
.audio-btn.sm { width: 36px; height: 36px; border-radius: 10px; }
.audio-btn.slow { background: var(--surface); color: var(--blue-ink); box-shadow: 0 3px 0 var(--line-2); border: 2px solid var(--line-2); }
.audio-btn.playing { animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 3px 0 var(--blue-deep), 0 0 0 6px rgba(28,167,236,.22); } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 2px solid var(--line);
}
.topbar-in { max-width: 1180px; margin: 0 auto; height: 64px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 36px; height: 36px; }
.brand b { font-weight: 900; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; }
.brand b span { color: var(--brand); }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.account { display: flex; align-items: center; gap: 10px; }
.points { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--gold-tint); color: #8A5A00; font-weight: 900; font-variant-numeric: tabular-nums; }
.points img { width: 24px; height: 24px; }
.points.bump { animation: bump 420ms var(--ease-out); }
@keyframes bump { 30% { transform: scale(1.14); } }
.acct { position: relative; }
.acct-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--violet); color: #fff; font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: 0 3px 0 var(--violet-deep); transition: transform 110ms var(--ease-out); }
.acct-btn:active { transform: scale(.94); }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(320px, calc(100vw - 24px)); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); padding: 8px; z-index: 40;
  transform-origin: top right; animation: pop 180ms var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.acct-head { padding: 10px 12px 12px; border-bottom: 2px solid var(--line); margin-bottom: 6px; display: grid; gap: 2px; }
.acct-head span { font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 12px; border-radius: 10px; border: 0; background: none; text-align: left; font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer; }
.acct-row > span { display: flex; align-items: center; gap: 10px; }
.acct-row .ico { color: var(--muted); }
.acct-row:hover { background: #F2F2F8; }
.acct-row.danger { color: var(--red-ink); justify-content: flex-start; gap: 10px; }
.acct-row.danger .ico { color: var(--red); }
.acct-row:not(.danger):not(label) { justify-content: flex-start; gap: 10px; }

.switch { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background-color 160ms ease; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 200ms var(--ease-out); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(18px); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 700;
  box-shadow: var(--shadow-2); opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity 260ms ease, transform 320ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; width: 100vw; height: 100vh; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 800; font-size: 15px; color: var(--ink-2); }
.field label small { font-weight: 700; color: var(--muted); }
.input, .select {
  width: 100%; min-height: 54px; padding: 0 16px; font: inherit; font-weight: 700; color: var(--ink);
  background: #F7F7FB; border: 2px solid var(--line); border-radius: 14px; outline: none;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.input::placeholder { color: #676C8A; font-weight: 600; }
.input:focus, .select:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px var(--blue-tint); }
.field.error .input, .field.error .select { border-color: var(--red); background: #FFF8F8; }
.field .err { color: var(--red-ink); font-size: 14px; font-weight: 700; display: none; align-items: center; gap: 6px; }
.field.error .err { display: flex; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237C819F' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 20px; padding-right: 44px; }
.email-wrap { position: relative; }
.email-wrap .suffix { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; font-size: 14px; pointer-events: none; }

/* ---------- sign-in page ---------- */
.auth {
  min-height: 100dvh; display: grid; grid-template-columns: 1fr; place-items: center; padding: 72px 16px 40px;
  background:
    radial-gradient(900px 500px at 110% -10%, #FFE2CC 0%, transparent 60%),
    radial-gradient(700px 500px at -20% 110%, #DDF1FF 0%, transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 460px; background: var(--surface); border: 2px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-2); padding: 28px 24px 24px; }
.auth-hero { text-align: center; margin-bottom: 22px; }
.auth-hero .mascot { width: 92px; height: 92px; margin: -64px auto 6px; filter: drop-shadow(0 10px 14px rgba(217,96,11,.25)); animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.auth-hero h1 { font-size: 34px; }
.auth-hero h1 span { color: var(--brand); }
.auth-hero .zh-hello { font-family: var(--zh); font-weight: 700; font-size: 18px; color: var(--brand-ink); margin-bottom: 2px; letter-spacing: .1em; }
.auth-hero p { color: var(--ink-2); margin-top: 8px; font-size: 16px; }
.auth form { display: grid; gap: 16px; }
.auth .note { font-size: 13px; color: var(--muted); text-align: center; margin-top: 14px; line-height: 1.45; }
.welcome { text-align: center; display: grid; gap: 12px; }
.welcome h2 { font-size: 26px; }
.welcome .who { background: #F7F7FB; border: 2px solid var(--line); border-radius: var(--r); padding: 14px; text-align: left; display: grid; gap: 2px; font-size: 15px; color: var(--ink-2); }
.welcome .who b { color: var(--ink); font-size: 17px; }
.linkish { background: none; border: 0; color: var(--blue-ink); font-weight: 800; cursor: pointer; padding: 10px; border-radius: 10px; }
.linkish:hover { background: var(--blue-tint); }

/* ---------- home ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 28px 16px 64px; }
.hello { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.hello img { width: 64px; height: 64px; flex: none; }
.hello h1 { font-size: clamp(26px, 5vw, 34px); }
.hello p { color: var(--ink-2); margin-top: 2px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); background: var(--red-tint); color: var(--red-ink); font-weight: 700; margin-bottom: 20px; border: 2px solid #FFCFCF; }
.subject-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 14px; flex-wrap: wrap; }
.subject-head h2 { font-size: 22px; }
.subject-head span { color: var(--muted); font-weight: 800; font-size: 14px; }

.continue {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 22px;
  border-radius: 24px; background: #FF8A2B; color: var(--ink); box-shadow: 0 6px 0 var(--brand-deep); position: relative; overflow: hidden;
}
.continue::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.12); }
.continue .art { width: 96px; height: 96px; background: rgba(255,255,255,.35); border-radius: 22px; display: grid; place-items: center; }
.continue .art img { width: 72px; height: 72px; }
.continue .ch { font-weight: 900; font-size: 14px; letter-spacing: .04em; opacity: .9; }
.continue h3 { font-size: clamp(22px, 4vw, 28px); margin: 2px 0 2px; }
.continue h3 .zh { font-weight: 700; }
.continue p { opacity: .92; font-size: 15px; }
.continue .row { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; position: relative; z-index: 1; }
.continue .btn { --c: #fff; --cd: #F3CBA9; --tc: var(--brand-ink); }
.bar { height: 14px; border-radius: 99px; background: rgba(29,33,64,.08); overflow: hidden; position: relative; flex: 1; min-width: 120px; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--green); transition: width 600ms var(--ease-out); }
.bar > i::after { content: ''; position: absolute; left: 8px; right: 8px; top: 3px; height: 3px; border-radius: 99px; background: rgba(255,255,255,.35); }
.continue .bar { background: rgba(29,33,64,.14); max-width: 260px; }
.continue .bar > i { background: #fff; }
.continue .bar > i::after { background: rgba(255,155,80,.35); }
.continue .pct { font-weight: 900; font-variant-numeric: tabular-nums; }

.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.chap {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; padding: 16px;
  background: var(--surface); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 20px; text-decoration: none; color: inherit;
  transition: transform 140ms var(--ease-out), border-color 150ms ease;
}
a.chap:active { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { a.chap:hover { border-color: #FFC9A0; } }
.chap .art { width: 64px; height: 64px; border-radius: 16px; background: var(--brand-tint); display: grid; place-items: center; }
.chap .art img { width: 46px; height: 46px; }
.chap .n { font-size: 13px; font-weight: 900; color: var(--brand-ink); letter-spacing: .04em; }
.chap h3 { font-size: 18px; margin: 1px 0 1px; }
.chap .en { font-size: 14px; color: var(--muted); }
.chap .meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-2); font-weight: 800; font-variant-numeric: tabular-nums; }
.chap .bar { height: 10px; }
.chap.locked { background: #FAFAFD; border-style: dashed; border-bottom-width: 2px; }
.chap.locked .art { background: #EEEFF5; }
.chap.locked .art img { filter: grayscale(1); opacity: .45; }
.chap.locked .n { color: var(--muted); }
.chap.locked h3 { color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 900; padding: 4px 9px; border-radius: 99px; background: #EEEFF5; color: var(--muted); letter-spacing: .02em; }
.tag.done { background: var(--green-tint); color: var(--green-ink); }
.empty { text-align: center; padding: 40px 20px; background: var(--surface); border: 2px dashed var(--line-2); border-radius: 24px; }
.empty img { width: 88px; height: 88px; margin: 0 auto 10px; }
.empty h3 { font-size: 22px; }
.empty p { color: var(--ink-2); margin-top: 6px; }

/* ---------- lesson layout ---------- */
.lesson-top .topbar-in { gap: 10px; }
.lesson-top .progress { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 10px; }
.lesson-top .progress .bar { height: 16px; background: #ECEDF4; }
.lesson-top .progress small { font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.lesson { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 32px; padding: 24px 16px 96px; align-items: start; }
.rail { position: sticky; top: 88px; display: grid; gap: 4px; max-height: calc(100dvh - 110px); overflow: auto; padding: 4px; }
.rail h2 { font-size: 13px; letter-spacing: .06em; color: var(--muted); padding: 4px 10px 8px; font-weight: 900; }
.sec-link {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 14px;
  text-decoration: none; color: var(--ink); border: 2px solid transparent; transition: background-color 150ms ease, border-color 150ms ease;
}
.sec-link:hover { background: #EEEFF6; }
.sec-link .dot { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #ECEDF4; color: var(--muted); font-weight: 900; font-size: 13px; font-variant-numeric: tabular-nums; }
.sec-link .t { min-width: 0; }
.sec-link .t b { display: block; font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-link .t b .zh { font-weight: 700; }
.sec-link .t > span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.sec-link .ok { color: var(--green); }
.sec-link.done .dot { background: var(--green-tint); color: var(--green-ink); }
.sec-link[aria-current="true"] { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.sec-link[aria-current="true"] .dot { background: var(--brand); color: #fff; }

.sec-picker { display: none; }
.content { min-width: 0; max-width: 780px; }
.lesson > main { min-width: 0; }

/* section header */
.sec-head { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 22px; }
.sec-head .art { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: var(--tone-tint, var(--brand-tint)); }
.sec-head .art img { width: 56px; height: 56px; }
.sec-head .k { font-size: 13px; font-weight: 900; letter-spacing: .05em; color: var(--tone-ink, var(--brand-ink)); }
.sec-head h1 { font-size: clamp(26px, 5vw, 36px); }
.sec-head h1 .zh { font-weight: 700; }
.sec-head p { color: var(--ink-2); margin-top: 4px; }
.tone-blue { --tone: var(--blue); --tone-tint: var(--blue-tint); --tone-ink: var(--blue-ink); }
.tone-violet { --tone: var(--violet); --tone-tint: var(--violet-tint); --tone-ink: var(--violet-ink); }
.tone-green { --tone: var(--green); --tone-tint: var(--green-tint); --tone-ink: var(--green-ink); }
.tone-orange { --tone: var(--brand); --tone-tint: var(--brand-tint); --tone-ink: var(--brand-ink); }

.block { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg); padding: 22px; margin-bottom: 18px; }
.block > h2 { font-size: 20px; margin-bottom: 14px; }
.block > h2 img { width: 32px; height: 32px; display: inline-block; vertical-align: -7px; margin-right: 8px; }
.block > h2 small { font-size: 14px; color: var(--muted); font-weight: 800; }
.lead { color: var(--ink-2); margin-bottom: 14px; }
.bi { display: grid; gap: 2px; }
.bi .en { color: var(--muted); font-size: .92em; }

.toggles { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 800; color: var(--ink-2); cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.chip-toggle[aria-pressed="true"] { background: var(--blue-tint); border-color: #A9DDF8; color: var(--blue-ink); }

/* objectives */
.goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: g; }
.goals li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; counter-increment: g; }
.goals li::before { content: counter(g); width: 34px; height: 34px; border-radius: 10px; background: var(--brand-tint); color: var(--brand-ink); display: grid; place-items: center; font-weight: 900; }
.goals .zh { font-weight: 700; color: var(--brand-ink); }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.howto img { width: 36px; height: 36px; flex: none; }
.howto div { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: #F7F7FB; font-size: 15px; }

/* vocabulary cards */
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.vcard {
  position: relative; display: grid; gap: 4px; justify-items: center; text-align: center; padding: 16px 10px 14px;
  border-radius: 18px; border: 2px solid var(--line); border-bottom-width: 4px; background: var(--surface); cursor: pointer;
  transition: transform 120ms var(--ease-out), border-color 150ms ease; user-select: none;
}
.vcard:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) { .vcard:hover { border-color: #A9DDF8; } }
.vcard img { width: 64px; height: 64px; margin-bottom: 4px; }
.vcard .zh { font-size: 26px; font-weight: 700; line-height: 1.25; }
.vcard .py { font-size: 15px; }
.vcard .m { font-size: 13.5px; color: var(--ink-2); line-height: 1.3; }
.vcard .m em { font-style: normal; color: var(--muted); display: block; }
.vcard .pos { position: absolute; top: 8px; left: 10px; font-size: 11px; font-weight: 900; color: var(--muted); }
.vcard .spk { position: absolute; top: 8px; right: 8px; color: var(--blue); }
.vcard.playing { border-color: var(--blue); }

.vlist { display: grid; gap: 8px; }
.vrow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 14px; background: #F8F8FC; }
.vrow .w { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.vrow .zh { font-size: 24px; font-weight: 700; }
.vrow .py { font-size: 15px; }
.vrow .m { font-size: 14.5px; color: var(--ink-2); }
.vrow .m em { font-style: normal; color: var(--muted); }
.vrow .pos { font-size: 12px; font-weight: 900; color: var(--muted); padding: 2px 8px; border-radius: 99px; background: #ECEDF4; }

/* dialogue */
.dialogue { display: grid; gap: 14px; }
.line { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: start; }
.line.r { grid-template-columns: minmax(0, 1fr) 44px; }
.line.r .avatar { order: 2; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--zh); font-weight: 700; font-size: 18px; flex: none; }
.bubble { position: relative; padding: 12px 14px 12px 14px; border-radius: 6px 18px 18px 18px; background: #F3F4F9; border: 2px solid transparent; max-width: 100%; justify-self: start; transition: border-color 150ms ease, background-color 150ms ease; }
.line.r .bubble { border-radius: 18px 6px 18px 18px; justify-self: end; background: var(--brand-tint); }
.bubble .who { font-size: 12.5px; font-weight: 900; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: baseline; }
.bubble .who .zh { font-weight: 700; color: var(--ink-2); }
.bubble .py { display: block; font-size: 14.5px; margin-bottom: 1px; }
.bubble .zh.say { display: block; font-size: 22px; line-height: 1.5; font-weight: 500; color: var(--ink); }
.bubble .tr { display: none; margin-top: 6px; padding-top: 6px; border-top: 2px dashed rgba(29,33,64,.1); font-size: 14.5px; color: var(--ink-2); }
.bubble .tr em { font-style: normal; color: var(--muted); display: block; }
.show-tr .bubble .tr { display: block; }
.hide-py .py { display: none !important; }
.bubble .play { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border-radius: 9px; border: 0; background: rgba(255,255,255,.8); color: var(--blue); display: grid; place-items: center; cursor: pointer; }
.bubble { padding-right: 48px; }
.bubble.speaking { border-color: var(--blue); background: var(--blue-tint); }
.dlg-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }

/* grammar */
.rule { padding: 14px 16px; border-radius: 14px; background: var(--violet-tint); color: #3B2479; margin-bottom: 14px; }
.rule b { color: var(--violet-ink); }
.formula { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; }
.formula span { padding: 6px 12px; border-radius: 10px; background: #fff; border: 2px solid #D9CCFF; font-weight: 800; font-size: 15px; }
.formula span.k { background: var(--violet); border-color: var(--violet); color: #fff; font-family: var(--zh); font-size: 18px; }
.formula i { font-style: normal; color: var(--violet-ink); font-weight: 900; }
.examples { display: grid; gap: 8px; }
.ex { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: #F8F8FC; }
.ex .zh { font-size: 20px; display: block; }
.ex .zh mark { background: none; color: var(--violet-ink); font-weight: 700; box-shadow: inset 0 -0.42em 0 #E6DBFF; border-radius: 2px; }
.ex .py { font-size: 14px; display: block; }
.ex .m { font-size: 14px; color: var(--ink-2); display: block; }
.ex .m em { font-style: normal; color: var(--muted); }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; margin: 6px 0 4px; }
table.grid th { text-align: left; font-size: 12.5px; letter-spacing: .04em; color: var(--muted); font-weight: 900; padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.grid td { padding: 10px; border-bottom: 2px solid #F0F0F6; vertical-align: middle; }
table.grid td .zh { font-size: 19px; }
table.grid td .py { display: block; font-size: 13px; }
.scroll-x { overflow-x: auto; }

.fact { display: grid; grid-template-columns: 72px 1fr; gap: 16px; align-items: start; background: var(--gold-tint); border: 2px solid #FFE7A3; }
.fact img { width: 72px; height: 72px; }
.fact h2 { margin-bottom: 6px; }
.fact p + p { margin-top: 8px; }

/* ---------- activity card ---------- */
.act { border: 2px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin-bottom: 18px; overflow: hidden; scroll-margin-top: 90px; }
.act-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.act-head .badge { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-tint); }
.act-head .badge img { width: 32px; height: 32px; }
.act-head h3 { font-size: 18px; }
.act-head p { font-size: 14px; color: var(--muted); font-weight: 700; }
.act-head .best { font-size: 13px; font-weight: 900; color: var(--green-ink); background: var(--green-tint); padding: 5px 10px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-prog { display: flex; gap: 5px; padding: 0 18px 4px; }
.act-prog i { flex: 1; height: 8px; border-radius: 99px; background: #ECEDF4; transition: background-color 250ms ease; }
.act-prog i.ok { background: var(--green); }
.act-prog i.no { background: var(--red); }
.act-prog i.cur { background: #FFD3B2; }
.act-body { padding: 18px; min-height: 120px; }
.act-body.enter { animation: slideIn 260ms var(--ease-out); }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } }
.q-prompt { margin-bottom: 16px; }
.q-prompt .ask { font-weight: 800; font-size: 15px; color: var(--ink-2); margin-bottom: 8px; }
.q-prompt .ask em { font-style: normal; color: var(--muted); font-weight: 700; }
.q-prompt .big { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.q-prompt .big .zh { font-size: 30px; font-weight: 700; line-height: 1.35; }
.q-prompt .big .py { display: block; font-size: 16px; }
.q-prompt .pic { width: 120px; height: 120px; margin: 4px auto 6px; }
.q-prompt.center { text-align: center; }
.q-prompt.center .big { justify-content: center; }
.q-prompt .blank { display: inline-block; min-width: 3.2em; border-bottom: 3px solid var(--line-2); text-align: center; color: var(--brand-ink); margin: 0 .15em; transition: border-color 150ms ease; }
.q-prompt .blank.filled { border-color: var(--brand); }
.claim { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--gold-tint); border: 2px solid #FFE7A3; display: grid; gap: 2px; text-align: left; }
.claim .claim-k { font-size: 12px; font-weight: 900; letter-spacing: .04em; color: #8A5A00; }
.claim .zh { font-size: 22px; font-weight: 700; }
.claim .py { font-size: 14px; }
.listen-big {width: 96px; height: 96px; border-radius: 26px; margin: 4px auto 10px; }
.listen-big .ico { width: 42px; height: 42px; }
.listen-row { display: flex; gap: 10px; justify-content: center; align-items: center; }

.opts { display: grid; gap: 10px; }
.opts.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts.pics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 58px; padding: 10px 14px;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 16px; background: var(--surface); cursor: pointer;
  transition: transform 110ms var(--ease-out), border-color 140ms ease, background-color 140ms ease;
}
.opt:active:not(:disabled) { transform: scale(.98); }
@media (hover: hover) and (pointer: fine) { .opt:hover:not(:disabled) { background: #F8F8FC; } }
.opt .key { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 900; color: var(--muted); flex: none; }
.opt .zh { font-size: 22px; font-weight: 500; }
.opt .py { display: block; font-size: 13.5px; }
.opt .t { font-size: 16px; font-weight: 700; }
.opt .t em { display: block; font-style: normal; color: var(--muted); font-size: 14px; }
.opts.pics .opt { flex-direction: column; justify-content: center; text-align: center; padding: 14px 8px; gap: 6px; }
.opts.pics .opt img { width: 72px; height: 72px; }
.opts.pics .opt .key { position: absolute; }
.opt[aria-pressed="true"] { border-color: #8ED2F6; background: var(--blue-tint); }
.opt[aria-pressed="true"] .key { border-color: var(--blue); color: var(--blue-ink); }
.opt.right { border-color: #9BE3B3; background: var(--green-tint); }
.opt.right .key { border-color: var(--green); background: var(--green); color: #fff; }
.opt.wrong { border-color: #FFB7B9; background: var(--red-tint); }
.opt.wrong .key { border-color: var(--red); background: var(--red); color: #fff; }
.opt:disabled { cursor: default; }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.mtile {
  display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 68px; padding: 8px 10px; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--surface);
  cursor: pointer; text-align: center; transition: transform 110ms var(--ease-out), border-color 140ms ease, background-color 140ms ease, opacity 260ms ease;
}
.mtile .zh { font-size: 22px; display: block; }
.mtile .py { font-size: 13px; display: block; }
.mtile .t { font-size: 14.5px; font-weight: 700; }
.mtile .t em { display: block; font-style: normal; color: var(--muted); font-size: 13px; }
.mtile:active { transform: scale(.97); }
.mtile.sel { border-color: var(--blue); background: var(--blue-tint); }
.mtile.ok { border-color: #9BE3B3; background: var(--green-tint); cursor: default; animation: okpop 300ms var(--ease-out); }
.mtile.gone { opacity: .35; pointer-events: none; }
.mtile.bad { border-color: var(--red); background: var(--red-tint); animation: shake 320ms ease; }
@keyframes okpop { 40% { transform: scale(1.04); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* sort */
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.bucket { border: 2px dashed var(--line-2); border-radius: 16px; padding: 10px; min-height: 120px; background: #FAFAFD; cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease; display: flex; flex-direction: column; gap: 8px; }
.bucket.armed { border-color: var(--blue); background: var(--blue-tint); }
.bucket h4 { text-align: center; font-size: 15px; }
.bucket h4 .zh { font-size: 26px; display: block; font-weight: 700; color: var(--brand-ink); }
.bucket h4 small { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.bucket .in { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tray { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 12px; border-radius: 16px; background: #F3F4F9; min-height: 64px; }
.tile {
  display: inline-flex; flex-direction: column; align-items: center; padding: 6px 12px; border: 2px solid var(--line); border-bottom-width: 4px;
  border-radius: 12px; background: var(--surface); cursor: pointer; transition: transform 110ms var(--ease-out), border-color 140ms ease, background-color 140ms ease;
}
.tile .zh { font-size: 20px; line-height: 1.3; }
.tile .py { font-size: 12px; }
.tile:active { transform: scale(.95); }
.tile.sel { border-color: var(--blue); background: var(--blue-tint); transform: translateY(-2px); }
.tile.right { border-color: #9BE3B3; background: var(--green-tint); }
.tile.wrong { border-color: #FFB7B9; background: var(--red-tint); }
.tile.ghost { visibility: hidden; }

/* build */
.answer-line { min-height: 72px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 10px 4px 12px; border-bottom: 2px solid var(--line); margin-bottom: 16px; background-image: linear-gradient(to bottom, transparent 66px, var(--line) 66px, var(--line) 68px, transparent 68px); background-size: 100% 70px; }
.answer-line.vertical { flex-direction: column; flex-wrap: nowrap; background: none; border: 2px dashed var(--line-2); border-radius: 16px; padding: 10px; min-height: 100px; }
.tray.vertical { flex-direction: column; align-items: stretch; }
.tile.long { flex-direction: row; justify-content: flex-start; gap: 10px; text-align: left; align-items: center; width: 100%; padding: 10px 12px; }
.tile.long .who { font-family: var(--zh); font-weight: 700; color: var(--brand-ink); font-size: 15px; flex: none; }
.tile.long .zh { font-size: 18px; display: block; }
.tile.long .py { display: block; }
.tray.vertical .tile.ghost { display: none; }

/* footer + feedback */
.act-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px 18px; border-top: 2px solid var(--line); background: #FCFCFE; transition: background-color 200ms ease, border-color 200ms ease; }
.act-foot .fb { flex: 1; display: none; align-items: center; gap: 12px; min-width: 0; }
.act-foot .fb .mark { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #fff; flex: none; }
.act-foot .fb .mark .ico { width: 26px; height: 26px; stroke-width: 3; }
.act-foot .fb b { display: block; font-size: 18px; font-weight: 900; }
.act-foot .fb .msg { display: block; font-size: 14.5px; font-weight: 700; }
.act-foot .fb .msg .zh { font-size: 17px; }
.act-foot.is-right { background: var(--green-tint); border-color: #C3EDD1; }
.act-foot.is-right .fb { display: flex; color: var(--green-ink); }
.act-foot.is-right .fb .mark { color: var(--green); }
.act-foot.is-wrong { background: var(--red-tint); border-color: #FFD0D1; }
.act-foot.is-wrong .fb { display: flex; color: var(--red-ink); }
.act-foot.is-wrong .fb .mark { color: var(--red); }
.act-foot.is-right .fb, .act-foot.is-wrong .fb { animation: fbIn 240ms var(--ease-out); }
@keyframes fbIn { from { opacity: 0; transform: translateY(6px); } }

/* result */
.result { text-align: center; padding: 8px 4px 4px; display: grid; gap: 8px; justify-items: center; }
.result img { width: 96px; height: 96px; }
.result h4 { font-size: 24px; }
.result .score { font-size: 15px; color: var(--ink-2); font-weight: 800; }
.stars { display: flex; gap: 6px; margin: 2px 0 4px; }
.stars img { width: 38px; height: 38px; }
.stars img.off { filter: grayscale(1); opacity: .25; }
.stars img.on { animation: starIn 420ms var(--ease-out) both; }
.stars img.on:nth-child(2) { animation-delay: 110ms; }
.stars img.on:nth-child(3) { animation-delay: 220ms; }
@keyframes starIn { from { opacity: 0; transform: scale(.6) rotate(-20deg); } }
.stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.stat { min-width: 110px; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); font-variant-numeric: tabular-nums; }
.stat b { display: block; font-size: 22px; font-weight: 900; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 800; }
.stat.gold { border-color: #FFE29A; background: var(--gold-tint); }
.stat.gold b { color: #A06A00; }

/* section footer */
.sec-next { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 26px; padding-top: 22px; border-top: 2px solid var(--line); flex-wrap: wrap; }
.sec-next .status { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 800; font-size: 15px; }
.sec-next .status.ok { color: var(--green-ink); }

/* chapter complete banner */
.finish { text-align: center; padding: 28px 22px; border-radius: 24px; background: var(--green-deep); color: #fff; box-shadow: 0 6px 0 #11592C; margin-top: 22px; }
.finish img { width: 96px; height: 96px; margin: 0 auto 6px; }
.finish h2 { font-size: 28px; }
.finish p { opacity: .95; margin-top: 4px; }
.finish .btn { --c: #fff; --cd: #BFE8CD; --tc: var(--green-ink); margin-top: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .lesson { grid-template-columns: 1fr; padding-top: 12px; gap: 0; }
  .rail { display: none; }
  .sec-picker { display: block; position: relative; margin-bottom: 18px; }
  .sec-picker > button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font-weight: 800; min-height: 52px; }
  .sec-picker > button .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sec-picker > button small { color: var(--muted); font-variant-numeric: tabular-nums; }
  .sec-picker .menu { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); padding: 6px; z-index: 25; max-height: 70dvh; overflow: auto; transform-origin: top center; animation: pop 180ms var(--ease-out); }
  .content { max-width: none; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .topbar-in { height: 58px; padding: 0 12px; }
  .brand small { display: none; }
  .brand b { font-size: 17px; }
  .points { padding: 5px 10px 5px 6px; }
  .block, .act-body { padding: 16px; }
  .act-head { padding: 14px 14px 10px; }
  .act-prog { padding: 0 14px 4px; }
  .act-foot { padding: 12px 14px 14px; flex-wrap: wrap; }
  .act-foot .fb { flex-basis: 100%; }
  .act-foot .btn { flex: 1; }
  .continue { grid-template-columns: 1fr; padding: 18px; }
  .continue .art { width: 72px; height: 72px; border-radius: 18px; }
  .continue .art img { width: 52px; height: 52px; }
  .vocab { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .vcard .zh { font-size: 22px; }
  .vrow { grid-template-columns: 40px minmax(0, 1fr); }
  .vrow .pos { display: none; }
  .bubble .zh.say { font-size: 20px; }
  .q-prompt .big .zh { font-size: 26px; }
  .opt .zh { font-size: 20px; }
  .lesson-top .progress small { display: none; }
  .fact { grid-template-columns: 1fr; }
  .fact img { width: 56px; height: 56px; }
  .match { gap: 8px; }
  .mtile .zh { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
