:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.topbar {
  background: linear-gradient(90deg, var(--brand), var(--brand-d));
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar .brand { font-size: 20px; font-weight: 700; }
.topbar .sub { font-size: 13px; opacity: .9; }
.container { max-width: 1180px; margin: 0 auto; padding: 18px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.btn {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.btn:hover { background: var(--brand-d); }
.btn.primary { background: var(--ok); }
.btn.primary:hover { background: #15803d; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
input[type=number], textarea, select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
  font-family: inherit;
}
textarea { width: 100%; resize: vertical; }
.cfg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cfg-item { display: flex; flex-direction: column; gap: 4px; }
.cfg-item.wide { grid-column: 1 / -1; }
.cfg-item label { font-weight: 600; }
.cfg-item .readonly {
  background: #f3f4f6; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; color: var(--ink);
}
.cfg-item small { color: var(--muted); font-size: 12px; }
.status { font-size: 13px; color: var(--ok); }
.status.err { color: var(--bad); }
.key-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px; margin-top: 10px;
}
.key-cell {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 13px;
}
.key-cell b { width: 26px; }
.key-cell select { padding: 2px 4px; }
.scoring-note { margin-top: 10px; color: var(--muted); font-size: 13px; }
.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; padding: 26px;
  text-align: center; color: var(--muted); background: #fafafa;
}
.dropzone.drag { border-color: var(--brand); background: #eff6ff; }
.dropzone p { margin: 0 0 10px; }
.dropzone small { display: block; margin-top: 10px; }
.sheet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 14px; }
.sheet-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer;
  position: relative; background: #fff; transition: border-color .15s;
}
.sheet-card:hover { border-color: var(--brand); }
.sheet-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(37,99,235,.2); }
.sheet-card .thumb { width: 100%; height: 110px; object-fit: contain; background: #f3f4f6; border-radius: 5px; }
.sheet-card .name { font-weight: 600; margin-top: 6px; font-size: 13px; word-break: break-all; }
.sheet-card .meta { font-size: 12px; color: var(--muted); }
.sheet-card .badge { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 2px 6px; border-radius: 10px; color: #fff; }
.badge.ok { background: var(--ok); }
.badge.warn { background: var(--warn); }
.badge.bad { background: var(--bad); }
.sheet-card .del { position: absolute; top: 4px; left: 4px; background: rgba(0,0,0,.5); color:#fff; border:0; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; display:none; }
.sheet-card:hover .del { display: block; }
.work-grid { display: grid; grid-template-columns: 1fr 420px; gap: 16px; }
.card-view { min-width: 0; }
.card-stage { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #f3f4f6; overflow: auto; max-height: 70vh; }
.card-stage canvas { display: block; max-width: 100%; height: auto; }
.card-stage svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.card-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.score-view { min-width: 0; }
.total-bar { font-size: 16px; padding: 8px 10px; background: #eff6ff; border-radius: 8px; margin-bottom: 10px; }
.total-bar b { color: var(--brand-d); font-size: 20px; }
.total-bar .muted { font-size: 13px; color: var(--muted); margin-left: 8px; }
.question-list { max-height: 64vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.q-row {
  display: grid; grid-template-columns: 46px 64px 64px 80px 1fr; gap: 6px;
  align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.q-row.head { background: #f9fafb; font-weight: 600; position: sticky; top: 0; }
.q-row.correct { background: #f0fdf4; }
.q-row.wrong { background: #fef2f2; }
.q-row .qnum { font-weight: 700; }
.q-row select { padding: 2px 4px; width: 100%; }
.q-row .qscore { font-weight: 700; text-align: center; }
.q-row .note { border: 0; border-bottom: 1px dashed var(--line); width: 100%; padding: 2px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 99;
  box-shadow: var(--shadow);
}
@media (max-width: 860px) {
  .work-grid { grid-template-columns: 1fr; }
  .cfg-grid { grid-template-columns: 1fr; }
}
