:root {
  --brand: #1e5eff;
  --brand-dark: #1445c4;
  --brand-light: #eaf0ff;
  --text: #1b2230;
  --text-sub: #6b7688;
  --line: #e6eaf2;
  --bg: #f5f7fb;
  --white: #fff;
  --green: #12a150;
  --green-bg: #e9f8ef;
  --red: #e5484d;
  --red-bg: #fdeeee;
  --orange: #f08c00;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(24, 46, 95, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 15px; }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; }

.page { padding: 0 16px 92px; }
.page-noscroll { padding: 0 16px 24px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--white);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-light); color: var(--brand); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.brand-row { display: flex; align-items: center; gap: 8px; flex: 1; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #1e5eff, #4d8bff); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 22px; }
.login-hero { text-align: center; margin-bottom: 26px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: linear-gradient(135deg, #1e5eff, #5b93ff); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px rgba(30, 94, 255, .25); }
.login-hero h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: .5px; }
.login-hero p { margin: 0; color: var(--text-sub); font-size: 13px; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card { padding: 22px 20px 20px; }
.tabs { display: flex; gap: 8px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 9px 0; border-radius: 9px; font-size: 14px; color: var(--text-sub); }
.tabs button.on { background: var(--white); color: var(--brand); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }
.input { width: 100%; height: 46px; border: 1px solid var(--line); background: #fbfcfe; border-radius: 11px; padding: 0 14px; outline: none; transition: .18s; }
.input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(30,94,255,.1); }
.btn { width: 100%; height: 46px; border-radius: 11px; background: var(--brand); color: #fff; font-size: 16px; font-weight: 600; }
.btn:active { background: var(--brand-dark); }
.btn[disabled] { opacity: .55; }
.btn-ghost { background: var(--brand-light); color: var(--brand); }
.btn-sm { height: 34px; width: auto; padding: 0 14px; font-size: 13px; border-radius: 9px; }
.btn-line { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.tip { font-size: 12px; color: var(--text-sub); text-align: center; margin-top: 14px; line-height: 1.7; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.alert-err { background: var(--red-bg); color: var(--red); }
.alert-ok { background: var(--green-bg); color: var(--green); }
.alert-info { background: var(--brand-light); color: var(--brand-dark); }

/* ---------- 激活页 ---------- */
.activate-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 28px 22px; }
.activate-card { padding: 26px 22px; text-align: center; }
.activate-icon { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; background: var(--brand-light); color: var(--brand); font-size: 26px; display: flex; align-items: center; justify-content: center; }
.activate-card h2 { margin: 0 0 8px; font-size: 19px; }
.activate-card p { margin: 0 0 18px; font-size: 13.5px; color: var(--text-sub); line-height: 1.7; }

/* ---------- 首页 ---------- */
.hero { margin: 16px 0 18px; padding: 20px 18px; border-radius: 18px; background: linear-gradient(135deg, #1e5eff, #4a86ff 70%, #6fa5ff); color: #fff; box-shadow: 0 12px 26px rgba(30,94,255,.22); }
.hero .hi { font-size: 15px; opacity: .92; }
.hero .hi b { font-weight: 600; }
.hero .vip { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 4px 10px; border-radius: 20px; background: rgba(255,255,255,.18); font-size: 12px; }
.stat-row { display: flex; margin-top: 16px; background: rgba(255,255,255,.14); border-radius: 12px; padding: 12px 0; }
.stat-row > div { flex: 1; text-align: center; }
.stat-row b { display: block; font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat-row span { font-size: 11.5px; opacity: .82; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.section-title h3 { margin: 0; font-size: 16px; font-weight: 600; }
.section-title small { color: var(--text-sub); font-size: 12px; }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-card { padding: 14px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.cat-card .ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; margin-bottom: 10px; background: var(--brand-light); color: var(--brand); }
.cat-card h4 { margin: 0 0 4px; font-size: 14.5px; font-weight: 600; }
.cat-card p { margin: 0; font-size: 11.5px; color: var(--text-sub); }
.cat-card:active { transform: scale(.987); }

.quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.quick { background: var(--white); border-radius: 12px; padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.quick b { display: block; font-size: 18px; color: var(--brand); }
.quick span { font-size: 12px; color: var(--text-sub); }

/* ---------- 章节列表 ---------- */
.chapter-item { background: var(--white); border-radius: 13px; padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.chapter-item .row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.chapter-item h4 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.chapter-item .meta { font-size: 12px; color: var(--text-sub); }
.progress-bar { height: 5px; border-radius: 3px; background: #eef1f7; margin-top: 10px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: linear-gradient(90deg, #1e5eff, #6c9bff); border-radius: 3px; }
.chapter-actions { display: flex; gap: 8px; margin-top: 12px; }
.chapter-actions button { flex: 1; height: 36px; border-radius: 9px; font-size: 13.5px; font-weight: 500; }
.chapter-actions .practice { background: var(--brand); color: #fff; }
.chapter-actions .recite { background: var(--brand-light); color: var(--brand); }

/* ---------- 刷题页 ---------- */
.q-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 10px; }
.q-head .no { font-size: 13px; color: var(--text-sub); }
.q-head .kind { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--brand-light); color: var(--brand); }
.q-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.parent-stem { background: #f7f9fd; border-left: 3px solid #cddafc; padding: 10px 12px; border-radius: 8px; font-size: 13.5px; color: #3c4759; margin-bottom: 12px; }
.stem { font-size: 16px; line-height: 1.75; word-break: break-word; }
.stem img, .parent-stem img { max-width: 100%; height: auto; border-radius: 8px; margin: 8px 0; display: block; }
.options { margin-top: 16px; }
.opt { display: flex; gap: 10px; width: 100%; text-align: left; padding: 13px 14px; border: 1px solid var(--line); background: #fbfcfe; border-radius: 11px; margin-bottom: 10px; font-size: 15px; line-height: 1.6; transition: .15s; }
.opt .tag { flex: 0 0 22px; height: 22px; border-radius: 6px; border: 1px solid #cfd8e8; color: #77839a; font-size: 13px; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.opt .txt { flex: 1; word-break: break-word; }
.opt.on { border-color: var(--brand); background: var(--brand-light); }
.opt.on .tag { background: var(--brand); border-color: var(--brand); color: #fff; }
.opt.right { border-color: var(--green); background: var(--green-bg); }
.opt.right .tag { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt.wrong .tag { background: var(--red); border-color: var(--red); color: #fff; }
.result-banner { margin-top: 14px; padding: 12px 14px; border-radius: 11px; font-size: 14px; font-weight: 600; }
.result-banner.ok { background: var(--green-bg); color: var(--green); }
.result-banner.no { background: var(--red-bg); color: var(--red); }
.result-banner.info { background: var(--brand-light); color: var(--brand); }
.answer-box { margin-top: 10px; padding: 12px 14px; background: #f8fafd; border-radius: 11px; font-size: 14px; line-height: 1.75; }
.answer-box .label { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.answer-box .ans { color: var(--green); font-weight: 600; }
.analysis { margin-top: 8px; color: #404b5e; }
.analysis img { max-width: 100%; }
.q-toolbar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; z-index: 30; max-width: 760px; margin: 0 auto; }
.q-toolbar button { flex: 1; height: 44px; border-radius: 11px; font-size: 14.5px; font-weight: 600; }
.q-toolbar .ghost { background: var(--brand-light); color: var(--brand); }
.q-toolbar .primary { background: var(--brand); color: #fff; }
.q-toolbar .primary[disabled] { opacity: .5; }
.q-toolbar .star { flex: 0 0 52px; background: #f2f4f9; color: #9aa4b6; font-size: 18px; }
.q-toolbar .star.on { background: #fff7e6; color: var(--orange); }

.sheet-mask { position: fixed; inset: 0; background: rgba(15,23,38,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 760px; border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 72vh; overflow: auto; }
.sheet h4 { margin: 0 0 14px; font-size: 16px; }
.sheet .grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 9px; }
.sheet .grid button { height: 40px; border-radius: 9px; background: #f2f5fa; color: #45536b; font-size: 14px; }
.sheet .grid button.done { background: var(--green-bg); color: var(--green); }
.sheet .grid button.done.no { background: var(--red-bg); color: var(--red); }
.sheet .grid button.cur { outline: 2px solid var(--brand); color: var(--brand); font-weight: 700; }

/* ---------- 列表页 ---------- */
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 14px; border-radius: 20px; background: #fff; color: var(--text-sub); font-size: 13px; border: 1px solid var(--line); }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.wrong-card { background: #fff; border-radius: 13px; padding: 15px; margin-bottom: 11px; box-shadow: var(--shadow); }
.wrong-card .meta { display: flex; gap: 8px; font-size: 11.5px; color: var(--text-sub); margin-bottom: 8px; flex-wrap: wrap; }
.wrong-card .meta span { background: #f2f5fa; padding: 2px 7px; border-radius: 5px; }
.wrong-card .stem { font-size: 15px; }
.wrong-card .opt-line { font-size: 13.5px; color: #4a566b; margin-top: 2px; }
.empty { text-align: center; padding: 56px 20px; color: var(--text-sub); font-size: 14px; }
.empty .ico { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- 我的 ---------- */
.me-card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.me-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg,#1e5eff,#6b9cff); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.me-head .info b { font-size: 16px; display: block; }
.me-head .info span { font-size: 12px; color: var(--text-sub); }
.list-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-row:last-child { border-bottom: none; }
.list-row .val { color: var(--text-sub); font-size: 13px; }
.menu-row { padding: 15px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.menu-row:last-child { border-bottom: none; }
.menu-row::after { content: '›'; color: #b9c2d2; }

/* ---------- 底部导航 ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); max-width: 760px; margin: 0 auto; }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 7px; font-size: 11.5px; color: #98a2b4; }
.tabbar a .i { display: block; font-size: 19px; line-height: 1.3; }
.tabbar a.on { color: var(--brand); font-weight: 600; }

/* ---------- 管理后台 ---------- */
.admin-tabs { display: flex; gap: 6px; background: #fff; border-radius: 11px; padding: 5px; margin: 14px 0; box-shadow: var(--shadow); }
.admin-tabs button { flex: 1; padding: 8px 0; border-radius: 8px; font-size: 13px; color: var(--text-sub); }
.admin-tabs button.on { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: #fff; border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.kpi b { font-size: 22px; color: var(--brand); display: block; line-height: 1.3; }
.kpi span { font-size: 12px; color: var(--text-sub); }
.admin-list { background: #fff; border-radius: 13px; box-shadow: var(--shadow); overflow: hidden; margin-top: 12px; }
.user-row { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: none; }
.user-row .l1 { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.user-row .name { font-size: 14.5px; font-weight: 600; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.no { background: var(--red-bg); color: var(--red); }
.badge.gray { background: #eef1f6; color: #6b7688; }
.user-row .l2 { font-size: 12px; color: var(--text-sub); margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }
.user-row .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.user-row .acts button { padding: 6px 11px; border-radius: 8px; font-size: 12px; background: #f2f5fa; color: #45536b; }

.card-code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,38,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; width: 100%; max-width: 380px; border-radius: 16px; padding: 20px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .acts { display: flex; gap: 10px; margin-top: 18px; }
.modal .acts button { flex: 1; height: 42px; border-radius: 10px; font-size: 14.5px; }

.toast { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(20,28,42,.9); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: 76vw; text-align: center; }

@media (min-width: 600px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .q-card { padding: 22px; }
}

/* ---------- 模拟考试 ---------- */
.exam-card .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.exam-card h4 { margin: 0 0 4px; font-size: 15.5px; }
.exam-card .meta { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.exam-card .chapter-actions { display: flex; gap: 10px; margin-top: 12px; }
.exam-card .chapter-actions button { flex: 1; height: 38px; border-radius: 9px; font-size: 14px; font-weight: 600; }

.exam-clock { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; font-weight: 700; color: var(--brand); background: var(--brand-light); padding: 3px 10px; border-radius: 8px; }
.exam-clock.danger { color: #fff; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .55; } }

.score-hero { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px; text-align: center; margin-top: 14px; }
.score-hero .label { font-size: 13.5px; color: var(--text-sub); }
.score-hero .score { font-size: 46px; font-weight: 700; line-height: 1.25; color: var(--brand); }
.score-hero .score small { font-size: 16px; color: var(--text-sub); font-weight: 400; }
.score-hero.pass .score { color: var(--green); }
.score-hero.fail .score { color: var(--red); }
.score-hero .badge-line { font-size: 14px; font-weight: 600; margin-top: 4px; }
.score-hero .meta { font-size: 12px; color: var(--text-sub); margin-top: 8px; }

.opt-line { padding: 9px 12px; border-radius: 9px; margin-bottom: 6px; font-size: 14px; line-height: 1.7; background: #fbfcfe; border: 1px solid var(--line); }
.opt-line.right-line { background: var(--green-bg); border-color: #a9e4c0; }
.opt-line.wrong-line { background: var(--red-bg); border-color: #f3b7b9; }

.q-sheet { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; max-height: 60vh; overflow: auto; }
.q-dot { height: 38px; border-radius: 9px; background: #f2f5fa; color: #45536b; font-size: 13.5px; font-weight: 600; }
.q-dot.done { background: var(--brand-light); color: var(--brand); }
.q-dot.cur { outline: 2px solid var(--brand); }
