:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #8a9099;
  --border: #e6e8eb;
  --primary: #1565c0;
  --primary-d: #0d47a1;
  --ok: #2e7d32;
  --ok-bg: #e8f5e9;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --warn: #ef6c00;
  --chip: #eef2f7;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}
body.night {
  --bg: #15171c;
  --card: #1f2228;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #2c3038;
  --primary: #4f9bff;
  --primary-d: #2f7fe0;
  --ok: #66bb6a;
  --ok-bg: #1d3220;
  --bad: #ef5350;
  --bad-bg: #3a2326;
  --warn: #ffa726;
  --chip: #262a31;
  --shadow: 0 1px 4px rgba(0,0,0,.4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.6;
  padding-bottom: 56px;
}

/* 顶部 */
.hd {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.hd-title { font-size: 15px; font-weight: 700; }
.hd-right { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 14px; cursor: pointer; background: var(--chip); }
.chip.vip-on { background: linear-gradient(90deg,#f9a825,#f57f17); color: #fff; }
.chip.vip-off { color: var(--muted); }
.chip.bank-off { color: var(--primary); border: 1px solid var(--primary); background: transparent; }

/* 题库（工种）选择 */
.bank-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.bank-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: .15s; }
.bank-item:hover { border-color: var(--primary); }
.bank-item.on { border-color: var(--primary); background: var(--chip); box-shadow: 0 0 0 2px var(--primary) inset; }
.bank-name { font-size: 15px; font-weight: 600; }
.bank-sub { font-size: 12px; color: var(--muted); }

/* 导航 */
.nav {
  position: sticky; top: 45px; z-index: 19;
  display: flex; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.nav button {
  flex: 1; border: none; background: none; padding: 11px 0;
  font-size: 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.nav button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.app { max-width: 760px; margin: 0 auto; padding: 12px; }

/* 卡片 */
.card, .wq, .card-in { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-in { margin: 8px 0 0; }

/* 控制条 */
.controls { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.controls .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.controls .row:last-child { margin-bottom: 0; }
.controls label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.controls select, .controls input[type=number], .controls input[type=text] {
  font-size: 14px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text);
}
.chk { cursor: pointer; }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.file { display: inline-block; position: relative; overflow: hidden; }
.btn.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions.wrap { gap: 8px; }

/* 进度/标签 */
.progress { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.qmeta { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--muted); }
.tag.hot { background: #fff3e0; color: #e65100; }
body.night .tag.hot { background: #3a2a17; color: #ffb74d; }
.scenario { background: var(--chip); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.stem { font-size: 16px; font-weight: 600; margin: 6px 0 12px; line-height: 1.7; }

/* 选项 */
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; transition: .15s; background: var(--card);
}
.opt.static { cursor: default; }
.opt .opt-key {
  flex: 0 0 24px; height: 24px; line-height: 24px; text-align: center;
  border-radius: 50%; background: var(--chip); color: var(--text); font-weight: 700; font-size: 13px;
}
.opt .opt-text { flex: 1; }
.opt.sel { border-color: var(--primary); background: rgba(21,101,192,.08); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }

/* 结果/解析 */
.result { font-weight: 700; padding: 8px 10px; border-radius: 8px; margin: 10px 0; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.bad { background: var(--bad-bg); color: var(--bad); }
.analysis { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.a-row { margin: 4px 0; }
.a-row b { color: var(--primary); }
.mastered { color: var(--ok); font-weight: 600; align-self: center; }

/* 模拟考试 */
.exam-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.timer { color: var(--warn); font-weight: 700; font-size: 14px; }
.timer.low { color: #c62828; }
.sheet { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 12px; }
.sheet .cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--card); cursor: pointer;
}
.sheet .cell.cur { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.sheet .cell.done { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.sheet .cell.mark { box-shadow: inset 0 0 0 2px var(--warn); }

/* 成绩单 */
.report .score { font-size: 40px; font-weight: 800; text-align: center; margin: 8px 0; }
.score.pass { color: var(--ok); }
.score.fail { color: var(--bad); }
.tbl { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.tbl th, .tbl td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.tbl th { background: var(--bg); color: var(--muted); font-weight: 600; }
.tbl .good { color: var(--ok); }
.tbl .mid { color: var(--warn); }
.tbl .weak { color: var(--bad); font-weight: 700; }
.wrong-list { display: flex; flex-direction: column; gap: 8px; }
.mini-q { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 14px; cursor: pointer; }
.mini-q:hover { background: var(--chip); }

/* 错题/找题列表 */
.wq { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.wq-head { cursor: pointer; font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* 我的 */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.stat { flex: 1; min-width: 70px; background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat .l { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h3 { margin: 0 0 8px; font-size: 15px; }

/* 弹窗 */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 420px; max-height: 86vh; overflow-y: auto; padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; margin-bottom: 12px; }
.modal .x { font-size: 22px; cursor: pointer; color: var(--muted); }
.tiers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tier { border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.t-name { font-size: 13px; }
.t-price { font-size: 18px; font-weight: 800; color: var(--primary); }
.t-code { font-size: 11px; color: var(--muted); }
.qr-row { display: flex; gap: 12px; justify-content: center; margin: 12px 0; }
.qr img { width: 130px; height: 130px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; }
.qr div { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.contact { margin: 10px 0; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type=text] { padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 9px 16px; border-radius: 20px;
  font-size: 13px; opacity: 0; transition: .25s; pointer-events: none; z-index: 99;
}
.toast.show { opacity: 1; }

/* 错题原因分类 */
.reason-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 2px; }
.rp-label { color: #666; font-size: 13px; }
.rchip { border: 1px solid #d0d7de; background: #fff; color: #444; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; transition: all .15s; }
.rchip:hover { border-color: #999; }
.rchip.r-confuse.on { background: #fff3e0; border-color: #fb8c00; color: #e65100; }
.rchip.r-misread.on { background: #e8f5e9; border-color: #43a047; color: #1b5e20; }
.rchip.r-unknown.on { background: #fce4ec; border-color: #e53935; color: #b71c1c; }
.tag.r-confuse { background: #fb8c00; color: #fff; }
.tag.r-misread { background: #43a047; color: #fff; }
.tag.r-unknown { background: #e53935; color: #fff; }
.chip-t.r-confuse.on { background: #fb8c00; border-color: #fb8c00; color: #fff; }
.chip-t.r-misread.on { background: #43a047; border-color: #43a047; color: #fff; }
.chip-t.r-unknown.on { background: #e53935; border-color: #e53935; color: #fff; }

/* 错题原因分布 */
.reason-dist { display: flex; flex-direction: column; gap: 10px; margin: 6px 0; }
.rd-row { display: flex; align-items: center; gap: 10px; }
.rd-tag { flex: 0 0 76px; font-size: 13px; color: #444; }
.rd-tag.r-confuse { color: #e65100; }
.rd-tag.r-misread { color: #1b5e20; }
.rd-tag.r-unknown { color: #b71c1c; }
.rd-bar { flex: 1; background: #eee; border-radius: 6px; height: 12px; overflow: hidden; }
.rd-fill { height: 100%; border-radius: 6px; background: #1565c0; }
.rd-fill.r-confuse { background: #fb8c00; }
.rd-fill.r-misread { background: #43a047; }
.rd-fill.r-unknown { background: #e53935; }
.rd-n { flex: 0 0 54px; text-align: right; font-size: 13px; color: #555; }

/* 专题速练 */
.topic-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.tc-label { font-size: 13px; color: var(--muted); }
.chip-t {
  font-size: 13px; padding: 5px 12px; border-radius: 14px;
  background: var(--chip); color: var(--muted); cursor: pointer; border: 1px solid transparent;
}
.chip-t.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 我的试卷 / 成绩 */
.paper-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.paper-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--bg); cursor: pointer;
}
.paper-row:hover { border-color: var(--primary); }
.p-score { flex: 0 0 auto; font-size: 20px; font-weight: 800; line-height: 1; }
.p-score.pass { color: var(--ok); }
.p-score.fail { color: var(--bad); }
.p-info { flex: 1; font-size: 14px; }
.p-act { color: var(--primary); font-weight: 600; font-size: 14px; }
.curve { width: 100%; height: 130px; display: block; background: var(--bg); border-radius: 8px; }
.curve-lbl { font-size: 9px; fill: var(--bad); }

/* 复卷页：答题标记 */
.mark-r { margin-left: auto; font-size: 12px; color: var(--ok); font-weight: 600; }
.mark-w { margin-left: auto; font-size: 12px; color: var(--bad); font-weight: 600; }

/* 成绩单及格徽章 */
.badge { font-size: 14px; padding: 2px 10px; border-radius: 12px; vertical-align: middle; margin-left: 6px; }
.badge.pass { background: var(--ok-bg); color: var(--ok); }
.badge.fail { background: var(--bad-bg); color: var(--bad); }

/* 复卷页头部分数小标 */
.exam-bar .p-score { font-size: 15px; }

/* 参考答案/您的答案 对照行（对齐安考汇） */
.ans-cmp {
  display: flex; justify-content: space-between; gap: 10px;
  background: var(--chip); border-radius: 8px;
  padding: 8px 12px; margin: 8px 0; font-size: 14px;
}
.ans-cmp b.ac-ok { color: var(--ok); }
.ans-cmp b.ac-bad { color: var(--bad); }
/* VIP 原价划线 */
.t-price s.t-orig { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ===== 手机版（窄屏 ≤640px）适配：纯 CSS 增强，桌面版布局不变 ===== */
@media (max-width: 640px) {
  body {
    font-size: 16px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
    -webkit-text-size-adjust: 100%;
  }

  /* 顶部标题栏：更紧凑 */
  .hd { padding: 8px 12px; }
  .hd-title { font-size: 16px; }
  .hd-right { gap: 6px; }
  .chip { padding: 3px 8px; font-size: 11px; }

  /* 底部固定导航（tab bar），贴合刘海/手势条 */
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    z-index: 40;
    border-bottom: none; border-top: 1px solid var(--border);
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
    background: var(--card);
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
  }
  .nav button {
    font-size: 12px; padding: 7px 0; gap: 2px;
    display: flex; align-items: center; justify-content: center;
  }

  .app { padding: 10px 10px 14px; }

  /* 卡片 */
  .card, .wq, .card-in { padding: 13px; margin-bottom: 10px; border-radius: 12px; }
  .card-in { margin: 8px 0 0; }

  /* 控制条：选择器占满整行，更易点 */
  .controls { padding: 12px; }
  .controls .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .controls label { font-size: 14px; }
  .controls select, .controls input[type=number], .controls input[type=text] {
    width: 100%; font-size: 16px; padding: 9px 10px;
  }
  .btn { padding: 11px 16px; font-size: 15px; }
  .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .actions .btn { flex: 1 1 auto; min-width: 110px; text-align: center; }

  /* 题干与选项：加大触摸区 */
  .stem { font-size: 17px; line-height: 1.7; }
  .opts { gap: 10px; }
  .opt { padding: 13px 14px; align-items: center; }
  .opt .opt-key { flex: 0 0 28px; height: 28px; line-height: 28px; font-size: 14px; }
  .opt .opt-text { font-size: 16px; line-height: 1.6; }

  .result { font-size: 15px; }
  .analysis { font-size: 15px; line-height: 1.7; }

  /* 模拟考试顶部栏 */
  .exam-bar { flex-wrap: wrap; gap: 6px 10px; }
  .exam-bar .btn.warn { padding: 7px 12px; font-size: 13px; }
  .timer { font-size: 14px; }

  /* 答题卡：窄屏改 5 列，单元格更好点 */
  .sheet { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .sheet .cell { font-size: 14px; border-radius: 10px; }

  /* 弹窗：底部弹出，接近全屏 */
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; width: 100%; max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
  .tiers { grid-template-columns: 1fr; }
  .qr img { width: 150px; height: 150px; }

  /* 统计卡片 */
  .stats { gap: 8px; }
  .stat { min-width: calc(50% - 4px); }

  /* 试卷行 */
  .paper-row { padding: 12px; gap: 10px; }
  .p-score { font-size: 22px; }
}

/* 发布锁（维护模式）遮罩：锁定后隐藏导航与头部功能入口 */
.locked .nav, .locked .hd-right { display: none !important; }
.locked-screen { min-height: 72vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ls-card {
  max-width: 420px; text-align: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 34px 26px; box-shadow: var(--shadow);
}
.ls-icon { font-size: 46px; line-height: 1; }
.ls-card h2 { margin: 12px 0 8px; color: var(--text); }
.ls-foot { margin-top: 18px; font-size: 12px; color: var(--muted); opacity: .55; cursor: default; user-select: none; }
