:root {
  --bg: #faf7f2; --card: #fff; --ink: #1f1b16; --muted: #7a7166; --line: #e7e0d6;
  --accent: #c62828; --ok: #2e7d32; --ok-bg: #e8f5e9; --bad: #c62828; --bad-bg: #fdecea; --warn-bg: #fff4e0;
  --t1: #e53935; --t2: #ef8a00; --t3: #2e9d3a; --t4: #1e63c6; --t5: #8a8a8a;
  --zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.icon { border: 0; background: none; font-size: 22px; min-width: 44px; min-height: 44px; }
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
#progFill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.py-toggle { min-width: 52px; min-height: 40px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--card);
  font-weight: 600; color: var(--muted); }
.py-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #fff1f0; }
.py-toggle:disabled { opacity: .35; }
.menu { position: absolute; z-index: 6; top: 60px; left: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; min-width: 220px; }
.menu a, .menu button { display: block; padding: 14px 16px; text-decoration: none; color: var(--ink); border: 0;
  background: none; text-align: left; width: 100%; border-bottom: 1px solid var(--line); }
.menu form { margin: 0; }

main { max-width: 560px; margin: 0 auto; padding: 14px 14px 120px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 60px 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 16px; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 10px; background: #f3eee6; font-size: 12px; color: var(--muted); }
.chip.hint { background: var(--warn-bg); color: #9a5b00; }
.ask { color: var(--muted); margin: 0 0 10px; }
.ru-prompt { font-size: 20px; font-weight: 600; margin: 6px 0 14px; }

.zh { font-family: var(--zh); }
.big { font-size: 46px; text-align: center; margin: 16px 0 18px; line-height: 1.9; }
.sent { font-size: 23px; line-height: 2.3; margin: 8px 0 14px; word-break: break-all; }
.w { border-radius: 6px; cursor: pointer; }
.w.hl { background: #fff1c2; box-shadow: 0 0 0 2px #fff1c2; }
.blank { color: var(--accent); letter-spacing: 2px; }
ruby { ruby-position: over; }
rt { font-family: system-ui, sans-serif; font-size: .42em; visibility: hidden; letter-spacing: 0; }
.big rt { font-size: .32em; }
body.py-on rt, .w.rev rt, .show-py rt { visibility: visible; }
body.no-py rt { visibility: hidden !important; }
body.no-py .feedback rt, body.no-py .show-py rt { visibility: visible !important; }
.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--t5); }

.opts { display: grid; gap: 10px; margin-top: 8px; }
.opt { min-height: 54px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card);
  text-align: left; font-size: 17px; }
.opt.zh-opt { text-align: center; font-size: 30px; line-height: 1.9; padding: 4px 10px; }
.opt.zh-opt rt { font-size: .4em; }
.opt:active { transform: scale(.99); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; color: var(--ink); }
.unknown { margin-top: 4px; border: 0; background: none; color: var(--muted); padding: 12px; min-height: 44px; text-decoration: underline; }

