/* ============================================================
   题库系统 · 教师端样式（v1.0.1）
   ------------------------------------------------------------
   组件只引用 tokens.css 的语义变量，不直接写色值。
   布局四档：≥1440 三栏 / 1024–1440 两栏+抽屉 / 768–1024 图标栏 / <768 底部 Tab
   ============================================================ */

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-14)/var(--lh) var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono); font-size: .92em;
  background: var(--surface-3); padding: 1px 5px; border-radius: 4px;
}
[hidden] { display: none !important; }
::selection { background: var(--brand-soft); color: var(--text); }

/* 焦点环：只在键盘操作时出现，避免鼠标点击满屏蓝框 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -60px; left: 12px; z-index: 400;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 8px 14px; box-shadow: var(--sh-2); transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 10px; }

/* 滚动条：细、低对比，不抢视线 */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-2); border-radius: var(--r-pill);
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

/* ---------------- 登录 ---------------- */
.login-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6);
  background:
    radial-gradient(1000px 520px at 12% -10%, var(--brand-soft) 0%, transparent 62%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-8) var(--s-6); box-shadow: var(--sh-2);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.login-brand { display: flex; gap: var(--s-3); align-items: center; margin-bottom: var(--s-1); }
.login-brand h1 { font-size: var(--fs-20); }
.login-brand p { margin: 2px 0 0; color: var(--text-3); font-size: var(--fs-12); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: var(--brand); color: var(--on-brand);
  font-size: var(--fs-20); font-weight: 600;
  display: grid; place-items: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset;
}
.login-hint { font-size: var(--fs-12); color: var(--text-3); margin: 0; line-height: 1.5; }
.login-error { color: var(--danger); font-size: var(--fs-13); margin: 0; min-height: 18px; }

/* v1.1.22 「本站接入大模型」徽标：登录页横幅 + 页眉小胶囊，紫色沿用 --ai（Qwen 品牌紫） */
.ai-brandline {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 10px 0 2px; padding: 9px 12px;
  border: 1px solid var(--ai-soft-border); border-radius: var(--r);
  background: var(--ai-soft);
  font-size: var(--fs-12); color: var(--text-2); line-height: 1.4; text-align: center;
}
.ai-brandline img { width: 20px; height: 20px; flex: none; }
.ai-brandline b { color: var(--ai); font-weight: 700; }

.appbar-ai {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px 3px 5px; border-radius: var(--r-pill);
  border: 1px solid var(--ai-soft-border); background: var(--ai-soft);
  font-size: 11px; font-weight: 600; color: var(--ai); white-space: nowrap;
  cursor: default;
}
.appbar-ai img { width: 16px; height: 16px; flex: none; }
.appbar-ai .appbar-ai-model { font-family: var(--mono); letter-spacing: .01em; }

/* v1.1.0 教师注册：字段比登录多，卡片放宽一点 */
#registerForm { max-width: 460px; }
.grade-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.chip.pick { cursor: pointer; user-select: none; }
.chip.pick[aria-pressed="true"] {
  background: var(--brand-soft); border-color: var(--brand); color: var(--brand);
}
.linkbtn {
  background: none; border: none; padding: 2px 0; margin: 0;
  color: var(--brand); font-size: var(--fs-13); cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-12); color: var(--text-2); font-weight: 500; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 9px 11px; background: var(--surface); outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ---------------- 应用外壳（v1.0.4：顶栏导航 + 内容双轴居中） ---------------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* 顶栏：sticky，内容与外层同轴 */
.appbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.5) blur(10px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: var(--app-max); margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: var(--appbar-h);
  display: flex; align-items: center; gap: var(--s-2);
}
.appbar-brand {
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 4px 8px 4px 4px; border-radius: var(--r);
  text-decoration: none; color: var(--text);
  transition: background var(--dur) var(--ease);
}
.appbar-brand:hover { background: var(--surface-3); }
.appbar-brand .brand-mark { width: 30px; height: 30px; font-size: var(--fs-16); border-radius: 9px; }
.appbar-brand-text { font-size: var(--fs-14); font-weight: 600; white-space: nowrap; }

/* 版本徽标：常驻顶栏，任何「打开的是哪一版」的疑问都能当场回答 */
.brand-ver {
  margin-left: 6px; padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-3);
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: .01em; white-space: nowrap;
}

/* 主导航 */
.topnav { display: flex; align-items: center; gap: 2px; margin-left: var(--s-3); }
.topnav button {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 13px; border: 0; background: none; border-radius: var(--r);
  color: var(--text-2); font-size: var(--fs-13); cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.topnav button:hover { background: var(--surface-3); color: var(--text); }
.topnav button[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topnav svg { width: 16px; height: 16px; flex: none; }
.topnav .nav-label { overflow: hidden; text-overflow: ellipsis; }

/* 工具区：学段 / 主题 / 更多 */
.appbar-tools {
  margin-left: auto; display: flex; align-items: center;
  gap: var(--s-2); position: relative; flex: none;
}
.appbar .appbar-menu-btn { display: none; }

/* 更多菜单（桌面下拉） */
.more-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  min-width: 212px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
}
.more-menu[hidden] { display: none; }
.more-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm);
  color: var(--text); font-size: var(--fs-13); cursor: pointer; text-align: left;
  transition: background var(--dur) var(--ease);
}
.more-menu button:hover { background: var(--surface-3); }
.more-menu button svg { width: 16px; height: 16px; flex: none; color: var(--text-3); }
.more-menu .menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.more-menu .menu-label {
  padding: 7px 10px 5px; font-size: var(--fs-11);
  color: var(--text-3); letter-spacing: .04em;
}

/* 内容区：--content-max 阅读轴，宽版页面用 .page.wide */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page {
  width: 100%; max-width: var(--content-max);
  margin-inline: auto;                 /* 修复 v1.0.3「内容靠左」的根因 */
  padding: 0 var(--gutter);
  flex: 1; display: flex; flex-direction: column;
}
.page.wide { max-width: var(--app-max); }
.page-head {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-5) 0 var(--s-3);
}
.page-head h1 {
  font-size: var(--fs-20); font-weight: 600; margin: 0 auto 0 0;
  letter-spacing: -.01em;
}
.topbar-actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.topbar-actions:empty { display: none; }

.view { padding: 0 0 96px; outline: none; width: 100%; }
.view.bare { padding-bottom: 32px; }

/* ---------------- 控件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  border-radius: var(--r); padding: 7px 13px; cursor: pointer;
  font-size: var(--fs-13); white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  box-shadow: var(--sh-1);
}
.btn-primary:hover {
  background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand);
}
.btn-danger { color: var(--danger); border-color: var(--danger-soft-border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { padding: 4px 9px; font-size: var(--fs-12); }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 10px 18px; font-size: var(--fs-14); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid transparent; background: none; color: var(--text-2);
  border-radius: var(--r); cursor: pointer; flex: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }
.icon-btn svg { width: 18px; height: 18px; }

/* 分段控件（学段 / 状态 / 视图切换） */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 13px; border-radius: var(--r-pill);
  font-size: var(--fs-13); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] {
  background: var(--surface); color: var(--brand);
  font-weight: 600; box-shadow: var(--sh-1);
}
/* v1.1.24 未开放的查看方式：明显置灰，鼠标悬停由 title 说明原因，
   不要做 :hover 变色——否则看着像还能点 */
.seg button[disabled] {
  color: var(--text-3); opacity: .55; cursor: not-allowed;
}
.seg button[disabled]:hover { color: var(--text-3); }

/* 学段切换（沿用旧类名，内部用新样式） */
.stage-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-pill);
  border: 1px solid var(--border); flex: none;
}
.stage-switch button {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 14px; border-radius: var(--r-pill);
  font-size: var(--fs-13); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.stage-switch button:hover { color: var(--text); }
.stage-switch button[aria-selected="true"] {
  background: var(--surface); color: var(--brand);
  font-weight: 600; box-shadow: var(--sh-1);
}

/* 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s-4);
}
.card + .card { margin-top: var(--s-3); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: var(--s-3);
}
.card-head h3 { font-size: var(--fs-14); }
.muted { color: var(--text-3); }
.small { font-size: var(--fs-12); }

/* 统计卡 */
.grid { display: grid; gap: var(--s-3); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 15px var(--s-4);
  box-shadow: var(--sh-1); transition: border-color var(--dur) var(--ease);
}
.stat:hover { border-color: var(--border-2); }
.stat .k { color: var(--text-3); font-size: var(--fs-12); }
.stat .v {
  font-size: var(--fs-30); font-weight: 600; margin-top: var(--s-1);
  letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}
.stat .u { font-size: var(--fs-12); color: var(--text-3); margin-left: 3px; font-weight: 400; }

/* 工具条 */
.toolbar {
  display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center;
  margin-bottom: var(--s-3);
}
.search { position: relative; flex: 1 1 220px; min-width: 150px; }
.search input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface);
}
.search input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.search svg {
  position: absolute; left: 10px; top: 50%; margin-top: -8px;
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.search .kbd {
  position: absolute; right: 8px; top: 50%; margin-top: -9px;
}
select.filter, .field select.filter {
  padding: 8px 10px; border: 1px solid var(--border-2);
  border-radius: var(--r); background: var(--surface); cursor: pointer;
}
.kbd {
  font: var(--fs-11)/1 var(--mono); color: var(--text-3);
  border: 1px solid var(--border-2); border-bottom-width: 2px;
  border-radius: 4px; padding: 2px 4px; background: var(--surface-2);
}

/* ---------------- 题目列表 ---------------- */
.qlist { display: flex; flex-direction: column; gap: var(--s-2); }
.qitem {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 13px 15px;
  display: flex; gap: var(--s-3); box-shadow: var(--sh-1);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  scroll-margin: 90px;
}
.qitem:hover { border-color: var(--border-2); }
.qitem.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), var(--sh-1);
}
.qitem .pick { padding-top: 3px; }
.qitem .body { flex: 1; min-width: 0; }
.qitem .stem {
  font-size: var(--fs-stem); line-height: var(--lh-stem);
  word-break: break-word; color: var(--text);
}
.qitem.compact .stem { font-size: var(--fs-14); line-height: 1.7; }
.qitem .stem img { max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--border); margin-top: 6px; }
.qitem .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.qitem .no {
  font-weight: 600; color: var(--text-3); margin-right: 2px;
  font-variant-numeric: tabular-nums;
}
.qitem .acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.qitem .body > img {
  display: block; max-width: 100%; max-height: 300px;
  object-fit: contain; object-position: left top;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  margin-top: 7px; background: #fff; padding: 4px;
}

