/* 汉语 Trainer – mobile first. Blue palette, light + dark, system fonts, 44 px touch targets, grouped lists. */
:root {
  color-scheme: light;
  --bg: #f1f4f9; --card: #ffffff; --raised: #f5f8fc; --ink: #0c1a2e; --mut: #5e6b80; --line: #dfe5ee; --fill: #e9eef6;
  --tint: #0a66e0; --tint-ink: #ffffff; --soft: #e3eeff; --deep: #0a3d91; --sky: #34a5f5; --navy: #082554;
  --ok: #17803d; --ok-bg: #dff5e6; --tone: #a15c00; --tone-bg: #fff0cf; --bad: #c22b24; --bad-bg: #fde5e3;
  --s-mastered: #0a3d91; --s-known: #2f86f6; --s-learning: #9cc8ff; --s-new: #dfe5ee;
  --shadow: 0 1px 2px rgba(12, 26, 46, .05), 0 6px 20px rgba(12, 26, 46, .06);
  --zh: "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "Heiti SC", sans-serif;
  --r: 16px; --pad: 16px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050b15; --card: #111a28; --raised: #18233450; --ink: #eef3fb; --mut: #93a1b8; --line: #223049; --fill: #1a2638;
  --tint: #4b9dff; --tint-ink: #04152e; --soft: #12305c; --deep: #9cc8ff; --sky: #6bbcff; --navy: #0a2a5e;
  --ok: #56d283; --ok-bg: #0f3320; --tone: #ffc35a; --tone-bg: #3a2b08; --bad: #ff7f76; --bad-bg: #40181a;
  --s-mastered: #4b9dff; --s-known: #2c6fd0; --s-learning: #1f4480; --s-new: #223049;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #050b15; --card: #111a28; --raised: #18233450; --ink: #eef3fb; --mut: #93a1b8; --line: #223049; --fill: #1a2638;
    --tint: #4b9dff; --tint-ink: #04152e; --soft: #12305c; --deep: #9cc8ff; --sky: #6bbcff; --navy: #0a2a5e;
    --ok: #56d283; --ok-bg: #0f3320; --tone: #ffc35a; --tone-bg: #3a2b08; --bad: #ff7f76; --bad-bg: #40181a;
    --s-mastered: #4b9dff; --s-known: #2c6fd0; --s-learning: #1f4480; --s-new: #223049;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
#app { max-width: 720px; margin: 0 auto; padding: 0 var(--pad); padding-top: env(safe-area-inset-top); }
.page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
h1, h2, p { margin: 0; }
.zh { font-family: var(--zh); } .py { color: var(--tint); font-size: 1.08rem; } .en { color: var(--ink); }
.big { font-size: 1.6rem; line-height: 1.45; } .huge { font-size: 3.4rem; line-height: 1.25; text-align: center; margin: 8px 0 14px; font-weight: 500; }
.py.huge { font-size: 2.3rem; } .pre { white-space: pre-line; } .muted { color: var(--mut); } .small { font-size: .87rem; } .center { text-align: center; } .grow { flex: 1; min-width: 0; } .thin { font-weight: 300; }
.loading { text-align: center; color: var(--mut); margin-top: 40vh; }
.ico { display: inline-flex; } .ico svg { display: block; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 10px; }

/* large title */
.large { padding: 22px 4px 14px; } .large h1 { font-size: 2.1rem; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; } .large p { margin-top: 4px; font-size: .95rem; }

/* buttons */
.btn { font: inherit; font-weight: 600; border: 0; background: var(--fill); color: var(--tint); border-radius: 14px; padding: 12px 18px; min-height: 48px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); opacity: .85; }
.btn.filled { background: var(--tint); color: var(--tint-ink); } .btn.tinted { background: var(--soft); color: var(--tint); } .btn.plain { background: transparent; color: var(--tint); font-weight: 500; }
.btn.wide { width: 100%; } .btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; } .btn.icon { min-width: 44px; min-height: 44px; padding: 8px; border-radius: 50%; }
.btn.onhero { background: #fff; color: #0a4fb8; margin-top: 16px; } .btn:disabled { opacity: .45; cursor: default; }

/* inputs */
.inp { font: inherit; width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); min-height: 50px; }
.inp:focus { outline: none; border-color: var(--tint); box-shadow: 0 0 0 4px var(--soft); } .inp::placeholder { color: var(--mut); opacity: .8; } textarea.inp { resize: vertical; }
.fld { display: block; margin-top: 14px; } .fld > span { display: block; font-size: .82rem; color: var(--mut); margin: 0 4px 6px; font-weight: 500; }
.err { color: var(--bad); min-height: 1.3em; font-size: .92rem; margin: 6px 4px; }
.menu { font: inherit; color: var(--tint); background: transparent; border: 0; padding: 8px 4px; max-width: 58%; text-align: right; cursor: pointer; min-height: 44px; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 99px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch:checked { background: var(--tint); } .switch:checked::after { transform: translateX(20px); } .switch:disabled { opacity: .4; }
.segmented { display: flex; background: var(--fill); border-radius: 12px; padding: 3px; gap: 2px; margin: 10px 0; }
.segmented button { flex: 1; font: inherit; font-size: .92rem; font-weight: 500; border: 0; background: transparent; color: var(--ink); padding: 8px 6px; min-height: 38px; border-radius: 9px; cursor: pointer; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, .14); font-weight: 600; color: var(--tint); }

