/* Mandarim: rice paper, vermilion ink, tone colors do the talking.
   Light is the default; dark follows the system unless Ajustes pins one
   (data-theme on <html>). Tone colors get their own dark values so hanzi stay
   legible on the dark paper. */
@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --m { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  --bg: #f4ecdf; --card: #fffaf2; --chip: #ece0cc; --line: #e2d3bc; --ink: #2a1f18; --soft: #7b6a58;
  --accent: #b8322a; --accent-deep: #8a2019; --accent-ink: #fff8ef; --accent-soft: #f5dcd2;
  --gold: #c08a22; --ok: #3a7a48; --bad: #b8322a; --warn: #99590f;
  --lip: #d9c7aa; --shadow: 0 1px 0 rgba(90,55,20,.05), 0 10px 24px -14px rgba(90,55,20,.35);
  --t1: #d32f2f; --t2: #2e7d32; --t3: #1565c0; --t4: #7b1fa2; --t5: #7a7a7a;
  --hz: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: ui-serif, "New York", "Iowan Old Style", Georgia, "Songti SC", serif;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --r: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110e; --card: #221b16; --chip: #2e251e; --line: #3b3028; --ink: #f1e6d6; --soft: #a99783;
    --accent: #e0574a; --accent-deep: #9e3027; --accent-ink: #fff8ef; --accent-soft: #3d221d;
    --gold: #e0b252; --ok: #6cc07e; --bad: #f0685b; --warn: #e9a650;
    --lip: #0c0908; --shadow: 0 1px 0 rgba(0,0,0,.35), 0 10px 24px -14px rgba(0,0,0,.8);
    --t1: #ff6b6b; --t2: #5fd07a; --t3: #6aaeff; --t4: #cf8bff; --t5: #a3a3a3;
    color-scheme: dark;
  }
  :root[data-palette="dummitt"]:not([data-theme="light"]) { --t1: #ff6b6b; --t2: #ffa94d; --t3: #5fd07a; --t4: #6aaeff; }
}
:root[data-theme="dark"] {
  --bg: #15110e; --card: #221b16; --chip: #2e251e; --line: #3b3028; --ink: #f1e6d6; --soft: #a99783;
  --accent: #e0574a; --accent-deep: #9e3027; --accent-ink: #fff8ef; --accent-soft: #3d221d;
  --gold: #e0b252; --ok: #6cc07e; --bad: #f0685b; --warn: #e9a650;
  --lip: #0c0908; --shadow: 0 1px 0 rgba(0,0,0,.35), 0 10px 24px -14px rgba(0,0,0,.8);
  --t1: #ff6b6b; --t2: #5fd07a; --t3: #6aaeff; --t4: #cf8bff; --t5: #a3a3a3;
  color-scheme: dark;
}
:root[data-palette="dummitt"] { --t1: #d32f2f; --t2: #ef6c00; --t3: #2e7d32; --t4: #1565c0; --t5: #7a7a7a; }
:root[data-palette="dummitt"][data-theme="dark"] { --t1: #ff6b6b; --t2: #ffa94d; --t3: #5fd07a; --t4: #6aaeff; }
:root[data-palette="off"] { --t1: var(--ink); --t2: var(--ink); --t3: var(--ink); --t4: var(--ink); --t5: var(--ink); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior: none; transition: background-color .3s; }
#main { padding: calc(env(safe-area-inset-top) + 14px) 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
#main > .page { animation: page-in .38s var(--ease) backwards; }
body.in-session #main, body.in-session #tabs { display: none; }
h1 { font: 700 2rem/1.1 var(--display); margin: .2rem 0 .5rem; letter-spacing: -.01em; }
h1.hzs, h1 .hzs { font-family: var(--hz); letter-spacing: 0; }
h1 small, h2 small { font: 500 .95rem var(--ui); color: var(--soft); margin-left: .25rem; }
h2 { font: 700 1.45rem/1.2 var(--display); margin: .4rem 0; }
h3 { font-size: .74rem; font-weight: 750; margin: 1.8rem 0 .6rem; color: var(--soft); text-transform: uppercase; letter-spacing: .12em; }
p { margin: .5rem 0; }
.small { font-size: .87rem; color: var(--soft); line-height: 1.45; }
.lede { font-size: .95rem; color: var(--soft); margin: 0 0 1rem; max-width: 34em; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: .5rem; }
.row.center { justify-content: center; }
.gap { gap: .6rem; }
.wrap { flex-wrap: wrap; }
.warn { color: var(--warn); }
.it { font-style: italic; }
.pad { padding: 1.5rem .5rem; }

/* hanzi */
.hz, .hzs { font-family: var(--hz); }
.hz .ch, .hz .pn { font-family: var(--hz); }
.hz.lg, .hzs.lg, .ch.lg { font-size: 1.6rem; }
.hz.xl, .hzs.xl { font-size: 2.8rem; line-height: 1.2; }
.hz.xxl { font-size: 5rem; line-height: 1.1; }
.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--t5); }
.ch.sd { position: relative; }
.ch.sd::after { content: ""; position: absolute; left: 50%; top: -.12em; width: .16em; height: .16em; margin-left: -.08em; border-radius: 50%; background: currentColor; opacity: .75; }
ruby { ruby-position: over; } rt { font-family: var(--ui); font-size: .42em; letter-spacing: 0; }
.py span { font-weight: 600; }
.strike { text-decoration: line-through; text-decoration-color: var(--bad); opacity: .8; }