/* 就地展开（v1.0.9） --------------------------------------------
   点题卡不再抢着开抽屉：答案与解析在题干下方展开，列表阅读不被打断；
   抽屉留给「编辑 / 打考点 / 识别文字」这些要做的事。 */
.qitem.expanded {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-soft-border, var(--border-2)), var(--sh-1);
}
.qitem .acts .x-toggle svg { transition: transform var(--dur) var(--ease); }
.qitem .acts .x-toggle[aria-expanded="true"] { color: var(--brand); background: var(--brand-soft); }
.qitem .acts .x-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.qexp {
  margin-top: 10px; padding: 10px 12px 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.qexp[hidden] { display: none; }
/* v1.0.11.1：选择题选项常驻卡片（不用点开），样式与展开区 qexp-opt 共用 */
.qopts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 18px; margin-top: 6px;
  font-size: var(--fs-13); line-height: 1.8;
}
.qexp-opts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 18px; margin-bottom: 8px;
  font-size: var(--fs-13); line-height: 1.8;
}
.qexp-opt {
  display: flex; gap: 6px; align-items: baseline;
  color: var(--text-2); border-radius: 4px; padding: 0 4px;
}
.qexp-opt b { flex: none; font-weight: 600; color: var(--text-3); }
.qexp-opt.on { background: var(--brand-soft); color: var(--text); }
.qexp-opt.on b { color: var(--brand); }
.qexp-row {
  display: flex; gap: 10px; padding: 3px 0;
  font-size: var(--fs-13); line-height: 1.85;
}
.qexp-k {
  flex: none; width: 2.2em; padding-top: 1px;
  font-size: var(--fs-12); color: var(--text-3);
}
.qexp-v { flex: 1; min-width: 0; color: var(--text); word-break: break-word; }
.qexp-v img { max-width: 100%; }
.qexp-v .mimg, .qexp-v .stem-img { margin: 2px 0; }
.qexp-v.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qexp-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: var(--fs-11); color: var(--text-3);
}
.qexp-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input[type="checkbox"], input[type="radio"] {
  width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer;
}

/* 批量操作条 ----------------------------------------------------
   v1.0.8：改为浮在视口底部（left/width 由 JS 对齐中列宽度）。
   旧实现是 sticky 在列表末尾——.lib 是 align-items:start 的网格，
   容器高度等于内容高度，sticky 没有可位移的空间，结果永远贴在页脚，
   选中题目后必须滚到底才能操作。 */
.bar {
  position: fixed;
  /* JS 会按题目列的实际位置覆盖 left / width；这里的值只作首帧兜底 */
  left: 0; right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  background: var(--surface); border: 1px solid var(--brand);
  border-radius: var(--r-lg); padding: 10px 14px;
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  box-shadow: 0 10px 28px -8px rgba(15, 23, 42, .3), var(--sh-2);
  animation: barIn 180ms var(--ease);
}
@keyframes barIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.bar .count { font-weight: 600; color: var(--brand); }
.bar .count b { font-variant-numeric: tabular-nums; }
.bar-sep { width: 1px; align-self: stretch; margin: 2px 2px; background: var(--border); }
.bar-hint {
  margin-left: auto; font: var(--fs-11)/1 var(--mono); color: var(--text-3);
  border: 1px solid var(--border-2); border-bottom-width: 2px;
  border-radius: 4px; padding: 2px 5px; background: var(--surface-2);
}
@media (max-width: 860px) {
  /* 手机底部有 tabbar，操作条往上让一格 */
  .bar {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    padding: 8px 10px; gap: 6px;
  }
  .bar-hint, .bar-sep { display: none; }
  .bar .count { margin-right: auto; }
}

/* 空态 / 骨架 */
.empty { text-align: center; padding: 46px var(--s-5); color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); margin-bottom: var(--s-1); font-size: var(--fs-14); }
.empty .btn { margin-top: var(--s-3); }

.skeleton { display: flex; flex-direction: column; gap: var(--s-2); }
.sk-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 15px;
}
.sk-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-hover) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: skShimmer 1.4s ease-in-out infinite;
  margin-bottom: 8px;
}
.sk-line:last-child { margin-bottom: 0; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-chip { height: 18px; width: 60px; border-radius: var(--r-pill); display: inline-block; margin-right: 6px; }
@keyframes skShimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
  * { transition-duration: 1ms !important; }
}

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table th {
  color: var(--text-3); font-weight: 500; font-size: var(--fs-12);
  background: var(--surface-2); position: sticky; top: 0;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow: auto; }

/* ---------------- 标签 chip ---------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 2px 9px;
  font-size: var(--fs-12); color: var(--text-2); white-space: nowrap;
}
.chip.primary { background: var(--brand-soft); border-color: var(--brand-soft-border); color: var(--brand); }
.chip.warn { background: var(--warn-soft); border-color: var(--warn-soft-border); color: var(--warn); }
.chip.success { background: var(--success-soft); border-color: var(--success-soft-border); color: var(--success); }
.chip.danger { background: var(--danger-soft); border-color: var(--danger-soft-border); color: var(--danger); }
/* v1.1.19 AI 解答：答案/解析由 AI 生成，提醒老师核过再用 */
.chip.ai {
  background: var(--ai-soft); border-color: var(--ai-soft-border); color: var(--ai);
  font-weight: 600; letter-spacing: .2px;
}
.chip button {
  border: 0; background: none; cursor: pointer; color: inherit;
  padding: 0 0 0 2px; opacity: .7; line-height: 1;
}
.chip button:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- 标签选择器 ---------------- */
.tagpicker {
  max-height: 320px; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px; background: var(--surface-2);
}
.tagpicker .grp { margin-bottom: var(--s-2); }
.tagpicker .grp > .gname {
  font-size: var(--fs-12); color: var(--text-3);
  margin: 6px 0 4px; font-weight: 500;
}
.tagpicker label {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 2px 10px 2px 0; font-size: var(--fs-13); cursor: pointer;
}
.tagpicker .lv2 { padding-left: 14px; }

/* ---------------- 弹窗 / 抽屉 / 底部面板 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: var(--overlay);
  display: grid; place-items: center; padding: var(--s-5);
  z-index: 120; overflow: auto;
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: 100%; max-width: 560px;
  max-height: 88dvh; display: flex; flex-direction: column;
  box-shadow: var(--sh-3);
  animation: popIn var(--dur) var(--ease);
}
.modal.wide { max-width: 880px; }
.modal-head {
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-2);
}
.modal-head h3 { font-size: var(--fs-16); }
.modal-body { padding: var(--s-4) var(--s-5); overflow: auto; }
.modal-foot {
  padding: 13px var(--s-5); border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap;
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* 右侧抽屉（题目详情）：≥1440 内联，以下浮层 */
.drawer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  display: flex; flex-direction: column; min-width: 0;
  max-height: calc(100dvh - var(--topbar-h) - var(--s-6));
}
.drawer-head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 13px var(--s-4); border-bottom: 1px solid var(--border);
}
.drawer-head h3 { font-size: var(--fs-14); flex: 1; min-width: 0; }
.drawer-body { padding: var(--s-4); overflow: auto; flex: 1; min-height: 0; }
.drawer-foot {
  padding: 10px var(--s-4); border-top: 1px solid var(--border);
  display: flex; gap: var(--s-2); flex-wrap: wrap; background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.drawer-backdrop { display: none; }

/* 底部面板（手机「我的」/ 筛选用） */
.sheet-mask {
  position: fixed; inset: 0; background: var(--overlay); z-index: 130;
  display: flex; align-items: flex-end; animation: fadeIn var(--dur) var(--ease);
}
.sheet {
  background: var(--surface); width: 100%;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-3) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom));
  box-shadow: var(--sh-3);
  animation: sheetUp 220ms var(--ease);
  max-height: 86dvh; overflow: auto;
}
.sheet-grab {
  width: 36px; height: 4px; border-radius: var(--r-pill);
  background: var(--border-2); margin: 0 auto var(--s-3);
}
.sheet h3 { font-size: var(--fs-14); margin-bottom: var(--s-3); }
.sheet-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 10px; border: 0; background: none; border-radius: var(--r);
  cursor: pointer; color: var(--text); font-size: var(--fs-14); text-align: left;
}
.sheet-row:hover { background: var(--surface-3); }
.sheet-row svg { width: 18px; height: 18px; color: var(--text-3); }
.sheet-sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

/* 表单 */
.form-row { margin-bottom: 13px; }
.form-row > label {
  display: block; font-size: var(--fs-12); color: var(--text-2);
  margin-bottom: 5px; font-weight: 500;
}
.form-row input[type="text"], .form-row input[type="number"],
.form-row input[type="email"], .form-row input[type="password"],
.form-row select, .form-row textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--surface);
}
.form-row textarea {
  min-height: 110px; resize: vertical;
  font-family: var(--font); line-height: 1.7;
}
.form-row textarea.code { font-family: var(--mono); font-size: var(--fs-13); }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.hint { font-size: var(--fs-12); color: var(--text-3); margin-top: var(--s-1); line-height: 1.6; }
.preview {
  border: 1px dashed var(--border-2); border-radius: var(--r);
  padding: 11px 13px; background: var(--surface-2);
  min-height: 46px; line-height: 1.9; font-size: var(--fs-14);
  word-break: break-word;
}
.preview:empty::before {
  content: "公式预览区（输入 $...$ 后即时显示）";
  color: var(--text-3); font-size: var(--fs-12);
}

/* 分组标题 */
.section-title {
  font-size: var(--fs-12); color: var(--text-3); font-weight: 500;
  margin: var(--s-5) 0 var(--s-2); letter-spacing: .02em;
}
.section-title:first-child { margin-top: 0; }

