:root {
  --blue: #1f4e79;
  --blue-2: #2f6ea5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dbe2ea;
  --text: #1b1b1f;
  --muted: #6b7785;
  --green: #2f7a5a;
  --red: #b3261e;
  --amber: #8a6d3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 70, .06), 0 8px 24px rgba(20, 40, 70, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.65;
}
a { color: var(--blue-2); text-decoration: none; }
img { max-width: 100%; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--blue); font-size: 17px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-size: 14px;
}
.nav a.active, .nav a:hover { background: #eef3f8; color: var(--blue); font-weight: 600; }
.course-switch {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  background: #fff; color: var(--text); font-size: 13px; max-width: 180px;
}

.app { max-width: 980px; margin: 0 auto; padding: 22px 18px 80px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 6px; font-size: 18px; color: var(--blue); }
.card h3 { margin: 18px 0 10px; font-size: 15px; color: #334; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.course-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.course-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; cursor: pointer; transition: .15s; box-shadow: var(--shadow);
}
.course-card:hover { transform: translateY(-2px); border-color: var(--blue-2); }
.course-card .name { font-size: 19px; font-weight: 700; color: var(--blue); }
.course-card .count { color: var(--muted); font-size: 13px; margin-top: 4px; }
.course-card .tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; background: #eef3f8; color: var(--blue); border-radius: 20px; padding: 2px 9px;
}
.tag.green { background: #eaf5ef; color: var(--green); }
.tag.amber { background: #fdf6e7; color: var(--amber); }
.tag.gray { background: #f0f2f4; color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

button, .btn {
  font-family: inherit; font-size: 14px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); padding: 8px 16px; cursor: pointer; transition: .15s;
}
button:hover, .btn:hover { border-color: var(--blue-2); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--blue-2); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: #e8c4c1; }
button:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=number], textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
input[type=number] { width: 84px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.chapter-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; cursor: pointer; font-size: 13.5px;
}
.chapter-item.checked { border-color: var(--blue-2); background: #eef5fb; }
.chapter-item .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.type-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd;
}
.type-item .name { font-weight: 600; font-size: 14px; }
.type-item .avail { color: var(--muted); font-size: 12px; }
.type-item input[type=number] { margin-left: auto; }

.progressbar { height: 6px; border-radius: 6px; background: #e8edf3; overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--blue-2); transition: .2s; }

.paper-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px; color: var(--muted); font-size: 13px;
}
.paper-head .timer { font-variant-numeric: tabular-nums; color: var(--blue); font-weight: 700; font-size: 15px; }

.qcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.qmeta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.qno { font-weight: 700; color: var(--blue); }
.qtype { font-size: 12px; background: #eef3f8; color: var(--blue); border-radius: 6px; padding: 1px 8px; }
.qsrc { font-size: 12px; color: #99a; }
.stem { font-size: 16px; margin: 6px 0 14px; white-space: pre-wrap; word-break: break-word; }
.stem.html { white-space: normal; }
.stem img, .ans-body img { display: block; max-width: 86%; margin: 10px 0; border: 1px solid var(--line); border-radius: 6px; }

.opts { display: grid; gap: 9px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; background: #fff;
  cursor: pointer; font-size: 14.5px; color: var(--text); width: 100%;
}
.opt:hover { border-color: var(--blue-2); background: #f8fbfe; }
.opt .k { font-weight: 700; color: var(--blue); }
.opt.sel { border-color: var(--blue); background: #eef5fb; }
.opt.correct { border-color: var(--green); background: #eaf5ef; }
.opt.wrong { border-color: var(--red); background: #fdecea; }
.opt:disabled { cursor: default; }

.fill-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.fill-row .idx { min-width: 26px; color: var(--muted); font-size: 13px; }
.fill-row input { flex: 1; }

.short-box { display: grid; gap: 10px; }

.answer-panel {
  margin-top: 16px; border-left: 3px solid var(--blue); background: #f5f8fb;
  padding: 12px 15px; border-radius: 0 8px 8px 0;
}
.answer-panel .label { font-weight: 700; color: var(--blue); font-size: 13px; margin-bottom: 4px; }
.answer-panel .body { white-space: pre-wrap; word-break: break-word; }
.answer-panel pre {
  white-space: pre-wrap; word-break: break-word; background: #0f1b26; color: #e6edf3;
  padding: 12px 14px; border-radius: 8px; font-size: 13px; overflow-x: auto;
  font-family: Consolas, "Courier New", monospace; line-height: 1.55;
}
.answer-panel .code-title { font-weight: 600; font-size: 13px; margin: 10px 0 4px; color: #334; }
.explain { margin-top: 10px; color: #445; font-size: 14px; white-space: pre-wrap; }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--green); }
.verdict.no { color: var(--red); }
.verdict.neutral { color: var(--amber); }

.answer-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.sheet-btn {
  padding: 7px 0; border-radius: 7px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; text-align: center;
}
.sheet-btn.done { background: #eef5fb; border-color: var(--blue-2); color: var(--blue); font-weight: 600; }
.sheet-btn.current { outline: 2px solid var(--blue); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 6px 0 4px; }
.stat { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat .v { font-size: 24px; font-weight: 700; color: var(--blue); line-height: 1.2; }
.stat .k { font-size: 12px; color: var(--muted); }

.list { display: grid; gap: 10px; }
.list-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff;
}
.list-item .t { font-weight: 600; font-size: 14px; }
.list-item .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1f3346; color: #fff; padding: 9px 18px; border-radius: 24px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 12.5px; }

@media (max-width: 720px) {
  .app { padding: 14px 12px 70px; }
  .course-cards { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .brand { font-size: 15px; }
  .course-switch { max-width: 130px; font-size: 12px; }
  .stem { font-size: 15px; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}