.listen-row { display: flex; gap: 10px; justify-content: center; margin: 12px 0 16px; }
.play { min-height: 56px; padding: 0 22px; border-radius: 28px; border: 0; background: var(--accent); color: #fff; font-size: 18px; font-weight: 600; white-space: nowrap; }
.play.secondary { background: #f3eee6; color: var(--ink); font-weight: 500; }

input.zh-in, textarea.zh-in, textarea.ru-in { width: 100%; font-size: 24px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; font-family: var(--zh); }
textarea.ru-in { font-family: inherit; font-size: 18px; }
textarea { resize: vertical; min-height: 84px; }
input.zh-in:focus, textarea:focus { outline: none; border-color: var(--accent); }
.primary { display: block; width: 100%; min-height: 54px; margin-top: 12px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 600; }
.primary:disabled { opacity: .5; }
.ghost { display: block; width: 100%; min-height: 48px; margin-top: 10px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); }

.tones { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 10px 0; }
.tone-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tone-col .ch { font-family: var(--zh); font-size: 40px; line-height: 1.2; }
.tone-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tone-btns button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); font-size: 18px; font-weight: 700; }
.tone-btns button.sel { border-color: var(--ink); background: var(--ink); color: #fff; }
.tone-btns button.exp { box-shadow: 0 0 0 3px var(--ok) inset; }
@media (max-width: 380px) {
  .play { padding: 0 16px; font-size: 17px; }
  .tone-btns { grid-template-columns: repeat(5, 1fr); }
  .tone-btns button { min-width: 40px; font-size: 16px; }
  .big { font-size: 40px; }
}

.feedback { margin-top: 14px; border-radius: 14px; padding: 14px; border: 1.5px solid var(--line); background: var(--card); }
.feedback.ok { border-color: var(--ok); background: var(--ok-bg); }
.feedback.bad { border-color: var(--bad); background: var(--bad-bg); }
.feedback.mid { border-color: #e0a800; background: var(--warn-bg); }
.feedback h3 { margin: 0 0 6px; font-size: 18px; }
.feedback .wcard { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0; }
.feedback .wcard .zh { font-size: 30px; line-height: 1.9; }
.feedback .line { margin: 4px 0; }
.feedback .ex { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(0,0,0,.15); }
.feedback .ex .sent { font-size: 20px; margin: 0; }
.feedback .next { font-size: 13px; color: var(--muted); margin-top: 6px; }
.diff .del { background: #f8c9c4; text-decoration: line-through; }
.diff .ins { background: #c8e6c9; }
.selfgrade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.selfgrade button { min-height: 50px; padding: 0 4px; font-size: 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); }
.next-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(250,247,242,0)); }
.next-bar .primary { max-width: 532px; margin: 0 auto; }

.stage-card { text-align: center; padding: 40px 16px; }
.stage-card h2 { margin: 6px 0 8px; }
.results h2 { margin-top: 0; }
.score { font-size: 48px; font-weight: 700; text-align: center; color: var(--accent); }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-mini { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar-mini div { height: 100%; background: var(--ok); }
.row > .muted:last-child { min-width: 72px; text-align: right; white-space: nowrap; }
.section { margin-top: 18px; }
.section h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.mist { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mist .zh { font-size: 22px; }
.mist .muted { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

.login-body { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.login h1 { margin: 0 0 14px; text-align: center; color: var(--accent); }
.login label { display: block; margin: 10px 0; color: var(--muted); font-size: 14px; }
.login input { display: block; width: 100%; margin-top: 4px; font-size: 18px; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line); }
.err { color: var(--bad); text-align: center; }
.voice-warn { font-size: 13px; color: #9a5b00; background: var(--warn-bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; }
.listen-row { flex-wrap: wrap; }
.recorder { margin-top: 14px; text-align: center; }
.rec-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.rec { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 34px; line-height: 1;
  box-shadow: 0 4px 14px rgba(198,40,40,.35); }
.rec.on { background: var(--ink); animation: pulse 1.2s infinite; }
.rec:disabled { opacity: .5; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(198,40,40,.15); } }
.level { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 14px auto 6px; max-width: 240px; }
.level span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.rec-status { min-height: 22px; font-size: 14px; }
.recorder .unknown { display: block; margin: 4px auto 0; }
.contour-wrap { margin: 6px 0 8px; }
.contour { width: 100%; height: auto; display: block; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.contour .guide { stroke: #ece6dc; stroke-width: 1; }
.contour .guide.mid { stroke-dasharray: 4 4; }
.contour .band.ok { fill: rgba(46,125,50,.08); } .contour .band.bad { fill: rgba(198,40,40,.10); } .contour .band.unsure { fill: rgba(224,168,0,.08); }
.contour .target { fill: none; stroke: #b9b0a3; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.contour .voice { fill: none; stroke: #1e63c6; stroke-width: 2.5; stroke-linejoin: round; }
.contour .lab { font: 14px var(--zh); text-anchor: middle; fill: var(--ink); }
.legend { font-size: 12px; margin-top: 4px; }
.lg { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.lg.target { background: #b9b0a3; height: 6px; } .lg.voice { background: #1e63c6; margin-left: 8px; }

.rtitle { margin: 4px 0 12px; font-size: 22px; }
.rtitle.zh { font-size: 26px; }
.ru-text { font-size: 18px; line-height: 1.6; margin: 0 0 10px; }
.reader { margin: 6px 0 4px; }
.rline { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; border-bottom: 1px dashed var(--line); border-radius: 8px; }
.rline.cur { background: #fff6d6; }
.rline .sent { margin: 0; font-size: 22px; line-height: 2.2; }
.rtext { flex: 1; min-width: 0; }
.lplay { flex: none; width: 40px; height: 40px; margin-top: 10px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); color: var(--accent); font-size: 14px; }
.ru-line { display: none; font-size: 15px; margin: -4px 0 6px; }
.reader.show-ru .ru-line { display: block; }
.play[aria-pressed="true"] { background: var(--ink); color: #fff; }
.gloss { position: fixed; left: 8px; right: 8px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 7; max-width: 544px; margin: 0 auto;
  background: var(--card); border: 1.5px solid var(--accent); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.gl-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gl-hz { font-size: 28px; }
.gl-py { font-size: 17px; color: var(--accent); }
.gl-ru { grid-column: 1; font-size: 16px; }
.gl-btns { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.gl-btns .play { min-height: 44px; min-width: 44px; padding: 0 12px; font-size: 16px; }
.yt { position: relative; padding-top: 56.25%; background: #000; border-radius: 12px; overflow: hidden; }
.yt iframe, .yt > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-status { text-align: center; font-size: 14px; min-height: 20px; margin-top: 6px; }
.opt.zh-sent { font-family: var(--zh); font-size: 20px; line-height: 2.1; padding: 6px 14px; }
.note { background: var(--warn-bg); color: #6b4300; border-radius: 12px; padding: 10px 12px; margin: 6px 0 10px; font-size: 15px; }
.units { display: grid; gap: 10px; margin-top: 10px; }
.unit, .cand { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; text-decoration: none; color: inherit; background: var(--card); }
.unit.done { border-color: var(--ok); }
.u-body { flex: 1; min-width: 0; }
.u-title { font-weight: 600; font-size: 17px; }
.u-sub { font-size: 13px; margin-top: 2px; }
.u-zh { font-size: 20px; color: var(--muted); margin-top: -4px; }
.thumb { flex: none; width: 112px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--line); }
.results > .thumb { width: 100%; margin: 8px 0 4px; }
.back { display: inline-block; color: var(--muted); text-decoration: none; padding: 6px 0 10px; min-height: 32px; }
.step { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px; margin-top: 8px; min-height: 56px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); }
.step.open { border-color: var(--accent); }
.step.passed { border-color: var(--ok); background: var(--ok-bg); }
.step.locked { opacity: .55; cursor: default; }
.st-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: #f3eee6; }
.step.open .st-ico { background: var(--accent); color: #fff; font-size: 13px; }
.step.passed .st-ico { background: var(--ok); color: #fff; }
.st-body { display: flex; flex-direction: column; }
.st-label { font-weight: 600; }
.st-sub { font-size: 13px; }
.score.fail { color: #b06d00; }
.link-btn { text-align: center; line-height: 44px; text-decoration: none; color: inherit; }
.src { font-size: 12px; margin-top: 14px; }
.cand { align-items: flex-start; margin-top: 8px; }
.cand .thumb { width: 120px; }
.cand-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ghost.small { width: auto; min-height: 40px; margin-top: 0; padding: 0 14px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
@media (max-width: 380px) {
  .thumb, .cand .thumb { width: 84px; }
  .rline .sent { font-size: 20px; }
}
.mk { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.mk.fixed { opacity: .65; }
.mk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.mk-q { font-size: 20px; overflow-wrap: anywhere; }
.mk-q .zh { font-size: 24px; line-height: 1.9; }
.mk-ans { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 4px 8px; border-radius: 8px; }
.mk-ans.ok { background: var(--ok-bg); }
.mk-ans.bad { background: var(--bad-bg); }
.mk-lbl { font-size: 13px; color: var(--muted); min-width: 86px; }
.mk-ans .wcard { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mk-ans .wcard .zh { font-size: 22px; line-height: 1.9; }
.zh-mix { overflow-wrap: anywhere; }
.mk .line { font-size: 14px; }
a.lrow { color: inherit; text-decoration: none; }
a.lrow.open .muted:last-child { color: var(--accent); font-weight: 600; }
a.lrow > .muted:last-child { white-space: normal; }