/* ---------------- Toast / Loading ---------------- */
.toast-root {
  position: fixed; right: 18px; bottom: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none;
}
.toast {
  background: var(--c-gray-900); color: #fff;
  padding: 9px 14px; border-radius: var(--r);
  font-size: var(--fs-13); box-shadow: var(--sh-2); max-width: min(340px, 84vw);
  animation: toastIn .18s var(--ease); pointer-events: auto;
}
html[data-theme="dark"] .toast { background: #2c323a; color: var(--text); border: 1px solid var(--border-2); }
.toast.ok { background: #16572f; }
.toast.err { background: #8f1f1f; }
html[data-theme="dark"] .toast.ok { background: #14532d; color: #dcfce7; }
html[data-theme="dark"] .toast.err { background: #7f1d1d; color: #fee2e2; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.loading-mask {
  position: fixed; inset: 0; background: var(--overlay);
  display: grid; place-items: center; z-index: 400;
  backdrop-filter: blur(1px);
}
.spinner {
  width: 26px; height: 26px; border: 2.5px solid var(--border-2);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- KaTeX 微调 ---------------- */
.katex { font-size: 1.02em; }
.stem .katex-display { margin: var(--s-2) 0; }
.qitem .stem > span[data-tex] { display: inline-block; }

/* ---------------- 错题状态色条 ---------------- */
.qitem.wrong-todo { border-left: 3px solid var(--danger); }
.qitem.wrong-fixed { border-left: 3px solid var(--warn); }
.qitem.wrong-mastered { border-left: 3px solid var(--success); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
  font-size: var(--fs-12); font-weight: 600; flex: none;
}
.list-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-weight: 500; }

/* ============================================================
   题库三栏（v1.0.1）
   筛选树 / 题目流 / 详情抽屉
   ============================================================ */
.lib {
  display: grid;
  grid-template-columns: var(--tree-w) minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.lib.has-detail { grid-template-columns: var(--tree-w) minmax(0, 1fr) var(--drawer-w); }
.lib-drawer {
  display: none;
  position: sticky; top: calc(var(--topbar-h) + var(--s-3));
  flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  max-height: calc(100dvh - var(--topbar-h) - var(--s-6));
  overflow: hidden;
}
.lib.has-detail .lib-drawer { display: flex; }

/* 左：筛选树 */
.lib-tree {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 10px; box-shadow: var(--sh-1);
  position: sticky; top: calc(var(--topbar-h) + var(--s-3));
  max-height: calc(100dvh - var(--topbar-h) - var(--s-6));
  display: flex; flex-direction: column; gap: var(--s-2); min-height: 0;
}
.tree-scroll { overflow: auto; flex: 1; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.tree-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-12); color: var(--text-3); font-weight: 500;
  padding: 2px 4px; margin-top: var(--s-2);
}
.tree-title:first-child { margin-top: 0; }
.tree-group { border-radius: var(--r); }
.tree-root {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 6px; border: 0; background: none; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text); font-size: var(--fs-13); text-align: left;
  font-weight: 500;
}
.tree-root:hover { background: var(--surface-3); }
.tree-root .tw { transition: transform var(--dur) var(--ease); flex: none; color: var(--text-3); }
.tree-root .tw svg { width: 14px; height: 14px; display: block; }
.tree-root[aria-expanded="true"] .tw { transform: rotate(90deg); }
.tree-root .n { margin-left: auto; font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.tree-items { display: flex; flex-direction: column; gap: 1px; padding-left: 12px; }
.tree-items[hidden] { display: none; }
.tree-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 7px; border: 0; background: none; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-2); font-size: var(--fs-12); text-align: left;
  width: 100%;
}
.tree-item:hover { background: var(--surface-3); color: var(--text); }
.tree-item[aria-pressed="true"] {
  background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.tree-item .n { margin-left: auto; font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.tree-quick { display: flex; flex-direction: column; gap: 1px; }
.tree-quick .tree-item { font-size: var(--fs-12); }
.tree-foot { border-top: 1px solid var(--border); padding-top: var(--s-2); display: flex; gap: 6px; }

/* 中：题目流 */
.lib-main { min-width: 0; display: flex; flex-direction: column; }

/* ---- v1.1.3 题库范围切换（我的 / 公共 / 我公开的） ---- */
.lib-scope { align-self: flex-start; margin-bottom: var(--s-3); }

/* ---- v1.1.3 积分排行榜（只在公共题库里出现） ---- */
.rank-panel {
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); padding: var(--s-3); margin-bottom: var(--s-3);
}
.rank-head {
  display: flex; align-items: center; gap: var(--s-2);
  flex-wrap: wrap; margin-bottom: 8px;
}
.rank-head b { font-size: var(--fs-13); color: var(--text); }
.rank-list { display: flex; flex-direction: column; gap: 2px; }
.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; border-radius: var(--r-sm); font-size: var(--fs-13);
}
.rank-row:nth-child(odd) { background: var(--surface-2); }
.rank-row.me { background: var(--brand-soft); font-weight: 600; }
.rank-no {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: var(--fs-12);
  background: var(--surface-3); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.rank-row.me .rank-no { background: var(--brand); color: #fff; }
.rank-name { color: var(--text); }
.rank-school { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-points { color: var(--brand); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }
.lib-head { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-3); }
.lib-count {
  font-size: var(--fs-12); color: var(--text-3); margin-bottom: var(--s-2);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 28px;
}
.lib-count .btn { padding: 2px 8px; font-size: var(--fs-12); }
.lib-count .mini-check { font-size: var(--fs-12); }
.lib-count b { color: var(--text-2); font-variant-numeric: tabular-nums; }

.pager {
  margin-top: var(--s-4); display: flex; justify-content: center;
  gap: var(--s-2); align-items: center; flex-wrap: wrap;
}

@media (max-width: 1439px) {
  .lib.has-detail { grid-template-columns: var(--tree-w) minmax(0, 1fr); }
  .lib.has-detail .lib-drawer {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
    width: min(var(--drawer-w), 94vw); z-index: 90;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    box-shadow: var(--sh-3); display: flex; max-height: none;
    animation: slideIn 180ms var(--ease);
  }
  .lib.has-detail .drawer-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: var(--overlay); z-index: 85;
  }
}

/* ============================================================
   错题本：学生卡片条
   ============================================================ */
.stu-strip { display: flex; gap: var(--s-2); overflow-x: auto; padding: 2px 2px 8px; }
.stu-card {
  display: flex; align-items: center; gap: 9px; flex: 0 0 auto;
  padding: 8px 12px 8px 8px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--r-pill);
  cursor: pointer; color: var(--text); font-size: var(--fs-13);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.stu-card:hover { border-color: var(--border-2); background: var(--surface-2); }
.stu-card[aria-pressed="true"] {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600;
}
.stu-card .n {
  font-size: var(--fs-11); color: var(--text-3);
  background: var(--surface-3); border-radius: var(--r-pill); padding: 0 6px;
}
.stu-card[aria-pressed="true"] .n { background: var(--surface); color: var(--brand); }

/* ============================================================
   导入页标签切换（v1.0.2）
   ============================================================ */
.tabs { display: flex; gap: 2px; margin-bottom: var(--s-3); border-bottom: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 16px; font-size: var(--fs-14); color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ============================================================
   扫描件导入工作台（v1.0.2）
   ============================================================ */
.scan { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }

.scan-drop {
  border: 2px dashed var(--border-2); border-radius: var(--r-lg);
  background: var(--surface); padding: 46px var(--s-5); text-align: center;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  cursor: pointer;
}
.scan-drop:hover, .scan-drop.over { border-color: var(--brand); background: var(--brand-soft); }
.scan-drop-inner { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.scan-drop-inner b { font-size: var(--fs-16); }
.scan-drop-inner p { margin: 0; line-height: 1.7; max-width: 420px; }
.scan-drop-icon {
  width: 48px; height: 48px; border-radius: 13px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.scan-drop-icon svg { width: 22px; height: 22px; }

.scan-work { display: flex; flex-direction: column; gap: var(--s-2); }

.scan-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 12px;
}
.scan-file { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.scan-file b {
  font-size: var(--fs-13); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 240px;
}
.scan-tools { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin-left: auto; }
.scan-mini {
  padding: 5px 8px; border: 1px solid var(--border-2);
  border-radius: 8px; background: var(--surface); font-size: var(--fs-12);
}
.scan-zoom { display: flex; align-items: center; gap: 3px; font-size: var(--fs-12); color: var(--text-2); }
.scan-zoom .btn { padding: 2px 8px; }
.scan-check { font-size: var(--fs-12); color: var(--text-2); display: flex; gap: 5px; align-items: center; }
.scan-progress { font-size: var(--fs-12); color: var(--brand); min-height: 16px; }

.scan-stage {
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s-3); overflow: auto;
  max-height: calc(100dvh - 330px); min-height: 420px;
  display: flex; justify-content: center; align-items: flex-start;
}
.scan-page { position: relative; background: #fff; box-shadow: var(--sh-1); flex: 0 0 auto; }
.scan-page canvas { width: 100%; height: 100%; display: block; }
/* v1.2.2：系统 crosshair 在白纸扫描件上是白色的，根本看不清鼠标在哪 ——
   换成黑白双描边的自定义十字（任何底色都有对比），再配一条跟随鼠标的 DOM 准线。 */
.scan-overlay {
  position: absolute; inset: 0; touch-action: none;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%23000' stroke-width='4'%3E%3Cpath d='M13 1v9M13 16v9M1 13h9M16 13h9'/%3E%3C/g%3E%3Cg fill='none' stroke='%23fff' stroke-width='2'%3E%3Cpath d='M13 1v9M13 16v9M1 13h9M16 13h9'/%3E%3C/g%3E%3Ccircle cx='13' cy='13' r='1.7' fill='%23fff' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E") 13 13, crosshair;
}
/* 跟随鼠标的十字准线：线体是主色，外面包一圈白描边，白纸和深色图上都看得见 */
.scan-cross { position: absolute; z-index: 5; pointer-events: none; background: var(--brand); box-shadow: 0 0 0 1px rgba(255, 255, 255, .85); }
.scan-cross[hidden] { display: none; }
.scan-cross-x { left: 0; right: 0; height: 1px; }
.scan-cross-y { top: 0; bottom: 0; width: 1px; }
.scan-box {
  position: absolute; border: 1.5px solid var(--brand); cursor: move;
  background: color-mix(in srgb, var(--brand) 6%, transparent);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .6) inset;
}
.scan-box.sel {
  border-color: var(--select-ring);
  background: rgba(249, 115, 22, .10);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, .22);
}
.scan-box-no {
  position: absolute; top: 1px; left: 1px;
  background: var(--brand); color: var(--on-brand);
  font-size: 10px; line-height: 14px; padding: 0 4px;
  border-radius: 3px; pointer-events: none;
}
.scan-box.sel .scan-box-no { background: var(--select-ring); color: #fff; }
/* 正在画的框：虚线 + 实时尺寸，画的时候就能看清框到哪了 */
.scan-box.drawing { border-style: dashed; }
.scan-box-dim {
  display: none; position: absolute; right: 2px; bottom: 2px;
  background: rgba(17, 24, 39, .78); color: #fff;
  font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: 3px;
  pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.scan-box.drawing .scan-box-dim { display: block; }
.scan-h {
  position: absolute; width: 10px; height: 10px;
  background: #fff; border: 1.5px solid var(--brand); border-radius: 2px;
}
.scan-box.sel .scan-h { border-color: var(--select-ring); }
.scan-h[data-handle="nw"] { left: -5px; top: -5px; cursor: nwse-resize; }
.scan-h[data-handle="ne"] { right: -5px; top: -5px; cursor: nesw-resize; }
.scan-h[data-handle="sw"] { left: -5px; bottom: -5px; cursor: nesw-resize; }
.scan-h[data-handle="se"] { right: -5px; bottom: -5px; cursor: nwse-resize; }

.scan-film { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.scan-thumb {
  position: relative; flex: 0 0 auto; width: 40px; height: 38px;
  border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); font-size: var(--fs-12); color: var(--text-2);
  cursor: pointer; transition: var(--dur) var(--ease);
}
.scan-thumb:hover { border-color: var(--brand); color: var(--brand); }
.scan-thumb.on { border-color: var(--brand); color: var(--brand); font-weight: 600; background: var(--brand-soft); }
.scan-thumb em {
  position: absolute; top: -5px; right: -5px;
  background: var(--brand); color: var(--on-brand);
  border-radius: var(--r-pill); font-size: 10px; font-style: normal;
  line-height: 14px; padding: 0 4px;
}

.scan-side {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 150px); position: sticky; top: 12px;
}
.scan-side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: var(--fs-13);
}
.scan-drafts { overflow-y: auto; padding: 10px; flex: 1; min-height: 130px; }
.scan-empty { color: var(--text-3); font-size: var(--fs-12); margin: 6px 2px; line-height: 1.75; }
.scan-group { font-size: var(--fs-11); color: var(--text-3); margin: 8px 2px 6px; }

/* ---- v1.1.18 答案与解析 ---- */
.scan-solve-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 8px; margin-top: 2px;
}
.scan-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.scan-field label { font-size: var(--fs-11); color: var(--text-3); }
.scan-ans, .scan-ana {
  width: 100%; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  padding: 6px 8px; font-family: var(--font); font-size: var(--fs-12); line-height: 1.6;
  resize: vertical; min-height: 52px;
}
.scan-ans:focus, .scan-ana:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.scan-aiflag {
  font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand); font-weight: 700; letter-spacing: .3px;
}
/* v1.1.19：答案/解析由 AI 生成，入库后列表里会带同样的标记 */
.scan-aiflag.ai { background: var(--ai-soft); color: var(--ai); }
.scan-ocr-btn.accent { border-style: solid; border-color: var(--brand); color: var(--brand); }
.scan-ocr-btn.accent:hover { background: var(--brand-soft); }
@media (max-width: 860px) {
  .scan-solve-grid { grid-template-columns: 1fr; }
}
.scan-card {
  display: flex; gap: var(--s-2); padding: 7px; margin-bottom: 7px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
}
.scan-card.sel { border-color: var(--select-ring); box-shadow: 0 0 0 2px color-mix(in srgb, var(--select-ring) 16%, transparent); }
.scan-card img {
  width: 78px; max-height: 92px; object-fit: contain; object-position: top;
  border-radius: 4px; background: #fff; border: 1px solid var(--border); flex: 0 0 auto;
}
.scan-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.scan-card-row { display: flex; gap: 4px; align-items: center; }
.scan-card-row select {
  padding: 3px 4px; border: 1px solid var(--border-2); border-radius: 6px;
  font-size: var(--fs-11); background: var(--surface); min-width: 0; max-width: 96px;
}
.scan-del {
  margin-left: auto; border: 0; background: transparent; color: var(--text-3);
  font-size: 17px; line-height: 1; cursor: pointer; padding: 1px 5px; border-radius: 5px;
}
.scan-del:hover { color: var(--danger); background: var(--danger-soft); }
.scan-card-body input {
  width: 100%; padding: 4px 6px; border: 1px solid var(--border-2);
  border-radius: 6px; font-size: var(--fs-11);
}
.scan-commit {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 9px; align-items: flex-start;
}
.scan-commit .btn-block { max-width: 300px; }
.scan-commit .form-row label { font-size: var(--fs-12); }
.scan-commit select, .scan-commit input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border-2);
  border-radius: 8px; font-size: var(--fs-12);
}
.scan-result {
  display: flex; gap: var(--s-2); align-items: center; justify-content: space-between;
  background: var(--success-soft); border: 1px solid var(--success-soft-border);
  border-radius: 8px; padding: 8px 10px; font-size: var(--fs-12);
}
.scan-noimg {
  width: 78px; min-height: 56px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 10.5px; color: var(--text-3);
  background: var(--surface-3); border: 1px dashed var(--border-2); border-radius: 4px;
}

