:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2f6fd0;
  --primary-dark: #245bb0;
  --green: #2e7d5b;
  --green-bg: #e9f6ee;
  --red: #c0392b;
  --red-bg: #fdecea;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 10px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 10px; }

.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 12px 28px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: #42506a; font-size: 14px; }
.topbar nav a:hover { color: var(--primary); }
.dbstat { margin-left: auto; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 5px;
  background: var(--red); color: #fff; border-radius: 9px; font-size: 11px;
  line-height: 18px; text-align: center;
}
.container { max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

.hero { background: linear-gradient(135deg, #eaf1fd, #f7fbff); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px 30px; margin-bottom: 26px; }
.hero h1 { font-size: 27px; }
.hero p { color: #4b5b73; max-width: 780px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.section-title { margin: 28px 0 14px; font-size: 18px; }
.lead { color: #4b5b73; margin-bottom: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.spacer { flex: 1; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.stat-head { display: flex; align-items: baseline; gap: 8px; }
.stat-head strong { font-size: 28px; }
.stat-head small { color: var(--muted); }
.stat-card .link { display: inline-block; margin-top: 6px; font-size: 14px; }
.pill { display: inline-block; background: #e8effc; color: var(--primary-dark);
  border-radius: 6px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.pill.soft { background: #f0f2f7; color: #52617a; font-weight: 500; }
.big-number { font-size: 34px; font-weight: 700; margin: 4px 0; }
.big-number small { font-size: 14px; color: var(--muted); font-weight: 400; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; gap: 12px; align-items: baseline; padding: 7px 0;
  border-bottom: 1px dashed var(--line); font-size: 13px; flex-wrap: wrap; }
.recent li span { color: var(--muted); }
.recent li strong { margin-left: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 14px; font-family: inherit; }
.btn:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.large { padding: 12px 24px; font-size: 16px; }
.btn.disabled { opacity: .45; cursor: default; }
.btn.disabled:hover { border-color: var(--line); color: var(--text); }
.link { cursor: pointer; background: none; border: 0; padding: 0;
  color: var(--primary); font: inherit; }
.link.danger { color: var(--red); margin-left: 10px; }
.inline { display: inline; }
.chip { padding: 5px 12px; border-radius: 16px; border: 1px solid var(--line);
  font-size: 13px; color: var(--muted); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

.page-head { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--line); font-size: 14px; color: #42506a; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 13px; }
.progress { flex: 1; height: 8px; background: #e7ecf5; border-radius: 5px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 5px; }

.question-card { padding: 22px 24px; }
.q-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stem { font-size: 18px; line-height: 1.6; margin: 14px 0 18px; white-space: pre-wrap; }
.stem.small { font-size: 15px; color: #4b5b73; }
.options { display: flex; flex-direction: column; gap: 9px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
  background: #fcfdff; transition: border-color .15s, background .15s; }
.option:hover { border-color: #b9c9e8; background: #f6f9ff; }
.option input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--primary); }
.opt-key { font-weight: 700; color: var(--primary-dark); min-width: 20px; }
.opt-text { flex: 1; white-space: pre-wrap; }
.option.is-correct { background: var(--green-bg); border-color: #a8d8bd; }
.option.is-correct .opt-key { color: var(--green); }
.opt-tag { font-size: 12px; color: var(--green); font-weight: 600; }

.answer-box { margin-top: 18px; padding: 14px 16px; background: #f7f9fc;
  border: 1px solid var(--line); border-radius: 9px; }
.answer-box > div { display: flex; gap: 12px; padding: 3px 0; flex-wrap: wrap; }
.answer-label { color: var(--muted); min-width: 72px; font-size: 13px; }
.answer-box strong { color: var(--green); }
.material { border: 1px solid #dfe7f5; border-radius: 9px; background: #f8fbff;
  padding: 10px 14px; margin-bottom: 16px; }
.material summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); font-size: 14px; }
.material-body { margin-top: 10px; white-space: pre-wrap; line-height: 1.7; font-size: 14px; }
.material-image img { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; margin-top: 10px; }

.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.jump { display: flex; align-items: center; gap: 6px; }
.jump input { width: 72px; padding: 7px 8px; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; }
.feedback { border-left: 4px solid var(--green); }
.feedback.bad { border-left-color: var(--red); }
.feedback.ok h2 { color: var(--green); }
.feedback.bad h2 { color: var(--red); }
.mastered-note { color: var(--green); font-weight: 700; font-size: 16px; }

.notice { padding: 14px 18px; background: #fff8e6; border: 1px solid #f0dfae;
  border-radius: 9px; margin: 14px 0; }
.notice.ok { background: var(--green-bg); border-color: #b9e0c8; color: var(--green); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
  background: #fff8e6; border: 1px solid #f0dfae; }
.flash.warn { background: var(--red-bg); border-color: #f3c3bd; color: var(--red); }

.rules { padding-left: 20px; margin: 0; color: #4b5b73; }
.rules li { margin-bottom: 7px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 14px; vertical-align: top; }
.table th { background: #f2f5fa; color: #4b5b73; font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 7px 10px; font-size: 13px; }
.table .ok { color: var(--green); font-weight: 600; }
.stem-cell { max-width: 520px; }
.field { margin-bottom: 16px; }
.field.row { display: flex; gap: 26px; flex-wrap: wrap; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field label.checkbox { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.field input[type=file], .field select { padding: 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font: inherit; }
.checkbox input { width: 16px; height: 16px; }
.import-form { padding: 4px 0; }

.score-card { display: flex; flex-direction: column; gap: 4px; }
.score-card strong { font-size: 30px; }
.score-card small { font-size: 15px; color: var(--muted); font-weight: 400; }
.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-item { background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; border-left: 4px solid var(--green); }
.review-item.bad { border-left-color: var(--red); }
.review-item summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  cursor: pointer; font-size: 14px; }
.review-item .idx { color: var(--muted); min-width: 28px; }
.review-item .mark { font-weight: 700; color: var(--green); }
.review-item.bad .mark { color: var(--red); }
.review-item .text { flex: 1; }
.review-body { padding: 0 18px 16px; }

@media (max-width: 900px) {
  .grid, .grid.two, .grid.three { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 16px; }
  .dbstat { display: none; }
}
@media (max-width: 620px) {
  .grid, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .container { padding: 18px 14px 40px; }
  .question-card { padding: 16px; }
}

/* ---- 多用户版：账号区、认证页、管理页 ---- */
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.userbox a, .userbox .link { white-space: nowrap; }
.userbox .uname { font-weight: 600; color: var(--text); }
.admin-tag { display: inline-block; margin-left: 6px; padding: 1px 6px;
  border-radius: 5px; background: #e8effc; color: var(--primary-dark);
  font-size: 11px; font-weight: 600; }

.auth-wrap { max-width: 460px; margin: 26px auto 0; }
.auth-card { padding: 26px 28px; }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card .lead { font-size: 14px; margin-bottom: 20px; }
.auth-card .field { margin-bottom: 15px; }
.text-input { width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font: inherit; font-size: 14px;
  color: var(--text); }
.text-input:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 208, .12); }
.auth-card .btn.large { width: 100%; margin-top: 4px; }
.auth-foot { margin: 16px 0 0; text-align: center; font-size: 14px; }
.hint.center { margin-top: 14px; }

.flash.ok { background: var(--green-bg); border-color: #b9e0c8; color: var(--green); }
.danger-hint { color: var(--red); }
.reset-notice { line-height: 1.9; }
.temp-pwd { display: inline-block; padding: 2px 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; font-size: 15px;
  font-weight: 600; color: var(--red); }
.state { font-weight: 600; }
.state.on { color: var(--green); }
.state.off { color: var(--red); }
.ops { white-space: nowrap; }
.ops form + form { margin-left: 10px; }
.link:disabled { color: var(--muted); cursor: default; opacity: .55; }
.error-code { font-size: 48px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.notice code { font-size: 13px; background: #fff; padding: 1px 5px; border-radius: 4px; }

@media (max-width: 620px) {
  .userbox { gap: 8px; font-size: 12px; }
  .auth-card { padding: 20px; }
  .table th, .table td { padding: 8px; }
}

/* ---- 掌握题目排行榜 ---- */
.leaderboard { max-width: 620px; }
.leaderboard td:first-child, .leaderboard th:first-child { width: 76px; }
.leaderboard tr.is-me { background: #f0f6ff; }
.rank-badge { display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; color: #fff;
  font-size: 12px; font-weight: 600; }
.rank-1 { background: #d99b16; }
.rank-2 { background: #8a97a8; }
.rank-3 { background: #b0763f; }

/* ---- 强制读题倒计时 ---- */
.read-lock { border-left: 4px solid var(--primary); }
.read-lock strong { color: var(--primary); font-size: 16px; }
.read-warn { color: var(--red); }
.btn.read-locked { opacity: .55; cursor: not-allowed; }

/* ---- 自定义组卷题数 ---- */
.count-input { width: 92px; padding: 8px 10px; font-size: 15px; text-align: center; }
.count-input.over-limit { border-color: #d99b16; background: #fff9e8; }
#count-total { font-size: 20px; color: var(--primary); }
#count-total.bad { color: var(--red); }
.table tfoot th, .table tfoot td { background: #f7f9fc; }