/* grouped lists */
.group { margin: 26px 0 0; } .grouptitle { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); margin: 0 6px 8px; }
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.lrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; min-height: 54px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; text-align: left; }
.list > :last-child { border-bottom: 0; } .lrow.tap { cursor: pointer; } .lrow.tap:active { background: var(--fill); } .lrow.col { flex-direction: column; align-items: stretch; gap: 8px; } .rowline { display: flex; align-items: center; gap: 10px; }
.rtitle { display: block; font-weight: 500; } .rhint { display: block; font-size: .85rem; color: var(--mut); margin-top: 1px; } .lrow.danger { color: var(--bad); justify-content: center; font-weight: 600; } .lrow.link { color: var(--tint); font-weight: 600; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; color: var(--tint-ink); } .sel .tick { background: var(--tint); border-color: var(--tint); }
.mini { width: 78px; flex: none; text-align: right; } .mini small { color: var(--mut); font-size: .75rem; } .mini .stack { height: 6px; }
.foot { font-size: .82rem; color: var(--mut); margin: 10px 6px 0; line-height: 1.45; }
details summary { cursor: pointer; list-style: none; color: var(--tint); } details summary::-webkit-details-marker { display: none; }
.stackform { display: grid; gap: 10px; margin: 12px 0; }
.glyph { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--tint), var(--sky)); color: #fff; display: grid; place-items: center; font-family: var(--zh); font-size: 1.25rem; font-weight: 600; flex: none; }

/* pills / chips */
.pillrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 4px 10px; } .pillrow.tight { margin: 0; gap: 6px; justify-content: flex-end; }
.pill { font: inherit; font-size: .9rem; font-weight: 500; padding: 7px 13px; min-height: 36px; border-radius: 99px; border: 0; background: var(--fill); color: var(--ink); cursor: pointer; }
.pill.on { background: var(--tint); color: var(--tint-ink); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--fill); color: var(--mut); }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.tone { background: var(--tone-bg); color: var(--tone); } .chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.core, .chip.kind { background: var(--soft); color: var(--tint); }
.marks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.dots { display: inline-flex; gap: 3px; } .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); } .dots i.on { background: var(--tint); }

