/* ============================================================
 *  styles.css — 错题闭环管理系统 · 明亮主题设计系统
 * ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f2;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8b93a7;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef2ff;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(17,24,39,.04), 0 8px 24px rgba(17,24,39,.06);
  --shadow-sm: 0 1px 2px rgba(17,24,39,.05);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: 0 0 250px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(79,70,229,.32);
}
.brand-text { display: flex; flex-direction: column; }
.brand-text b { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.nav-group {
  font-size: 11px; color: var(--muted); font-weight: 600;
  letter-spacing: .6px; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; cursor: pointer;
  transition: all .16s ease; margin-bottom: 2px;
}
.nav-item i { font-style: normal; font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.28);
}
.side-foot { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- 云端同步状态 ---------- */
.sync-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.sync-pill i { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; flex: 0 0 7px; }
.sync-pill.on { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.sync-pill.on i { background: #10b981; }
.sync-pill.busy { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.sync-pill.busy i { background: #3b82f6; animation: pulse 1s infinite; }
.sync-pill.err { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.sync-pill.err i { background: #ef4444; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.badge.err { background: #fee2e2; color: #b91c1c; }

.sync-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.sync-grid > div {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; display: flex; flex-direction: column; gap: 2px;
}
.sync-grid span { font-size: 11px; color: var(--muted); }
.sync-grid b { font-size: 13px; word-break: break-all; }
@media (max-width: 620px) { .sync-grid { grid-template-columns: 1fr; } }

.quiz-img { margin-top: 14px; text-align: center; }
.quiz-img img { max-width: 100%; max-height: 340px; border-radius: 12px; border: 1px solid var(--border); }
/* 分卷录入：学生作答（答题卡）那张单独标注一下，别和题干原图混淆 */
.quiz-img.sheet { margin-top: 10px; }
.quiz-img.sheet img { border-color: #fde68a; background: #fffdf5; }
.quiz-cap {
  font-size: 11.5px; font-weight: 700; color: var(--amber);
  margin-bottom: 6px; text-align: center;
}
.side-tip { background: var(--primary-soft); border-radius: 12px; padding: 12px 13px; }
.side-tip b { font-size: 12px; color: var(--primary); }
.side-tip p { font-size: 11px; color: #5b5f77; margin-top: 4px; line-height: 1.5; }

.main { flex: 1; min-width: 0; }
.view { padding: 26px 32px 60px; max-width: 1280px; margin: 0 auto; }

/* ---------- 移动端导航（窄屏改为抽屉，桌面端不显示） ---------- */
.mobile-bar { display: none; }
.sidebar-mask { display: none; }

/* ---------- 页头 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.4px; }
.page-head p { font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; }
.card.hero { padding: 26px; }
.card.quick { display: flex; align-items: center; gap: 14px; cursor: pointer; transition: all .18s ease; }
.card.quick:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d7dbf0; }
.q-ico { font-size: 26px; }
.card.quick b { font-size: 15px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2,1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .view { padding: 16px 14px 72px; }

  /* 顶部移动栏 */
  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 60;
    padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mb-btn {
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
    background: var(--surface-2); border: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  }
  .mb-btn span { display: block; width: 16px; height: 2px; border-radius: 2px; background: var(--text-2); }
  .mb-title { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bar .sync-pill { padding: 5px 9px; font-size: 11px; flex: 0 0 auto; }

  /* 侧栏 -> 滑出抽屉 */
  .sidebar {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0; height: 100%;
    width: 268px; flex: 0 0 268px; z-index: 70;
    transform: translateX(-105%); transition: transform .24s ease;
    box-shadow: 0 12px 40px rgba(17,24,39,.22);
  }
  .app.menu-open .sidebar { transform: translateX(0); }

  .sidebar-mask {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(17,24,39,.45); opacity: 0; pointer-events: none; transition: opacity .24s ease;
  }
  .app.menu-open .sidebar-mask { opacity: 1; pointer-events: auto; }

  /* 内容让开固定顶栏 */
  .main { padding-top: 54px; }
  .nav-item { padding: 11px 12px; }
}

/* ---------- 统计卡 ---------- */
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.stat-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; flex: 0 0 46px; }
.stat-num { font-size: 25px; font-weight: 800; letter-spacing: -.6px; line-height: 1.15; }
.stat-lab { font-size: 12px; color: var(--muted); }

/* ---------- 小列表 ---------- */
.mini-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.mini-list li { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.mini-sub { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.mini-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; display: inline-block; }

/* ---------- 条形 / 掌握度 ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-label { flex: 0 0 66px; color: var(--text-2); }
.bar-track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }
.bar-val { flex: 0 0 30px; text-align: right; font-weight: 700; font-size: 12px; color: var(--text-2); }

.mbar { display: inline-block; width: 56px; height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.mbar i { display: block; height: 100%; border-radius: 4px; }
.mval { font-size: 11px; font-weight: 700; margin-left: 6px; vertical-align: middle; }

/* ---------- 徽标 / chip ---------- */
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px;
  border: 1px solid transparent; font-weight: 600; white-space: nowrap;
}
.chip-k { background: #eef2f7; color: #475569; border-color: #e2e8f0; margin: 1px 2px; font-weight: 500; }
.badge {
  display: inline-block; background: var(--primary-soft); color: var(--primary);
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
.badge.on { background: #dcfce7; color: var(--green); }

/* ---------- 环形图 ---------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.legend { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-item b { margin-left: auto; color: var(--text); }

/* ---------- 薄弱点 ---------- */
.weak-row { margin-bottom: 11px; }
.weak-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: all .16s ease;
}
.btn:hover { background: var(--surface-2); border-color: #d7dbf0; }
.btn-primary { background: linear-gradient(135deg, #4f46e5, #6366f1); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, #4f46e5, #6366f1); }
.btn.block { width: 100%; }
.btn.lg { padding: 12px 28px; font-size: 15px; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.file-btn { cursor: pointer; }
.icon-btn { padding: 4px 6px; border-radius: 8px; font-size: 14px; opacity: .55; }
.icon-btn:hover { opacity: 1; background: #fef2f2; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.row-center { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.row-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.chip-btn {
  padding: 9px 16px; border-radius: 22px; font-weight: 600; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  transition: all .16s ease;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.chip-btn.primary { background: var(--primary); border-color: transparent; color: #fff; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg-btn.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- 表格 ---------- */
.table { display: flex; flex-direction: column; }
.tr { display: grid; grid-template-columns: 84px 2fr 118px 1.4fr 110px 40px; gap: 12px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tr:last-child { border-bottom: none; }
.tr.th { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .3px; border-bottom: 1px solid var(--border); }
.tr:hover:not(.th) { background: var(--surface-2); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) {
  .tr { grid-template-columns: 70px 1fr 90px; }
  .tr > *:nth-child(n+4) { display: none; }
  /* 最近录入：保留「学科 / 题目 / 操作」，隐藏题型与知识点 */
  .tr.eb { grid-template-columns: 66px 1fr 88px; }
  .tr.eb > *:nth-child(3) { display: none; }
  .tr.eb > *:nth-child(4) { display: none; }
  .tr.eb > *:nth-child(5) { display: none; }
  .tr.eb > *:nth-child(6) { display: flex; }
}

/* ---------- 表单 ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
label.full { display: block; margin-bottom: 14px; }
label.full > input, label.full > textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.form-grid label { display: block; }
input, select, textarea {
  width: 100%; margin-top: 6px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  outline: none; transition: all .16s ease; font-size: 13px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(99,102,241,.13); }
textarea { resize: vertical; line-height: 1.6; }
.req { color: var(--red); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.55; }

.upload {
  display: block; border: 2px dashed #d7dbf0; border-radius: 14px; cursor: pointer;
  background: var(--surface-2); overflow: hidden; transition: all .16s ease; min-height: 180px;
  display: grid; place-items: center; padding: 18px; text-align: center;
}
.upload:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.upload img.thumb { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.upload-ph b { display: block; margin-top: 6px; font-size: 14px; }

.cause-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 8px; }
.cause-opt { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); font-weight: 600; font-size: 12.5px; transition: all .16s ease; }
.cause-opt input { width: auto; margin: 0; accent-color: var(--c); }
.cause-opt:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, #fff); }
@media (max-width: 620px) { .cause-pick { grid-template-columns: 1fr 1fr; } .form-grid { grid-template-columns: 1fr; } }

/* ---------- 进度条 ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-bottom: 18px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #4f46e5, #7c3aed); border-radius: 6px; transition: width .4s ease; }

/* ---------- 答题卡 ---------- */
.quiz { padding: 26px 30px; }
.quiz-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.quiz-q { font-size: 17px; line-height: 1.85; font-weight: 500; padding: 18px 20px; background: var(--surface-2); border-radius: 12px; border-left: 4px solid var(--primary); }
.quiz-fig { margin-top: 12px; font-size: 13px; color: var(--text-2); background: #f0f4ff; padding: 10px 14px; border-radius: 10px; }
.ask { margin: 18px 0 14px; color: var(--text-2); font-size: 14px; }
.answer-box { margin-top: 18px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 16px 18px; }
.ans-row { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 7px 0; font-size: 14px; }
.ans-row b { color: var(--green); font-size: 12.5px; }
.ans-row.wrong b { color: var(--red); }
.ans-row.wrong div { color: var(--red); }

.rate-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rate { padding: 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 3px; transition: all .16s ease; }
.rate b { font-size: 14px; }
.rate span { font-size: 11.5px; color: var(--muted); }
.rate:hover { transform: translateY(-2px); }
.rate.good { border-color: #bbf7d0; } .rate.good:hover { background: #f0fdf4; } .rate.good b { color: var(--green); }
.rate.fuzzy { border-color: #fde68a; } .rate.fuzzy:hover { background: #fffbeb; } .rate.fuzzy b { color: var(--amber); }
.rate.bad { border-color: #fecaca; } .rate.bad:hover { background: #fef2f2; } .rate.bad b { color: var(--red); }

/* ---------- 选项 ---------- */
.options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border: 1.5px solid var(--border); border-radius: 11px; cursor: pointer; font-weight: 500; font-size: 14px; margin: 0; transition: all .16s ease; }
.opt input { width: auto; margin: 0; accent-color: var(--primary); }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- 出卷知识点选择 ---------- */
.kpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.kopt { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; transition: all .16s ease; background: var(--surface); margin: 0; }
.kopt:hover { border-color: #c7cdf0; }
.kopt input { width: auto; margin: 0; accent-color: var(--primary); }
.kopt-in { display: flex; flex-direction: column; }
.kopt-in b { font-size: 13.5px; }
.kopt-in em { font-style: normal; font-size: 11px; color: var(--muted); }
.kopt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.kopt.weak { border-color: #fde68a; background: #fffdf5; }
.kopt.weak:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- 总结 ---------- */
.summary { text-align: center; }
.big-pct { font-size: 58px; font-weight: 800; letter-spacing: -2px; line-height: 1; color: var(--primary); }
.big-pct small { font-size: 22px; font-weight: 700; }
.sum-grid { display: flex; justify-content: center; gap: 44px; margin: 22px 0; }
.sum-grid > div { display: flex; flex-direction: column; }
.sum-grid b { font-size: 24px; }
.sum-grid span { font-size: 12px; color: var(--muted); }
.growth { background: var(--primary-soft); color: #4338ca; padding: 13px 18px; border-radius: 12px; font-size: 13.5px; margin: 14px auto; max-width: 640px; }
.hero h2 { font-size: 22px; margin-bottom: 6px; }

/* ---------- 批改 ---------- */
.grade-item { border: 1px solid var(--border); border-radius: 12px; padding: 15px 17px; margin-bottom: 12px; border-left: 4px solid var(--green); }
.grade-item.no { border-left-color: var(--red); }
.grade-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grade-tag { font-size: 12px; font-weight: 700; }
.grade-item.ok .grade-tag { color: var(--green); }
.grade-item.no .grade-tag { color: var(--red); }
.grade-q { background: var(--surface-2); padding: 11px 14px; border-radius: 9px; margin-bottom: 10px; font-size: 14px; line-height: 1.7; }
.grade-row { font-size: 13.5px; padding: 2px 0; }
.grade-row b { color: var(--text-2); font-size: 12.5px; }
.grade-row .bad { color: var(--red); }
.grade-row .good { color: var(--green); font-weight: 600; }
.grade-sol { margin-top: 9px; font-size: 13px; color: var(--text-2); line-height: 1.7; background: #f8fafc; padding: 10px 13px; border-radius: 9px; }

/* ---------- 字词卡 ---------- */
.flashcard { perspective: 1200px; height: 260px; cursor: pointer; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d; }
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; box-shadow: var(--shadow); }
.fc-front { background: var(--surface); border: 1px solid var(--border); }
.fc-back { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; transform: rotateY(180deg); }
.fc-tag { position: absolute; top: 16px; left: 20px; font-size: 11px; font-weight: 700; letter-spacing: .5px; opacity: .6; }
.fc-text { font-size: 22px; font-weight: 700; line-height: 1.5; }
.fc-hint { position: absolute; bottom: 14px; font-size: 11.5px; opacity: .5; }

.card-list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; }
.card-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.ci-main { display: flex; flex-direction: column; min-width: 0; }
.ci-main b { font-size: 13.5px; }
.ci-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ---------- 试卷库 ---------- */
.exam-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.trend { display: flex; align-items: flex-end; gap: 12px; height: 120px; padding-top: 12px; }
.trend-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.trend-bar i { width: 60%; max-width: 46px; border-radius: 6px 6px 0 0; min-height: 6px; transition: height .5s ease; }
.trend-bar span { font-size: 12px; font-weight: 700; }
.trend-bar em { font-style: normal; font-size: 10.5px; color: var(--muted); }

/* ---------- 设置 ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.json-view { background: #0f172a; color: #a5f3d0; padding: 16px 18px; border-radius: 12px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.65; overflow-x: auto; max-height: 420px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 26px 12px; font-size: 13.5px; }
.empty.big { padding: 46px 12px; font-size: 16px; line-height: 1.9; }

/* ---------- 提示 ---------- */
#toast-root { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(-12px); transition: all .28s ease; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-err { background: #b91c1c; }

/* ============================================================
 *  拍照收 2.0 —— 识别流水线
 * ============================================================ */

/* ---------- 步骤条 ---------- */
.steps { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.step.on { color: var(--primary); border-color: var(--primary-2); background: var(--primary-soft); }
.step.done { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.step.done::before { content: "✓ "; }

/* ---------- 上传模式切换（同一张图 / 分卷两张图） ---------- */
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.mode-btn {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 11px 14px; border-radius: 12px; background: #fff;
  border: 1.6px solid var(--border); color: var(--text-2);
  transition: all .16s ease;
}
.mode-btn:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.mode-btn.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: var(--shadow-sm); }
.mode-btn b { font-size: 13px; font-weight: 700; }
.mode-btn em { font-size: 11px; font-style: normal; color: var(--muted); line-height: 1.45; }
.mode-btn.on em { color: #6366f1; }

/* ---------- 分卷：试卷槽 + 答题卡槽 ---------- */
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.split-slot {
  border: 1.5px solid var(--border); border-radius: 14px;
  padding: 12px; background: var(--surface-2); transition: all .18s ease;
}
.split-slot.over, .split-slot.paste-on { border-color: var(--primary-2); background: var(--primary-soft); }
.slot-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.slot-head b { font-size: 13px; }
.slot-paste {
  margin-left: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap;
}
.slot-paste input { accent-color: var(--primary); cursor: pointer; }
.split-slot .upload-row { padding: 10px; }
.split-slot .u-thumb, .split-slot .upload-add { width: 92px; height: 92px; }
.split-slot .upload-add b { font-size: 12px; }
.slot-hint {
  margin-top: 9px; font-size: 11.5px; color: var(--muted); line-height: 1.55;
}
/* 缩略图上的角色角标（分卷时才出现） */
.u-role {
  position: absolute; left: 6px; top: 6px; z-index: 2;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 7px;
  color: #fff; background: rgba(79,70,229,.86);
}
.u-role.sheet { background: rgba(217,119,6,.9); }

/* ---------- 多图上传 ---------- */
.upload-row {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 12px; border: 1.6px dashed var(--border); border-radius: 14px;
  background: var(--surface-2); transition: all .18s ease;
}
.upload-row.over { border-color: var(--primary); background: var(--primary-soft); }
.u-thumb {
  position: relative; width: 118px; height: 118px; border-radius: 12px;
  overflow: hidden; border: 1px solid var(--border); background: #fff;
  box-shadow: var(--shadow-sm); flex: 0 0 auto;
}
.u-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.u-idx {
  position: absolute; left: 6px; bottom: 6px; z-index: 2;
  background: rgba(17,24,39,.72); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: grid; place-items: center;
}
.u-del {
  position: absolute; right: 5px; top: 5px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(17,24,39,.72); color: #fff; font-size: 12px; line-height: 1;
  display: grid; place-items: center; transition: background .15s;
}
.u-del:hover { background: var(--red); }
.upload-add {
  width: 118px; height: 118px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px dashed #c9d2e6; border-radius: 12px; cursor: pointer;
  color: var(--text-2); background: #fff; text-align: center; padding: 6px;
  transition: all .18s ease;
}
.upload-add:hover { border-color: var(--primary-2); background: var(--primary-soft); color: var(--primary); }
.upload-add b { font-size: 12.5px; }
.upload-add em { font-size: 10.5px; font-style: normal; color: var(--muted); line-height: 1.35; }

/* ---------- 识别状态提示 ---------- */
.rec-msg {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  font-size: 12.5px; font-weight: 600; line-height: 1.6;
  background: #eef2ff; color: #4338ca; border: 1px solid #dbe2ff;
  white-space: pre-wrap;
}
.rec-msg.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.rec-msg.err { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.hint.warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; border-radius: 9px; padding: 9px 12px; }

/* ---------- 识别结果卡片 ---------- */
.ri-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ri-card {
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface-2); padding: 14px;
}
.ri-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.ri-pick { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ri-pick input { width: 16px; height: 16px; accent-color: var(--primary); }
.ri-pick b { font-size: 13px; }
.ri-tags { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; flex: 1; }
.ri-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.ri-more { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.ri-more summary { font-size: 12px; color: var(--muted); cursor: pointer; margin-bottom: 10px; font-weight: 600; }
.ri-card .form-grid { margin-bottom: 12px; }
.ri-card label.full { display: block; margin-bottom: 12px; }
.btn-mini {
  padding: 6px 12px; border-radius: 9px; font-size: 12px; font-weight: 600;
  background: #fff; border: 1px solid var(--border); color: var(--text-2);
}
.btn-mini:hover { border-color: var(--primary-2); color: var(--primary); background: var(--primary-soft); }

/* ---------- 识别度徽标 ---------- */
.chip.chip-good { background: #dcfce7; color: #047857; border-color: #bbf7d0; }
.chip.chip-mid { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.chip.chip-warn { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* ---------- 免配置通道 ---------- */
.paste-card summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 2px 0; }
.paste-card summary:hover { color: var(--primary); }
.paste-card > p { margin: 10px 0; }
.paste-card textarea {
  width: 100%; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6;
}

@media (max-width: 1100px) { .ri-list { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .mode-switch, .split-grid { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
  .u-thumb, .upload-add { width: 92px; height: 92px; }
  .steps { display: none; }
}

/* 错题原图：云端存储需带会话下载、本机图片在 IndexedDB，
   均由 JS 取回后替换为 blob URL。取回前先显示占位框。 */
.quiz-img img[src^="data:image/gif"] {
  min-width: 180px;
  min-height: 130px;
  border-style: dashed;
  background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 10px, #e9eef5 10px, #e9eef5 20px);
}

/* ---- 设置页：云服务 / 登录 ---- */
.link-btn {
  border: none; background: none; padding: 0 2px; margin: 0;
  color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--primary-2, var(--primary)); }

.auth-pane { margin-top: 4px; }
.auth-pane[hidden] { display: none; }
.auth-pane .row-inline { flex-wrap: nowrap; }
.auth-pane .row-inline input { flex: 1 1 auto; min-width: 0; }
.auth-pane .row-inline .btn { white-space: nowrap; }
#a-pwd-wrap[hidden] { display: none; }

/* ============================================================
 *  错题库
 * ============================================================ */
.chip-type { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.chip-type.need-space { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.chip-src { background: #fff7ed; color: #c2410c; border-color: #fed7aa; font-weight: 500; }

/* 最近录入表格：题型 / 操作列 */
.tr.eb { grid-template-columns: 78px 2fr 96px 1.4fr 104px 92px; }
.tr[data-err-id] { cursor: pointer; }
.tr-ops { display: flex; align-items: center; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.tr-ops .btn-mini { padding: 4px 9px; font-size: 11.5px; }

.eb-toolbar { display: flex; flex-direction: column; gap: 12px; }
.eb-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.eb-search { flex: 1 1 240px; min-width: 180px; margin-top: 0; }
.eb-tools select { flex: 0 0 auto; width: auto; min-width: 118px; margin-top: 0; }
.eb-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.eb-actions .m-spacer { flex: 1 1 auto; min-width: 4px; }
/* 批量删除后的「撤销」提示 */
.eb-undo {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: #92400e; background: #fef3c7; border: 1px solid #fde68a;
}
.eb-undo .link-btn { color: #b45309; font-weight: 800; text-decoration: underline; }
.eb-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.eb-opt input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.eb-count { font-size: 12.5px; font-weight: 700; color: var(--primary); }

.eb-list { display: flex; flex-direction: column; }
.eb-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 12px; border-bottom: 1px solid var(--border);
  border-radius: 10px; transition: background .16s ease;
}
.eb-item:last-child { border-bottom: none; }
.eb-item:hover { background: var(--surface-2); }
.eb-item.on { background: var(--primary-soft); }
.eb-item.on .eb-content { color: var(--primary); }
.eb-check { display: flex; align-items: center; padding-top: 3px; cursor: pointer; }
.eb-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.eb-main { flex: 1; min-width: 0; }
.eb-title { display: flex; align-items: baseline; gap: 8px; }
.eb-content { font-size: 14px; font-weight: 500; line-height: 1.6; word-break: break-word; }
.eb-tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.eb-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.eb-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
@media (max-width: 860px) {
  .eb-side { flex-direction: column; align-items: flex-end; gap: 5px; }
  .eb-time { display: none; }
  .eb-actions .btn { margin-left: 0; width: 100%; }
}

/* ============================================================
 *  错题详情弹窗
 * ============================================================ */
body.modal-open { overflow: hidden; }
.modal-mask {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: maskIn .18s ease;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: 18px; width: min(720px, 100%);
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
  animation: modalIn .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.mh-tags { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: 1; }
.modal-x {
  width: 30px; height: 30px; border-radius: 9px; font-size: 15px; flex: 0 0 30px;
  color: var(--text-2); background: var(--surface-2);
}
.modal-x:hover { background: #fee2e2; color: var(--red); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.m-lab {
  font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .5px;
  margin: 0 0 7px;
}
.m-lab:not(:first-child) { margin-top: 20px; }
.m-question {
  font-size: 16px; line-height: 1.85; padding: 15px 17px;
  background: var(--surface-2); border-radius: 12px; border-left: 4px solid var(--primary);
  word-break: break-word;
}
.m-ans {
  font-size: 15px; line-height: 1.8; padding: 13px 16px; color: #047857; font-weight: 600;
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; word-break: break-word;
}
.m-sub { display: flex; gap: 10px; margin-top: 10px; font-size: 13.5px; line-height: 1.7; }
.m-sub b { flex: 0 0 92px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.m-sub span { flex: 1; word-break: break-word; }
.m-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.m-meta > div {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; display: flex; flex-direction: column; gap: 2px;
}
.m-meta span { font-size: 11px; color: var(--muted); }
.m-meta b { font-size: 13px; word-break: break-all; }
.m-qtype { margin-top: 18px; margin-bottom: 0; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 18px 18px;
}
.m-spacer { flex: 1; }
.m-opt { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.m-opt input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
@media (max-width: 620px) {
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: 18px 18px 0 0; }
  .m-meta { grid-template-columns: 1fr; }
  .modal-foot .danger { order: 9; }
  .m-spacer { display: none; }
}

/* 导出 PDF 用的隐藏打印 frame（iframe 兜底方案） */
#ecm-print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

/* ============================================================
 *  题目正文里的几何图形（识别还原）
 * ============================================================ */

/* 正文中内联的图形行（与原题一样，横向并排） */
.fig-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin: 8px 0 4px;
}
.fig-img {
  display: block; max-height: 190px; max-width: min(100%, 340px);
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.m-question .fig-img, .quiz-q .fig-img { max-height: 230px; }

/* 原卷版式：图形与文字左右并排（图在右侧），文字环绕在图的左边 */
.fig-flow { display: flow-root; }
.fig-float {
  float: right;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px;
  margin: 0 0 6px 14px; max-width: 46%;
}
.fig-float .fig-img { max-height: 190px; max-width: 100%; }
.m-question .fig-float .fig-img, .quiz-q .fig-float .fig-img { max-height: 210px; }
/* 屏幕很窄时不再浮动，避免把文字挤成一列 */
@media (max-width: 560px) {
  .fig-float { float: none; max-width: 100%; margin: 8px 0 4px; }
}

/* 校对卡片里的图形条 */
.ri-figs {
  margin: 4px 0 12px; padding: 10px 12px;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.ri-figs-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}
.ri-figs-head b { font-size: 13px; }
.fig-strip { display: flex; flex-wrap: wrap; gap: 12px; }
.fig-thumb {
  width: 168px; padding: 7px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
}
.fig-thumb img {
  display: block; width: 100%; height: 108px; object-fit: contain;
  background: #fff; border-radius: 6px; cursor: zoom-in;
}
.fig-thumb.empty { border-style: dashed; }
.fig-thumb-empty {
  height: 108px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px; background: repeating-linear-gradient(45deg, #f6f8fc, #f6f8fc 9px, #eef1f8 9px, #eef1f8 18px);
  border-radius: 6px;
}
.fig-thumb-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px;
}
.fig-thumb-foot b { font-size: 12.5px; }
.fig-ops { display: flex; align-items: center; gap: 3px; }
.fig-thumb-desc {
  margin-top: 5px; font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 图形相对文字的位置（决定导出 PDF 时并排还是另起一行） */
.fig-place {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 11.5px; color: var(--muted);
}
.fig-place select {
  flex: 1; min-width: 0; padding: 3px 6px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; color: inherit;
}

/* 图形重新框选弹窗 */
.crop-modal { max-width: 860px; width: 92vw; }
.crop-stage {
  position: relative; margin: 12px 0; user-select: none; touch-action: none;
  background: #f1f3f9; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; line-height: 0; cursor: crosshair;
}
.crop-stage img { display: block; width: 100%; height: auto; }
.crop-sel {
  position: absolute; display: none; pointer-events: none;
  border: 2px solid var(--primary); border-radius: 4px;
  background: rgba(79, 70, 229, .12);
  box-shadow: 0 0 0 9999px rgba(17, 24, 39, .38);
}

/* 错题编辑弹窗 */
.edit-modal { width: min(820px, 100%); }
.edit-modal .modal-body { padding-bottom: 20px; }
.edit-modal label.full { font-size: 13px; }
.edit-modal .ri-figs { margin-top: 2px; }
/* 编辑里的缩略图只是展示，不做点击放大 */
.edit-modal .fig-thumb img { cursor: default; }
