:root {
  --paper: #f4ecdd;
  --paper-deep: #e9dcc3;
  --ink: #1b1a17;
  --ink-soft: #5b5648;
  --ink-faint: #a69c86;
  --vermilion: #c8321f;
  --vermilion-deep: #9e2416;
  --card: #fbf6ea;
  --line: rgba(27, 26, 23, 0.14);
  --shadow: 0 24px 50px -24px rgba(27, 26, 23, 0.45), 0 2px 0 rgba(27, 26, 23, 0.06);
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Noto Serif", "Iowan Old Style", Georgia, serif;
  --hanzi: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141311;
    --paper-deep: #1d1b18;
    --ink: #f1e9d8;
    --ink-soft: #b8ae9b;
    --ink-faint: #6f6757;
    --vermilion: #e0462f;
    --vermilion-deep: #b53320;
    --card: #211f1b;
    --line: rgba(241, 233, 216, 0.14);
    --shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.9), 0 2px 0 rgba(255, 255, 255, 0.03);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(120% 70% at 100% 0%, var(--paper-deep) 0%, transparent 60%),
    radial-gradient(90% 60% at 0% 100%, var(--paper-deep) 0%, transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grain { mix-blend-mode: screen; opacity: .25; } }

.top, main { position: relative; z-index: 1; }
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 22px 20px 6px;
  max-width: 520px; margin: 0 auto;
}
.seal {
  width: 46px; height: 46px; border-radius: 6px;
  background: var(--vermilion); color: #fff;
  font-family: var(--hanzi); font-size: 30px; line-height: 46px; text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 6px 14px -8px var(--vermilion-deep);
  transform: rotate(-4deg);
}
.top h1 {
  margin: 0; font-family: var(--display); font-weight: 500; font-size: 22px; letter-spacing: -.01em;
  font-variation-settings: "opsz" 48;
}
.top p { margin: 0; font-size: 13px; }
.build {
  margin-left: auto; align-self: flex-start; margin-top: 2px;
  font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); opacity: .8;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

main { max-width: 520px; margin: 0 auto; padding: 8px 20px 40px; }
.view[hidden] { display: none; }
.view { display: flex; flex-direction: column; gap: 18px; animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.eyebrow {
  margin: 0 0 4px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--vermilion); font-weight: 600;
}
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.hint { color: var(--ink-faint); font-size: 13px; font-style: italic; margin: 0; }

.hero { padding: 26px 0 8px; }
.hero-title {
  margin: 0 0 6px; font-family: var(--display); font-weight: 300; line-height: .9;
  font-size: clamp(56px, 18vw, 92px); letter-spacing: -.03em; font-variation-settings: "opsz" 144;
}
.hero-title .num { font-style: italic; color: var(--vermilion); font-weight: 400; }
.hero-title .of { font-size: .4em; color: var(--ink-faint); margin-left: .1em; }
.hero p { margin: 0 0 4px; }

