:root {
  color-scheme: light dark;
  --bg: #f4f1e9;
  --surface: #fffdf7;
  --text: #1c1b17;
  --muted: #6e6a60;
  --line: #d6d0c3;
  --ink: #225f55;
  --ink-dark: #16463f;
  --fail: #a74336;
  --pass: #2f7650;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
a { color: inherit; }
header { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 9px; align-items: center; font-weight: 750; text-decoration: none; letter-spacing: -.02em; }
.brand span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--text); color: var(--bg); }
main { width: min(720px, 100%); margin: 0 auto; padding: 28px 18px 100px; }
nav { position: fixed; z-index: 5; inset: auto 0 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 95%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
nav a { padding: 9px 2px; color: var(--muted); font-size: .75rem; font-weight: 700; text-align: center; text-decoration: none; border-radius: 8px; }
nav a.active { color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent); }
h1 { margin: 0 0 8px; font-size: clamp(2rem, 8vw, 3.5rem); line-height: 1; letter-spacing: -.055em; }
h2 { margin: 0 0 10px; font-size: 1.25rem; }
p { line-height: 1.55; }
.lead, .muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 28px rgb(40 33 20 / 5%); }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:active { transform: scale(.99); }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.prompt { margin: 0; font-size: clamp(1.35rem, 5vw, 2rem); line-height: 1.35; letter-spacing: -.02em; }
.answer { padding-top: 18px; border-top: 1px solid var(--line); }
.answer .hanzi { margin: 0 0 8px; font-size: clamp(1.5rem, 6vw, 2.4rem); line-height: 1.35; }
.pinyin { color: var(--muted); line-height: 1.5; }
.yours { padding: 12px 14px; border-left: 3px solid var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); white-space: pre-wrap; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .85rem; font-weight: 650; }
input, textarea, select { width: 100%; padding: 13px 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
textarea { min-height: 125px; resize: vertical; font-size: 1.15rem; line-height: 1.5; }
button, .button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 10px 16px; color: white; background: var(--ink); border: 0; border-radius: 11px; font-weight: 750; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--ink-dark); }
button:disabled { cursor: wait; opacity: .55; }
button.quiet { color: var(--text); background: transparent; border: 1px solid var(--line); }
button.fail { background: var(--fail); }
button.pass { background: var(--pass); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions > * { flex: 1 1 130px; }
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); text-decoration: none; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat strong { display: block; font-size: 2rem; letter-spacing: -.04em; }
.stat span { color: var(--muted); font-size: .82rem; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.error { padding: 12px 14px; color: #7f261d; background: #f8dcd6; border-radius: 10px; }
.success { padding: 12px 14px; color: #164c32; background: #dcefe4; border-radius: 10px; }
.loading { color: var(--muted); }
code { overflow-wrap: anywhere; }
.recovery { columns: 2; padding-left: 1.4rem; font-family: ui-monospace, monospace; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #171713; --surface: #22221d; --text: #f2efe5; --muted: #aaa497; --line: #3d3a32; --ink: #71b9a8; --ink-dark: #5ba292; }
  button { color: #122c27; }
  button.quiet { color: var(--text); }
  .error { color: #ffbcb2; background: #4a221e; }
  .success { color: #a9e3c1; background: #173c2a; }
}
@media (min-width: 760px) {
  nav { position: sticky; top: 58px; width: min(720px, 100%); margin: 0 auto; border: 1px solid var(--line); border-radius: 0 0 14px 14px; }
  main { padding-top: 40px; }
}