@media (max-width: 1100px) {
  .scan-stage { max-height: 62vh; min-height: 240px; }
  .scan-tools { margin-left: 0; width: 100%; }
}

/* ============================================================
   扫描工作台：左预览 + 右题目卡片（v1.1.27）
   ------------------------------------------------------------
   一屏两栏：左边翻卷面、右边管题目卡片。右栏 sticky 且自带滚动，
   卡片再多也不用上下翻整页——左手翻页、右手截题，手不用离开卷面。
   ============================================================ */
.scan-wb {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(390px, 33vw, 500px);
  gap: var(--s-3);
  align-items: start;
}

/* ---- 左栏 ---- */
.wb-left { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.wb-toolbar { gap: 8px; }
.wb-stage { max-height: calc(100dvh - 320px); min-height: 340px; }

.wb-arm {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand-soft); border: 1px solid var(--brand-soft-border);
  color: var(--brand); border-radius: var(--r); padding: 7px 11px; font-size: var(--fs-12);
}
.wb-arm b { font-weight: 600; }
.wb-arm .btn { color: var(--brand); border-color: transparent; }
.wb-arm-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  animation: wbPulse 1.2s var(--ease) infinite;
}
@keyframes wbPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.7); }
}

.wb-pager {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 7px 10px;
}
.wb-pageno {
  font-size: var(--fs-12); color: var(--text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.wb-pager .scan-film { flex: 1; margin: 0; padding: 0; }

/* ---- 右栏 ---- */
.wb-right {
  position: sticky; top: 12px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  max-height: calc(100dvh - 120px); overflow: hidden;
}
.wb-right-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 9px 11px; border-bottom: 1px solid var(--border); font-size: var(--fs-13);
}
.wb-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
  font-size: var(--fs-11); font-weight: 700; display: inline-grid; place-items: center;
}
.wb-cards {
  flex: 1; min-height: 140px; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.wb-commit {
  border: 0; border-top: 1px solid var(--border); border-radius: 0;
  padding: 10px 11px; gap: 7px; align-items: stretch;
}
.wb-commit .btn-block { max-width: none; }

/* ---- 题目卡片 ---- */
.qcard {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); padding: 10px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.qcard.ready { background: var(--surface); }
.qcard.active {
  border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.qcard-top { display: flex; align-items: center; gap: 6px; }
.qcard-no {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-size: var(--fs-12); font-weight: 700;
}
.qcard.ready .qcard-no { background: var(--brand); color: var(--on-brand); }
.qcard-title { font-size: var(--fs-13); font-weight: 600; }
.qcard-state {
  font-size: 10px; line-height: 16px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-soft-border);
}
.qcard-state.ok {
  background: var(--success-soft); color: var(--success); border-color: var(--success-soft-border);
}
.qcard-seg { font-size: 10px; color: var(--text-3); }
.qcard-mini {
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-3);
  font-size: var(--fs-11); padding: 2px 8px; border-radius: var(--r-pill); cursor: pointer;
}
.qcard-mini:hover { border-color: var(--brand); color: var(--brand); }
.qcard-mini.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* 一段截图 = 一张小图；一题可以有很多段 */
.qcard-shots { display: flex; flex-wrap: wrap; gap: 7px; }
.qshot {
  position: relative; margin: 0; width: 96px; padding: 3px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff;
  display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}
.qshot:hover { border-color: var(--brand); }
.qshot.sel {
  border-color: var(--select-ring);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--select-ring) 18%, transparent);
}
.qshot img {
  width: 100%; height: 64px; object-fit: contain; object-position: top center;
  display: block; background: #fff; border-radius: 5px; cursor: zoom-in;
}
.qshot-empty {
  height: 64px; display: grid; place-items: center;
  font-size: 10px; color: var(--text-3); background: var(--surface-3); border-radius: 5px;
}
.qshot figcaption { display: flex; align-items: center; gap: 4px; }
.qshot-kind {
  font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: 3px;
  background: var(--brand-soft); color: var(--brand);
}
.qshot-kind.img { background: var(--ai-soft); color: var(--ai); }
.qshot-page { font-size: 10px; color: var(--text-3); }
.qshot-del {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text-3);
  font-size: 12px; line-height: 1;
}
.qshot-del:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft-border); }
.qshot-order {
  position: absolute; top: -7px; left: -7px; width: 18px; height: 18px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); font-size: 10px; font-weight: 700;
}
.qshot-none {
  width: 100%; text-align: center; font-size: var(--fs-11); color: var(--text-3);
  background: var(--surface-3); border: 1px dashed var(--border-2);
  border-radius: 9px; padding: 14px 10px;
}
/* v1.1.28：取消「题干截图入库」的段 —— 只是拿来转文字的，淡化表示不进题库 */
.qshot.off { border-style: dashed; border-color: var(--border-2); background: var(--surface-3); }
.qshot.off img { opacity: .38; filter: grayscale(.75); }
.qshot-nosave {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 2px 7px; border-radius: var(--r-pill); white-space: nowrap;
  background: var(--text); color: var(--surface);
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .22);
}

