:root {
  --bg: #f2f2f3;
  --card: #ffffff;
  --line: #dcdcdc;
  --border: #b6b6b6;
  --text: #1f1f1f;
  --sub: #8a8a8a;
  --dark: #2e2e2e;
  --green: #2fa36b;
  --red: #e23b3b;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid #ececec;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 2px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: #222;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:active { opacity: 0.5; }

.page { flex: 1; padding: 14px 14px 90px; }
.page.no-pad { padding: 0 0 0; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.section-title {
  font-family: var(--sans);
  color: #9a9a9a;
  font-size: 14px;
  margin: 18px 6px 8px;
  letter-spacing: 1px;
}
.muted { color: var(--sub); }

button { font-family: inherit; }

.btn-primary {
  width: 100%;
  height: 50px;
  border: 0;
  background: var(--dark);
  color: #fff;
  font-size: 17px;
  letter-spacing: 3px;
  border-radius: 2px;
  cursor: pointer;
}
.btn-primary:disabled { background: #cfcfcf; color: #f2f2f2; letter-spacing: 3px; }
.btn-primary:active:not(:disabled) { background: #000; }

.footer-bar {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  z-index: 15;
}

/* ---------- 导入页 ---------- */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin-top: 6px;
}
.file-icon {
  width: 46px;
  height: 52px;
  border-radius: 6px;
  background: #e8453c;
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: end center;
  padding-bottom: 8px;
  position: relative;
  flex: 0 0 auto;
}
.file-icon::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-width: 0 14px 14px 0;
  border-style: solid;
  border-color: var(--bg) #fff #fff var(--bg);
  border-radius: 0 6px 0 0;
}
.file-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-all;
}
.file-meta { font-family: var(--sans); color: var(--sub); font-size: 13px; margin-top: 6px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #333;
  padding: 4px 2px;
  cursor: pointer;
}
.radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid #bdbdbd;
  display: inline-block;
  flex: 0 0 auto;
  position: relative;
}
.radio.on { border-color: #2e2e2e; }
.radio.on::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #2e2e2e;
}

