/* 精读测试系统样式 */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --primary: #5b6cff;
  --primary-2: #7c3aed;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --slate: #475569;
  --slate-light: #64748b;
  --border: #e2e8f0;
  --code-bg: #0f172a;
  --shadow: 0 4px 16px rgba(15,23,42,.06);
  --radius: 12px;

  /* 句法标注 4 色 */
  --tag-S:  #3b82f6;   /* 主语    蓝 */
  --tag-V:  #ef4444;   /* 谓语    红 */
  --tag-PP: #f59e0b;   /* 介词    橙 */
  --tag-CL: #10b981;   /* 从句    绿 */
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 30%, var(--bg) 100%);
  color: #0f172a;
  line-height: 1.6;
  min-height: 100vh;
}

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 20px; }
.brand .sub { font-size: 12px; color: var(--slate-light); }
.logo { font-size: 32px; }
.userbox { display: flex; gap: 8px; align-items: center; }
.userbox label { font-size: 12px; color: var(--slate-light); margin-right: 6px; }

/* 角色徽章 */
.role-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.role-badge.student { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.role-badge.teacher { background: #fef3c7; color: #92400e; border-color: #fde68a; }
input[type="text"], input:not([type]), input[type="file"], input[type="number"], textarea, select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,108,255,.15); }