/* v1.1.28：一卡一开关 —— 只为转文字截的题干图，可以选择不进题库 */
.qcard-keep {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px;
}
.qcheck { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.qcheck input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; margin: 0; }
.qcheck span { font-size: var(--fs-12); color: var(--text); }

.qcard-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qcard-locked {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-11); color: var(--text-3);
  background: var(--surface-3); border-radius: 8px; padding: 7px 9px;
}
.qcard-locked svg { width: 14px; height: 14px; flex: 0 0 auto; }

.qcard-more {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px dashed var(--border); padding-top: 9px;
}
.qcard.collapsed .qcard-more { display: none; }
.qcard-airow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qcard-airow.sub { font-size: var(--fs-11); color: var(--text-3); }
.qcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qcard-meta select {
  padding: 3px 5px; border: 1px solid var(--border-2); border-radius: 6px;
  font-size: var(--fs-11); background: var(--surface); min-width: 0;
}
.qhint { font-size: var(--fs-11); color: var(--text-3); }
.qhint.err { color: var(--danger); }
.qhint .demo { color: var(--warn); }

/* 图上：等老师落框 */
.scan-overlay.arming { box-shadow: inset 0 0 0 2px var(--brand); }
.scan-box.own { border-color: var(--brand); }
.scan-box.other {
  border-color: var(--border-strong);
  background: rgba(107, 114, 128, .08);
}
.scan-box.other .scan-box-no { background: var(--text-3); }

@media (max-width: 1180px) {
  .scan-wb { grid-template-columns: minmax(0, 1fr); }
  .wb-right { position: static; max-height: none; }
  .wb-cards { overflow: visible; }
  .wb-stage { max-height: 60vh; }
}

/* ============================================================
   移动端底部 Tab
   ============================================================ */
.tabbar { display: none; }

/* ============================================================
   响应式：1024–1439 / 768–1023 / <768
   ============================================================ */

/* 中等宽度：品牌只留图标，导航收紧，筛选树变窄 */
@media (max-width: 1100px) {
  .appbar-brand-text { display: none; }
  .brand-ver { margin-left: 4px; }
  .appbar-brand { padding-inline: 4px; }
  .topnav { margin-left: var(--s-2); }
  .topnav button { padding: 8px 10px; gap: 6px; }
  .page { padding: 0 var(--s-4); }
  .lib { grid-template-columns: 200px minmax(0, 1fr); }
  :root { --tree-w: 200px; }
}

/* 窄平板 / 大屏手机：顶栏导航收进汉堡，筛选树收起为按钮 */
@media (max-width: 860px) {
  .appbar { --appbar-h: 56px; }
  .topnav { display: none; }
  .appbar .appbar-menu-btn { display: inline-flex; }
  .appbar-brand { padding-left: 0; }
  .appbar-brand-text { display: inline; }
  /* 接入大模型徽标：窄屏只留 logo，别把顶栏挤爆 */
  .appbar-ai .appbar-ai-model { display: none; }
  .appbar-ai { padding: 3px 5px; }
  .page { padding: 0 var(--s-3); }
  .page-head { padding: var(--s-4) 0 var(--s-3); }
  .page-head h1 { font-size: var(--fs-16); }
  .more-menu { min-width: 196px; }
  .view { padding-bottom: 96px; }
  .lib { grid-template-columns: 1fr; }
  .lib-tree {
    position: static; max-height: none; display: none;
    order: -1;
  }
  .lib.show-tree .lib-tree { display: flex; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .qitem { padding: 11px 12px; }
  .qitem .acts { flex-direction: row; align-items: center; }
  .stat .v { font-size: var(--fs-24); }
  .modal { max-height: 92dvh; }
  .modal-foot { position: sticky; bottom: 0; }

  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    border: 0; background: none; padding: 8px 2px 7px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-3); font-size: 10.5px; position: relative;
  }
  .tabbar button[aria-current="page"] { color: var(--brand); font-weight: 600; }
  .tabbar svg { width: 20px; height: 20px; }
  .tabbar button[aria-current="page"]::after {
    content: ""; position: absolute; top: 0; left: 50%; margin-left: -10px;
    width: 20px; height: 2px; background: var(--brand); border-radius: var(--r-pill);
  }
  .toast-root { bottom: calc(64px + env(safe-area-inset-bottom)); left: 12px; right: 12px; align-items: center; }
}

@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  /* 5 张统计卡在手机上排 2 列，别拉成一长条 */
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-actions .btn span { display: none; }
  .stage-switch button { padding: 5px 10px; font-size: var(--fs-12); }
  /* 窄屏：操作按钮换到内容下方，避免与题干抢宽度 */
  .qitem { flex-wrap: wrap; }
  .qitem .acts { flex-direction: row; align-items: center; width: 100%; justify-content: flex-end; }
  .lib.has-detail .lib-drawer { width: 100%; border-radius: 0; }
  /* v1.0.9：小屏选项单列，答案/解析标签不下沉 */
  .qexp { padding: 9px 10px 6px; }
  .qexp-opts, .qopts { grid-template-columns: 1fr; gap: 1px; }
  .qexp-row { gap: 8px; }
  .qexp-k { width: 2.4em; }
  .lib-count { gap: 6px; }
  .lib-count [data-xhint] { display: none; }
  .lib-count .btn { padding: 2px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .lib.has-detail .lib-drawer, .sheet, .modal, .modal-mask { animation: none; }
}

@media print {
  .appbar, .page-head, .tabbar, .toolbar, .bar, .lib-tree, .lib-drawer,
  .toast-root, .loading-mask, .drawer-backdrop { display: none !important; }
  .page, .view { padding: 0; max-width: none; }
  .app { display: block; }
  .qitem { break-inside: avoid; box-shadow: none; }
}

/* ============================================================
   v1.0.3 错题闭环：热力图 / 分布条 / 重练模式 / 模板选择
   ============================================================ */

/* ---- 视图切换（列表 / 热力图 / 重练） ---- */
.mode-tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-pill); }
.mode-tabs button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 6px 14px; border-radius: var(--r-pill); font: inherit; font-size: var(--fs-13);
  cursor: pointer; white-space: nowrap; transition: background var(--dur), color var(--dur);
}
.mode-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); font-weight: 600; }
.mode-tabs button:hover:not([aria-selected="true"]) { color: var(--text); }

/* ---- 热力图（GitHub 贡献图风格，按周成列） ---- */
.heat-panel { display: flex; flex-direction: column; gap: 10px; }
.heat-scroll { overflow-x: auto; padding-bottom: 6px; }
.heat-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 15px); gap: 4px; width: max-content; }
.heat-cell {
  width: 15px; height: 15px; border-radius: 3px;
  background: var(--surface-3); outline-offset: 1px;
  transition: transform var(--dur);
}
.heat-cell:hover { transform: scale(1.25); outline: 1px solid var(--brand); }
.heat-cell.l1 { background: rgba(220, 38, 38, .18); }
.heat-cell.l2 { background: rgba(220, 38, 38, .38); }
.heat-cell.l3 { background: rgba(220, 38, 38, .62); }
.heat-cell.l4 { background: rgba(220, 38, 38, .92); }
.heat-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.heat-legend { display: flex; align-items: center; gap: 5px; font-size: var(--fs-12); color: var(--text-3); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); display: inline-block; }
.heat-legend i.l1 { background: rgba(220, 38, 38, .18); }
.heat-legend i.l2 { background: rgba(220, 38, 38, .38); }
.heat-legend i.l3 { background: rgba(220, 38, 38, .62); }
.heat-legend i.l4 { background: rgba(220, 38, 38, .92); }
.heat-months { display: flex; gap: 0; font-size: var(--fs-11); color: var(--text-3); height: 14px; }
.heat-months span { white-space: nowrap; }

/* ---- 分布条（错因 / 复习阶段） ---- */
.dist { display: flex; flex-direction: column; gap: 7px; }
.dist-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: var(--fs-13); }
.dist-row .name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 类名用 dist-bar：.bar 已被「批量操作条」占用，会带边框与 padding */
.dist-row .dist-bar { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.dist-row .dist-bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--danger); }
.dist-row .n { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
.dist-row.is-stage .dist-bar > i { background: var(--brand); }

/* ---- 重练模式 ---- */
.review-box { display: flex; flex-direction: column; gap: 14px; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.review-progress { display: flex; align-items: center; gap: 10px; font-size: var(--fs-13); color: var(--text-2); }
.stage-dots { display: flex; gap: 4px; }
.stage-dots i {
  width: 22px; height: 6px; border-radius: 3px; background: var(--surface-3);
  transition: background var(--dur);
}
.stage-dots i.on { background: var(--brand); }
.review-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-5); box-shadow: var(--sh-1);
}
.review-card .stem { font-size: var(--fs-16); line-height: 1.75; }
.review-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.review-actions { display: flex; gap: 10px; margin-top: var(--s-4); }
.review-actions .btn { flex: 1; justify-content: center; }
.review-reveal {
  margin-top: var(--s-4); padding: var(--s-4); border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--border);
}
.review-done { text-align: center; padding: var(--s-6) var(--s-4); }
.review-done .big { font-size: 28px; font-weight: 700; margin-bottom: 6px; }