/* ---------- buttons: every one has a lip and sinks when pressed ---------- */
button, .btnlike { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, .btnlike:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary, .ghost, .btnlike, .opt, .grade, .tile, .tile-btn, .tbtn, .seg button, .node, .vrow, .cc, .btn-round {
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), background-color .2s, border-color .2s, color .2s;
}
.primary { background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: .9rem 1.2rem; font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; box-shadow: 0 4px 0 var(--accent-deep); margin-bottom: 4px; }
.primary:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-deep); }
.primary:disabled { opacity: 1; background: var(--chip); color: var(--soft); box-shadow: 0 4px 0 var(--lip); }
.ghost, .btnlike { background: var(--chip); border-radius: 12px; padding: .62rem .95rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; box-shadow: 0 3px 0 var(--lip); margin-bottom: 3px; }
.ghost:not(:disabled):active, .btnlike:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.ghost .ic, .btnlike .ic { width: 18px; height: 18px; }
.ghost.small { padding: .36rem .75rem; font-size: .85rem; box-shadow: 0 2px 0 var(--lip); }
.ghost.danger { color: var(--bad); }
.ghost.on { background: var(--accent-soft); color: var(--accent); }
.wide { width: 100%; display: flex; justify-content: center; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; flex: none; }
.icon-btn:active { background: var(--chip); transform: scale(.92); }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* play / pause */
.btn-round { position: relative; width: 46px; height: 46px; border-radius: 50%; background: var(--chip); color: var(--ink); display: inline-grid; place-items: center; flex: none; box-shadow: 0 3px 0 var(--lip); }
.btn-round:active { transform: translateY(2px) scale(.94); box-shadow: 0 1px 0 var(--lip); }
.btn-round.big { width: 64px; height: 64px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-deep); }
.btn-round.big:active { box-shadow: 0 1px 0 var(--accent-deep); }
.btn-round.big .ic { width: 26px; height: 26px; }
.btn-round .ic { fill: currentColor; stroke: none; }
.btn-round .pi { grid-area: 1 / 1; display: grid; place-items: center; transition: transform .22s var(--spring), opacity .15s; }
.btn-round .pi.off { opacity: 0; transform: scale(.4) rotate(-45deg); }
.btn-round.playing .pi.on { opacity: 0; transform: scale(.4) rotate(45deg); }
.btn-round.playing .pi.off { opacity: 1; transform: none; }
.btn-round .sonar { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; opacity: 0; }
.btn-round.playing .sonar { animation: sonar 1.4s var(--ease) infinite; }
.btn-round.playing:not(.big) { background: var(--accent-soft); color: var(--accent); }
@keyframes sonar { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); opacity: 1; } 100% { box-shadow: 0 0 0 16px transparent; opacity: 1; } }
.btn-round.rec .ic { fill: none; stroke: currentColor; }
.btn-round.rec { background: var(--ink); color: var(--bg); box-shadow: 0 4px 0 #000; }
.btn-round.rec.on { background: var(--bad); color: #fff; animation: breathe 1s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); } }

/* ---------- tab bar ---------- */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .7rem; color: var(--soft); padding: 4px 0; }
#tabs button .ic { width: 44px; height: 28px; padding: 3px 11px; border-radius: 99px; transition: background-color .25s, color .25s, transform .3s var(--spring); }
#tabs button:active .ic { transform: scale(.88); }
#tabs button.on { color: var(--accent); }
#tabs button.on .ic { background: var(--accent-soft); }
#tabs button span { font-weight: 650; letter-spacing: .01em; }

/* ---------- home ---------- */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: .8rem; }
.hello .small { font-family: var(--hz); font-size: .95rem; }
.hello h1 { margin-bottom: .2rem; }
.chips { display: flex; gap: .4rem; padding-bottom: .45rem; }
.chip { background: var(--chip); border-radius: 999px; padding: .28rem .7rem; font-weight: 700; font-size: .88rem; display: inline-flex; align-items: center; gap: .2rem; white-space: nowrap; }
.chip.flame { color: var(--accent); } .chip.flame .ic { width: 16px; height: 16px; fill: var(--accent); stroke: var(--accent); }
.chip.flame.cold { color: var(--soft); } .chip.flame.cold .ic { fill: none; stroke: var(--soft); }
.chip.new { background: var(--accent); color: var(--accent-ink); }
.xpline { display: flex; align-items: center; gap: .6rem; margin: .1rem 0 1.1rem; }
.xpline small { font-size: .75rem; color: var(--soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.xpbar { flex: 1; height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; animation: grow 1s var(--ease) backwards .15s; }
@keyframes grow { from { width: 0; } }
.today { display: flex; gap: 1.1rem; align-items: center; background: var(--card); border-radius: 20px; padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: .9rem; }
.ring { --p: 0; width: 88px; height: 88px; flex: none; border-radius: 50%; display: grid; place-content: center; text-align: center; background: radial-gradient(closest-side, var(--card) 80%, transparent 82%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--chip) 0); animation: ringfill 1.1s var(--ease) backwards .1s; }
@keyframes ringfill { from { --p: 0; } }
.ring b { font-size: 1.2rem; font-variant-numeric: tabular-nums; } .ring small { font-size: .68rem; color: var(--soft); }
.todaytxt { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.todaytxt b { font-size: 1.15rem; line-height: 1.25; }
.go { margin: 0 0 1.4rem; font-size: 1.2rem; padding: 1.05rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.tile-btn { background: var(--card); border-radius: var(--r); padding: 1rem .6rem .85rem; box-shadow: 0 3px 0 var(--lip), var(--shadow); margin-bottom: 3px; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.tile-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.tile-btn .big { font-family: var(--hz); font-size: 1.7rem; font-weight: 600; line-height: 1.2; }
.tile-btn small { color: var(--soft); font-size: .82rem; }
.forecast { margin: 1.4rem 0 1rem; background: var(--card); border-radius: var(--r); padding: .9rem 1rem .7rem; box-shadow: var(--shadow); }
.forecast .small { font-weight: 650; }
.fbars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 96px; margin-top: .5rem; }
.fbars .fb { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: .7rem; color: var(--soft); padding: 0; border-radius: 0; text-align: center; }
.fbars .fb span { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.fbars .fb span:empty, .fbars .fb span.zero { visibility: hidden; }
.fbars .fb i { display: block; width: 62%; background: color-mix(in srgb, var(--accent) 30%, var(--chip)); border-radius: 5px; min-height: 3px; transform-origin: bottom; animation: bar-up .7s var(--spring) backwards; }
.fbars .fb:first-child i { background: var(--accent); }
.fbars .fb:nth-child(2) i { animation-delay: .04s; } .fbars .fb:nth-child(3) i { animation-delay: .08s; } .fbars .fb:nth-child(4) i { animation-delay: .12s; }
.fbars .fb:nth-child(5) i { animation-delay: .16s; } .fbars .fb:nth-child(6) i { animation-delay: .2s; } .fbars .fb:nth-child(7) i { animation-delay: .24s; }
@keyframes bar-up { from { transform: scaleY(0); } }
.note { display: flex; gap: .6rem; align-items: flex-start; background: color-mix(in srgb, var(--warn) 9%, var(--card)); color: var(--ink); border-radius: 14px; padding: .75rem .9rem; font-size: .85rem; line-height: 1.45; margin: .8rem 0; }
.note b { color: var(--warn); }

/* ---------- onboarding ---------- */
.onb { text-align: center; padding-top: 2.2rem; }
.onb .logo { display: inline-grid; place-items: center; font-family: var(--hz); font-size: 2.6rem; color: var(--accent-ink); background: var(--accent); width: 5.4rem; height: 5.4rem; border-radius: 18px; box-shadow: 0 5px 0 var(--accent-deep); transform: rotate(-4deg); animation: stamp .6s var(--spring) backwards; }
.onb h1 { margin-top: 1.1rem; }
.onb > p { color: var(--soft); max-width: 30em; margin: 0 auto 1.2rem; }
.onb label { display: block; text-align: left; margin: 1.3rem 0 .5rem; font-weight: 650; }
.onb input { margin: 1.3rem 0; }
input[type=text], input[type=password], input[type=date], input:not([type]), select { width: 100%; font: inherit; padding: .75rem .85rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg button { background: var(--chip); border-radius: 10px; padding: .5rem .8rem; font-weight: 650; font-size: .92rem; box-shadow: 0 2px 0 var(--lip); margin-bottom: 2px; border: 1.5px solid transparent; }
.seg button:active { transform: translateY(2px); box-shadow: none; }
.seg button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, transparent); animation: pick .3s var(--spring); }
@keyframes pick { 40% { transform: scale(1.07); } }
.seg.tabs { margin: 1.1rem 0 .9rem; background: var(--chip); padding: 4px; border-radius: 13px; gap: 2px; flex-wrap: nowrap; }
.seg.tabs button { flex: 1; background: none; box-shadow: none; border: 0; margin: 0; padding: .5rem .2rem; font-size: .86rem; color: var(--soft); }
.seg.tabs button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); animation: none; }
.set { padding: .95rem 0; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set > label { display: block; font-weight: 650; margin-bottom: .55rem; }
.set > .small { margin-top: .5rem; }
.group { background: var(--card); border-radius: var(--r); padding: 0 1rem; box-shadow: var(--shadow); }
details.sync { margin: .8rem 0; background: var(--card); padding: .9rem 1rem; border-radius: var(--r); box-shadow: var(--shadow); }
details.sync summary { font-weight: 650; cursor: pointer; }
details.sync input { margin: .35rem 0; }

/* ---------- session ---------- */
.session { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 10; animation: session-in .35s var(--ease) backwards; }
@keyframes session-in { from { opacity: 0; transform: translateY(24px); } }
.shead { display: flex; align-items: center; gap: .7rem; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; max-width: 680px; width: 100%; margin: 0 auto; position: relative; }
.bar { flex: 1; height: 12px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s var(--spring); position: relative; }
.bar i::after { content: ""; position: absolute; left: 6px; right: 6px; top: 3px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.35); }
.xpc { font-weight: 800; font-size: .92rem; color: var(--gold); min-width: 60px; text-align: right; font-variant-numeric: tabular-nums; }
.xpc.pop { animation: pop .45s var(--spring); } @keyframes pop { 40% { transform: scale(1.3); } }
.xpfloat { position: absolute; right: 16px; top: calc(env(safe-area-inset-top) + 30px); font-weight: 800; color: var(--gold); pointer-events: none; animation: float-up .9s var(--ease) forwards; }
@keyframes float-up { from { opacity: 0; transform: translateY(6px) scale(.8); } 25% { opacity: 1; transform: translateY(0) scale(1.1); } to { opacity: 0; transform: translateY(-26px); } }
.combo { font-family: var(--hz); font-weight: 800; font-size: .82rem; color: var(--accent-ink); background: var(--accent); border-radius: 99px; padding: .15rem .55rem; white-space: nowrap; display: none; }
.combo.on { display: inline-block; animation: pop .45s var(--spring); }
.cardhost { flex: 1; overflow-y: auto; padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 640px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; }
.cardhost > * { animation: rise .42s var(--ease) backwards; }
.cardhost > :nth-child(2) { animation-delay: .04s; } .cardhost > :nth-child(3) { animation-delay: .08s; }
.cardhost > :nth-child(4) { animation-delay: .12s; } .cardhost > :nth-child(n+5) { animation-delay: .15s; }
.cardhost > :first-child { margin-top: clamp(4px, 5vh, 48px); }
.cardhost.leave > * { animation: leave .16s ease-in both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes leave { to { opacity: 0; transform: translateX(-24px); } }
.prompt { font-weight: 600; font-size: 1.02rem; color: var(--soft); text-align: center; }
.face { text-align: center; display: flex; flex-direction: column; gap: .4rem; align-items: center; }
.face.hidden { visibility: hidden; }
.face.hero { padding: 1.4rem 0 .6rem; }
.pyl { font-size: 1.3rem; }
.mean { font-size: 1.12rem; }
.mean.xl { font-family: var(--display); font-size: 1.7rem; font-weight: 700; line-height: 1.25; }
.meta { font-size: .85rem; color: var(--soft); }
.badge { align-self: center; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: .25rem .85rem; font-size: .78rem; font-weight: 750; letter-spacing: .02em; }
.actions { margin-top: auto; padding-top: .8rem; display: flex; gap: .6rem; }
.actions.col { flex-direction: column; }
.actions.row2 > * { flex: 1; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; width: 100%; }
.grade { border-radius: 14px; padding: .65rem .2rem .55rem; background: var(--card); border: 1.5px solid var(--line); box-shadow: 0 3px 0 var(--lip); margin-bottom: 3px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.grade:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.grade b { font-size: .95rem; }
.grade small { font-size: .72rem; color: var(--soft); font-variant-numeric: tabular-nums; }
.grade.again b { color: var(--bad); } .grade.hard b { color: var(--warn); } .grade.good b { color: var(--ok); } .grade.easy b { color: var(--t3); }
.grade.picked { transform: scale(1.06); border-color: currentColor; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.options.col { grid-template-columns: 1fr; }
.opt { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: .85rem .5rem; min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; box-shadow: 0 3px 0 var(--lip); margin-bottom: 3px; }
.opt:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.opt:disabled { opacity: 1; }
.opt.txt { text-align: left; align-items: flex-start; padding: .85rem 1rem; min-height: 0; }
.opt small { color: var(--soft); font-size: .78rem; }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--card)); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: jump .5s var(--spring); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 55%, transparent); animation: shake .4s ease; }
.opt:disabled:not(.right):not(.wrong) { opacity: .55; }
@keyframes jump { 35% { transform: translateY(-5px) scale(1.04); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.fb { border-radius: 16px; padding: .75rem 1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.fb b { display: inline-flex; align-items: center; gap: .4rem; font-size: 1.05rem; }
.fb b .ic { width: 20px; height: 20px; stroke-width: 3; }
.fb.ok { background: color-mix(in srgb, var(--ok) 14%, var(--card)); color: var(--ok); }
.fb.bad { background: color-mix(in srgb, var(--bad) 12%, var(--card)); color: var(--bad); }
.cardhost > .fb.ok { animation: rise .35s var(--spring) backwards; }
.cardhost > .fb.bad { animation: rise .3s var(--ease) backwards, shake .4s ease .1s; }
.fb .small { color: inherit; opacity: .9; }
.example { background: var(--card); border-radius: 14px; padding: .7rem .85rem; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .15rem .6rem; }
.example > .hz, .example > .hzs { font-size: 1.2rem; line-height: 1.9; }
.example .small { grid-column: 1; }
.example .btn-round { grid-row: 1 / span 2; grid-column: 2; width: 40px; height: 40px; }
.example.bad { box-shadow: none; background: transparent; border: 1.5px dashed color-mix(in srgb, var(--bad) 60%, transparent); display: block; }
.exlist { display: flex; flex-direction: column; gap: .55rem; margin: .6rem 0; }
.sentface { text-align: center; display: flex; flex-direction: column; gap: .4rem; align-items: center; background: var(--card); border-radius: var(--r); padding: 1rem .9rem; box-shadow: var(--shadow); }
.sentface .hz { line-height: 2; }
/* grammar rule: a paper slip with a seal tag, no side stripe */
.rule { position: relative; background: var(--card); border-radius: var(--r); padding: 1rem 1rem .9rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .35rem; }
.rule > b { font-size: 1.02rem; line-height: 1.35; padding-right: 2.8rem; }
.rule-tag { position: absolute; top: .85rem; right: .85rem; font-family: var(--hz); font-size: .72rem; font-weight: 700; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 5px; padding: .05rem .3rem; transform: rotate(4deg); opacity: .85; }
.rule .small { color: var(--ink); opacity: .82; }
.pattern { font-family: var(--hz); font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: .35rem .6rem; align-self: flex-start; }
.pattern.center { align-self: center; }
.breakdowns { display: flex; flex-direction: column; gap: .4rem; }
.breakdown { font-size: .88rem; color: var(--soft); background: var(--chip); border-radius: 12px; padding: .45rem .7rem; display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .35rem; }
.breakdown .hzs.lg { color: var(--ink); margin-right: .2rem; }
.breakdown b.hzs { color: var(--ink); }

/* ---------- tone drill ---------- */
.tonerows { display: flex; flex-direction: column; gap: .6rem; }
.tonerow { display: grid; grid-template-columns: 2.6rem 1fr; align-items: center; gap: .5rem; background: var(--card); border-radius: var(--r); padding: .55rem; box-shadow: var(--shadow); }
.tonerow .hzs { text-align: center; }
.tbtns { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.tbtn { background: var(--chip); border-radius: 11px; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1; box-shadow: 0 2px 0 var(--lip); }
.tbtn:active { transform: translateY(2px); box-shadow: none; }
.tbtn .tsyl { font-size: 1.05rem; font-weight: 700; }
.tbtn small { font-size: .7rem; opacity: .7; }
.tbtn.on { color: #fff; animation: pick .3s var(--spring); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.tbtn.t1.on { background: var(--t1); } .tbtn.t2.on { background: var(--t2); } .tbtn.t3.on { background: var(--t3); } .tbtn.t4.on { background: var(--t4); } .tbtn.t5.on { background: var(--t5); }
:root[data-palette="off"] .tbtn.on { background: var(--ink); color: var(--bg); }

/* ---------- writing ---------- */
.stage { display: flex; justify-content: center; }
.tzg-wrap { position: relative; color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--card); border-radius: 10px; box-shadow: var(--shadow); }
.tzg-wrap .tzg { position: absolute; inset: 0; }
.tzg-wrap .hw { position: absolute; inset: 0; touch-action: none; }
.tzg-wrap.miss { animation: shake .35s ease; }
.slots { display: flex; justify-content: center; gap: .5rem; }
.slot { font-family: var(--hz); font-size: 1.7rem; width: 2.4rem; height: 2.6rem; display: grid; place-items: center; border-bottom: 2.5px solid var(--line); color: var(--soft); }
.slot.ch { border-color: currentColor; animation: jump .45s var(--spring); }
.pitch { width: 100%; height: 130px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.pitchbox { display: flex; flex-direction: column; gap: .5rem; align-items: center; }

/* ---------- sentence tiles ---------- */
.tileline { min-height: 70px; border-bottom: 2px dashed var(--line); display: flex; flex-wrap: wrap; gap: .45rem; padding: .5rem 0; align-content: flex-start; justify-content: center; }
.tilebank { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; padding-top: .3rem; }
.tile { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: .45rem .75rem; font-size: 1.35rem; display: flex; flex-direction: column; align-items: center; line-height: 1.15; box-shadow: 0 3px 0 var(--lip); margin-bottom: 3px; }
.tile:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.tile.just { animation: drop .3s var(--spring); }
@keyframes drop { from { transform: translateY(24px) scale(.8); opacity: 0; } }
.tile small { font-size: .68rem; color: var(--soft); }
.tile.used { visibility: visible; opacity: 1; background: var(--chip); border-color: transparent; box-shadow: none; }
.tile.used > * { visibility: hidden; }
.gloss { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.gl { display: flex; flex-direction: column; align-items: center; background: var(--chip); border-radius: 12px; padding: .35rem .6rem; }
.gl .hz { font-size: 1.35rem; } .gl small { font-size: .7rem; color: var(--soft); max-width: 7rem; text-align: center; }

/* ---------- seals (replace the emoji) ---------- */
.seal { display: inline-grid; place-items: center; font-family: var(--hz); font-weight: 800; color: var(--accent-ink); background: var(--accent); border-radius: 14px; width: 4.6rem; height: 4.6rem; font-size: 2.5rem; line-height: 1; box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 5px color-mix(in srgb, var(--accent-ink) 55%, transparent); transform: rotate(-5deg); animation: stamp .55s var(--spring) backwards .1s; align-self: center; }
.seal.soft { background: var(--chip); color: var(--soft); box-shadow: inset 0 0 0 3px var(--chip), inset 0 0 0 5px var(--line); }
@keyframes stamp { from { transform: scale(2.2) rotate(-18deg); opacity: 0; } 60% { opacity: 1; } }

/* ---------- summary ---------- */
.summary { text-align: center; padding-top: 1.5rem; display: flex; flex-direction: column; gap: .7rem; }
.summary h2 { margin: .8rem 0 .2rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .6rem; }
.stat { background: var(--card); border-radius: 14px; padding: .75rem .2rem; display: flex; flex-direction: column; gap: .1rem; box-shadow: var(--shadow); animation: rise .45s var(--spring) backwards; }
.stat:nth-child(2) { animation-delay: .07s; } .stat:nth-child(3) { animation-delay: .14s; } .stat:nth-child(4) { animation-delay: .21s; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; } .stat small { color: var(--soft); font-size: .74rem; }
.stat.gold b { color: var(--gold); }

/* ---------- lessons path ---------- */
.path { position: relative; display: flex; flex-direction: column; gap: .7rem; margin-top: 1.2rem; }
.path::before { content: ""; position: absolute; left: calc(.9rem + 26px); top: 30px; bottom: 30px; border-left: 2px dashed var(--line); }
.node { position: relative; display: flex; align-items: center; gap: .9rem; background: var(--card); border-radius: 18px; padding: .8rem .9rem; box-shadow: 0 3px 0 var(--lip), var(--shadow); margin-bottom: 3px; text-align: left; animation: rise .4s var(--ease) backwards; }
.node:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--lip); }
.node:nth-child(2) { animation-delay: .03s; } .node:nth-child(3) { animation-delay: .06s; } .node:nth-child(4) { animation-delay: .09s; } .node:nth-child(n+5) { animation-delay: .12s; }
.node.locked { background: color-mix(in srgb, var(--card) 45%, var(--bg)); box-shadow: none; }
.node.locked .nodetxt, .node.locked .ringsm { opacity: .5; }
.nodetxt { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: .05rem; }
.nodetxt b { font-size: 1.15rem; } .nodetxt small { color: var(--soft); }
.nodetxt .meta { font-size: .78rem; font-variant-numeric: tabular-nums; }
.ringsm { --p: 0; width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; background: radial-gradient(closest-side, var(--card) 76%, transparent 78%), conic-gradient(var(--accent) calc(var(--p) * 1%), var(--chip) 0); animation: ringfill 1s var(--ease) backwards .2s; }
.node.locked .ringsm { background: var(--chip); }
.medal { flex: none; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; font-family: var(--hz); font-weight: 800; font-size: .95rem; color: #fff; transform: rotate(-6deg); }
.medal.gold { background: #c8971f; box-shadow: inset 0 0 0 2px #e8c35a; }
.medal.silver { background: #8d9197; box-shadow: inset 0 0 0 2px #c3c7cc; }
.medal.bronze { background: #a8652f; box-shadow: inset 0 0 0 2px #d09463; }

/* lesson page */
.lhead { display: grid; grid-template-columns: 40px 1fr; gap: .4rem; align-items: start; margin-left: -8px; }
.lhead .icon-btn { margin-top: .3rem; }
.lesson h1 { margin: 0 0 .15rem; font-size: 1.9rem; }
.lhead .small { line-height: 1.35; }
.lesson .toolbar { margin-top: .9rem; }
.dialog { display: flex; flex-direction: column; gap: .5rem; margin: .6rem 0 1.2rem; }
.dl { background: var(--card); border-radius: 14px; padding: .6rem .8rem; box-shadow: var(--shadow); display: grid; grid-template-columns: auto 1fr auto; gap: 0 .4rem; align-items: center; transition: background-color .25s, box-shadow .25s; }
.dl .hz { font-size: 1.35rem; line-height: 2.1; }
.dl > span { cursor: pointer; }
.dl .spk { font-size: .85rem; color: var(--soft); align-self: start; padding-top: .95rem; }
.dl .btn-round { width: 38px; height: 38px; }
.dl .tr, .dl > .small { grid-column: 1 / -1; }
.dl.playing { background: color-mix(in srgb, var(--accent) 8%, var(--card)); box-shadow: 0 0 0 1.5px var(--accent), var(--shadow); }
.dialog .tr { display: none; } .dialog.show-tr .tr, .lesson .dialog .tr { display: block; }
.ctx { margin-top: 1.2rem; font-style: italic; }
.vlist { display: flex; flex-direction: column; gap: .4rem; }
.vrow { display: grid; grid-template-columns: auto auto 1fr auto; gap: .7rem; align-items: center; background: var(--card); border-radius: 14px; padding: .6rem .8rem; text-align: left; box-shadow: var(--shadow); }
button.vrow:active { transform: scale(.985); }
.vrow.ref { box-shadow: none; background: var(--chip); }
.vpy { font-size: .9rem; } .vm { font-size: .88rem; color: var(--soft); min-width: 0; }
.vrow.pack { grid-template-columns: 1fr auto; }
.vrow.pack .ptxt { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.vrow.pack b { font-size: .98rem; line-height: 1.3; }
.vrow.res { grid-template-columns: auto 1fr auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dot.young { background: var(--warn); } .dot.ok { background: var(--gold); } .dot.solid { background: var(--ok); }
.fchip { background: var(--chip); border-radius: 99px; padding: .22rem .65rem; font-size: .8rem; font-weight: 600; }
.fchip.ok { background: color-mix(in srgb, var(--gold) 22%, var(--card)); } .fchip.solid { background: color-mix(in srgb, var(--ok) 22%, var(--card)); }
.gblock { margin: 1rem 0 1.4rem; }
.notes p { background: var(--card); padding: .8rem 1rem; border-radius: 14px; box-shadow: var(--shadow); line-height: 1.55; }
.track { display: flex; flex-direction: column; gap: .3rem; margin: .8rem 0; } .track audio { width: 100%; }
.player audio { width: 100%; }

/* ---------- collection ---------- */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: .5rem; margin-top: 1rem; }
.cc { --m: 0; aspect-ratio: 1; border-radius: 14px; display: grid; place-items: center; font-family: var(--hz); font-size: 1.75rem; background: radial-gradient(closest-side, var(--card) 86%, transparent 88%), conic-gradient(var(--accent) calc(var(--m) * 1%), var(--chip) 0); animation: ringfill-m .9s var(--ease) backwards; }
@keyframes ringfill-m { from { --m: 0; } }
.cc:active { transform: scale(.9); }
.cc.locked { background: var(--chip); color: var(--line); font-size: 1rem; opacity: .6; animation: none; }

/* ---------- modal (bottom sheet) & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,12,6,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 30; animation: fade .25s ease backwards; }
.modal-bg.out { animation: fade .2s ease reverse both; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding: 1.4rem 16px calc(1.3rem + env(safe-area-inset-bottom)); position: relative; animation: sheet .38s var(--ease) backwards; }
.modal::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line); }
.modal-bg.out .modal { animation: sheet .2s ease-in reverse both; }
@keyframes sheet { from { transform: translateY(100%); } }
.modal.tall { max-height: 88vh; overflow-y: auto; }
.modal .close { position: absolute; right: 8px; top: 8px; }
.modal > div { display: flex; flex-direction: column; gap: .7rem; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px) scale(.96); background: var(--ink); color: var(--bg); padding: .75rem 1.05rem; border-radius: 14px; max-width: calc(100% - 32px); opacity: 0; transition: opacity .25s, transform .35s var(--spring); z-index: 40; font-size: .92rem; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; width: 100%; height: 100%; }

/* ---------- homework ---------- */
.q { background: var(--card); border-radius: var(--r); padding: .8rem; box-shadow: var(--shadow); margin: .5rem 0; }
.qt { font-weight: 650; margin-bottom: .5rem; }
.qs { display: flex; flex-direction: column; }
.seg.multi.types button { font-size: .84rem; }
.builder { background: var(--card); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .8rem; }
.builder > .small { margin: -.3rem 0 0; }
.builder .primary { margin-top: .3rem; }

@media (min-width: 700px) { .grid2 { grid-template-columns: repeat(4, 1fr); } }
.tpair { display: flex; gap: .4rem; }
.tpill { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 10px; font-weight: 800; font-size: 1.2rem; color: #fff !important; }
.tpill.t1 { background: var(--t1); } .tpill.t2 { background: var(--t2); } .tpill.t3 { background: var(--t3); } .tpill.t4 { background: var(--t4); } .tpill.t5 { background: var(--t5); }
:root[data-palette="off"] .tpill { background: var(--ink); color: var(--bg) !important; }
.leech { background: color-mix(in srgb, var(--warn) 10%, var(--card)); border-radius: 14px; padding: .7rem .85rem; display: flex; flex-direction: column; gap: .45rem; }
.page-in { animation: page-in .35s var(--ease) backwards; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-delay: 0s !important; transition-duration: .001s !important; }
}

/* spacing fixes after the first screenshots */
.builder .seg.tabs { margin: 0; }
.builder label.small { margin-bottom: -.4rem; font-weight: 650; }
.actions { justify-content: center; }
.seg button { padding: .45rem .75rem; font-size: .9rem; }
.seg.tabs button { font-size: .82rem; }
.ctx + .row { margin: .5rem 0 .2rem; }
h1, h2, .mean.xl { font-variant-numeric: lining-nums; }
.onb .logo { font-size: 2.05rem; letter-spacing: -.02em; }
