:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1d1b19;
  --muted: #5f5a54;
  --line: #e2ddd5;
  --ink: #1d1b19;
  --on-ink: #ffffff;
  --t1: #c62828;
  --t2: #2e7d32;
  --t3: #1565c0;
  --t4: #7b1fa2;
  --t5: #616161;
  --ok: #2e7d32;
  --no: #b3261e;
  --tabs-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1e1c1a;
    --text: #f1ede8;
    --muted: #a8a29b;
    --line: #36322e;
    --ink: #f1ede8;
    --on-ink: #141312;
    --t1: #f07575;
    --t2: #6cc070;
    --t3: #6aaef5;
    --t4: #cf8ae6;
    --t5: #aaa49d;
    --ok: #6cc070;
    --no: #f07575;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: calc(var(--tabs-h) + 24px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -100px; background: var(--ink); color: var(--on-ink); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }

main { max-width: 760px; margin: 0 auto; padding: 28px 16px 40px; outline: none; }
body.has-dock main { padding-bottom: 170px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 60ch; }

.t1 { --tc: var(--t1); } .t2 { --tc: var(--t2); } .t3 { --tc: var(--t3); } .t4 { --tc: var(--t4); } .t5 { --tc: var(--t5); }
.contour { width: 26px; height: 26px; flex: none; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.contour circle { fill: currentColor; stroke: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .legend { grid-template-columns: repeat(4, 1fr); } }
.tone {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--tc);
  transition: border-color .15s;
}
.tone:hover { border-color: var(--tc); }
.tone-p { display: block; font-size: 1.3rem; font-weight: 600; line-height: 1.2; }
.tone-name { display: block; font-size: .8rem; color: var(--muted); }

.group { margin-top: 22px; }
.group h2 { font-size: .9rem; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.chip {
  min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 1.05rem;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.credits { margin-top: 36px; font-size: .85rem; color: var(--muted); }
.credits a { color: inherit; }

.dock {
  position: fixed; left: 0; right: 0; z-index: 5;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgb(0 0 0 / .06);
  padding: 10px 16px;
}
.dock-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.dock-syl { font-size: 1.1rem; font-weight: 700; min-width: 3.2em; }
.dock-tones { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dtone {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px; padding: 6px 2px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--tc);
  font-size: 1.15rem; font-weight: 600;
  transition: background-color .15s, color .15s;
}
.dtone.on { background: var(--tc); color: var(--surface); border-color: var(--tc); }
@media (max-width: 420px) {
  .dock-in { flex-wrap: wrap; }
  .dock-tones { order: 3; flex-basis: 100%; }
  .dock-syl { flex: 1; }
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: 1fr 1fr;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .8rem; font-weight: 600;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); box-shadow: inset 0 3px 0 var(--text); }

.seg { border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin: 0; display: inline-flex; background: var(--surface); max-width: 100%; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--muted); transition: background-color .15s, color .15s; }
.seg input:checked + span { background: var(--ink); color: var(--on-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

.card {
  margin-top: 16px; padding: 28px 16px; text-align: center;
  display: grid; justify-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
.play {
  width: 88px; height: 88px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: var(--ink); color: var(--on-ink);
  transition: transform .15s;
}
.play:active { transform: scale(.96); }
.play svg { width: 38px; height: 38px; fill: currentColor; }
.q { margin: 0; color: var(--muted); }
.answers { width: 100%; max-width: 460px; display: grid; gap: 14px; }
.arow { display: grid; gap: 6px; }
.alabel { font-size: .85rem; color: var(--muted); }
.abtns { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 8px; }
.ans {
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--tc);
  font-weight: 700; font-size: .95rem;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.ans:hover { border-color: var(--tc); }
.ans[aria-pressed="true"] { border-color: var(--tc); box-shadow: inset 0 0 0 1px var(--tc); }
.ans.right { background: color-mix(in srgb, var(--ok) 26%, var(--surface)); border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
.ans.wrong { background: color-mix(in srgb, var(--no) 24%, var(--surface)); border-color: var(--no); box-shadow: inset 0 0 0 2px var(--no); }
.ans.right::after, .ans.wrong::after { font-size: .75rem; font-weight: 700; }
.ans.right::after { content: "right"; color: var(--ok); }
.ans.wrong::after { content: "your pick"; color: var(--no); }
.feedback { max-width: 460px; }
.feedback p { margin: 0 0 8px; }
.feedback .ok { color: var(--ok); }
.feedback .no { color: var(--no); }
.py { color: var(--tc); font-weight: 700; }
.word { font-size: 1.5rem; }
.word [lang="zh-Hans"] { margin-right: 8px; }
.note { color: var(--muted); font-size: .9rem; }
.compare { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.score { text-align: center; color: var(--muted); margin: 14px 0 0; min-height: 1.5em; }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
@media (hover: none) { .hint { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
