:root {
  --bg: #f5f6f8;
  --bg-grad: radial-gradient(1200px 600px at 50% -200px, #eef1ff 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6e8ee;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --ok-line: #a7f3d0;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --bad-line: #fecaca;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e16;
    --bg-grad: radial-gradient(1200px 600px at 50% -200px, #161c33 0%, transparent 60%);
    --surface: #121826;
    --surface-2: #0f1420;
    --ink: #e8ecf3;
    --muted: #93a0b4;
    --line: #232b3b;
    --accent: #6366f1;
    --accent-hover: #7c7ff5;
    --accent-soft: #1b2140;
    --accent-ink: #ffffff;
    --ok: #34d399;
    --ok-soft: #0e2a22;
    --ok-line: #1c4d3e;
    --bad: #f87171;
    --bad-soft: #2a1414;
    --bad-line: #5b2323;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ring: 0 0 0 3px rgba(99, 102, 241, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-repeat: no-repeat;
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  color: #fff; font-size: 15px; font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.brand h1 { font-size: 17px; margin: 0; }

.shell { max-width: 720px; margin: 0 auto; padding: 28px 20px 72px; }
.shell--center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 16px; }

h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

/* buttons */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* inputs */
.input, .select {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }

/* stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  text-align: center;
}
.stat b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat--accent b { color: var(--accent); }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
.chip--accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* prompt */
.prompt {
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 6px 0 22px;
  word-break: break-word;
}
.prompt--zh { font-size: clamp(24px, 5vw, 34px); }

/* dictionary link */
.dict-row { margin: -14px 0 20px; }
.dict-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  transition: border-color 0.15s, background 0.15s;
}
.dict-link:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--accent-soft); }
.dict-link:focus-visible { outline: none; box-shadow: var(--ring); }
.dict-link__arrow { font-size: 11px; opacity: 0.75; }
.feedback .fb-ans .dict-link { margin-left: 8px; vertical-align: middle; }

/* recently studied (gloss hidden until clicked) */
.recall { display: grid; }
.recall-item {
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.recall-item:first-child { border-top: 0; }
.recall-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.recall-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.recall-word {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-bottom: 2px dotted color-mix(in srgb, var(--accent) 40%, var(--line));
  transition: color 0.15s, border-color 0.15s;
}
.recall-word:hover { color: var(--accent); border-bottom-color: var(--accent); }
.recall-word:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.recall-item.is-open .recall-word { color: var(--accent); border-bottom-color: transparent; }
.recall-phon { font-size: 13px; color: var(--muted); }
.recall-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.recent-time { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.recall-gloss {
  position: relative;
  margin-top: 8px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.55;
  overflow: hidden;
}
.recall-item:not(.is-open) .recall-gloss { cursor: pointer; user-select: none; }
.recall-item:not(.is-open) .recall-gloss-text { visibility: hidden; }
.recall-item:not(.is-open) .recall-gloss::after {
  content: "点击显示释义";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

/* word list / search */
.wordlist { display: grid; }
.word-row {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.word-row:first-child { border-top: 0; }
.word-row__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.word-row__word {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--ink);
  text-decoration: none;
}
.word-row__word:hover { color: var(--accent); }
.word-row__word .dict-link__arrow { font-size: 11px; opacity: 0.55; margin-left: 2px; }
.word-row__gloss { position: relative; font-size: 13.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.word-slot { position: relative; display: inline-flex; align-items: center; }

/* masked fields in the word list: covered until the row is clicked */
.cover {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  white-space: nowrap;
  cursor: pointer;
}
.cover:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.word-row.mask-en:not(.is-revealed) .word-slot { min-width: 78px; }
.word-row.mask-en:not(.is-revealed) .word-row__word { visibility: hidden; }
.word-row.mask-en:not(.is-revealed) .recall-phon { visibility: hidden; }
.word-row.mask-en:not(.is-revealed) .cover--word { display: flex; }
.word-row.mask-zh:not(.is-revealed) .word-row__gloss-text { visibility: hidden; }
.word-row.mask-zh:not(.is-revealed) .cover--gloss { display: flex; }
.word-row__action { margin-left: auto; }
.btn--sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.list-toggle.is-in {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
}

/* options */
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.option + .option { margin-top: 10px; }
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--surface-2); }
.option:active { transform: translateY(1px); }
.option:focus-visible { outline: none; box-shadow: var(--ring); }
.option .key {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.option.is-correct { border-color: var(--ok-line); background: var(--ok-soft); }
.option.is-wrong { border-color: var(--bad-line); background: var(--bad-soft); }
.option:disabled { cursor: default; opacity: 1; }
.option:disabled:hover { background: var(--surface); border-color: var(--line); }
.option.is-correct:disabled:hover { background: var(--ok-soft); }
.option.is-wrong:disabled:hover { background: var(--bad-soft); }

/* self-assessment reveal */
.reveal {
  font-size: clamp(20px, 4.5vw, 26px);
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: -0.01em;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade { width: 100%; padding: 14px 8px; }
.grade--ok { border-color: var(--ok-line); color: var(--ok); }
.grade--ok:hover { background: var(--ok-soft); border-color: var(--ok); }
.grade--mid { color: var(--ink); }
.grade--mid:hover { background: var(--surface-2); }
.grade--bad { border-color: var(--bad-line); color: var(--bad); }
.grade--bad:hover { background: var(--bad-soft); border-color: var(--bad); }

/* feedback */
.feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.feedback.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.feedback.bad { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.feedback .fb-head { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.feedback .fb-ans { color: var(--ink); margin-top: 6px; }
.feedback .fb-ans b { font-weight: 750; }
.feedback .fb-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.feedback .row { margin-top: 12px; }
.override { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin-top: 10px; }
.override input { width: 16px; height: 16px; accent-color: var(--accent); }

/* views */
.view { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.view:first-child { border-top: 0; padding-top: 0; }
.view .view-label { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.view h1, .view h2, .view h3 { font-size: 16px; margin: 10px 0 8px; }
.view table { border-collapse: collapse; width: 100%; font-size: 13.5px; display: block; overflow-x: auto; }
.view th, .view td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; white-space: nowrap; }
.view th { background: var(--surface-2); font-weight: 700; }
.view p { margin: 8px 0; }
.view code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; font-size: 0.9em; }

/* misc */
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.center { text-align: center; }
kbd {
  font: inherit; font-size: 12px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; color: var(--muted);
}
