:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #185fa5;
  --brand-ink: #0c447c;
  --ok: #2e7d32;
  --ok-bg: #e8f5e9;
  --bad: #c62828;
  --bad-bg: #fdecea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
}

.brand { font-weight: 600; color: var(--brand-ink); font-size: 16px; }

#nav { display: flex; gap: 16px; }
#nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  position: relative;
}
#nav a:hover { color: var(--brand); }

.badge {
  display: none;
  margin-left: 4px;
  background: var(--bad);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 0 6px;
  vertical-align: middle;
}

main { max-width: 720px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.qmeta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.stem { font-size: 15px; line-height: 1.6; white-space: pre-wrap; margin: 6px 0; }
.qtext { font-size: 15px; line-height: 1.6; white-space: pre-wrap; margin: 6px 0 12px; }

.qimg {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #f0f0f0;
  border-radius: 8px;
  margin: 8px 0;
}

.option {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 8px 0;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}
.option:active { background: #f0f6ff; }
.option.sel { border-color: var(--brand); background: #f0f6ff; }
.option.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row.end { justify-content: flex-end; }

.btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 15px;
  cursor: pointer;
}
.btn.ghost { background: #fff; color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.expl {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.expl[hidden] { display: none; }

select, input[type=text] {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  margin: 6px 0;
}

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.center { text-align: center; padding: 40px 10px; color: var(--muted); }

/* ---------- 页面标题 ---------- */
.pagetitle { font-size: 20px; color: var(--brand-ink); margin: 4px 0 2px; }
.pagesub { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ---------- 目录（6 大类 → 小类） ---------- */
.catlist { display: flex; flex-direction: column; gap: 10px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.cat-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.cat-title { font-size: 16px; font-weight: 600; color: var(--ink); flex: 1; }
.cat-count { font-size: 12px; color: var(--ok); }
.cat-count:empty { display: none; }
.chev { font-size: 16px; color: var(--muted); width: 18px; text-align: center; }

.subs { margin-top: 8px; }
.whole-cat {
  display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer;
  color: var(--brand); font-weight: 500; font-size: 14px;
}
.whole-cat .play { font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.sub-row {
  display: flex; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.sub-row:last-child { border-bottom: none; }
.sub-name { flex: 1; font-size: 15px; color: var(--ink); }
.sub-count { font-size: 12px; color: var(--muted); }
.sub-chev { font-size: 18px; color: var(--muted); }

/* ---------- 做题页 ---------- */
.player-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 0 10px; position: sticky; top: 0;
  background: var(--bg); z-index: 5;
}
.player-head .back { color: var(--brand); text-decoration: none; font-size: 15px; }
.player-head .ptitle { flex: 1; font-size: 16px; font-weight: 600; color: var(--brand-ink); }
.player-head .pact { color: var(--brand); text-decoration: none; font-size: 14px; }

.progress {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); padding: 4px 0 10px; flex-wrap: wrap;
}
.progress .note { color: var(--muted); font-size: 12px; }
.progress .note.ok { color: var(--ok); }
.progress .acc { color: var(--brand); font-size: 12px; font-weight: 600; }
.progress .acc.muted { color: var(--muted); font-weight: 400; }

/* ---------- 重做整章确认弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 30; padding: 24px;
}
.modal-box {
  background: var(--card); border-radius: 14px; padding: 20px; max-width: 320px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.modal-body { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--bad); }

.player-body { padding-bottom: 8px; }

.zh-block {
  background: #eaf1f8; border-radius: 12px; padding: 12px; margin: 6px 0 12px;
}
.zh-line { font-size: 13px; line-height: 1.6; color: #334155; }
.zh-line + .zh-line { margin-top: 6px; }
.hint { font-size: 12px; color: var(--muted); text-align: center; margin: 8px 0 4px; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: 12px 14px; font-size: 15px; color: var(--ink);
  cursor: pointer;
}
.option:active { background: #f0f6ff; }
.option.sel { border-color: var(--brand); background: #f0f6ff; }
.option.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.option.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.opt-letter { font-weight: 700; margin-right: 6px; }
.opt-zh { display: block; font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 6px; }

.imgwrap { margin: 8px 0; }

/* ---------- 解析卡 ---------- */
.expl {
  margin-top: 12px; padding: 12px; background: #eaf1f8; border-radius: 12px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
}
.expl-title { font-weight: 700; color: var(--brand); font-size: 14px; }
.expl-correct { font-weight: 700; color: var(--ok); font-size: 14px; margin: 6px 0; }
.expl-body { color: #334155; }
.expl-zh { color: var(--muted); margin-top: 6px; }

#nav a.active { color: var(--brand); font-weight: 600; }

.payimg {
  width: 220px; height: 220px; object-fit: contain;
  border: 1px dashed var(--line); border-radius: 12px; background: #fafafa;
  display: block; margin: 14px auto;
}

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(31,41,51,.92); color: #fff; padding: 10px 16px;
  border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .2s;
  pointer-events: none; z-index: 20; max-width: 90%;
}
.toast.show { opacity: 1; }

/* ---------- 图片点击放大 ---------- */
.qimg { cursor: pointer; }
.zoom-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.88); z-index: 100;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
  animation: fadeIn .15s;
}
.zoom-img { max-width: 96vw; max-height: 96vh; object-fit: contain; border-radius: 6px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 错题目录分类（红色"错题 X 道"标记） ---------- */
.wrong-catlist .cat-count { color: var(--bad); font-weight: 600; }

/* ---------- 试用介绍页 ---------- */
.trial-feat { padding: 8px 0; font-size: 14px; line-height: 1.7; color: var(--ink); }
.trial-feat b { color: var(--brand); }
