/* ==========================================================================
   HSK 3.0 · 汉语 — русскоязычный тренажёр
   Design language: 宣纸 · 朱砂 (xuan paper & cinnabar ink)
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --bg-deep: #efe7d8;
  --surface: #fffdf8;
  --surface-2: #fbf6ec;
  --surface-3: #f4ecdd;
  --ink: #211d18;
  --ink-2: #5f574c;
  --ink-3: #928876;
  --line: #e7ddcb;
  --line-strong: #d6c9b2;

  --cinnabar: #b8382b;
  --cinnabar-deep: #8f2a20;
  --cinnabar-soft: #fbeae4;
  --cinnabar-line: #f0c9c0;

  --jade: #2f6f63;
  --jade-deep: #235349;
  --jade-soft: #e5f0ec;

  --gold: #a9822f;
  --gold-soft: #f8efd8;

  --azur: #3f6484;
  --azur-soft: #e8eff5;

  --danger: #b8382b;
  --danger-soft: #fbeae4;
  --ok: #2f6f63;
  --ok-soft: #e5f0ec;

  --t1: #c0392b;
  --t2: #c47a1f;
  --t3: #3f7a52;
  --t4: #3f6484;
  --t5: #928876;

  --r-xs: 6px;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 26px;

  --sh-1: 0 1px 2px rgba(73, 54, 28, 0.06);
  --sh-2: 0 4px 14px rgba(73, 54, 28, 0.07);
  --sh-3: 0 14px 34px rgba(73, 54, 28, 0.12);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 70px;
  --tab-space: calc(var(--tab-h) + var(--safe-bottom));
  --maxw: 560px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-han: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "Songti TC",
    "Noto Sans SC", serif;
  --font-ru: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PT Sans", "Arial", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110d;
  --bg-deep: #0d0b08;
  --surface: #1d1915;
  --surface-2: #232019;
  --surface-3: #2b261e;
  --ink: #f0e9dd;
  --ink-2: #b6ab99;
  --ink-3: #857b6b;
  --line: #322c24;
  --line-strong: #453d31;

  --cinnabar: #d9584a;
  --cinnabar-deep: #b8382b;
  --cinnabar-soft: #34211d;
  --cinnabar-line: #573029;

  --jade: #5ba192;
  --jade-deep: #3f7f72;
  --jade-soft: #1c2b28;

  --gold: #d0a851;
  --gold-soft: #2e2717;

  --azur: #7ba3c4;
  --azur-soft: #1b242c;

  --danger: #d9584a;
  --danger-soft: #34211d;
  --ok: #5ba192;
  --ok-soft: #1c2b28;

  --t1: #e0705f;
  --t2: #d99a45;
  --t3: #6fa87c;
  --t4: #7ba3c4;
  --t5: #9a9080;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 6px 18px rgba(0, 0, 0, 0.36);
  --sh-3: 0 18px 40px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-deep);
}

html[data-theme="light"] {
  background:
    radial-gradient(1200px 600px at 50% -10%, #fdf8ee, transparent 70%),
    linear-gradient(180deg, #f1e9db, #e9dfcd);
}

html[data-theme="dark"] {
  background: #0a0907;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ru);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(184, 56, 43, 0.05), transparent 22%),
    radial-gradient(circle at 82% 8%, rgba(169, 130, 47, 0.06), transparent 26%),
    radial-gradient(circle at 70% 88%, rgba(47, 111, 99, 0.05), transparent 30%);
}

[data-theme="dark"] body::before {
  opacity: 0.7;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--cinnabar);
  color: #fff;
}

/* ---------- shell ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(60, 44, 20, 0.14);
}

@media (min-width: 620px) {
  .app-shell {
    min-height: calc(100dvh - 32px);
    margin: 16px auto;
    border-radius: 28px;
    overflow: hidden;
  }
}

#view {
  min-height: 100dvh;
  padding-bottom: var(--tab-space);
}

body[data-route="/splash"] #view,
body[data-route="/onboarding"] #view,
body[data-route="/login"] #view,
body[data-route="/register"] #view,
body[data-route^="/exam/"] #view,
body[data-route^="/unit/"] #view,
body[data-route^="/placement"] #view {
  padding-bottom: 0;
}

/* ---------- typography helpers ---------- */

.han {
  font-family: var(--font-han);
  letter-spacing: 0.02em;
}