.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  font-family: var(--display); font-size: 19px; font-weight: 500;
  padding: 16px 28px; border-radius: 999px; min-width: 150px;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: var(--ink); color: var(--paper);
  box-shadow: 0 14px 30px -16px var(--ink);
}
.btn-primary:hover { background: var(--vermilion); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.link {
  appearance: none; background: none; border: 0; color: var(--ink-soft); font: inherit; font-size: 15px;
  text-decoration: underline; text-underline-offset: 4px; cursor: pointer; align-self: center; padding: 8px;
}

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0; font-family: var(--display); font-weight: 500; font-size: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel .muted { margin: 6px 0 0; }
.status { margin: 10px 0 0; font-size: 14px; padding-left: 14px; position: relative; min-height: 1.4em; }
.status::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint);
}
.status.ok::before { background: var(--vermilion); box-shadow: 0 0 0 3px rgba(200,50,31,.18); }
.status.warn::before { background: #c99a1f; }

.switch { position: relative; display: inline-block; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch .track {
  display: block; width: 52px; height: 30px; border-radius: 999px; background: var(--paper-deep);
  box-shadow: inset 0 0 0 1.5px var(--line); transition: background .2s;
}
.switch .knob {
  position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
.switch input:checked + .track { background: var(--vermilion); box-shadow: none; }
.switch input:checked + .track .knob { transform: translateX(22px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--vermilion); outline-offset: 3px; }

.stats dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 0; }
.stats dt { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.stats dd { margin: 2px 0 0; font-family: var(--display); font-size: 30px; font-weight: 400; line-height: 1; }
.weak { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 12px; }
.weak ul, .review-list { list-style: none; margin: 0; padding: 0; }
.weak li, .review-list li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.weak li:last-child, .review-list li:last-child { border-bottom: 0; }
.review-list .py { font-weight: 600; }
.review-list .hz, .weak .hz { font-family: var(--hanzi); color: var(--ink-soft); }

/* progress seals */
.progress { list-style: none; display: flex; gap: 7px; margin: 10px 0 0; padding: 0; justify-content: center; }
.progress li {
  width: 22px; height: 22px; border-radius: 4px; border: 1.5px solid var(--ink-faint);
  transition: all .25s ease; position: relative;
}
.progress li.current { border-color: var(--ink); transform: scale(1.12); }
.progress li.hit { background: var(--vermilion); border-color: var(--vermilion); }
.progress li.miss { border-color: var(--ink); }
.progress li.miss::after {
  content: ""; position: absolute; inset: 4px; background:
    linear-gradient(45deg, transparent 44%, var(--ink) 44%, var(--ink) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--ink) 44%, var(--ink) 56%, transparent 56%);
}

/* card */
.card-wrap { perspective: 1400px; padding: 12px 0 4px; }
.card {
  appearance: none; border: 0; padding: 0; background: none; font: inherit; color: inherit;
  display: block; width: 100%; aspect-ratio: 4 / 5; max-height: 62vh; position: relative;
  transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3,.8,.2,1); cursor: pointer;
  text-align: center;
}
.card.flipped { transform: rotateY(180deg); }
.card:focus-visible { outline: none; }
.card:focus-visible .face { box-shadow: var(--shadow), 0 0 0 3px var(--vermilion); }
.face {
  position: absolute; inset: 0; border-radius: 20px; background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 28px;
  overflow: hidden;
}
.face::before {
  content: ""; position: absolute; inset: 10px; border-radius: 13px; border: 1px solid var(--line); pointer-events: none;
}
.front::after {
  content: "问"; position: absolute; right: -8px; bottom: -22px; font-family: var(--hanzi);
  font-size: 150px; line-height: 1; color: var(--paper-deep); opacity: .9; pointer-events: none; z-index: 0;
}
.back { transform: rotateY(180deg); }
/* the face turned away must not take touches: Chrome still hit-tests a hidden back face in 3D */
.card.flipped .front, .card:not(.flipped) .back { pointer-events: none; }
.back::after {
  content: "答"; position: absolute; left: -8px; bottom: -22px; font-family: var(--hanzi);
  font-size: 150px; line-height: 1; color: var(--paper-deep); opacity: .9; pointer-events: none; z-index: 0;
}
.face > * { position: relative; z-index: 1; }
.card-en {
  margin: 0; font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: clamp(34px, 10vw, 54px); line-height: 1.05; letter-spacing: -.02em; text-wrap: balance;
  font-variation-settings: "opsz" 144;
}
.card-pinyin {
  margin: 0; font-family: var(--body); font-weight: 600; color: var(--vermilion);
  font-size: clamp(34px, 10vw, 52px); line-height: 1.1; letter-spacing: .005em;
}
.card-hanzi { margin: 2px 0 0; font-family: var(--hanzi); font-size: clamp(28px, 8vw, 40px); color: var(--ink-soft); }
.back .hint { margin-top: 6px; }
.back .hint.notice { color: var(--vermilion); font-style: normal; }
.parts {
  list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  max-width: 100%;
}
.parts:empty { display: none; }
.parts li {
  display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 8px 7px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.parts .hz { font-family: var(--hanzi); font-size: 22px; line-height: 1.1; color: var(--ink); }
.parts .py { font-size: 13px; font-weight: 600; color: var(--vermilion); margin-top: 2px; }
.parts .en { font-size: 11px; color: var(--ink-soft); line-height: 1.2; text-align: center; max-width: 92px; }
.parts .unknown .py { color: var(--ink-faint); }
.speak {
  appearance: none; border: 1.5px solid var(--vermilion); background: transparent; color: var(--vermilion);
  width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; margin-top: 6px; transition: background .15s, color .15s, transform .15s;
}
.speak[hidden] { display: none; }
.speak:hover, .speak:focus-visible { background: var(--vermilion); color: #fff; outline: none; }
.speak:active { transform: scale(.94); }
.speak.speaking { background: var(--vermilion); color: #fff; }
.speak.speaking .w1 { animation: wave .9s ease-in-out infinite; }
.speak.speaking .w2 { animation: wave .9s ease-in-out .15s infinite; }
@keyframes wave { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.grade[hidden] { display: none; }
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; animation: rise .3s ease both; }
.grade .btn { min-width: 0; width: 100%; }

@media (max-width: 380px) {
  body { font-size: 16px; }
  main, .top { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .view, .grade { animation: none; }
  .card { transition: none; }
}

/* learning steps */
.stage {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 6px;
}
.stage .pips { display: inline-flex; gap: 3px; }
.stage .pips i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--ink-faint); }
.stage .pips i.on { background: var(--vermilion); border-color: var(--vermilion); }
.front .card-hanzi:empty, .back .back-en:empty, .front-sub:empty { display: none; }
.back-en { font-size: clamp(26px, 7vw, 36px); color: var(--ink-soft); margin: 0 0 2px; }
.back-en:empty { display: none; }
.back.answer-en .card-pinyin { font-size: clamp(22px, 6vw, 30px); }
.back.answer-en .back-en { color: var(--ink); font-size: clamp(34px, 10vw, 54px); }
.card.locked { cursor: default; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; animation: rise .3s ease both; }
.choices[hidden] { display: none; }
.btn-choice {
  min-width: 0; width: 100%; padding: 18px 12px; background: var(--card); color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line), var(--shadow); font-size: 20px; line-height: 1.2; min-height: 72px;
  white-space: normal; overflow-wrap: anywhere;
}
.btn-choice.pinyin { font-family: var(--body); font-weight: 600; font-size: 22px; }
.btn-choice:hover { box-shadow: inset 0 0 0 1.5px var(--ink), var(--shadow); }
.btn-choice:disabled { cursor: default; }
.btn-choice.correct { background: var(--vermilion); color: #fff; box-shadow: 0 14px 30px -16px var(--vermilion-deep); }
.btn-choice.wrong { color: var(--ink-faint); text-decoration: line-through; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-choice.dim { opacity: .45; }

.next { grid-template-columns: 1fr auto; align-items: center; }
.next[hidden] { display: none; }
.verdict { margin: 0; font-family: var(--display); font-size: 20px; }
.verdict.good { color: var(--vermilion); }
.verdict.bad { color: var(--ink-soft); }
.verdict small { display: block; font-family: var(--body); font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.stages { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; margin-top: 14px; font-size: 14px; color: var(--ink-soft); }
.stages b { color: var(--ink); font-family: var(--display); font-size: 17px; margin-right: 2px; }
.stages .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; border: 1.5px solid var(--ink-faint); vertical-align: 1px; }
.stages .dot.s1 { border-color: var(--vermilion); }
.stages .dot.s2 { border-color: var(--vermilion); background: color-mix(in srgb, var(--vermilion) 25%, transparent); }
.stages .dot.s3 { border-color: var(--vermilion); background: color-mix(in srgb, var(--vermilion) 50%, transparent); }
.stages .dot.s4 { border-color: var(--vermilion); background: color-mix(in srgb, var(--vermilion) 75%, transparent); }
.stages .dot.s5 { background: var(--vermilion); border-color: var(--vermilion); }

/* speakers wherever there is Chinese */
.no-speech .speak { display: none !important; }
.speak-mini { width: 34px; height: 34px; margin: 0; flex: none; }
.speak-mini svg { width: 17px; height: 17px; }
.choice { position: relative; }
.choice .speak-mini { position: absolute; top: -8px; right: -4px; background: var(--card); box-shadow: var(--shadow); }
.choice .speak-mini:hover, .choice .speak-mini.speaking { background: var(--vermilion); }
.front .speak { margin-top: 2px; }
.weak li, .review-list li { align-items: center; }
.review-list li .speak-mini, .weak li .speak-mini { margin-left: 6px; }
.row-right { display: inline-flex; align-items: center; gap: 4px; }

/* pronunciation self-check */
.back-actions { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; }
.back-actions .speak { margin-top: 0; }
.pron {
  appearance: none; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 10px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: transparent; color: var(--ink-soft);
  transition: background .15s, color .15s, border-color .15s;
}
.pron:hover { border-color: var(--ink); color: var(--ink); }
.pron[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pron[aria-pressed="true"]::before { content: "✕ "; }
.regen { font-size: 12.5px; padding: 2px 6px; margin-top: 4px; color: var(--ink-faint); }
.regen:hover { color: var(--vermilion); }
body:not(.server-tts) .regen { display: none; }
.tag { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--vermilion); border: 1px solid var(--vermilion); border-radius: 999px; padding: 1px 7px; margin-left: 6px; white-space: nowrap; }

/* listening steps: nothing to read, just a big speaker */
.card.listen #btn-speak-front { width: 92px; height: 92px; margin: 6px 0 4px; }
.card.listen #btn-speak-front svg { width: 44px; height: 44px; }
.card.listen .front .card-en:empty { display: none; }
.card.listen .front-eyebrow, .card.listen #front-eyebrow { font-size: 14px; letter-spacing: .2em; }

/* syllables light up as the audio plays */
.syl { transition: color .12s, background .12s; border-radius: 6px; padding: 0 .04em; margin: 0 -.04em; }
.card-pinyin .syl.on { color: var(--ink); background: color-mix(in srgb, var(--vermilion) 22%, transparent); box-shadow: 0 2px 0 var(--vermilion); }
.card-hanzi .syl.on { color: var(--vermilion); }

/* tone changes */
.tone-note { margin: 6px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); max-width: 100%; }
.tone-note:empty { display: none; }
.tone-note span { display: block; }
.tone-note b { color: var(--vermilion); font-weight: 600; }
.parts .alone { font-size: 10.5px; color: var(--ink-faint); font-style: italic; line-height: 1.2; }

/* lessons on the home screen */
.lessons { display: flex; flex-direction: column; gap: 14px; }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.lesson-head .muted { margin-top: 4px; }
.btn-sm { font-size: 17px; padding: 12px 22px; min-width: 0; flex: none; }
.bar { display: flex; gap: 2px; height: 8px; margin-top: 14px; border-radius: 999px; overflow: hidden; background: var(--paper-deep); }
.bar i { display: block; background: color-mix(in srgb, var(--vermilion) calc(var(--p) * 100%), var(--ink-faint)); opacity: calc(.35 + var(--p) * .65); }
.bar-legend { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.lesson.mix { background: transparent; box-shadow: none; border-style: dashed; }
.choice[hidden] { display: none; }

/* daily count-off */
.count .eyebrow { margin: 0 0 6px; }
.count.due { border-color: color-mix(in srgb, var(--vermilion) 60%, var(--line)); }
.count-badge {
  flex: none; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.count-badge.due { color: var(--vermilion); box-shadow: inset 0 0 0 1.5px var(--vermilion); }
.count-badge.due::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--vermilion); animation: pulse 1.6s ease-in-out infinite; }
.count-badge.ok { color: var(--paper); background: var(--vermilion); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,50,31,.35); } 50% { box-shadow: 0 0 0 5px rgba(200,50,31,0); } }
.count-actions { display: flex; gap: 10px; margin-top: 14px; }
.count-actions .btn { flex: 1; }
.count.nudge { text-align: left; }
.count.nudge .muted { margin-top: 2px; }
.eyebrow.center { text-align: center; margin: 6px 0 0; }
.progress.dots { gap: 5px; flex-wrap: wrap; }
.progress.dots li { width: 14px; height: 14px; border-radius: 50%; }
.count-num {
  margin: 0; font-family: var(--display); font-weight: 300; font-size: clamp(110px, 36vw, 170px); line-height: .95;
  letter-spacing: -.05em; font-variation-settings: "opsz" 144; color: var(--ink);
}
.grade.single { grid-template-columns: 1fr; }
.count-done .hero { text-align: center; padding: 34px 0 22px; }
.count-done .hero-title .of { font-family: var(--body); font-size: .22em; letter-spacing: 0; margin-left: .3em; color: var(--ink-soft); }
.count-done .btn { width: 100%; margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) { .count-badge.due::before { animation: none; } }

/* phone-number dictation */
.count-phone .panel { margin-top: 14px; text-align: center; }
.count-phone .panel .muted { margin: 6px 0 0; }
.speak.big { width: 84px; height: 84px; margin: 18px auto 6px; }
.speak.big svg { width: 36px; height: 36px; }
#phone-form { display: grid; gap: 12px; margin-top: 14px; }
#phone-form .btn { width: 100%; min-width: 0; }
#phone-form:has(.btn[hidden]) { grid-template-columns: 1fr; }
.phone-input {
  width: 100%; box-sizing: border-box; appearance: none; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper);
  color: var(--ink); font-family: var(--display); font-weight: 400; font-size: 40px; letter-spacing: .3em; text-align: center; padding: 12px 0 12px .3em;
  font-variant-numeric: tabular-nums;
}
.phone-input:focus { outline: none; border-color: var(--vermilion); }
.phone-input:disabled { border-style: dashed; }
.phone-result { margin: 14px 0 0; font-size: 15px; color: var(--ink-soft); line-height: 1.5; }
.phone-result[hidden] { display: none; }
.phone-result b { color: var(--ink); }
.phone-result .py { color: var(--vermilion); font-weight: 600; }
.phone-result.good::before { content: "Right. "; color: var(--vermilion); font-family: var(--display); font-size: 20px; display: block; }
.phone-result.bad::before { content: "Not quite. "; color: var(--ink); font-family: var(--display); font-size: 20px; display: block; }

