:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e4e6eb;
  --text: #17181c;
  --muted: #6b7280;
  --brand: #2f6fed;
  --brand-weak: #eaf1ff;
  --ok: #12895f;
  --ok-weak: #e6f6ef;
  --err: #d92d20;
  --err-weak: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --line: #262a32;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --brand: #6d9bff;
    --brand-weak: #1b2740;
    --ok: #3ddc97;
    --ok-weak: #12251d;
    --err: #ff6b60;
    --err-weak: #2a1614;
    --shadow: none;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px 32px;
}

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px 10px;
}
.topbar h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: .3px;
}
.topbar .sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 15.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .45; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.actions .btn.primary { grid-column: 1 / -1; }

/* ---------- 分组 ---------- */
.groupTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .5px;
}
.groupTitle::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.banks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bank {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  color: inherit;
  box-shadow: var(--shadow);
}
.bank:active { transform: scale(.995); }
.bank .row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bank .name { font-size: 16px; font-weight: 600; }
.bank .count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.bank .bar {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin-top: 9px;
  overflow: hidden;
}
.bank .bar i { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 3px; }
.bank .meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; }

/* ---------- 答题 ---------- */
.quizhead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.iconbtn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
}
.quizhead .title { flex: 1; min-width: 0; }
.quizhead .title b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quizhead .title small { color: var(--muted); font-size: 11.5px; }
.progress { height: 3px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .25s; }

.qcard, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 14px;
  margin-top: 13px;
  box-shadow: var(--shadow);
}
.qtags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-weak);
  color: var(--brand);
  font-weight: 600;
}
.tag.gray { background: var(--line); color: var(--muted); }
.stem { font-size: 16.5px; line-height: 1.75; word-break: break-word; }
.stem p, .explain p { margin: 0 0 8px; }
.stem p:last-child, .explain p:last-child { margin-bottom: 0; }

.opts { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  word-break: break-word;
}
.opt .k {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.opt .v { flex: 1; }
.opt.sel { border-color: var(--brand); background: var(--brand-weak); }
.opt.sel .k { border-color: var(--brand); background: var(--brand); color: #fff; }
.opt.ok { border-color: var(--ok); background: var(--ok-weak); }
.opt.ok .k { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.bad { border-color: var(--err); background: var(--err-weak); }
.opt.bad .k { border-color: var(--err); background: var(--err); color: #fff; }
.opt[disabled] { cursor: default; }

.verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 600;
}
.verdict.ok { background: var(--ok-weak); color: var(--ok); }
.verdict.bad { background: var(--err-weak); color: var(--err); }
.verdict .right { font-weight: 700; }

.explain h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .5px;
}
.explain { font-size: 15px; line-height: 1.8; }
.explain p { color: var(--text); }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--muted);
}
.inline-fig { max-width: 100%; vertical-align: middle; }
.fig-block {
  display: block;
  max-width: 100%;
  margin: 10px auto;
  border-radius: 8px;
}
.qfoot { display: flex; gap: 10px; margin: 16px 0 4px; }
.qfoot .btn { flex: 1; }

.bottomspace { height: 16px; }

.loading { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 40px; }

/* ---------- 账号条 ---------- */
.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--muted);
}
.userbar .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .who b { color: var(--text); font-weight: 600; }
.userbar .sync { color: var(--brand); font-size: 12px; }
.linkbtn {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.linkbtn:disabled { opacity: .5; }

/* ---------- 登录页 ---------- */
.authpage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}
.authpage .userbar {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  margin: 12px 0 0;
}
.authpage.widetop .userbar { max-width: 560px; }
.authwrap {
  width: 100%;
  max-width: 420px;
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom));
}
.authhead h1 { font-size: 24px; margin: 0 0 6px; }
.authbrand {
  margin: 0 0 30px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .5px;
}
.authhead .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input {
  width: 100%;
  box-sizing: border-box;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.field input:focus { border-color: var(--brand); }
.autherr { min-height: 18px; margin: 2px 0 10px; color: var(--err); font-size: 13px; }
.autherr.ok { color: #198754; }
.autherr:empty { margin: 0; }
.authhint { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; text-align: center; }
.authhint a { color: var(--brand); text-decoration: none; }

/* ---------- 账号管理页 ---------- */
.authpage.adminpage { align-items: center; justify-content: flex-start; padding-top: 10px; }
.authwrap.wide { max-width: 560px; }
.adminbox { margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adminlist { margin-top: 8px; }
.adminempty { text-align: center; color: var(--muted); font-size: 13px; padding: 22px 0; }
.urow {
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.urow.isoff { opacity: .6; }
.umain { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.umain b { font-size: 15px; }
.umeta { margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.uops { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.linkbtn.danger { color: var(--err); }
.utag {
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 18px;
}
.utag.adm { background: rgba(47, 111, 237, .14); color: var(--brand); }
.utag.off { background: rgba(220, 53, 69, .14); color: var(--err); }
.utag.me { background: rgba(25, 135, 84, .14); color: #198754; }
@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; gap: 0; }
}
