/* 移动端优先样式：单列布局、大点击区、适配刘海屏 */

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7685;
  --line: #e3e8ef;
  --math: #2f6df6;
  --math-soft: #eaf1fe;
  --sci: #12a06a;
  --sci-soft: #e6f7f0;
  --accent: #2f6df6;        /* 由 app.js 按学科切换：数学蓝 / 科学绿 */
  --ok: #17924b;
  --ok-soft: #e7f7ee;
  --bad: #d13c3c;
  --bad-soft: #fdeaea;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

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

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(20, 32, 55, .06);
}

/* ---------- 屏幕切换 ---------- */
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }

.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

/* ---------- 首页 ---------- */
.home-inner { padding: 36px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; flex: 1; }
.home-head { text-align: center; margin-bottom: 28px; }
.home-head h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: 1px; }
.home-head p { margin: 0; color: var(--muted); font-size: 14px; }

.subject-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 20px 18px;
  margin-bottom: 14px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  text-align: left;
  transition: transform .12s, box-shadow .12s;
}
.subject-card:active { transform: scale(.985); }
.sc-icon {
  flex: 0 0 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  font-size: 15px; font-weight: 700;
  color: #fff;
}
.subject-card.math .sc-icon { background: var(--math); }
.subject-card.sci .sc-icon { background: var(--sci); }
.subject-card.math { border-color: #cfe0fd; }
.subject-card.sci { border-color: #c6ecdb; }
.sc-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sc-body b { font-size: 18px; }
.sc-body em { font-style: normal; font-size: 13px; color: var(--muted); }
.sc-arrow { font-size: 24px; color: #c3ccd8; }

.home-foot { margin-top: auto; padding-top: 24px; text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.9; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { flex: 1; text-align: center; font-size: 17px; margin: 0; font-weight: 600; }
.topbar-pad { width: 64px; }
.icon-btn {
  min-height: 40px; padding: 6px 10px;
  border: 0; background: transparent;
  color: var(--accent); font-size: 15px;
  border-radius: 8px;
}
.icon-btn:active { background: #f0f3f8; }

.prog { flex: 1; height: 6px; background: #edf0f4; border-radius: 3px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .2s; }
.count { font-size: 13px; color: var(--muted); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 科目页 ---------- */
.mode-card {
  display: flex; flex-direction: column; gap: 4px;
  width: 100%; text-align: left;
  padding: 18px;
  margin-bottom: 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 17px; font-weight: 600;
  color: var(--ink);
}
.mode-card em { font-style: normal; font-size: 13px; font-weight: 400; color: var(--muted); }
.mode-card:active { background: #f7f9fc; border-color: #c8d6e8; }

.subject-stats {
  margin: 4px 0 18px;
  padding: 12px 16px;
  background: #f7f9fc;
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--muted);
  display: flex; justify-content: space-between; gap: 12px;
}
.subject-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- 答题 ---------- */
.q-meta {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px; color: var(--muted);
}
.q-tag {
  background: #eef2f8; color: #4a5a6e;
  padding: 2px 9px; border-radius: 20px;
}
/* 难度系数 = 平均得分 / 满分，数值越小越难 */
.q-diff {
  background: #fff4e5; color: #8a5a00;
  padding: 2px 9px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
.q-stem {
  font-size: 17px; line-height: 1.75;
  margin-bottom: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; min-height: 54px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 16px; line-height: 1.5;
  text-align: left; color: var(--ink);
  transition: background .12s, border-color .12s;
}
.opt .tag {
  flex: 0 0 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: #f0f3f8; color: #67758a;
  font-size: 13px; font-weight: 700;
}
.opt:active { background: #f7f9fc; }
.opt.picked { border-color: var(--accent); background: var(--math-soft); }
.opt.picked .tag { background: var(--accent); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .tag { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .tag { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }

/* 填空作答 */
.blanks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 6px; }
.blank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.blank-row .lbl { flex: 0 0 auto; font-size: 14px; color: var(--muted); min-width: 56px; }
.blank-row input {
  flex: 1; min-width: 0;
  border: 0; outline: none;
  font-size: 17px;            /* 16px 以上，iOS 才不会自动放大 */
  padding: 4px 0;
  background: transparent;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.blank-row .unit { color: var(--muted); font-size: 15px; }
.blank-row.filled { border-color: var(--accent); background: #fbfcff; }
.blank-row.right { border-color: var(--ok); background: var(--ok-soft); }
.blank-row.wrong { border-color: var(--bad); background: var(--bad-soft); }

.input-tip { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.7; }

/* 反馈与解析 */
.fb {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
}
.fb.ok { background: var(--ok-soft); color: var(--ok); }
.fb.bad { background: var(--bad-soft); color: var(--bad); }
.exp {
  margin-top: 10px;
  padding: 14px;
  background: #f7f9fc;
  border-radius: 12px;
  font-size: 14.5px; line-height: 1.8;
  color: #37414f;
  white-space: pre-wrap;
}
.exp b { color: var(--ink); }

/* 底部操作条 */
.actions {
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: #fff;
}
.btn {
  flex: 1;
  min-height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px; color: var(--ink);
  transition: background .12s;
}
.btn:active:not(:disabled) { background: #f3f6fa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:active { background: #2559d0; }
.btn:disabled { opacity: .4; }

/* ---------- 成绩页 ---------- */
.score-hero { text-align: center; padding: 24px 0 16px; }
.score-hero .num { font-size: 52px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score-hero .num small { font-size: 20px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.score-hero .cap { margin-top: 10px; font-size: 14px; color: var(--muted); }
.score-hero .num.pass { color: var(--ok); }
.score-hero .num.fail { color: var(--bad); }

.stat-grid { display: flex; gap: 10px; margin-bottom: 18px; }
.stat-cell { flex: 1; background: #f7f9fc; border-radius: 12px; padding: 12px; text-align: center; }
.stat-cell b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat-cell span { font-size: 12px; color: var(--muted); }

.review-item {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.review-item.bad { border-color: #f0cdcd; }
.review-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.review-head .no { font-weight: 700; color: var(--ink); }
.review-stem { font-size: 15px; line-height: 1.7; margin-bottom: 10px; }
.review-line { font-size: 14px; margin: 4px 0; }
.review-line .k { color: var(--muted); }
.review-line.mine { color: var(--bad); }
.review-line.right { color: var(--ok); }
.review-exp {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 14px; line-height: 1.8; color: #37414f;
  white-space: pre-wrap;
}

.empty-tip { text-align: center; color: var(--muted); font-size: 14px; padding: 30px 0; }

/* ---------- 掌握报告 ---------- */
.rtabs {
  display: flex; gap: 8px;
  padding: 10px 16px 0;
  background: #fff;
}
.rtab {
  flex: 1;
  min-height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  color: var(--muted);
}
.rtab.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.donut { width: 150px; height: 150px; flex: 0 0 150px; }
.donut-num { font-size: 22px; font-weight: 700; fill: var(--ink); }
.donut-cap { font-size: 10px; fill: var(--muted); }

.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.lg-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.lg-row i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.lg-name { flex: 1; color: #37414f; }
.lg-num { color: var(--muted); font-variant-numeric: tabular-nums; }

.donut-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.cat-row { margin-bottom: 13px; }
.cat-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; margin-bottom: 5px;
}
.cat-name { color: var(--ink); }
.cat-num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.cat-bar {
  height: 7px; background: #eef2f7; border-radius: 4px; overflow: hidden;
}
.cat-bar > i {
  display: block; height: 100%; border-radius: 4px;
  transition: width .3s;
  min-width: 0;
}