button {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .05s, background .15s, box-shadow .15s;
}
button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(91,108,255,.35);
}
button.primary:hover { transform: translateY(-1px); }
button.ghost { background: #eef2ff; color: var(--primary); }
button.ghost:hover { background: #e0e7ff; }
button.danger { background: var(--red); color: #fff; }
button.small { padding: 4px 10px; font-size: 12px; }
button.tag-btn.active { box-shadow: 0 0 0 2px var(--primary); background: #dbeafe; color: var(--primary); }

/* tabs */
.tabs {
  display: flex; gap: 4px;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky; top: 78px;
  z-index: 9;
}
.tabs button {
  background: transparent;
  color: var(--slate-light);
  border-radius: 8px 8px 0 0;
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}
.tabs button:hover { color: var(--primary); }
.tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(91,108,255,.05);
}

main { padding: 26px 28px 60px; max-width: 1100px; margin: 0 auto; }
.panel { display: none; animation: fadeIn .25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

h2 { margin: 0 0 16px; font-size: 22px; }
h3 { margin: 22px 0 12px; font-size: 16px; color: var(--slate); }
p.hint { color: var(--slate-light); font-size: 13px; margin: -8px 0 18px; }

/* doc list */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.doc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; gap: 8px;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15,23,42,.08); }
.doc-card .title { font-weight: 600; font-size: 16px; }
.doc-card .meta { font-size: 12px; color: var(--slate-light); display: flex; gap: 8px; flex-wrap: wrap; }
.doc-card .meta .chip { background: #eef2ff; color: var(--primary); padding: 2px 8px; border-radius: 999px; }
.doc-card .steps { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; }
.doc-card .steps .s { padding: 2px 6px; border-radius: 6px; background: #f1f5f9; color: var(--slate); }
.doc-card .steps .s.s1 { background: #fef3c7; color: #92400e; }
.doc-card .steps .s.s2 { background: #dbeafe; color: #1e40af; }
.doc-card .steps .s.s3 { background: #ede9fe; color: #5b21b6; }
.doc-card .steps .s.s4 { background: #dcfce7; color: #166534; }
.doc-card .steps .s.s5 { background: #fce7f3; color: #9d174d; }
.doc-card .steps .s.s6 { background: #cffafe; color: #155e75; }
.doc-card .steps .s.s7 { background: #ffe4e6; color: #9f1239; }
.doc-card .actions { display: flex; gap: 8px; margin-top: auto; }

/* runner */
.runner-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap; gap: 8px;
}
.runner-meta { display: flex; gap: 18px; color: var(--slate-light); font-size: 14px; align-items: center; }
.runner-meta b { color: #0f172a; }
.timer {
  background: #0f172a; color: #fff;
  padding: 4px 12px; border-radius: 999px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px; font-weight: 600;
  letter-spacing: 1px;
}
.timer.overtime { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.q-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border-left: 4px solid var(--primary);
}
/* 按 7 类配色 */
.q-card[data-step="1"] { border-left-color: #f59e0b; }
.q-card[data-step="2"] { border-left-color: #3b82f6; }
.q-card[data-step="3"] { border-left-color: #7c3aed; }
.q-card[data-step="4"] { border-left-color: #10b981; }
.q-card[data-step="5"] { border-left-color: #ec4899; }
.q-card[data-step="6"] { border-left-color: #06b6d4; }
.q-card[data-step="7"] { border-left-color: #f43f5e; }

.q-card .q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-head-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-card .q-step {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; padding: 2px 10px; border-radius: 999px;
  font-size: 12px;
}
.q-card .q-num {
  display: inline-block;
  background: #0f172a; color: #fff;
  padding: 2px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 1px;
}
.q-card .q-type { font-size: 12px; color: var(--slate-light); }
.q-card .q-prompt { font-size: 15px; line-height: 1.7; }
.q-card .q-prompt pre {
  white-space: pre-wrap; word-break: break-word;
  background: #f8fafc; border: 1px dashed var(--border);
  padding: 10px 12px; border-radius: 8px; font-family: inherit;
}
.q-card .q-prompt strong { background: #fef08a; padding: 0 4px; border-radius: 4px; }

/* option list (mcq) */
.opts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opts label { display: flex; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.opts label:hover { background: #eef2ff; }
.opts input { margin-top: 4px; }

/* vocab / phrase answer input */
.vocab-input, .phrase-input, .knowledge-input { width: 100%; min-height: 60px; margin-top: 8px; }
/* 知识点问答题：中文成句作答，给足书写空间 */
.knowledge-input { min-height: 96px; line-height: 1.7; }
.word-card { background: #fef3c7; padding: 8px 14px; border-radius: 8px; font-size: 15px; margin: 6px 0 4px; }
.word-card .big { font-size: 20px; font-weight: 700; color: #92400e; }

/* framework editor */
.framework-edit { display: grid; gap: 10px; margin-top: 10px; }
.framework-edit .row { margin: 0; }
.framework-edit .para-line { display: flex; gap: 8px; align-items: center; }
.framework-edit .para-line .pno { background: #eef2ff; color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 12px; flex-shrink: 0; }
.framework-edit .para-line input { flex: 1; }

/* sentence parser */
.parse-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.parse-toolbar .label-info { font-size: 12px; color: var(--slate-light); margin-right: 6px; }
.parse-toolbar .hint-line {
  font-size: 11px; color: var(--slate-light);
  margin-left: 8px; padding: 2px 8px;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px;
}
.parse-token {
  display: inline-block;
  padding: 2px 6px; margin: 2px 1px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
  font-size: 15px;
}
.parse-token:hover { background: #eef2ff; }
.parse-token:active { transform: scale(.97); }
.parse-token.tagged-S  { background: #dbeafe; border-color: var(--tag-S);  color: #1e40af; font-weight: 600; }
.parse-token.tagged-V  { background: #fee2e2; border-color: var(--tag-V);  color: #991b1b; font-weight: 600; }
.parse-token.tagged-PP { background: #fed7aa; border-color: var(--tag-PP); color: #9a3412; font-weight: 600; }
.parse-token.tagged-CL { background: #d1fae5; border-color: var(--tag-CL); color: #065f46; font-weight: 600; }
/* 多标签时左侧出现小字母徽章叠列 */
.tag-chips {
  display: inline-flex; gap: 1px;
  margin-left: 4px; vertical-align: 1px;
}
.tag-chips .badge {
  display: inline-block;
  min-width: 14px; height: 14px;
  padding: 0 3px;
  font-size: 9px; font-weight: 800;
  text-align: center; line-height: 14px;
  border-radius: 3px;
  letter-spacing: -0.5px;
  font-family: ui-monospace, monospace;
  border: 1px solid rgba(0,0,0,.1);
}
.badge.badge-S  { background: var(--tag-S);  color: #fff; }
.badge.badge-V  { background: var(--tag-V);  color: #fff; }
.badge.badge-PP { background: var(--tag-PP); color: #fff; }
.badge.badge-CL { background: var(--tag-CL); color: #fff; }

.parse-legend { display: flex; gap: 12px; font-size: 12px; color: var(--slate); margin-top: 4px; flex-wrap: wrap; }
.parse-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }

/* result */
.result-summary {
  background: linear-gradient(135deg, #5b6cff 0%, #7c3aed 100%);
  color: #fff;
  padding: 24px; border-radius: var(--radius);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(91,108,255,.4);
}
.result-summary .cell { text-align: center; }
.result-summary .num { font-size: 30px; font-weight: 700; }
.result-summary .lbl { font-size: 12px; opacity: .85; }
.result-summary .timer { background: rgba(255,255,255,.18); }

/* 结果页：每类题型得分率 */
.breakdown-wrap { margin-top: 18px; grid-column: 1 / -1; }
.breakdown-title {
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
  color: #fff; opacity: .95;
}
.breakdown-table {
  width: 100%; border-collapse: collapse;
  background: rgba(255,255,255,.12);
  border-radius: 10px; overflow: hidden; font-size: 13px;
}
.breakdown-table th, .breakdown-table td {
  padding: 8px 12px; text-align: left; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.breakdown-table th { font-weight: 600; background: rgba(255,255,255,.08); }
.breakdown-table td:nth-child(2), .breakdown-table td:nth-child(3) { text-align: center; }
.breakdown-table tr:last-child td { border-bottom: none; }
.bd-bar {
  position: relative; height: 18px; background: rgba(255,255,255,.2);
  border-radius: 9px; overflow: hidden; min-width: 80px;
}
.bd-fill {
  height: 100%; background: rgba(255,255,255,.75);
  border-radius: 9px 0 0 9px;
}
.bd-bar span {
  position: absolute; right: 6px; top: 0; font-size: 11px;
  line-height: 18px; font-weight: 600;
}

.res-question {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  position: relative;
}
.res-question.right { border-left: 4px solid var(--green); }
.res-question.partial { border-left: 4px solid var(--amber); }
.res-question.wrong { border-left: 4px solid var(--red); }
.res-question.pending { border-left: 4px solid var(--slate-light); }
.res-question .badge {
  position: absolute; right: 14px; top: 14px;
  font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500;
}
.res-question.right .badge { background: #d1fae5; color: #065f46; }
.res-question.partial .badge { background: #fef3c7; color: #92400e; }
.res-question.wrong .badge { background: #fee2e2; color: #991b1b; }
.res-question.pending .badge { background: #f1f5f9; color: #475569; }
.res-question .meta { font-size: 12px; color: var(--slate-light); }
.res-question .ref { background: #fff7ed; padding: 10px; border-radius: 8px; font-size: 13px; }
.res-question .resp { background: #f8fafc; padding: 10px; border-radius: 8px; font-size: 13px; }
.res-question .resp .token { padding: 2px 4px; border-radius: 4px; margin-right: 1px; display: inline-block; }
.res-question .resp .token.tagged-S  { background: #dbeafe; border: 1px solid var(--tag-S);  color: #1e40af; font-weight: 600; }
.res-question .resp .token.tagged-V  { background: #fee2e2; border: 1px solid var(--tag-V);  color: #991b1b; font-weight: 600; }
.res-question .resp .token.tagged-PP { background: #fed7aa; border: 1px solid var(--tag-PP); color: #9a3412; font-weight: 600; }
.res-question .resp .token.tagged-CL { background: #d1fae5; border: 1px solid var(--tag-CL); color: #065f46; font-weight: 600; }

/* table */
table.steps-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.steps-table th, table.steps-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.steps-table th { background: #eef2ff; color: var(--primary); font-weight: 600; }
table.leaderboard { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.leaderboard th, table.leaderboard td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.leaderboard th { background: #1e293b; color: #fff; font-weight: 600; }
table.leaderboard tr.top td { background: linear-gradient(90deg, #fef3c7, transparent); }
table.leaderboard td.score { font-weight: 600; color: var(--primary); }
table.leaderboard td.time { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--slate); }
table.leaderboard .status { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
table.leaderboard .status.in_progress { background: #fef3c7; color: #92400e; }
table.leaderboard .status.submitted { background: #dbeafe; color: #1e40af; }
table.leaderboard .status.graded { background: #d1fae5; color: #065f46; }

.row { display: flex; gap: 14px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.row label, .row .field-label { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 220px; font-size: 13px; color: var(--slate); }
.row .field-label { display: block; margin-bottom: 6px; cursor: pointer; }
.field-label .sub-hint { display: block; }
.row input, .row select, .row textarea { width: 100%; }
.row-buttons { justify-content: flex-end; }
textarea { font: inherit; }

.hidden { display: none !important; }
.status { font-size: 14px; margin-top: 8px; min-height: 18px; }
.status.success { color: var(--green); }
.status.error { color: var(--red); }

.empty { padding: 40px 20px; text-align: center; color: var(--slate-light); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--card); }
.gold { color: #d97706; font-weight: 700; }
.green { color: #10b981; font-weight: 700; }
.red { color: var(--red); font-weight: 700; }

.audio-playback audio { width: 100%; margin-top: 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.kbd { background: #0f172a; color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px 18px; }
  .tabs { position: static; padding: 0 8px; }
  main { padding: 18px; }
}
/* ===== 多篇上传 / 换一套题（新增） ===== */
label .sub-hint { color: var(--slate-light); font-size: 12px; font-weight: 400; }

.file-preview { margin-top: 8px; font-size: 13px; color: var(--slate-light); }
.file-preview .fp-ok { color: var(--green); }
.file-preview .fp-warn { color: var(--red); font-weight: 600; }
.file-preview ul { margin: 6px 0 0; padding-left: 18px; }
.file-preview li { margin: 2px 0; }
.file-preview .fp-size { color: var(--slate-light); margin-left: 8px; font-size: 12px; }
.file-preview.over { border: 1px dashed var(--red); border-radius: var(--radius); padding: 8px 12px; background: #fef2f2; }

/* 拖拽上传区 */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover { border-color: var(--primary); }
.drop-zone.dragover { border-color: var(--primary); background: #eef2ff; }
.drop-zone input[type="file"] { display: block; margin: 0 auto 8px; max-width: 100%; font-size: 12px; }
.drop-zone .dz-hint { font-size: 12px; color: var(--slate-light); }
.uploaded-item.pending {
  border-left-color: var(--primary);
  color: var(--slate-light);
  font-size: 13px;
}

.status.warn { color: var(--amber); }

.uploaded-list { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.uploaded-item {
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--green);
  border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow);
}
.uploaded-item.failed { border-left-color: var(--red); }
.uploaded-item .ui-title { font-weight: 600; color: var(--slate); margin-bottom: 6px; }
.uploaded-item .ui-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--slate-light); }
.uploaded-item .ui-meta .chip { background: #eef2ff; color: var(--primary); padding: 2px 8px; border-radius: 999px; }
.uploaded-item .ui-meta .chip.repeat { background: #fef3c7; color: #92400e; }

.doc-card .meta .chip.set { background: #fef3c7; color: #92400e; }

/* 换题能力提示：材料太短、候选不足时的高亮 */
.chip.repeat.over,
.doc-card .meta .chip.set.over { background: #fee2e2; color: #b91c1c; }
.ui-hint { margin-top: 6px; font-size: 12px; line-height: 1.55; }
.ui-hint.warn { color: #92400e; background: #fffbeb; border-left: 3px solid #f59e0b; padding: 6px 10px; border-radius: 4px; }

/* === 学生视角：按测试状态分组 === */
.status-group {
  margin-bottom: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.status-group[data-status="in_progress"]       { border-left: 4px solid #06b6d4; }
.status-group[data-status="untested"]          { border-left: 4px solid var(--border); }
.status-group[data-status="submitted_pending"] { border-left: 4px solid #f59e0b; }
.status-group[data-status="graded"]            { border-left: 4px solid var(--green); }
.status-group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.status-group-head h3 { margin: 0; font-size: 16px; }
.status-group-count { font-size: 12px; color: var(--slate-light); }
.status-group .doc-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.empty.sub { padding: 18px; text-align: center; color: var(--slate-light); }

/* 学生视角：用户状态徽章 */
.chip.user-status { font-weight: 600; }
.chip.user-status.in-progress        { background: #cffafe; color: #155e75; }
.chip.user-status.submitted-pending  { background: #fef3c7; color: #92400e; }
.chip.user-status.graded             { background: #dcfce7; color: #166534; }
.user-score {
  display: inline-block; padding: 2px 8px;
  background: #f1f5f9; color: #0f172a;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.dim { color: var(--slate-light); font-weight: normal; font-size: 12px; margin-left: 4px; }

/* === 老师批改：分组 === */
.grading-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-chip {
  padding: 6px 14px; border-radius: 999px;
  background: #eef2ff; color: var(--primary);
  border: 1px solid transparent; font-size: 13px;
  cursor: pointer; font-weight: 500;
}
.filter-chip:hover { background: #dbeafe; }
.filter-chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 2px 6px rgba(91,108,255,.3);
}
.filter-chip b { font-weight: 700; margin-left: 4px; opacity: .85; }
.grading-toolbar-right {
  margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.grading-toolbar-right .dim { margin-left: 0; }

/* 状态色块（pill / badge） */
.status-pill {
  display: inline-block; padding: 2px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  margin-left: 6px;
}
.status-pill.s-pending   { background: #fef3c7; color: #92400e; }
.status-pill.s-grading   { background: #cffafe; color: #155e75; }
.status-pill.s-auto      { background: #ede9fe; color: #5b21b6; }
.status-pill.s-graded    { background: #dcfce7; color: #166534; }
.status-pill.s-abandoned { background: #f1f5f9; color: #64748b; text-decoration: line-through; }

.item-status {
  display: inline-block; padding: 2px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.item-status.status-pending   { background: #fef3c7; color: #92400e; }
.item-status.status-grading   { background: #cffafe; color: #155e75; }
.item-status.status-auto      { background: #ede9fe; color: #5b21b6; }
.item-status.status-graded    { background: #dcfce7; color: #166534; }
.item-status.status-abandoned { background: #f1f5f9; color: #64748b; }

/* AI 批改：设置面板 + 每题的自动判分摘要 */
.ai-config-box { margin-bottom: 12px; }
.ai-config {
  background: #fafaff; border: 1px solid #ddd6fe; border-radius: 10px;
  padding: 10px 14px;
}
.ai-config summary { cursor: pointer; font-weight: 600; color: #4c1d95; }
.ai-config-body {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-top: 10px;
}
.ai-config-body label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #475569; min-width: 220px; flex: 1;
}
.ai-input {
  padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 13px; width: 100%; box-sizing: border-box;
}
.ai-config-actions { display: flex; align-items: center; gap: 10px; }
.ai-tip { flex: 1 0 100%; font-size: 12px; line-height: 1.7; }
.ai-tip code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
.ai-regrade-btn { white-space: nowrap; }
.ai-feedback {
  background: #f8f7ff; border-left: 3px solid #8b5cf6;
  padding: 6px 10px; border-radius: 6px; font-size: 13px; margin: 6px 0;
}
.ai-score { font-weight: 700; color: #5b21b6; }

.student-block {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.student-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: #f8fafc; border-bottom: 1px solid var(--border);
}
.student-name { font-size: 16px; }
.student-meta { display: flex; flex-wrap: wrap; }
.student-body { padding: 14px 18px; }

.doc-block {
  background: #fcfcfd;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 12px;
}
.doc-block:last-child { margin-bottom: 0; }
.doc-block-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.doc-title { font-weight: 600; color: #0f172a; }
.doc-meta { font-size: 12px; }

.step-block { margin-bottom: 10px; }
.step-block:last-child { margin-bottom: 0; }
.step-label {
  font-size: 12px; font-weight: 600; color: var(--slate);
  background: #eef2ff; padding: 4px 10px; border-radius: 6px;
  display: inline-block; margin-bottom: 8px;
}
.step-items { display: flex; flex-direction: column; gap: 8px; }

.grade-item {
  background: #fff;
  border: 1px solid var(--border); border-left: 3px solid var(--amber);
  border-radius: 8px; padding: 10px 14px;
}
.grade-item:focus { outline: none; box-shadow: 0 0 0 2px rgba(91,108,255,.3); }
.grade-item-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.grade-item-title { margin: 4px 0 8px; font-size: 14px; color: var(--slate); font-weight: 600; }
.grade-item-resp { background: #f8fafc; padding: 6px 10px; border-radius: 6px; margin-top: 6px; }
.grade-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.grade-row .grade-feedback { flex: 1; min-width: 180px; }
.status-select {
  font-size: 12px; padding: 4px 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
}

/* ===== 登录门（首次访问 / 切换用户）===== */
.login-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eef2ff 0%, #e0e7ff 45%, #f8fafc 100%);
  overflow: auto;
}
.login-gate.hidden { display: none; }
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .16);
  padding: 32px 28px 28px;
  text-align: center;
}
.login-logo { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.login-card h2 { margin: 0 0 6px; font-size: 22px; color: #0f172a; }
.login-sub { margin: 0 0 22px; font-size: 13px; color: var(--slate-light); }
.login-card label {
  display: block; text-align: left;
  font-size: 13px; font-weight: 600; color: var(--slate); margin-bottom: 6px;
}
.login-card input[type="text"],
.login-card input:not([type]) {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; margin-bottom: 16px;
}
.login-card input[type="text"]:focus,
.login-card input:not([type]):focus,
.login-card input[type="password"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 108, 255, .16);
}
.login-card input[type="password"] {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; margin-bottom: 6px;
}
.login-card small { display: block; text-align: left; font-size: 12px; color: var(--slate-light); margin-bottom: 14px; }
.role-pick { display: flex; gap: 10px; margin-bottom: 16px; }
.role-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px !important; font-weight: 500 !important;
  padding: 10px 8px; margin: 0 !important;
  border: 1px solid var(--border); border-radius: 9px;
  cursor: pointer; transition: all .15s;
}
.role-opt:hover { border-color: var(--primary); background: #f5f7ff; }
.role-opt input { margin: 0; }
.login-card .primary {
  width: 100%; padding: 12px; font-size: 16px; font-weight: 600;
  border: none; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}
.login-card .primary:disabled { opacity: .6; cursor: default; }
.login-err {
  margin-top: 14px; padding: 9px 12px;
  font-size: 13px; color: #b91c1c; text-align: left;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
}
.login-err.hidden { display: none; }
.hidden { display: none !important; }

/* ===== 分享链接卡片 ===== */
.share-box {
  background: #fff; border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 24px;
}
.share-loading, .share-empty { color: var(--slate-light); font-size: 13px; }
.share-item { margin-bottom: 14px; }
.share-item:last-child { margin-bottom: 0; }
.share-label { font-size: 13px; font-weight: 600; color: var(--slate); margin-bottom: 5px; }
.share-label .tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  font-size: 11px; font-weight: 500; border-radius: 20px; vertical-align: 1px;
}
.share-label .tag.wan { background: #dcfce7; color: #15803d; }
.share-label .tag.lan { background: #e0e7ff; color: #4338ca; }
.share-status {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  font-size: 11px; font-weight: 500; border-radius: 20px; vertical-align: 1px;
}
.share-status.st-ok   { background: #dcfce7; color: #15803d; }
.share-status.st-bad  { background: #fee2e2; color: #b91c1c; }
.share-status.st-idle { background: #f1f5f9; color: #64748b; }
.share-qr { margin-top: 8px; }
.share-qr img {
  width: 132px; height: 132px; display: block;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 4px;
}
.share-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.share-url {
  flex: 1; min-width: 220px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  padding: 8px 10px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 8px;
  overflow-x: auto; white-space: nowrap;
}
.share-copy {
  padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; color: var(--slate);
}
.share-copy:hover { border-color: var(--primary); color: var(--primary); background: #f5f7ff; }
.share-note { margin-top: 10px; font-size: 12px; color: var(--slate-light); line-height: 1.7; }

/* ===== 老师批改：按学生整套重审（侧边栏 + 右侧整卷） ===== */
.grading-view-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grading-layout { display: flex; gap: 14px; align-items: flex-start; }
@media (max-width: 900px) { .grading-layout { flex-direction: column; } }

.grading-sidebar {
  width: 260px; flex: 0 0 260px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  position: sticky; top: 12px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
@media (max-width: 900px) { .grading-sidebar { width: 100%; flex: none; position: static; max-height: none; } }
.sidebar-head { padding: 10px 12px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.sidebar-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--slate); }
.sidebar-search {
  width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.sidebar-list { overflow-y: auto; flex: 1; padding: 4px 0; }
.sidebar-foot { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; }

.stu-node { border-bottom: 1px solid #f1f5f9; }
.stu-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  cursor: pointer; font-size: 13px; user-select: none;
}
.stu-head:hover { background: #f5f7ff; }
.stu-caret { transition: transform .15s; color: var(--slate-light); font-size: 11px; }
.stu-node.open .stu-caret { transform: rotate(90deg); }
.stu-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stu-count { font-size: 11px; color: var(--slate-light); }
.stu-attempts { display: none; padding: 0 8px 8px 22px; }
.stu-node.open .stu-attempts { display: block; }
.attempt-node {
  padding: 7px 9px; border-radius: 8px; cursor: pointer; margin-bottom: 5px;
  border: 1px solid transparent; background: #f8fafc;
}
.attempt-node:hover { background: #eef2ff; }
.attempt-node.active { background: #e0e7ff; border-color: var(--primary); }
.attempt-title { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attempt-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 3px; font-size: 11px; color: var(--slate-light); }

.grading-main { flex: 1; min-width: 0; }
.review-head {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.review-title { font-size: 15px; font-weight: 700; }
.review-sub { font-size: 12px; margin-top: 4px; }
.review-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.review-item-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.rv-no { font-weight: 700; font-size: 13px; color: var(--slate); }
.rv-prompt { font-size: 13px; color: var(--slate); margin-bottom: 6px; line-height: 1.6; }
.rv-ref { color: #0f766e; }
.rv-auto { color: var(--slate-light); font-size: 12px; }

/* 词汇题：词性 + 文中义 两项必填 */
.vocab-answer { margin-top: 8px; }
.vocab-label { display: block; font-size: 12px; color: var(--slate); margin: 6px 0 4px; font-weight: 600; }
.vocab-label .req { color: var(--red); font-style: normal; font-size: 11px; margin-left: 4px; }
.vocab-pos-row { display: block; }
.vocab-pos {
  width: 100%; box-sizing: border-box; padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.vocab-pos:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
/* 必填项没填时交卷：短暂高亮 */
.req-missing { border-color: var(--red) !important; background: #fff5f5 !important; }