/* hero */
.hero { background: linear-gradient(140deg, #0a4fb8 0%, #0a66e0 45%, #34a5f5 100%); color: #fff; border-radius: 22px; padding: 20px; box-shadow: 0 10px 30px rgba(10, 80, 190, .28); }
.herotop { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; } .herobig { font-size: 1.45rem; font-weight: 700; line-height: 1.2; } .herosub { font-size: .88rem; opacity: .88; margin-top: 4px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; display: grid; place-items: center; text-align: center; } .ring svg { position: absolute; inset: 0; }
.ring .rbg { fill: none; stroke: rgba(255, 255, 255, .25); stroke-width: 8; } .ring .rfg { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray .5s; }
.ring b { font-size: 1.2rem; line-height: 1; margin-top: 4px; } .ring small { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; margin-top: -30px; }
.stack { display: flex; height: 10px; background: var(--s-new); border-radius: 99px; overflow: hidden; } .stack i { display: block; height: 100%; transition: width .4s; }
.s-mastered { background: var(--s-mastered); } .s-known { background: var(--s-known); } .s-learning { background: var(--s-learning); } .s-new { background: var(--s-new); }
.hero .stack { background: rgba(255, 255, 255, .22); } .hero .s-mastered { background: #fff; } .hero .s-known { background: rgba(255, 255, 255, .72); } .hero .s-learning { background: rgba(255, 255, 255, .42); } .hero .s-new { background: rgba(255, 255, 255, .22); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; margin-top: 10px; } .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; } .legendwrap { margin: 4px 6px 0; color: var(--mut); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tilecard { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--r); border: 0; background: var(--card); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); min-height: 124px; }
.tilecard:active { transform: scale(.98); } .tname { font-weight: 600; line-height: 1.25; margin-top: 4px; } .tilecard .pbar { margin: auto 0 0; } .tilecard small { font-size: .78rem; }
.pbar { display: block; height: 6px; background: var(--fill); border-radius: 99px; overflow: hidden; margin: 6px 0; } .pfill { display: block; height: 100%; background: var(--tint); width: 0; transition: width .3s; border-radius: 99px; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--card) 82%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; max-width: 150px; font: inherit; font-size: .7rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; min-height: 50px; border: 0; background: transparent; color: var(--mut); cursor: pointer; border-radius: 12px; }
.tabbar button.on { color: var(--tint); }
.in-session .tabbar { display: none; }

/* session */
.sessionbar { display: flex; align-items: center; gap: 8px; padding: 10px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; } .sessiontitle { font-weight: 600; font-size: .95rem; } .count { color: var(--mut); font-size: .88rem; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.stage { padding-bottom: 40px; }
.card { background: var(--card); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); }
.tag { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin-bottom: 6px; } .cardmeta { display: flex; justify-content: space-between; align-items: center; min-height: 18px; }
.prompt { font-size: 1.6rem; font-weight: 600; text-align: center; margin: 18px 0; line-height: 1.3; } .prompt .py { font-weight: 400; margin-top: 6px; } .en.big { font-size: 1.4rem; font-weight: 600; margin: 6px 0; }
.task p.muted { margin: 2px 0 8px; font-size: .95rem; } .introword { padding: 14px 0; } .introword .zh.big { font-size: 3.2rem; line-height: 1.2; } .introword .py { font-size: 1.4rem; margin-top: 6px; } .introword .en { font-size: 1.15rem; margin-top: 2px; }
.actions { display: flex; gap: 10px; margin-top: 18px; } .actions .btn { flex: 1; } .more { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 8px; }
.feedback { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.verdict { display: inline-block; font-weight: 700; padding: 7px 14px; border-radius: 12px; margin-bottom: 12px; background: var(--soft); color: var(--tint); }
.verdict.ok { background: var(--ok-bg); color: var(--ok); } .verdict.tone { background: var(--tone-bg); color: var(--tone); } .verdict.bad { background: var(--bad-bg); color: var(--bad); }
.solution { background: var(--raised); border-radius: 14px; padding: 12px 14px; } .solrow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; } .clickable span { cursor: pointer; }
.anim { width: 120px; height: 120px; border-radius: 12px; margin: 8px 0; background: #fff; border: 1px solid var(--line); }

.opts { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 14px; } .opts.four { grid-template-columns: repeat(2, 1fr); }
.opt { font: inherit; font-size: 1.1rem; font-weight: 500; padding: 14px; min-height: 56px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.opt.zh { font-size: 1.7rem; font-family: var(--zh); } .opt:active, .opt.sel { border-color: var(--tint); background: var(--soft); } .opt.right { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); } .opt.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); } .opt:disabled { cursor: default; }
.answerline { min-height: 68px; border-bottom: 2px solid var(--line); padding: 8px 0; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 1.5rem; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { font: inherit; font-family: var(--zh); font-size: 1.4rem; padding: 8px 16px; min-height: 52px; border-radius: 14px; border: 0; background: var(--fill); color: var(--ink); cursor: pointer; box-shadow: 0 2px 0 var(--line); }
.tile.on { background: var(--soft); color: var(--tint); } .tile:disabled { opacity: .22; }
.tile.letter { font-family: inherit; font-size: inherit; padding: 2px 9px; min-height: 0; margin: 0 1px; box-shadow: none; } .syl sup { font-size: .9rem; color: var(--mut); margin-left: 2px; }
.sentence { font-size: 1.7rem; line-height: 2.7; margin: 10px 0; }
.gap { display: inline-flex; flex-direction: column; align-items: center; vertical-align: bottom; margin: 0 3px; line-height: 1.2; }
.gap small { font-size: .8rem; color: var(--tint); font-family: system-ui, sans-serif; min-height: 1em; }
.gap b { font-weight: 400; min-width: 1.5em; text-align: center; border: 1.5px dashed var(--mut); border-radius: 9px; padding: 0 4px; }
.gap.cur b { border-color: var(--tint); border-style: solid; background: var(--soft); } .gap.ok b { border-color: var(--ok); background: var(--ok-bg); border-style: solid; } .gap.bad b { border-color: var(--bad); background: var(--bad-bg); border-style: solid; }
.passage { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; background: var(--raised); } .passage summary { font-weight: 600; } .passage .zh { font-size: 1.22rem; line-height: 1.9; margin: 8px 0; color: var(--ink); }

.writer, .work { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 10px; } .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wcap { color: var(--tint); min-height: 1.4em; font-size: 1.1rem; }
.wpad { position: relative; background: #fff; border-radius: 16px; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: var(--shadow); }
.wpad .tian { position: absolute; inset: 0; width: 100%; height: 100%; } .tian path { stroke: #b9d3f7; stroke-width: .5; stroke-dasharray: 2 2; fill: none; } .tian rect { stroke: #5b9cf0; stroke-width: 1.2; fill: none; rx: 4; }
.wtarget { position: absolute; inset: 0; } .wtarget svg { touch-action: none; }

.gshow { display: flex; justify-content: center; margin: 10px 0; } .bigtxt { font-size: 3.2rem; font-weight: 800; letter-spacing: -.02em; }
.clock { width: 210px; height: 210px; } .clock .face { fill: var(--card); stroke: var(--deep); stroke-width: 3; } .clock .tick { stroke: var(--mut); stroke-width: 1; } .clock .tick5 { stroke: var(--ink); stroke-width: 2.5; }
.clock .num { fill: var(--ink); font: 600 15px system-ui, sans-serif; text-anchor: middle; dominant-baseline: central; } .clock .hh { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; } .clock .mh { stroke: var(--tint); stroke-width: 4; stroke-linecap: round; } .clock .pin { fill: var(--tint); }
.cal { width: 180px; border-radius: 20px; overflow: hidden; text-align: center; background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); } .calm { background: var(--tint); color: var(--tint-ink); padding: 7px; font-weight: 700; } .cald { font-size: 4rem; font-weight: 800; line-height: 1.2; } .calw { padding-bottom: 10px; color: var(--mut); }

.triple { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0; }
.stat { border-radius: 16px; padding: 14px 8px; text-align: center; font-size: .8rem; background: var(--card); color: var(--mut); box-shadow: var(--shadow); line-height: 1.25; } .stat b { display: block; font-size: 1.7rem; color: var(--tint); line-height: 1.2; }
.stat.ok { background: var(--ok-bg); color: var(--ok); box-shadow: none; } .stat.tone { background: var(--tone-bg); color: var(--tone); box-shadow: none; } .stat.bad { background: var(--bad-bg); color: var(--bad); box-shadow: none; } .stat.ok b, .stat.tone b, .stat.bad b { color: inherit; }
.summary { margin-top: 8vh; } .summary h2 { margin: 6px 0 14px; } .summary .btn { margin-top: 16px; } .bigcheck { width: 76px; height: 76px; border-radius: 50%; background: var(--soft); color: var(--tint); display: grid; place-items: center; margin: 0 auto 8px; }
.word .wz { font-size: 1.35rem; min-width: 3.2em; } .wstat { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; } .wstat small { font-size: .72rem; white-space: nowrap; }

/* sign-in */
.auth { max-width: 400px; margin: 0 auto; padding: 8vh 4px 40px; display: grid; gap: 10px; text-align: center; } .auth h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; } .auth .stackform { text-align: left; }
.logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 6px; display: grid; place-items: center; background: linear-gradient(140deg, #0a4fb8, #34a5f5); color: #fff; font-size: 2.7rem; font-weight: 600; box-shadow: 0 10px 26px rgba(10, 80, 190, .35); }
.authlang { margin-top: 8px; } .authlang .menu { max-width: none; text-align: center; }

/* larger screens: more columns, roomier */
@media (min-width: 600px) { :root { --pad: 24px; } .tiles { grid-template-columns: repeat(3, 1fr); } .opts.four { grid-template-columns: repeat(4, 1fr); } .hero { padding: 26px; } .card { padding: 28px; } .huge { font-size: 4rem; } }
@media (min-width: 900px) {
  #app { max-width: 860px; } .page { padding-bottom: 40px; padding-top: 64px; }
  .tabbar { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding: 6px 16px; } .tabbar button { flex-direction: row; gap: 8px; font-size: .92rem; max-width: 170px; min-height: 44px; } .tabbar button.on { background: var(--soft); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
