:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2f5fe0;
  --brand-soft: #e8eefc;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6;
  min-height: 100vh;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px 14px calc(30px + env(safe-area-inset-bottom)); }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- common ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); border: 1px solid var(--line); }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 16px; font-size: .95rem;
  cursor: pointer; background: var(--brand); color: #fff; min-height: 42px;
  transition: opacity .15s; font-family: inherit;
}
.btn:active { opacity: .8; }
.btn.full { width: 100%; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.plain { background: #f1f3f7; color: var(--ink); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: .82rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 140px; resize: vertical; line-height: 1.7; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 5px; }
.err { color: var(--red); font-size: .85rem; min-height: 20px; margin: 4px 0; }
.ok { color: var(--green); font-size: .85rem; }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 1px 8px; font-size: .78rem; margin-right: 6px; }
.tag.gray { background: #f1f3f7; color: var(--muted); }
.tag.green { background: #e7f6ec; color: var(--green); }
.tag.red { background: #fdeaea; color: var(--red); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.back-btn { background: none; border: none; color: var(--brand); font-size: 1rem; cursor: pointer; padding: 6px 4px; font-family: inherit; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  flex: 1; border: none; background: none; padding: 9px 6px; border-radius: 9px; font-size: .9rem;
  cursor: pointer; color: var(--muted); white-space: nowrap; font-family: inherit; min-height: 40px;
}
.tabs button.on { background: var(--brand); color: #fff; font-weight: 600; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 26px 16px 10px; }
.hero .logo { font-size: 2.4rem; }
.hero p { color: var(--muted); margin-top: 4px; font-size: .9rem; }
.module-card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.06); transition: transform .12s; font-family: inherit; }
.module-card:active { transform: scale(.985); }
.module-card .mc-head { display: flex; align-items: center; gap: 12px; }
.module-card .mc-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.module-card h3 { font-size: 1.05rem; }
.module-card .mc-desc { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.stats { display: flex; gap: 10px; margin: 16px 0; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { font-size: 1.3rem; color: var(--brand); display: block; }
.stat span { font-size: .78rem; color: var(--muted); }

/* ---------- quiz ---------- */
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.q-progress { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.q-title { font-size: 1.08rem; font-weight: 600; margin-bottom: 8px; }
.q-hint { background: #fffbeb; border: 1px dashed #f0d48a; color: #92600a; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: .9rem; }
.q-ansbox { border-radius: 10px; }
.ans-line { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: .95rem; }
.ans-line.hit { background: #e7f6ec; }
.ans-line.miss { background: #fdeaea; }
.ans-line .sim { color: var(--muted); font-size: .78rem; margin-left: 6px; }
.selfcheck { display: flex; gap: 10px; margin-top: 12px; }
.selfcheck .btn { flex: 1; }
.result-hero { text-align: center; padding: 30px 10px; }
.result-hero .big { font-size: 2.6rem; font-weight: 700; color: var(--brand); }
.progress-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 14px; }
.progress-bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width .2s; }

/* ---------- recite ---------- */
.recite-ans { background: var(--brand-soft); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.recite-ans li { margin: 6px 0 6px 18px; font-size: .97rem; }
.recite-actions { display: flex; gap: 10px; margin-top: 16px; }
.recite-actions .btn { flex: 1; }

/* ---------- wrong book ---------- */
.wq-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.wq-item.closed { opacity: .55; background: #f7f8fa; }
.wq-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.wq-q { font-size: .95rem; margin: 6px 0; }
.wq-ops { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 12px; cursor: pointer; }
.switch input { width: 18px; min-height: 18px; height: 18px; }

/* ---------- auth ---------- */
.auth-wrap { max-width: 400px; margin: 30px auto 0; }
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero .logo { font-size: 2.6rem; }
.otp-row { display: flex; gap: 8px; }
.otp-row .btn { flex-shrink: 0; white-space: nowrap; }
.mode-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
.mode-toggle button { flex: 1; }
.notice { background: #f0f6ff; border: 1px solid #cfe0fb; color: #2a4d9b; border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin-bottom: 12px; }

@media (max-width: 480px) {
  html { font-size: 15px; }
  .card { padding: 14px; }
  .stats { gap: 8px; }
}