/* ---- 模板选择卡 ---- */
.tpl-list { display: grid; gap: 10px; }
.tpl-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--r);
  cursor: pointer; background: var(--surface); transition: border-color var(--dur), background var(--dur);
}
.tpl-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.tpl-card[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tpl-card .radio {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong);
  flex: none; margin-top: 3px;
}
.tpl-card[aria-checked="true"] .radio { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); }
.tpl-card strong { display: block; font-size: var(--fs-14); margin-bottom: 2px; }
.tpl-card small { color: var(--text-3); font-size: var(--fs-12); line-height: 1.5; }

/* ---- 按卷录入 ---- */
.exam-pick { display: flex; flex-direction: column; gap: 10px; }
.exam-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
}
.exam-item[aria-checked="true"] { border-color: var(--danger); background: var(--danger-soft); }
.exam-item .no {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-size: var(--fs-12); color: var(--text-2);
}
.exam-item[aria-checked="true"] .no { background: var(--danger); color: #fff; }
.exam-item .stem { flex: 1; min-width: 0; font-size: var(--fs-13); line-height: 1.6; }
.exam-item select { max-width: 120px; }

@media (max-width: 560px) {
  .dist-row { grid-template-columns: 64px minmax(0, 1fr) 38px; font-size: var(--fs-12); }
  .review-actions { flex-direction: column; }
  .heat-cell, .heat-legend i { width: 12px; height: 12px; }
  .heat-grid { grid-template-rows: repeat(7, 11px); }
  .mode-tabs button { padding: 5px 10px; font-size: var(--fs-12); }
}

/* ---- 通用小工具（v1.0.3 起共用） ---- */
.spacer { flex: 1 1 auto; }
.stat.is-clickable { cursor: pointer; transition: border-color var(--dur), box-shadow var(--dur); }
.stat.is-clickable:hover { border-color: var(--brand); box-shadow: var(--sh-2); }
.stat.is-clickable:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============================================================
   v1.0.5 考点智能识别
   ------------------------------------------------------------
   三处交互共用同一套「预测 chip」：扫描工作台 / 题库抽屉 / 批量核对。
   共用一套类名，是为了让老师在三处看到的「建议」长得完全一样。
   ============================================================ */

/* ---------------- 预测 chip ---------------- */
.pchip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: var(--r-pill);
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-12); font-family: var(--font);
  cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.pchip:hover { border-color: var(--brand); color: var(--brand); }
.pchip em { font-style: normal; font-size: var(--fs-11); color: var(--text-3); }
.pchip.top { border-color: var(--brand-soft-border); background: var(--brand-soft); color: var(--brand); }
.pchip.top em { color: var(--brand); opacity: .75; }
.pchip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pchip.on em { color: var(--on-brand); opacity: .8; }
.pchip .pk {
  display: inline-grid; place-items: center; width: 15px; height: 15px;
  border-radius: 50%; background: var(--surface-3); color: var(--text-3);
  font-size: 10px; line-height: 1;
}
.pchip.on .pk { background: rgba(255, 255, 255, .22); color: var(--on-brand); }
.pnone { font-size: var(--fs-12); color: var(--text-3); }

/* ---------------- 工具类（v1.0.5 起统一使用） ---------------- */
.row { display: flex; align-items: center; }
.gap { gap: var(--s-2); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--text-3); font-weight: 500; font-size: var(--fs-12); }
.tbl tbody tr:hover { background: var(--surface-hover); }

/* ---------------- 批量核对 ---------------- */
.review { display: flex; flex-direction: column; gap: var(--s-3); }
.review-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); flex-wrap: wrap;
}
.review-stat { font-size: var(--fs-13); color: var(--text-2); line-height: 1.7; }
.review-stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.review-tools { display: flex; align-items: center; gap: var(--s-2); }
.review-list { display: flex; flex-direction: column; gap: 6px; }

.rv-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(240px, 400px);
  gap: var(--s-4); align-items: center;
  padding: 10px var(--s-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.rv-row.focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.rv-row.done { opacity: .5; }
.rv-row.sk { display: block; }
.rv-id { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-3); }
.rv-stem { min-width: 0; }
.rv-text {
  font-size: var(--fs-13); line-height: 1.7; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.rv-stem img {
  max-height: 88px; margin-top: 6px; border-radius: var(--r-sm);
  border: 1px solid var(--border); display: block;
}
.rv-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rv-pred { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.rv-done { font-size: var(--fs-12); color: var(--success); }

.review-keys {
  display: flex; flex-wrap: wrap; gap: var(--s-4);
  font-size: var(--fs-12); color: var(--text-3);
  padding: var(--s-3) 2px var(--s-6);
}
.review-keys kbd {
  display: inline-block; min-width: 18px; text-align: center;
  padding: 1px 5px; margin: 0 1px;
  border: 1px solid var(--border-2); border-bottom-width: 2px;
  border-radius: var(--r-sm); background: var(--surface);
  font-family: var(--mono); font-size: 11px; color: var(--text-2);
}

/* ---------------- 考点学习 ---------------- */
.ailab { display: flex; flex-direction: column; gap: var(--s-4); }
.cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-3); }
.cards .card + .card { margin-top: 0; }
.card-k { font-size: var(--fs-12); color: var(--text-3); }
.card-v {
  font-size: var(--fs-24); font-weight: 600; margin-top: 2px;
  font-variant-numeric: tabular-nums; letter-spacing: -.4px;
}
.card-h { font-size: var(--fs-11); color: var(--text-3); margin-top: 2px; line-height: 1.5; }

.ailab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s-4);
}
.panel h3 { font-size: var(--fs-14); margin: 0 0 var(--s-1); }
.panel textarea, .panel select {
  width: 100%; border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 9px 11px; background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: var(--fs-13); line-height: 1.7;
  resize: vertical;
}
.panel textarea:focus, .panel select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.trial-out { margin-top: var(--s-2); }
.word-list { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow: auto; }
.word {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.word-text { flex: 1; min-width: 0; font-size: var(--fs-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word .icon-btn { width: 24px; height: 24px; }

/* ---------------- 扫描工作台：卡片内预测 ---------------- */
.scan-pred { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.scan-pred-hint { font-size: var(--fs-11); color: var(--text-3); line-height: 1.5; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ailab-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .rv-row { grid-template-columns: 42px minmax(0, 1fr); }
  .rv-pred { grid-column: 2; justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .review-keys { display: none; }
}

/* ============================================================
   v1.0.6 扫描件文字识别
   ------------------------------------------------------------
   三处共用：设置页（配置 + 用量）、扫描工作台（逐块识别）、
   题库抽屉（图片题识别）。识别出的文字必须可编辑 —— 再好的模型
   也会把「α」认成「a」，老师改一个字比重新录入快得多。
   ============================================================ */

/* ---------------- 设置页：用量 ---------------- */
.usage-bars {
  display: flex; align-items: flex-end; gap: 4px;
  height: 40px; padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.usage-bar {
  flex: 1; min-width: 4px; max-width: 26px;
  background: var(--brand-soft-border);
  border-radius: 2px 2px 0 0;
  transition: background var(--dur) var(--ease);
}
.usage-bar:hover { background: var(--brand); }

/* ---------------- 扫描工作台：识别 ---------------- */
.scan-ocr-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.scan-ocr-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  border: 1px dashed var(--border-2); background: transparent;
  color: var(--text-2); font-size: var(--fs-12); font-family: var(--font);
  cursor: pointer; transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.scan-ocr-btn:hover { border-color: var(--brand); color: var(--brand); border-style: solid; }
.scan-ocr-btn[disabled] { opacity: .55; cursor: default; }
.scan-ocr-note { font-size: var(--fs-11); color: var(--text-3); }
.scan-ocr-note.err { color: var(--danger); }
.scan-stem {
  width: 100%; margin-top: 6px;
  border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  padding: 6px 8px; font-family: var(--font); font-size: var(--fs-12); line-height: 1.6;
  resize: vertical; min-height: 54px;
}
.scan-stem:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.scan-stem-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: var(--fs-11); color: var(--text-3); }
.scan-stem-meta .demo { color: var(--warn); }

/* ---- v1.1.16 题干公式预览与校验 ---- */
.scan-tex:empty { display: none; }
.scan-tex { margin-top: 4px; }
.scan-tex .tex-ok {
  font-size: var(--fs-11); color: var(--success); letter-spacing: .2px;
}
.scan-tex .tex-msg-wrap { display: flex; flex-direction: column; gap: 3px; }
.scan-tex .tex-msg {
  display: flex; align-items: flex-start; gap: 4px;
  font-size: var(--fs-11); line-height: 1.5; color: var(--danger, #c0392b);
}
.scan-tex .tex-msg svg { flex: none; width: 12px; height: 12px; margin-top: 2px; }
.scan-tex .tex-msg code {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: var(--fs-11);
  background: var(--surface-2, rgba(127,127,127,.12)); padding: 0 3px; border-radius: 3px;
  word-break: break-all;
}
.scan-tex .tex-body {
  margin-top: 5px; padding: 6px 8px;
  border: 1px dashed var(--border-2); border-radius: var(--r-sm);
  background: var(--surface-2, rgba(127,127,127,.06));
  font-size: var(--fs-12); line-height: 1.85; color: var(--text);
  overflow-x: auto; max-height: 190px;
}
.scan-tex.bad .tex-body { border-color: var(--danger, #c0392b); }
/* 编译不过的公式原样显示，方便对照修改 */
.tex-bad {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: var(--fs-11);
  color: var(--danger, #c0392b); background: rgba(192,57,43,.1);
  padding: 0 3px; border-radius: 3px;
}

/* ============================================================
   v1.0.6 修 · 版本可见性
   ------------------------------------------------------------
   之前「打开看到的还是旧版」没法自查：页面不显示版本，也没有任何
   提示。现在三处标明版本（登录页 / 更多菜单 / 设置页），
   并且页面与服务端版本不一致时顶部会浮出一条刷新提示。
   ============================================================ */

.login-ver {
  margin: var(--s-3) 0 0; text-align: center;
  font-size: var(--fs-11); color: var(--text-3);
  font-family: var(--mono); letter-spacing: .02em;
}

.menu-ver {
  padding: 6px 10px 2px; margin-top: 2px;
  font-size: 11px; color: var(--text-3);
  font-family: var(--mono);
  border-top: 1px solid var(--border);
}

.update-bar {
  position: fixed; left: 50%; top: calc(var(--appbar-h, 60px) + 10px); transform: translateX(-50%);
  z-index: 900;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 10px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--brand-soft-border);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-2);
  font-size: var(--fs-13); color: var(--text-2);
  animation: update-in .28s var(--ease);
}
.update-bar b { color: var(--text); font-variant-numeric: tabular-nums; }
@keyframes update-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- v1.1.23 设置页：已接入模型 + 支持模型 logo 墙 ---------- */
.ai-cur {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--r);
}
.ai-cur-logo { width: 46px; height: 46px; object-fit: contain; flex: none; }
.ai-cur-line { font-size: 15px; color: var(--text); }
.ai-cur-line b { color: var(--brand); font-family: var(--mono); font-size: 15.5px; }
.ai-cur.off { border-style: dashed; background: var(--warn-soft); border-color: var(--warn-soft-border); }
.ai-cur-ico { display: inline-flex; width: 24px; height: 24px; color: var(--warn); flex: none; }
.ai-cur-ico svg { width: 24px; height: 24px; }

.brand-wall {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.brand-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface-2);
}
.brand-card.on {
  border-color: var(--brand); background: var(--brand-soft);
}
.brand-card img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.brand-fallback {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-3); font-size: 11px; font-weight: 700;
}
.brand-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-meta b { font-size: 13px; color: var(--text); font-weight: 600; }
.brand-meta .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-card .chip { margin-left: auto; }

.about {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2);
  margin-top: var(--s-5); padding: var(--s-3) 2px;
  font-size: var(--fs-12); color: var(--text-3);
}
.about b { color: var(--text-2); font-family: var(--mono); font-weight: 600; }
.about-sep { color: var(--border-2); }
.about [data-about-build] { font-family: var(--mono); }

@media (max-width: 560px) {
  /* 窄屏改用左右吸附：transform 动画会带着 -50% 错位，干脆不要动画 */
  .update-bar { left: 12px; right: 12px; transform: none; animation: none; justify-content: space-between; }
}

/* ---------------- 扫描工作台：空态下的识别状态徽标 ---------------- */
.scan-vision-badge {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 8px; margin-top: var(--s-3);
  font-size: var(--fs-12);
}
.scan-vision-badge .badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-12); font-weight: 500;
}
.scan-vision-badge .badge.ok  { background: var(--success-soft); color: var(--success); }
.scan-vision-badge .badge.warn { background: var(--warn-soft); color: var(--warn); }
.scan-vision-badge .badge.off { background: var(--surface-3); color: var(--text-3); }
.scan-vision-badge .badge-link { font-size: var(--fs-12); color: var(--brand); }
.scan-vision-badge .badge-link:hover { text-decoration: underline; }

/* ============================================================
   v1.0.7 Word 整卷导入
   ------------------------------------------------------------
   一条链：拖入 → 阶段进度 → 卷面识别 → 逐题校对 → 入库。
   样式只做"状态可见"：进度到哪一步、哪题有问题、入库结果是什么。
   ============================================================ */

/* 拖入区直接复用扫描件的 .scan-drop（两个导入通道长得一样） */

/* ---- 解析进度：圆环（v1.0.13）---- */
.ring-box {
  display: flex; align-items: center; gap: var(--s-4);
  margin-top: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
}
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 104px; height: 104px; transform: rotate(-90deg); display: block; }
.ring-bg { fill: none; stroke: var(--border-2); stroke-width: 9; }
.ring-fg {
  fill: none; stroke: var(--brand); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset .18s linear, stroke var(--dur) var(--ease);
}
.ring-mid { position: absolute; inset: 0; display: grid; place-items: center; }
.ring-mid b { font-size: var(--fs-20); font-variant-numeric: tabular-nums; }
.ring-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ring-side b { font-size: var(--fs-14); }
.ring.done .ring-fg { stroke: var(--success); }
.ring.done .ring-mid b { color: var(--success); }
.ring.fail .ring-fg { stroke: var(--danger); }
.ring.fail .ring-mid b { color: var(--danger); font-size: var(--fs-24); }
.ring.fail ~ .ring-side b { color: var(--danger); }

