:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-soft: #f3f1eb;
  --ink: #1e2421;
  --muted: #5c6660;
  --line: #e4e1d8;
  --accent: #b83b2d;
  --accent-dark: #942b20;
  --accent-soft: #fdf0ee;
  --jade: #1e6348;
  --jade-soft: #e7f3ed;
  --warn: #b36b00;
  --warn-soft: #fff6e5;
  --radius: 14px;
  --container: 1120px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 66px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-seal {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  box-shadow: 0 2px 6px rgba(184, 59, 45, 0.24);
}
.nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.nav a:hover, .nav a.active {
  color: var(--ink);
  text-decoration: none;
}

/* Hero */
.hero {
  padding: 56px 0 42px;
  text-align: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
}
.hero h1 {
  margin: 0 auto 14px;
  max-width: 820px;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.hero p.lead {
  margin: 0 auto 26px;
  max-width: 66ch;
  color: var(--muted);
  font-size: 17px;
}
.cta-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-soft); text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.jade {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}
.btn.jade:hover { background: #164c37; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Sections & Cards */
section.block { padding: 34px 0; }
.section-head {
  text-align: center;
  margin-bottom: 26px;
}
.section-head h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 2.8vw, 30px);
  letter-spacing: -0.02em;
}
.section-head p {
  margin: 0 auto;
  max-width: 64ch;
  color: var(--muted);
  font-size: 15px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.prose-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px;
}
.prose-inner {
  max-width: 70ch;
  margin: 0 auto;
}

/* Grids */
.grid-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 16px;
}
.level-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.level-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(30, 36, 33, 0.06);
}
.level-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.level-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent);
}
.level-badge.hsk30 {
  background: var(--jade-soft);
  color: var(--jade);
}
.level-meta { font-size: 12px; color: var(--muted); }
.level-card h3 { margin: 0; font-size: 18px; }
.level-card p { margin: 0; font-size: 14px; color: var(--muted); flex: 1; }
.level-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* FAQ: balanced 2-column grid on desktop, 1 column on mobile */
.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.faq-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.4;
}
.faq-item p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* Breadcrumb & Page Hero */
.page-top {
  padding: 28px 0 20px;
}
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--muted); }
.page-top h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3.6vw, 36px);
  line-height: 1.2;
}
.page-top .sub {
  margin: 0;
  color: var(--muted);
  max-width: 72ch;
}

/* Exam Runner */
.exam-bar {
  position: sticky;
  top: 66px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 4px 16px rgba(30, 36, 33, 0.05);
}
.exam-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 600;
}
.timer {
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--surface-soft);
  font-variant-numeric: tabular-nums;
}
.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.chip-toggle.on {
  background: var(--jade-soft);
  border-color: var(--jade);
  color: var(--jade);
}

.q-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.q-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.q-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}
.q-zh {
  font-size: 20px;
  line-height: 1.6;
  font-weight: 600;
  margin: 6px 0;
}
.q-pinyin {
  font-size: 14px;
  color: var(--jade);
  margin: 0 0 8px;
}
.hide-pinyin .q-pinyin, .hide-pinyin .opt-pinyin, .hide-pinyin .line-pinyin {
  display: none;
}
.hide-trans .line-en {
  display: none;
}
.q-prompt {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 14px;
}
.audio-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-soft);
  border-radius: 10px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}
.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.opt-btn {
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt-btn:hover { border-color: #b7b3a8; background: #fcfbf9; }
.opt-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-btn.correct { border-color: var(--jade); background: var(--jade-soft); }
.opt-btn.wrong { border-color: var(--accent); background: #fde8e6; }
.opt-zh { font-size: 16px; font-weight: 600; display: block; }
.opt-pinyin { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.explain {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 14px;
  border-left: 3px solid var(--jade);
}
.explain.is-wrong { border-left-color: var(--accent); background: var(--accent-soft); }

.result-banner {
  background: var(--surface);
  border: 2px solid var(--jade);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.result-score {
  font-size: 36px;
  font-weight: 800;
  color: var(--jade);
  line-height: 1.1;
}
.result-banner.fail { border-color: var(--accent); }
.result-banner.fail .result-score { color: var(--accent); }

/* Story Reader */
.story-line {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.story-line:last-child { border-bottom: 0; }
.story-line.is-playing { background: var(--jade-soft); border-radius: 10px; }
.line-zh { font-size: 21px; line-height: 1.65; font-weight: 500; }
.line-pinyin { font-size: 14px; color: var(--jade); margin-top: 2px; }
.line-en { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* Vocabulary Table */
.vocab-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.vocab-toolbar input, .vocab-toolbar select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.vocab-toolbar input { flex: 1; min-width: 220px; }
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.vocab-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vocab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vocab-hanzi { font-size: 24px; font-weight: 700; }
.vocab-pinyin { font-size: 14px; color: var(--jade); font-weight: 600; }
.vocab-pos { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface-soft); color: var(--muted); }
.vocab-en { font-size: 14px; font-weight: 600; }
.vocab-ex { font-size: 13px; color: var(--muted); padding-top: 6px; border-top: 1px dashed var(--line); }

/* Footer */
.site-footer {
  margin-top: 56px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 32px 0;
  font-size: 13px;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }

@media (max-width: 820px) {
  .grid-3, .grid-2, .faq-grid, .options { grid-template-columns: 1fr; }
  .hero { padding: 38px 0 28px; }
  .prose-card { padding: 22px 18px; }
}
