:root {
  --blue: #1a66d6;
  --blue-dark: #1453b0;
  --blue-light: #e8f0fc;
  --text: #222;
  --muted: #7a8594;
  --bg: #e9eef3;
  --card: #fff;
  --red: #e5484d;
  --green: #18a058;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f3f6f9 0%, var(--bg) 100%);
  min-height: 100vh;
  font-size: 15px;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar { background: #fff; border-bottom: 1px solid #dfe5eb; }
.topbar h1 { margin: 0; padding: 18px 0; font-size: 18px; font-weight: 700; padding-left: 60px; }

.card { background: var(--card); border-radius: 8px; box-shadow: 0 1px 4px rgba(20, 40, 70, 0.08); }

.btn {
  border: 1px solid #c9d3de; background: #fff; color: var(--text);
  border-radius: 4px; padding: 6px 16px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); color: #fff; }
.btn.ghost { border-style: dashed; }
.btn.big { padding: 10px 28px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Setup ---------- */
.setup-card { max-width: 720px; margin: 40px auto; padding: 32px 36px; }
.setup-card h2 { margin: 0 0 8px; }
.minute-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 24px 0 12px; }
.minute-field { background: var(--blue-light); border-radius: 8px; padding: 14px; }
.minute-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.minute-field .sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.minute-field input {
  width: 100%; font-size: 22px; padding: 6px 10px; border: 1px solid #b9c7d8;
  border-radius: 6px; text-align: center;
}
.minute-field input:focus { outline: 2px solid var(--blue); border-color: transparent; }
.total-line { margin: 8px 0 16px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: #444; }
.setup-actions { display: flex; gap: 12px; justify-content: center; margin-top: 28px; }
.share { margin-top: 18px; text-align: center; }
.share span { margin-left: 8px; font-size: 13px; }

/* ---------- Exam ---------- */
.exam-layout { display: flex; gap: 18px; padding-top: 14px; padding-bottom: 70px; }
.exam-main { flex: 1; min-width: 0; }
.exam-side { width: 190px; flex-shrink: 0; padding-top: 34px; }
.subbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 4px 10px; font-size: 13px; color: #555;
}
.timer {
  display: inline-flex; align-items: center; gap: 4px; color: var(--blue);
  font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600;
}
.timer.warn { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.paper { padding: 18px 26px 30px; min-height: calc(100vh - 200px); }
.q { padding: 10px 0 16px; }
.q-hint { color: var(--blue); font-size: 13px; margin-bottom: 8px; }
.q-no { font-size: 13px; margin-bottom: 6px; }
.q-text { line-height: 2.3; font-size: 14px; }
.q-fig { margin: 10px 0 0 10px; }
.fig { max-width: 100%; height: auto; }
.matrix { font-family: "Times New Roman", "Songti SC", serif; font-size: 19px; line-height: 1.7; padding: 6px 0 0 20px; }
.blank {
  width: 58px; height: 30px; border: 1px solid #b7c0ca; border-radius: 5px;
  text-align: center; font-size: 14px; margin: 0 4px; vertical-align: middle;
  font-family: inherit;
}
.blank:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26, 102, 214, .18); }
.num-grid { border-collapse: collapse; }
.num-grid td {
  width: 62px; height: 62px; border: 2px solid #222; text-align: center;
  font-family: "Times New Roman", serif; font-size: 34px;
}

.side-card { padding: 12px 14px; position: sticky; top: 12px; }
.side-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.section-btns { display: flex; gap: 8px; }
.sec-btn {
  width: 26px; height: 26px; border-radius: 4px; border: none; background: #e6ebf0;
  color: #555; font-size: 12px; cursor: pointer;
}
.sec-btn.active { background: var(--blue); color: #fff; }
.sec-btn.locked { background: #f1f1f1; color: #bbb; text-decoration: line-through; cursor: not-allowed; }
.section-times { list-style: none; padding: 0; margin: 14px 0 0; font-size: 12px; color: #555; }
.section-times li { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px dashed #e3e8ee; }
.section-times li.active { color: var(--blue); font-weight: 600; }
.section-times li.locked { color: #aaa; }
.section-times .t { font-variant-numeric: tabular-nums; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  gap: 10px; padding: 10px; background: linear-gradient(180deg, rgba(233, 238, 243, 0), var(--bg) 40%);
}

/* ---------- Overlay ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: flex;
  align-items: center; justify-content: center; z-index: 10;
}
.toast-box { background: #fff; border-radius: 12px; padding: 28px 44px; text-align: center; min-width: 300px; animation: pop .25s; }
.toast-icon { font-size: 42px; }
.toast-title { font-size: 20px; font-weight: 700; margin: 8px 0 6px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* ---------- Access gate ---------- */
body.locked > :not(.gate) { display: none !important; }
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #f3f6f9 0%, var(--bg) 100%); z-index: 50; }
body:not(.locked) .gate { display: none; }
.gate-box { background: #fff; border-radius: 14px; box-shadow: 0 4px 24px rgba(20, 40, 70, .12); padding: 36px 40px; text-align: center; width: 340px; }
.gate-icon { font-size: 40px; }
.gate-box h2 { margin: 6px 0 4px; }
.gate-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.gate-box input { font-size: 16px; padding: 10px 12px; border: 1px solid #b9c7d8; border-radius: 8px; text-align: center; }
.gate-msg { margin-top: 12px; font-size: 13px; color: var(--red); min-height: 18px; }
.gate-tabs { justify-content: center; margin-top: 14px; }
.gate-note { margin: 4px 0 0; }

/* ---------- Book questions ---------- */
.fig-img { max-width: 100%; height: auto; max-height: 360px; }
.ask { margin-top: 4px; }
textarea.free { display: block; width: 100%; max-width: 640px; height: auto; min-height: 64px; text-align: left; margin: 6px 0 0; padding: 6px 8px; resize: vertical; line-height: 1.6; }
.qt { border-collapse: collapse; margin: 6px 0; }
.qt td, .qt th { border: 1px solid #555; padding: 2px 10px; text-align: center; line-height: 2; }
.qt .blank { width: 64px; margin: 0; }
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 12px; padding: 0 4px; text-decoration: underline; }
.sol-row td { background: #f8fbff; font-size: 13px; color: #334; line-height: 1.7; }
.self-btns { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.wb-sol { margin-top: 6px; font-size: 13px; color: #334; background: #f8fbff; border-radius: 6px; padding: 6px 10px; line-height: 1.7; }
.cov .cov-bar { display: inline-block; width: 120px; height: 8px; background: #e3e8ef; border-radius: 4px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.cov .cov-bar span { display: block; height: 100%; background: var(--green); }
.gen-options select { max-width: 100%; }

/* ---------- Bank picker ---------- */
.step-title { display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 26px 0 10px; }
.step-title:first-child { margin-top: 0; }
.step { width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; }
.bank-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.bank-card { text-align: left; border: 2px solid #dde4ec; background: #fff; border-radius: 10px; padding: 14px 16px;
  cursor: pointer; font: inherit; transition: border-color .15s, box-shadow .15s; }
.bank-card:hover { border-color: #a9c3ea; }
.bank-card.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 102, 214, .12); background: #f7faff; }
.bank-name { font-weight: 700; font-size: 15px; }
.bank-desc { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.gen-options { margin-top: 14px; background: #f7f9fc; border-radius: 10px; padding: 12px 16px; }
.opt-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 0; }
.opt-label { width: 84px; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #c9d3de; background: #fff; border-radius: 16px; padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.gen-options select, .gen-options input[type=number] { font: inherit; font-size: 14px; padding: 4px 8px; border: 1px solid #b9c7d8; border-radius: 6px; }
.gen-options input[type=number] { width: 110px; }
.tag { display: inline-block; font-size: 11px; color: #5b6b80; background: #eef2f7; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.25; margin: 0 2px; font-size: 13px; }
.fr > span:first-child { border-bottom: 1px solid currentColor; padding: 0 2px; }

/* ---------- Top nav ---------- */
.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
.topnav { display: flex; gap: 6px; }
.nav-btn {
  background: none; border: none; font: inherit; font-size: 14px; color: #445; cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
}
.nav-btn:hover { background: var(--blue-light); color: var(--blue); }
.badge { background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 6px; margin-left: 2px; }
body[data-view="exam"] .topnav { display: none; }
.exit-btn { display: none; }
body[data-view="exam"] .exit-btn { display: inline-block; }
.exit-box { max-width: 380px; }
.exit-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.exit-actions .btn.big { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.exit-actions small { font-size: 12px; opacity: .8; font-weight: normal; }
.btn.danger { color: var(--red); border-color: #f1b8ba; }
.btn.danger:hover { background: #fff5f5; color: var(--red); border-color: var(--red); }
.resume-info { margin-top: 12px; text-align: center; font-size: 13px; color: #7a4b00; background: #fff4e5; border-radius: 8px; padding: 8px 12px; }
.name-field { margin-top: 20px; }
.name-field label { font-weight: 600; margin-right: 10px; }
.name-field input { font-size: 15px; padding: 6px 10px; border: 1px solid #b9c7d8; border-radius: 6px; width: 200px; }

/* ---------- Active question ---------- */
.paper-tip { font-size: 12px; color: var(--muted); background: #f6f9fd; border-radius: 6px; padding: 6px 10px; margin-bottom: 6px; }
.q { border-left: 3px solid transparent; padding-left: 12px; margin-left: -15px; border-radius: 2px; transition: border-color .2s, background .2s; }
.q.active { border-left-color: var(--blue); background: linear-gradient(90deg, #f3f7fe, transparent 60%); }
.q-clock { display: none; margin-left: 8px; font-size: 12px; color: var(--blue); font-variant-numeric: tabular-nums; }
.q.active .q-clock { display: inline; }

/* ---------- Report ---------- */
.report-card { max-width: 1000px; margin: 28px auto 40px; padding: 28px 32px; }
.report-card h2 { margin: 0 0 4px; }
.report-card h3 { font-size: 16px; margin: 26px 0 10px; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.actions-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; }
.stat { background: var(--blue-light); border-radius: 10px; padding: 16px; text-align: center; }
.stat-v { font-size: 30px; font-weight: 700; color: var(--blue); }
.stat-v small { font-size: 15px; color: var(--muted); font-weight: 500; }
.stat-k { font-size: 13px; color: #556; margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rtable th, .rtable td { border-bottom: 1px solid #e8ecf1; padding: 8px 10px; text-align: left; vertical-align: middle; }
.rtable th { background: #f5f7fa; font-weight: 600; white-space: nowrap; }
.rtable .sec-row td { background: #fafbfd; font-weight: 600; color: var(--blue); }
.rtable .wrong-row { background: #fff7f7; }
.q-cell { max-width: 330px; color: #333; }
.nowrap { white-space: nowrap; }
.time-cell { min-width: 130px; position: relative; white-space: nowrap; }
.tbar { position: absolute; left: 6px; top: 50%; height: 18px; transform: translateY(-50%); background: #dbe7fb; border-radius: 3px; z-index: 0; max-width: calc(100% - 12px); }
.tbar.slow { background: #ffe1c2; }
.time-cell span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.ok { color: var(--green); font-weight: 600; }
.bad { color: var(--red); font-weight: 600; }
.na { color: var(--muted); }
.small { font-size: 12px; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.wb-note { margin-top: 22px; padding: 12px 16px; border-radius: 8px; background: #fff4e5; color: #7a4b00; }
.wb-note.good { background: #e8f7ee; color: #146c3a; }
.wb-note a { color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Wrong-question book ---------- */
.tabs { display: flex; gap: 6px; margin: 18px 0 8px; border-bottom: 1px solid #e3e8ee; }
.tab { background: none; border: none; font: inherit; font-size: 14px; padding: 8px 14px; cursor: pointer; color: #556; border-bottom: 2px solid transparent; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.wb-card { border: 1px solid #e3e8ee; border-radius: 10px; padding: 14px 18px; margin-top: 14px; break-inside: avoid; }
.wb-card.mastered { opacity: .75; }
.wb-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.wb-count { color: var(--red); font-weight: 600; }
.wb-info { font-size: 13px; margin-top: 8px; color: #555; }
.wb-result { margin-top: 6px; font-size: 14px; min-height: 4px; }
.wb-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

@media print {
  body { background: #fff; }
  .topnav, .no-print, .bottombar, .overlay { display: none !important; }
  .card { box-shadow: none; }
  .report-card { margin: 0; padding: 0; max-width: none; }
  .wb-ref { display: inline !important; }
}

@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .report-card { padding: 18px 14px; margin: 12px auto; }
  .topbar-inner { flex-direction: column; }
  .topbar h1 { padding: 12px 0 4px; }

  .wrap { padding: 0 10px; }
  .topbar h1 { padding-left: 0; text-align: center; }
  .exam-layout { flex-direction: column-reverse; }
  .exam-side { width: auto; padding-top: 0; }
  .section-times { display: flex; gap: 12px; }
  .section-times li { border: none; gap: 4px; }
  .paper { padding: 12px 14px 24px; }
  .minute-inputs { grid-template-columns: 1fr; }
  .setup-card { padding: 22px 18px; margin: 16px auto; }
  .num-grid td { width: 46px; height: 46px; font-size: 26px; }
}

/* ===== 账号 / Account dialog ===== */
.acct-dialog { border: none; border-radius: 14px; padding: 20px 22px; width: min(420px, 92vw); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.acct-dialog::backdrop { background: rgba(20, 30, 45, .45); }
.acct-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.acct-head h3 { margin: 0; font-size: 17px; }
.acct-tabs { margin-bottom: 12px; }
.acct-form { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.acct-form input { font-size: 16px; padding: 10px 12px; border: 1px solid #b9c7d8; border-radius: 8px; }
.acct-msg { min-height: 18px; font-size: 13px; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.acct-status { font-size: 13px; }
.acct-status.ok { color: var(--green); }
.acct-status.error { color: var(--red); }
.acct-status.busy { color: var(--muted); }
@media print { .acct-dialog { display: none; } }
.acct-dialog.forced [data-acct=close] { display: none; }

a.nav-btn, a.btn { text-decoration: none; display: inline-block; }

/* 选题 */
.pick-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #eef1f5; }
.pick-item.off { opacity: .45; }
.pick-check { white-space: nowrap; font-weight: 600; padding-top: 4px; cursor: pointer; }
.pick-body { flex: 1; min-width: 0; }
.pick-body .q-text { line-height: 1.9; }
.pick-fig img { max-height: 160px; max-width: 100%; }
.pick-blank { color: var(--muted); letter-spacing: 1px; }