/* write it: a square 米字格 box to write in, then your strokes under the stroke-order animation */
.write-card { cursor: default; }
.write-card.flipped { cursor: pointer; }
.write-card .face { gap: 8px; padding: 24px 20px; }
.pads { display: flex; justify-content: center; gap: 8px; width: 100%; margin-top: 2px; }
.pads[hidden] { display: none; }
.pads .writebox { width: calc((100% - 8px * (var(--n, 1) - 1)) / var(--n, 1)); max-width: 104px; }
.back .pads .writebox { max-width: 80px; border-radius: 9px; }
#count-card .back .pads { margin-top: 6px; }
#count-card .back .pads .writebox { max-width: 118px; border-radius: 12px; }
#count-card .back .card-hanzi { margin-bottom: 0; }
.pads.big .writebox { width: min(100%, 58vh, 290px); max-width: 290px; }
.small-link { font-size: 14px; padding: 2px 8px; }
.writebox {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--paper); border: 1.5px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none;
}
.writebox canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.writebox .anim { position: absolute; inset: 0; pointer-events: none; }
.writebox .anim svg { display: block; width: 100%; height: 100%; }
.write-tools { display: flex; justify-content: center; min-height: 20px; }
.write-tools .link { padding: 2px 8px; font-size: 14px; }
.write-py { margin: 0; font-family: var(--body); font-weight: 600; color: var(--vermilion); font-size: 24px; }
.write-card .back-actions { margin-top: 0; }
/* writing cards: the back carries the comparison boxes, so the rest is made more compact to fit */
.card.writing .back .back-en { font-size: clamp(24px, 6.5vw, 34px); }
.card.writing .back.answer-en .card-pinyin { font-size: clamp(20px, 5vw, 26px); }
.card.writing .back .parts { display: none; }
.card.writing .back .tone-note { font-size: 13px; }
.card.writing .back .regen { font-size: 13px; }