/* ---- v1.1.1 双版导入：学生版 / 解析版并列 ---- */
.docx-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  align-items: stretch;
}
/* 两张卡是并排兄弟，不吃 .card + .card 的上边距，否则右卡整体下坠一截 */
.docx-two > .card + .card { margin-top: 0; }
.docx-pane { display: flex; flex-direction: column; height: 100%; }
/* 两个拖入区等高对齐：撑满卡片剩余空间，内容垂直居中 */
.docx-pane .scan-drop {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5) var(--s-4);
}
.docx-pane .scan-drop-inner { width: 100%; }
/* 副文案统一占两行的位置，保证两侧标题 / 按钮 / 状态行逐行对齐 */
.docx-pane .scan-drop-inner p {
  min-height: calc(1.7em * 2);
  display: flex; align-items: center; justify-content: center;
}

/* ---- v1.1.1 匹配结果表 ---- */
.match-bar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
}
.match-bar b[data-offset] { font-variant-numeric: tabular-nums; }
.mlist {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: var(--s-2);
  max-height: 460px; overflow: auto;
}
.mrow {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(150px, 210px) 78px minmax(0, 120px);
  gap: var(--s-2);
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  font-size: var(--fs-12);
}
.mrow:hover { border-color: var(--border-strong); }
.mrow.unbound { border-color: var(--danger-soft-border); background: var(--danger-soft); }
.mno { font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mstem, .mans {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2);
}
.mans { color: var(--text-3); font-variant-numeric: tabular-nums; }
.mreason { text-align: right; }
.mrow select { min-height: 30px; padding: 2px 6px; font-size: var(--fs-12); }

/* ---- 提示块 ---- */
.import-error,
.import-warn {
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r);
  font-size: var(--fs-13);
  line-height: 1.7;
}
.import-error { background: var(--danger-soft); border: 1px solid var(--danger-soft-border); }
.import-warn { background: var(--warn-soft); border: 1px solid var(--warn-soft-border); }
.import-error > b,
.import-warn > b { display: block; margin-bottom: var(--s-1); }
.import-warn ul { margin: 0; padding-left: 18px; }
.import-warn details { margin-top: var(--s-2); }
.import-warn summary { cursor: pointer; color: var(--text-2); }

/* ---- 卷面识别 ---- */
.paper-struct { display: flex; flex-direction: column; gap: 4px; }
.struct-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-13);
}
.struct-name { font-weight: 600; }
.struct-num { color: var(--text-3); font-size: var(--fs-12); }

/* ---- 逐题校对 ---- */
.import-toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.mini-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-2); }
.mini-check input { margin: 0; }