.ru {
  font-family: var(--font-ru);
}

.muted {
  color: var(--ink-2);
}

.dim {
  color: var(--ink-3);
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.eyebrow-han {
  font-family: var(--font-han);
  letter-spacing: 0.2em;
}

.small {
  font-size: 12.5px;
}

.tiny {
  font-size: 11.5px;
}

.strong {
  font-weight: 700;
}

.center {
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row {
  display: flex;
  align-items: center;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.stack {
  display: flex;
  flex-direction: column;
}

.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
  min-width: 0;
}

.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }

/* ---------- page scaffolding ---------- */

.page {
  padding: 0 16px 24px;
  animation: page-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  padding: 18px 0 14px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.page-title small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-title span {
  font-family: var(--font-han);
  font-weight: 700;
  color: var(--ink-3);
  margin-left: 6px;
  font-size: 13px;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cinnabar);
  white-space: nowrap;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: calc(var(--safe-top) + 8px) 14px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.topbar.is-stuck {
  border-bottom-color: var(--line);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.01em;
}

.topbar-side {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 40px;
}

.topbar-side.is-end {
  justify-content: flex-end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  transition: background 0.16s, transform 0.16s;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.is-bordered {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}

/* ---------- brand ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--cinnabar), var(--cinnabar-deep));
  color: #fff;
  font-family: var(--font-han);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(143, 42, 32, 0.28);
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
}

.brand-name small {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ---------- tabbar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 100%;
  max-width: var(--maxw);
  height: var(--tab-space);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  padding-top: 7px;
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}

.tabbar[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0 0;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  transition: color 0.16s;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border-radius: 10px;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}

.tab-label {
  font-family: var(--font-ru);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.tab-label .han {
  display: block;
  font-size: 8.5px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  opacity: 0.72;
}

.tab.is-active {
  color: var(--cinnabar);
}

.tab.is-active .tab-icon {
  background: var(--cinnabar-soft);
  transform: translateY(-1px);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--r-m);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.005em;
  transition: transform 0.14s, box-shadow 0.16s, background 0.16s, opacity 0.16s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.975);
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(180deg, #c34434, var(--cinnabar));
  color: #fff;
  box-shadow: 0 6px 18px rgba(184, 56, 43, 0.26);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #cb4938, #b93a2c);
}

.btn-jade {
  background: linear-gradient(180deg, #37806f, var(--jade));
  color: #fff;
  box-shadow: 0 6px 18px rgba(47, 111, 99, 0.24);
}

.btn-soft {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
}

.btn-soft:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 54px;
  font-size: 16px;
  border-radius: var(--r-l);
}

.btn-sm {
  height: 36px;
  padding: 0 13px;
  border-radius: var(--r-s);
  font-size: 13px;
}

.btn-icon {
  width: 46px;
  padding: 0;
}

.btn .btn-sub {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.72;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--sh-1);
}

.card-pad {
  padding: 16px;
}

.card-inset {
  background: var(--surface-2);
  box-shadow: none;
}

.tap {
  transition: transform 0.14s, box-shadow 0.18s, border-color 0.18s;
}

.tap:active {
  transform: scale(0.99);
}

a.card:hover,
button.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--sh-2);
}

/* ---------- level chips ---------- */

.lv {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}

.lv-1 { background: #eef3e6; color: #4a6b34; }
.lv-2 { background: #e9f2e4; color: #426b31; }
.lv-3 { background: #e4f0ee; color: #2f6f63; }
.lv-4 { background: #e6eef4; color: #3b5f7d; }
.lv-5 { background: #ede9f3; color: #5a4a7c; }
.lv-6 { background: #f3e8ef; color: #7a4462; }
.lv-7 { background: #f8ece2; color: #8d5a2b; }
.lv-8 { background: #f8e8e4; color: #93402f; }
.lv-9 { background: #f6e3e0; color: #8f2a20; }

[data-theme="dark"] .lv-1 { background: #212a1b; color: #9cc07c; }
[data-theme="dark"] .lv-2 { background: #1f2a1a; color: #96bf7a; }
[data-theme="dark"] .lv-3 { background: #162625; color: #6fb4a5; }
[data-theme="dark"] .lv-4 { background: #17222b; color: #87aac8; }
[data-theme="dark"] .lv-5 { background: #221d2b; color: #a595c6; }
[data-theme="dark"] .lv-6 { background: #2a1e25; color: #c08ba7; }
[data-theme="dark"] .lv-7 { background: #2b2118; color: #d0a171; }
[data-theme="dark"] .lv-8 { background: #2c1a17; color: #d48574; }
[data-theme="dark"] .lv-9 { background: #331816; color: #e0806f; }

.lv.is-active {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

/* ---------- pills & badges ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill-han {
  font-family: var(--font-han);
  letter-spacing: 0.06em;
}

.pill-cinnabar { background: var(--cinnabar-soft); color: var(--cinnabar); }
.pill-jade { background: var(--jade-soft); color: var(--jade); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }
.pill-azur { background: var(--azur-soft); color: var(--azur); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- progress ---------- */

.ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
}

.ring svg {
  transform: rotate(-90deg);
  display: block;
}

.ring-track {
  stroke: var(--line);
}

.ring-fill {
  stroke: var(--cinnabar);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-body {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.05;
}

.ring-value {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ring-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.bar {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cinnabar), #d1664f);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar.is-jade span {
  background: linear-gradient(90deg, var(--jade), #4a9987);
}

.bar.is-gold span {
  background: linear-gradient(90deg, var(--gold), #c9a24f);
}

.bar.is-thin {
  height: 4px;
}

/* ---------- stat tiles ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-tile {
  padding: 11px 8px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat-label {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* ---------- hanzi display ---------- */

.hanzi-hero {
  font-family: var(--font-han);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.pinyin {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}

.pinyin .t1 { color: var(--t1); }
.pinyin .t2 { color: var(--t2); }
.pinyin .t3 { color: var(--t3); }
.pinyin .t4 { color: var(--t4); }
.pinyin .t5 { color: var(--t5); }

.meaning-ru {
  font-family: var(--font-ru);
  color: var(--ink-2);
  line-height: 1.45;
}

/* ---------- word rows ---------- */

.wrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.14s;
}

.wrow:last-child {
  border-bottom: 0;
}

.wrow:hover {
  background: var(--surface-2);
}

.homograph-num {
  font-size: 0.42em;
  vertical-align: super;
  margin-left: 2px;
  color: var(--cinnabar);
  font-weight: 600;
  letter-spacing: 0;
}

/* Reading without pinyin (setting «Пиньинь под иероглифами») */
html[data-pinyin="off"] .wrow-py,
html[data-pinyin="off"] .word-hero-py,
html[data-pinyin="off"] .example-py {
  display: none;
}

/* Russian-only interface (setting «Язык подсказок») */
html[data-zh="off"] .section-title span,
html[data-zh="off"] .topbar-title span {
  display: none;
}

.wrow-han {
  font-family: var(--font-han);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.wrow-py {
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
}

.wrow-ru {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wrow-state {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
}

.state-dot.is-new { border-color: var(--line-strong); }
.state-dot.is-learning { background: var(--gold); border-color: var(--gold); }
.state-dot.is-known { background: var(--jade); border-color: var(--jade); }
.state-dot.is-mastered { background: var(--cinnabar); border-color: var(--cinnabar); }

/* ---------- list groups ---------- */

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  overflow: hidden;
  box-shadow: var(--sh-1);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: transparent;
  transition: background 0.14s;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: var(--surface-2);
}

.list-ico {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--ink-2);
  flex: none;
}

.list-ico.is-cinnabar { background: var(--cinnabar-soft); color: var(--cinnabar); }
.list-ico.is-jade { background: var(--jade-soft); color: var(--jade); }
.list-ico.is-gold { background: var(--gold-soft); color: var(--gold); }
.list-ico.is-azur { background: var(--azur-soft); color: var(--azur); }

.list-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.list-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
}

.list-chev {
  color: var(--ink-3);
  flex: none;
}

/* ---------- options (quiz) ---------- */

.opts {
  display: grid;
  gap: 9px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  text-align: left;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1.5px solid var(--line);
  box-shadow: var(--sh-1);
  transition: border-color 0.16s, background 0.16s, transform 0.12s;
}

.opt:hover {
  border-color: var(--line-strong);
}

.opt:active {
  transform: scale(0.995);
}

.opt-key {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  flex: none;
}

.opt-body {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
}

.opt-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
  font-weight: 500;
}

.opt.is-selected {
  border-color: var(--cinnabar);
  background: var(--cinnabar-soft);
}

.opt.is-selected .opt-key {
  background: var(--cinnabar);
  color: #fff;
}

.opt.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.opt.is-correct .opt-key {
  background: var(--ok);
  color: #fff;
}

.opt.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.opt.is-wrong .opt-key {
  background: var(--danger);
  color: #fff;
}

.opt[disabled] {
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- feedback ---------- */

.feedback {
  display: flex;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--r-m);
  font-size: 13px;
  line-height: 1.5;
  animation: fb-in 0.24s ease-out;
}

@keyframes fb-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.feedback-sym {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
  font-weight: 900;
  font-size: 13px;
}

.feedback.is-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.feedback.is-ok .feedback-sym {
  background: var(--ok);
  color: #fff;
}

.feedback.is-no {
  background: var(--danger-soft);
  color: var(--danger);
}

.feedback.is-no .feedback-sym {
  background: var(--danger);
  color: #fff;
}

.feedback strong {
  display: block;
  color: inherit;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.feedback p {
  color: var(--ink-2);
  margin-top: 3px;
}

/* ---------- segmented control ---------- */

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-3);
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--cinnabar);
  box-shadow: var(--sh-1);
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-item {
  position: relative;
  padding: 10px 12px 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
  white-space: nowrap;
}

.tab-item.is-active {
  color: var(--cinnabar);
}

.tab-item.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--cinnabar);
}

/* ---------- inputs ---------- */

.field {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1.5px solid var(--line);
  font-size: 15px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.field:focus {
  outline: none;
  border-color: var(--cinnabar);
  box-shadow: 0 0 0 3px var(--cinnabar-soft);
}

.field.is-invalid {
  border-color: var(--danger);
}

.search {
  position: relative;
}

.search .field {
  padding-left: 42px;
  padding-right: 40px;
}

.search-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--ink-3);
}

textarea.field {
  height: auto;
  min-height: 92px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}

/* ---------- dialogue / overlay ---------- */

.dialog-layer,
.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  opacity: 0;
  transition: opacity 0.18s;
}

.dialog-layer.is-open,
.sheet-layer.is-open {
  opacity: 1;
}

.dialog-backdrop,
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 22, 12, 0.42);
  backdrop-filter: blur(2px);
}

.dialog-card {
  position: relative;
  margin: auto;
  width: min(360px, calc(100vw - 44px));
  padding: 20px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-3);
  transform: scale(0.96);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.dialog-layer.is-open .dialog-card {
  transform: none;
}

.dialog-card h3 {
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.dialog-card p {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

.dialog-field {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}

.dialog-input {
  width: 100%;
  height: 44px;
  margin-top: 6px;
  padding: 0 12px;
  border-radius: var(--r-s);
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-size: 15px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.bottom-sheet {
  position: relative;
  margin-top: auto;
  width: 100%;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 18px calc(18px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--sh-3);
  transform: translateY(18px);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.sheet-layer.is-open .bottom-sheet {
  transform: none;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line-strong);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
}

.sheet-head h3 {
  font-size: 16px;
  font-weight: 800;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- toast ---------- */

.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-space) + 14px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 18px;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(440px, 100%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(33, 29, 24, 0.92);
  color: #f7f1e6;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sh-2);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-show {
  opacity: 1;
  transform: none;
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e0a24a;
}

.toast-success .toast-dot {
  background: #6fbf9c;
}

.toast-error .toast-dot {
  background: #e0705f;
}

/* ---------- empty / skeleton ---------- */

.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
}

.empty-ico {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-3);
}

.empty h3 {
  font-size: 15px;
  font-weight: 800;
}

.empty p {
  font-size: 12.5px;
  color: var(--ink-3);
  max-width: 260px;
  line-height: 1.5;
}

.skeleton {
  border-radius: var(--r-m);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}

/* ---------- audio button ---------- */

.audio-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-2);
  flex: none;
  transition: transform 0.16s, background 0.16s, color 0.16s;
}

.audio-btn:hover {
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
}

.audio-btn:active {
  transform: scale(0.92);
}

.audio-btn.is-solid {
  background: linear-gradient(160deg, #c34434, var(--cinnabar));
  color: #fff;
  box-shadow: 0 6px 16px rgba(184, 56, 43, 0.28);
}

.audio-btn.is-playing {
  animation: audio-pulse 1.1s ease-in-out infinite;
}

@keyframes audio-pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(184, 56, 43, 0.16);
  }
}

/* ---------- session shell ---------- */

.session {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
}

.session-head {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.session-head-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-bar {
  margin-top: 10px;
}

.session-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.session-main {
  flex: 1;
  padding: 8px 16px 16px;
}

.session-foot {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 32%);
}

.quiz-card {
  padding: 18px;
  border-radius: var(--r-l);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
  animation: page-in 0.24s ease-out;
}

.quiz-kind {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.quiz-prompt {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.5;
}

.quiz-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 0 12px;
}

/* ---------- word detail ---------- */

.word-hero {
  padding: 20px 18px 18px;
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 100% at 100% 0%, var(--cinnabar-soft), transparent 62%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-2);
}

.word-hero-han {
  font-family: var(--font-han);
  font-size: 46px;
  line-height: 1.12;
  letter-spacing: 0.06em;
  word-break: break-word;
}

.word-hero-py {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 600;
}

.word-hero-ru {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.char-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.char-strip::-webkit-scrollbar {
  display: none;
}

.char-cell {
  display: grid;
  place-items: center;
  gap: 2px;
  min-width: 58px;
  padding: 8px 6px;
  border-radius: var(--r-s);
  background: var(--surface);
  border: 1px solid var(--line);
  flex: none;
}

.char-cell .han {
  font-size: 26px;
  line-height: 1.1;
}

.char-cell small {
  font-size: 10.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.example-box {
  padding: 14px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.example-zh {
  font-family: var(--font-han);
  font-size: 18px;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.example-py {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 600;
}

.example-ru {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ---------- stroke stage ---------- */

.stroke-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 300px;
  margin: 0 auto;
  border-radius: var(--r-l);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 50% 50%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 50% 50%,
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}

.stroke-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stroke-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.stroke-pip {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background 0.2s;
}

.stroke-pip.is-done {
  background: var(--cinnabar);
}

.pad {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 320px;
  margin: 0 auto;
  border-radius: var(--r-l);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 50% 50%,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 50% 50%,
    var(--surface);
  border: 1px solid var(--line);
  touch-action: none;
  overflow: hidden;
}

.pad canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 2;
  touch-action: none;
}

.pad-ghost {
  position: absolute;
  inset: 0;
  z-index: 1;
  user-select: none;
  pointer-events: none;
  overflow: hidden;
}

.pad-ghost .trace-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.pad-ghost .trace-outline path {
  fill: rgba(184, 56, 43, 0.08);
  stroke: var(--cinnabar-line);
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.pad-ghost .trace-median {
  fill: none;
  stroke: var(--cinnabar-line);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26 24;
  opacity: 0.55;
}

.pad-ghost-text {
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--font-han);
  font-size: 190px;
  line-height: 1;
  color: var(--line);
}

/* ---------- tone plot ---------- */

.tone-plot {
  width: 100%;
  height: 96px;
  border-radius: var(--r-m);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.tone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1px solid var(--line);
}

.tone-badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  flex: none;
  background: var(--surface-3);
  color: var(--ink-2);
}

.tone-badge.is-ok { background: var(--ok); color: #fff; }
.tone-badge.is-bad { background: var(--danger); color: #fff; }
.tone-badge.is-mid { background: var(--gold); color: #fff; }

.rec-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(160deg, #c34434, var(--cinnabar));
  color: #fff;
  box-shadow: 0 10px 26px rgba(184, 56, 43, 0.32);
  transition: transform 0.16s;
}

.rec-btn:active {
  transform: scale(0.95);
}

.rec-btn.is-recording {
  animation: rec-pulse 1.4s ease-in-out infinite;
}

@keyframes rec-pulse {
  50% {
    box-shadow: 0 0 0 14px rgba(184, 56, 43, 0.14);
  }
}

/* ---------- radar ---------- */

.radar-wrap {
  display: grid;
  place-items: center;
  padding: 6px;
}

.radar-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.radar-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
}

.radar-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
}

/* ---------- heatmap ---------- */

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 2.5px;
  background: var(--surface-3);
}

.heat-cell.l1 { background: #f0d6cd; }
.heat-cell.l2 { background: #e0a595; }
.heat-cell.l3 { background: #cd7561; }
.heat-cell.l4 { background: var(--cinnabar); }

[data-theme="dark"] .heat-cell.l1 { background: #3a2320; }
[data-theme="dark"] .heat-cell.l2 { background: #5c2f28; }
[data-theme="dark"] .heat-cell.l3 { background: #8b3f33; }
[data-theme="dark"] .heat-cell.l4 { background: var(--cinnabar); }

/* ---------- level ladder ---------- */

.ladder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ladder-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  transition: border-color 0.16s, transform 0.14s, box-shadow 0.18s;
}

.ladder-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--sh-2);
}

.ladder-row:active {
  transform: scale(0.995);
}

.ladder-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 900;
  flex: none;
  letter-spacing: -0.02em;
}

.ladder-main {
  flex: 1;
  min-width: 0;
}

.ladder-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
}

.ladder-title .han {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
}

.ladder-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.ladder-row.is-locked {
  opacity: 0.55;
}

/* ---------- skill tiles ---------- */

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.skill-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: var(--r-l);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  text-align: left;
  overflow: hidden;
  transition: transform 0.14s, box-shadow 0.18s;
}

.skill-tile:active {
  transform: scale(0.985);
}

.skill-tile:hover {
  box-shadow: var(--sh-2);
}

.skill-han {
  position: absolute;
  right: -8px;
  bottom: -18px;
  font-family: var(--font-han);
  font-size: 68px;
  line-height: 1;
  color: var(--ink);
  opacity: 0.045;
  pointer-events: none;
}

.skill-ico {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
}

.skill-name {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.skill-desc {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.4;
}

/* ---------- passage ---------- */

.passage {
  font-family: var(--font-han);
  font-size: 18px;
  line-height: 2;
  letter-spacing: 0.03em;
  color: var(--ink);
}

.passage em {
  font-style: normal;
  border-bottom: 2px solid var(--cinnabar-line);
  background: linear-gradient(180deg, transparent 62%, var(--cinnabar-soft) 62%);
}

.passage-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ruby {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  margin: 0 1px;
}

.ruby rt {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0;
}

/* ---------- exam ---------- */

.exam-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 12.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.exam-timer.is-urgent {
  background: var(--danger-soft);
  color: var(--danger);
  animation: timer-blink 1s steps(2, end) infinite;
}

@keyframes timer-blink {
  50% {
    opacity: 0.55;
  }
}

.qmap {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.qmap-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--surface-3);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-3);
}

.qmap-cell.is-answered {
  background: var(--jade-soft);
  color: var(--jade);
}

.qmap-cell.is-flagged {
  background: var(--gold-soft);
  color: var(--gold);
}

.qmap-cell.is-current {
  outline: 2px solid var(--cinnabar);
  outline-offset: 1px;
  color: var(--cinnabar);
}

/* ---------- score dial ---------- */

.score-dial {
  position: relative;
  display: grid;
  place-items: center;
  padding: 8px;
}

.score-value {
  position: absolute;
  text-align: center;
}

.score-value strong {
  display: block;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

.score-value span {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 110;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 7px;
  height: 11px;
  border-radius: 1.5px;
  animation: confetti-fall 1.5s cubic-bezier(0.3, 0.6, 0.6, 1) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(96vh) rotate(560deg);
    opacity: 0;
  }
}

/* ---------- celebrate ---------- */

.celebrate {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 30px 18px 24px;
  text-align: center;
}

.celebrate-medal {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #f6dca0, var(--gold));
  color: #fff;
  font-size: 34px;
  box-shadow: 0 12px 30px rgba(169, 130, 47, 0.34);
}

/* ---------- misc ---------- */

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.hr-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hr-dots::before,
.hr-dots::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.scroll-x {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 6px;
  margin: 0 -16px;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.scroll-x::-webkit-scrollbar {
  display: none;
}

.scroll-x > * {
  scroll-snap-align: start;
  flex: none;
}

.fatal {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 70dvh;
  padding: 30px;
  text-align: center;
}

.fatal h1 {
  font-size: 18px;
  font-weight: 800;
}

.fatal p {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 320px;
}

.fab {
  position: fixed;
  right: max(16px, calc(50vw - var(--maxw) / 2 + 16px));
  bottom: calc(var(--tab-space) + 14px);
  z-index: 30;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(160deg, #c34434, var(--cinnabar));
  color: #fff;
  box-shadow: 0 10px 26px rgba(184, 56, 43, 0.34);
}

.boot-splash {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 100dvh;
  text-align: center;
}

.boot-splash strong {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.boot-splash small {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.boot-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--cinnabar);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- onboarding ---------- */

.onboard {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 18px) 22px calc(22px + var(--safe-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, var(--cinnabar-soft), transparent 62%),
    var(--bg);
}

.onboard-art {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 240px;
}

.onboard-han {
  font-family: var(--font-han);
  font-size: 118px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--cinnabar);
  text-shadow: 0 18px 40px rgba(184, 56, 43, 0.16);
}

.onboard h1 {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.onboard p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
}

.onboard-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 22px 0 16px;
}

.onboard-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: width 0.24s, background 0.24s;
}

.onboard-dot.is-active {
  width: 20px;
  border-radius: 3px;
  background: var(--cinnabar);
}

/* ---------- welcome / auth ---------- */

.welcome {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 40px) 24px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(110% 70% at 50% 0%, var(--cinnabar-soft), transparent 60%),
    var(--bg);
}

.welcome-brand {
  display: grid;
  place-items: center;
  gap: 14px;
  text-align: center;
  padding: 20px 0 6px;
}

.welcome-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: linear-gradient(150deg, #c34434, var(--cinnabar-deep));
  color: #fff;
  font-family: var(--font-han);
  font-size: 38px;
  box-shadow: 0 16px 36px rgba(143, 42, 32, 0.3);
}

.welcome h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.welcome-sub {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 300px;
  text-align: center;
  line-height: 1.6;
}

/* ---------- placement ---------- */

.placement-scale {
  display: grid;
  gap: 7px;
}

.placement-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-s);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
}

.placement-step.is-hit {
  border-color: var(--cinnabar);
  background: var(--cinnabar-soft);
}

.placement-step b {
  width: 30px;
  font-weight: 900;
}

/* ---------- plan ---------- */

.plan-day {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.plan-day:last-child {
  border-bottom: 0;
}

.plan-day-no {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-2);
  flex: none;
}

.plan-day.is-today .plan-day-no {
  background: var(--cinnabar);
  color: #fff;
}

.plan-day.is-done .plan-day-no {
  background: var(--ok-soft);
  color: var(--ok);
}

/* ---------- achievements ---------- */

.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ach {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.ach.is-locked {
  opacity: 0.5;
  filter: grayscale(1);
}

.ach-ico {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 18px;
}

.ach-name {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.ach-bar {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.ach-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
}

/* ---------- notebook ---------- */

.nb-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.nb-row:last-child {
  border-bottom: 0;
}

.nb-main {
  flex: 1;
  min-width: 0;
}

.nb-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.nb-wrong {
  font-size: 11.5px;
  color: var(--cinnabar);
  margin-top: 3px;
  font-weight: 600;
}

/* ---------- writing builder ---------- */

.builder {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 62px;
  padding: 10px;
  border-radius: var(--r-m);
  border: 1.5px dashed var(--line-strong);
  background: var(--surface-2);
}

.builder.is-filled {
  border-style: solid;
}

.token {
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--sh-1);
  font-family: var(--font-han);
  font-size: 16px;
  font-weight: 500;
  transition: transform 0.12s, opacity 0.16s;
}

.token:active {
  transform: scale(0.95);
}

.token.is-placed {
  background: var(--cinnabar-soft);
  border-color: var(--cinnabar-line);
}

.token-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- responsive ---------- */

@media (max-width: 360px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .word-hero-han { font-size: 38px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 2px;
  border-radius: 6px;
}

.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;
}

/* ---------- switch ---------- */

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  flex: none;
  transition: background 0.18s, border-color 0.18s;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.switch.is-on {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
}

.switch.is-on span {
  transform: translateX(18px);
  background: #fff;
}

.hidden {
  display: none;
}

/* ---------- stroke rendering ---------- */

.strokes-ink .strokes-outline {
  fill: var(--ink);
  stroke: none;
}

.strokes-brush {
  fill: none;
  stroke: var(--ink);
  stroke-width: 74;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.strokes-ghost path {
  fill: var(--line);
  opacity: 0.55;
}

.icon {
  display: block;
  flex: none;
}

/* ---------- avatar ---------- */

.avatar {
  font-family: var(--font-han);
  line-height: 1;
}

/* ---------- reading ruby ---------- */

ruby {
  ruby-position: over;
}