.option-list { background: #fff; border-radius: 10px; overflow: hidden; }
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px;
  font-size: 16.5px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.option-row:last-child { border-bottom: 0; }
.option-row:active { background: #fafafa; }

.notice {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: #7a7a7a;
  margin: 12px 6px;
}
.notice b { color: #333; }

/* ---------- 首页 ---------- */
.bank-head { text-align: center; padding: 22px 10px 6px; }
.bank-title { font-size: 21px; font-weight: 700; line-height: 1.5; margin: 0 0 10px; }
.bank-count { font-size: 15px; color: #666; }
.tip { font-family: var(--sans); font-size: 12.5px; color: #a3a3a3; padding: 10px 6px 0; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 10px; }
.tile {
  background: #fff;
  border-radius: 10px;
  padding: 22px 10px 16px;
  text-align: center;
  cursor: pointer;
  border: 0;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}
.tile:active { background: #fbfbfb; }
.tile .ico { font-size: 26px; line-height: 1; }
.tile .name { font-size: 18px; font-weight: 700; letter-spacing: 2px; }
.tile .desc { font-family: var(--sans); font-size: 12.5px; color: #9b9b9b; }
.tile[disabled] { opacity: 0.45; }
.badge-vip {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #f7941e;
  color: #fff;
  font-family: var(--sans);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 8px;
}

.progress-line {
  margin: 18px 4px 0;
  font-family: var(--sans);
  font-size: 13px;
  color: #777;
  display: flex;
  justify-content: space-between;
}
.bar { height: 6px; background: #e6e6e6; border-radius: 3px; margin: 8px 4px 0; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #3d3d3d; border-radius: 3px; }

/* ---------- 做题页 ---------- */
.practice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: #4a4a4a;
  color: #fff;
  border-radius: 18px;
  padding: 8px 16px;
  font-size: 14.5px;
  font-family: var(--sans);
  cursor: pointer;
}
.pill .no { color: #d8d8d8; font-size: 13px; }

.q-scroll { padding: 14px 16px 120px; }
.q-stem {
  font-size: 17.5px;
  line-height: 1.72;
  margin: 8px 0 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.choices { display: flex; flex-direction: column; gap: 9px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 13px 14px;
  font-size: 16.5px;
  line-height: 1.6;
  font-family: var(--serif);
  color: #1f1f1f;
  cursor: pointer;
  transition: border-color 0.12s;
}
.choice .k { flex: 0 0 auto; }
.choice.sel { border-color: #2e2e2e; border-width: 1.5px; background: #f7f7f7; }
.choice.right { border-color: var(--green); border-width: 1.5px; background: #f2fbf6; }
.choice.wrong { border-color: var(--red); border-width: 1.5px; background: #fff7f7; }
.choice .mark { margin-left: auto; font-size: 15px; }
.choice.wrong .mark { color: var(--red); }
.choice.right .mark { color: var(--green); }

.q-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: #8a8a8a;
}
.tag {
  background: #5a5a5a;
  color: #fff;
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 3px 8px;
  border-radius: 2px;
}

.answer-box {
  margin-top: 6px;
  background: #fff;
  border-top: 1px solid #eee;
  padding: 14px 0 0;
}
.answer-box .h { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.answer-letters {
  background: #fffdf1;
  border-top: 1px solid #f6efd0;
  border-bottom: 1px solid #f6efd0;
  padding: 14px 12px;
  font-size: 18px;
  letter-spacing: 3px;
  margin-bottom: 12px;
}
.verdict { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }
.verdict.ok { color: var(--green); }
.verdict.bad { color: var(--red); }
.explain { font-size: 15px; line-height: 1.75; color: #444; white-space: pre-wrap; }

.actionbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid #e8e8e8;
  z-index: 18;
}
.actionbar button {
  height: 48px;
  border-radius: 2px;
  font-size: 17px;
  letter-spacing: 2px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: #333;
}
.actionbar .prev { flex: 0 0 29%; }
.actionbar .submit { flex: 1; background: var(--dark); color: #fff; border-color: var(--dark); }
.actionbar .submit:disabled { background: #bdbdbd; border-color: #bdbdbd; }
.actionbar .next { flex: 0 0 24%; }

/* ---------- 答题卡 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: #fff;
  width: 100%;
  max-width: 520px;
  border-radius: 14px 14px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 78dvh;
  overflow: auto;
}
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .legend { font-family: var(--sans); font-size: 12px; color: #999; display: flex; gap: 14px; margin: 8px 0 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.todo { background: #d9d9d9; }
.cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 9px; }
.cell {
  aspect-ratio: 1 / 1;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-size: 14px;
  background: #fff;
  cursor: pointer;
  color: #444;
}
.cell.cur { border-color: #2e2e2e; border-width: 2px; font-weight: 700; }
.cell.done { background: #eef7f1; border-color: #bfe3cd; }
.cell.bad { background: #fdeeee; border-color: #f0c2c2; color: #b03a3a; }

/* ---------- 错题列表 ---------- */
.wrong-item {
  position: relative;
  background: #fff;
  border-radius: 8px;
  padding: 14px 52px 14px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.wrong-item .stem { font-size: 15.5px; line-height: 1.65; }
.wrong-item .sub { font-family: var(--sans); font-size: 12px; color: #999; margin-top: 8px; }
.master-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #cfd8e3;
  background: #fff;
  color: #9aa5b1;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.master-check:active { background: #eef7f1; border-color: #7fb89a; color: #2f6b4f; }
.toast.undo { cursor: pointer; background: rgba(47, 107, 79, 0.92); }

.empty {
  text-align: center;
  color: #9a9a9a;
  font-family: var(--sans);
  font-size: 14px;
  padding: 60px 20px;
  line-height: 2;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 60;
  max-width: 80vw;
  text-align: center;
}

.preview-box {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.7;
  color: #555;
}
.preview-box ul { margin: 6px 0 0; padding-left: 18px; }
.preview-box .warn { color: #b26a00; }

.link-btn {
  border: 0;
  background: transparent;
  color: #3a6ea5;
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 8px 2px;
  cursor: pointer;
  text-decoration: underline;
}
textarea.paste {
  width: 100%;
  min-height: 46vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
}
/* ---------- 添加到桌面 ---------- */
.install-btn {
  display: block;
  width: 100%;
  margin: 18px 0 4px;
  padding: 13px 0;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: #fff;
  color: var(--green);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.install-btn:active { background: #eef5f1; }

.sheet-lead { margin: 10px 0 6px; font-family: var(--sans); font-size: 14px; color: #555; line-height: 1.6; }
.sheet .steps { margin: 10px 0 0; padding-left: 20px; font-family: var(--sans); font-size: 15px; color: #333; }
.sheet .steps li { margin: 9px 0; line-height: 1.55; }
.wide-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 13px 0;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-family: var(--sans);
  font-size: 16px;
  cursor: pointer;
}