/* 侧栏清单行的题干摘要 */
.docx-mini { cursor: pointer; align-items: center; }
.docx-mini:hover { border-color: var(--brand); }
.docx-mini .scan-card-row b { font-size: var(--fs-12); }
.docx-mini-stem {
  font-size: var(--fs-11); color: var(--text-3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 从侧栏跳过来时闪一下，长卷里能立刻找到是哪题 */
.qitem.flash { animation: qflash 1.1s var(--ease); }
@keyframes qflash {
  0% { box-shadow: 0 0 0 3px var(--brand-soft); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.docx-preview {
  margin-top: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  font-size: var(--fs-14);
  line-height: var(--lh-stem);
}
.docx-opts { display: flex; flex-wrap: wrap; gap: 6px var(--s-4); margin-top: var(--s-2); }
.docx-opt { min-width: 40%; font-size: var(--fs-13); }
.docx-ans {
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px dashed var(--border-2);
  font-size: var(--fs-13);
}

/* ---- 入库结果 ---- */
.import-done {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-3);
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
}

/* ---- 题干插图（rich() 渲染 ![图片](url)） ----
   导入的整页扫描图往往上千像素高，这里统一压到可读尺寸；
   点一下可放大看原图（见 app.js 的图片放大器）。 */
.stem-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 300px;
  margin: var(--s-1) 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: #fff;
}

@media (max-width: 860px) {
  .docx-opt { min-width: 100%; }
  .ring-box { gap: var(--s-3); }
  .ring, .ring svg { width: 84px; height: 84px; }
}

/* ============================================================
   v1.0.8 整卷
   ------------------------------------------------------------
   一条链：左边挑卷 → 右边看结构 → 逐题勾选 → 底部浮出批量操作。
   复用题库的 .bar 浮层，不重复造操作条。
   ============================================================ */

.papers {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}

/* ---- 左：卷列表 ---- */
.papers-side {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  position: sticky; top: calc(var(--topbar-h) + var(--s-3));
  max-height: calc(100dvh - var(--topbar-h) - var(--s-6));
  display: flex; flex-direction: column; gap: var(--s-2); min-height: 0;
  padding: 10px;
}
.papers-side-head { display: flex; flex-direction: column; gap: var(--s-2); }
/* .search 默认 flex-basis 220px 是给横向头部用的；放进纵向侧栏会把盒子撑高 */
.papers-side-head .search { flex: none; }
.papers-tabs {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-pill);
}
.ptab {
  flex: 1; border: 0; background: none; cursor: pointer;
  padding: 5px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-12); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ptab:hover { color: var(--text); }
.ptab[aria-pressed="true"] {
  background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: var(--sh-1);
}
.papers-list {
  overflow: auto; display: flex; flex-direction: column; gap: 6px;
  min-height: 0; padding-right: 2px;
}
.paper-card {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.paper-card:hover { border-color: var(--border-2); background: var(--surface-2); }
.paper-card[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.pc-title {
  font-size: var(--fs-13); font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pc-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums;
}
.pc-sub {
  font-size: var(--fs-11); color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-sel { color: var(--brand); }
/* v1.1.3 公开卷的上传人（姓名 · 学校） */
/* ---------------- v1.1.25 文件夹 ---------------- */
.papers-folders { display: flex; flex-direction: column; gap: 4px; }
.pf-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pf-title { font-size: var(--fs-11); color: var(--text-3); letter-spacing: .02em; }
.pf-head .btn { padding: 2px 6px; gap: 2px; }
.pf-head .btn svg { width: 13px; height: 13px; }
.pf-list { display: flex; flex-direction: column; gap: 1px; }
.pf-row { position: relative; display: flex; align-items: center; }
.pf-item {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 5px 7px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
  font-size: var(--fs-12); transition: background var(--dur) var(--ease);
}
.pf-item svg { width: 14px; height: 14px; flex: none; color: var(--text-3); }
.pf-item:hover { background: var(--surface-3); }
.pf-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.pf-item.on svg { color: var(--brand); }
.pf-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-n { flex: none; font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pf-item.on .pf-n { color: var(--brand); }
/* hover 才显图标：目录多的时候不晃眼；键盘 focus 也要看得见 */
.pf-acts { display: flex; gap: 1px; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.pf-acts { background: var(--surface); border-radius: var(--r); padding-left: 4px; }
.pf-row .pf-acts { opacity: 0; }
.pf-row:hover .pf-acts, .pf-row:focus-within .pf-acts { opacity: 1; }
.pf-acts .icon-btn { padding: 2px; }
.pf-acts .icon-btn svg { width: 13px; height: 13px; }

/* v1.1.26 二级子目录：折叠箭头 + 缩进 */
.pf-tw {
  flex: none; width: 16px; height: 20px; display: grid; place-items: center;
  padding: 0; border: 0; background: transparent; color: var(--text-3); cursor: pointer;
}
.pf-tw svg { width: 12px; height: 12px; transition: transform var(--dur) var(--ease); }
.pf-tw.open svg { transform: rotate(90deg); }
.pf-row.pf-sub .pf-item { font-size: var(--fs-12); }
.pf-row.pf-sub .pf-item svg { width: 13px; height: 13px; }

/* v1.1.26 拖拽归类：目录行是投放区 */
.pf-row.drop { outline: 2px dashed var(--brand); outline-offset: -2px; border-radius: var(--r); }
.pf-row.drop .pf-item { background: var(--brand-soft); color: var(--brand); }
.pc-wrap.dragging { opacity: .45; }
.pc-wrap.dragging .paper-card { cursor: grabbing; }

/* v1.1.26 多选批量移动 */
.pc-pick {
  position: absolute; left: 6px; top: 8px; z-index: 1;
  display: grid; place-items: center; cursor: pointer;
}
.pc-pick input { width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--brand); }
.pc-wrap .paper-card { padding-left: 26px; }
.pc-wrap.picked .paper-card { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.papers-batch {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 6px 8px; border-radius: var(--r);
  background: var(--brand-soft); color: var(--brand);
}
.papers-batch[hidden] { display: none; }
.pb-n { font-size: var(--fs-12); }
.papers-batch .btn { padding: 2px 8px; gap: 3px; }
.papers-batch .btn svg { width: 13px; height: 13px; }

/* 列表卡片：右上角「移动到目录」 */
.pc-wrap { position: relative; }
.pc-wrap .paper-card { padding-right: 26px; }
.pc-move {
  position: absolute; top: 7px; right: 7px; padding: 2px;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.pc-wrap:hover .pc-move, .pc-move:focus-visible { opacity: 1; }
.pc-move svg { width: 14px; height: 14px; }

.paper-crumb { display: flex; align-items: center; gap: 2px; margin-bottom: 2px; }
.crumb {
  border: 0; background: transparent; padding: 1px 2px; cursor: pointer;
  font-size: var(--fs-11); color: var(--text-3); border-radius: 4px;
}
.crumb:hover { color: var(--brand); background: var(--brand-soft); }
.crumb-sep { font-size: var(--fs-11); color: var(--text-3); }

.papers-scope { align-self: flex-start; }
.pc-owner {
  display: flex; align-items: center; gap: 4px;
  font-size: var(--fs-11); color: var(--brand);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pc-owner svg { width: 12px; height: 12px; flex: none; }

/* ---- 右：卷详情 ---- */
.papers-main { min-width: 0; }
.paper-detail { display: flex; flex-direction: column; gap: var(--s-3); }

.paper-hero {
  display: flex; gap: var(--s-4); justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap;
  padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--sh-1);
}
.paper-hero-main { min-width: 0; flex: 1; }
.paper-title { margin: 0 0 var(--s-2); font-size: var(--fs-20); line-height: 1.4; word-break: break-word; }
.paper-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.paper-sub { margin-top: var(--s-2); font-size: var(--fs-12); color: var(--text-3); }
.paper-sub svg { width: 13px; height: 13px; flex: none; vertical-align: -2px; }
.paper-hero-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.paper-toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: 0 2px; }
.paper-toolbar .grow { flex: 1; }

/* ---- 原卷（PDF / A4 版式，v1.0.10） ---- */
.pdf-state {
  font-size: var(--fs-12); color: var(--text-2);
  max-width: min(52%, 520px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pdf-state b { color: var(--text); font-weight: 600; }
.pdf-state.muted { color: var(--text-3); }
.pdf-wrap {
  position: relative; overflow: hidden;
  height: clamp(520px, calc(100dvh - 340px), 1400px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface-2); box-shadow: var(--sh-1);
}
.pdf-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.pdf-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: var(--fs-13); color: var(--text-3); background: var(--surface-2);
  text-align: center; padding: 0 24px;
}

/* ---- v1.1.24 PDF 整卷导入 ---- */
.pdf-file-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); font-size: var(--fs-13);
}
.pdf-file-row svg { width: 16px; height: 16px; flex: none; color: var(--brand); }
.pdf-file-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.pdf-preview { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 420px; }
.pdf-preview-head {
  display: flex; align-items: center; gap: 8px; font-size: var(--fs-12); flex: none;
}
.pdf-preview-head .grow { flex: 1; }
.pdf-preview .pdf-frame {
  flex: 1; min-height: 380px;
  border: 1px solid var(--border); border-radius: var(--r);
}
.pc-pdf { color: var(--brand); font-weight: 600; }

/* ---- 大题分组 ---- */
.sec-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden;
}
.sec-head {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.sec-name { font-size: var(--fs-14); font-weight: 600; }
.sec-num { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.sec-pick { margin-left: auto; }

/* ---- 题目行 ---- */
.prow {
  display: flex; gap: var(--s-3); padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
.prow:last-child { border-bottom: 0; }
.prow:hover { background: var(--surface-2); }
.prow.on { background: var(--brand-soft); }
.prow .pick { padding-top: 3px; }
.prow-main { flex: 1; min-width: 0; }
.prow-stem { font-size: var(--fs-14); line-height: 1.8; color: var(--text); word-break: break-word; }
.prow-stem.clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prow.expanded .prow-stem.clamp { display: block; overflow: visible; }
.prow-stem .no { font-weight: 600; color: var(--text-3); margin-right: 3px; font-variant-numeric: tabular-nums; }
.prow-img {
  display: block; max-width: 100%; max-height: 170px; object-fit: contain; object-position: left top;
  margin-top: 6px; padding: 3px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.prow-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.prow-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.prow-score { font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.prow-acts .icon-btn svg { transition: transform var(--dur) var(--ease); }
.prow-acts .icon-btn[aria-expanded="true"] svg { transform: rotate(90deg); }
/* 移出本卷（v1.0.11.1）：平时低调，悬停才见危险色 */
.prow-acts .q-del { color: var(--text-3); }
.prow-acts .q-del:hover { color: var(--danger); background: var(--danger-soft); }

.prow-more {
  display: flex; flex-direction: column; gap: var(--s-2);
  margin-top: var(--s-2); padding: 10px 12px;
  background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: var(--r);
}
.prow-more[hidden] { display: none; }
/* 选项排布自 v1.0.11.1 起与题库共用 .qopts / .qexp-opt（两列栅格、正确项高亮） */
.pm-row { display: flex; gap: var(--s-2); font-size: var(--fs-13); }
.pm-label { flex: none; width: 28px; color: var(--text-3); }
.pm-body { min-width: 0; line-height: 1.8; }
.pm-acts { display: flex; gap: 6px; }

@media (max-width: 1100px) {
  .papers { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .papers { grid-template-columns: 1fr; }
  .papers-side { position: static; max-height: none; }
  .papers-list { max-height: 232px; }
  .paper-title { font-size: var(--fs-16); }
  .paper-hero-acts { width: 100%; }
  .pdf-wrap { height: 68dvh; }
  .pdf-state { max-width: 100%; }
  .prow { padding: 10px 12px; }
  .sec-head { padding: 9px 12px; }
  .sec-pick { margin-left: 0; }
}

/* ---- v1.1.1：窄屏把两个上传区与匹配表收成单列 ---- */
@media (max-width: 860px) {
  .docx-two { grid-template-columns: 1fr; }
  .mrow { grid-template-columns: 46px minmax(0, 1fr) 78px; }
  .mrow select { grid-column: 1 / -1; }
  .mans { display: none; }
  .mlist { max-height: 340px; }
}

/* ---- v1.0.7.2 Word 公式图（按原尺寸回贴，与正文基线对齐） ---- */
.mimg {
  display: inline-block;
  vertical-align: -0.18em;
  margin: 0 1px;
  background: #fff;
  border: 0;
  max-width: 100%;
}

/* ---- v1.1.6 题目图片：显示压到可读尺寸，点一下看原图 ---- */
img[data-zoomable] { cursor: zoom-in; }
.zoom-box { display: grid; place-items: center; }
.zoom-box img {
  max-width: 100%; max-height: 70vh;
  object-fit: contain; border-radius: var(--r);
}
/* 编辑弹窗 / 错题本里的原题图 */
.qimg-box { margin-top: 8px; }
.qimg-box img {
  display: block; max-width: 100%; max-height: 220px;
  border: 1px solid var(--border); border-radius: 8px;
}

/* ---- v1.1.8 AI 切题 ---- */
.btn-ai {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  color: var(--brand);
  background: var(--brand-soft);
}
.btn-ai:hover { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.scan-qno {
  flex: none; min-width: 22px; padding: 1px 5px;
  border-radius: 5px; background: var(--surface-3);
  border: 1px solid var(--border-2);
  font-size: var(--fs-11); color: var(--text-2);
  font-variant-numeric: tabular-nums; text-align: center;
}
