/* Physics Bank Web UI */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  margin: 0;
  background: #f7f8fa;
  color: #1f2329;
  font-size: 14px;
  line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* 全局布局：左侧导航 + 主区 */
.layout {
  display: flex;
  min-height: 100vh;
}
/* 讲义预览页：恢复 base.html 默认行为，让讲义内容自然撑开。
   - body / html 不锁高度 → 讲义 2162px 时 body / html 都撑到 2162
   - body 视口 660px < 2162px → 出滚动条
   - sidebar position:sticky + align-self:flex-start → 滚时 sidebar 停顶
   - 打印时 document 2162px → A4 多页（按 @page A4 划 ~3 页） */
body.page-handout_preview .layout { display: flex; min-height: 100vh; }
body.page-handout_preview .sidebar { align-self: flex-start; }   /* 关键：让 flex-start，sticky 才能停在视口顶 */
body.page-handout_preview .main { display: block; }   /* 主区自然撑开讲义内容 */

.sidebar {
  flex: none;
  width: 200px;
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

.sidebar-brand {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #334155;
  line-height: 1.3;
}

.side-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1;
}
.side-nav a {
  color: #cbd5e1;
  padding: 9px 20px;
  border-left: 3px solid transparent;
  font-size: 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.side-nav a:hover { background: #334155; color: #fff; text-decoration: none; }
.side-nav a.active {
  background: #0f172a;
  color: #fff;
  border-left-color: #2563eb;
  font-weight: 500;
}

.sidebar-foot {
  padding: 12px 20px;
  border-top: 1px solid #334155;
  color: #64748b;
  font-size: 12px;
}

.main { flex: 1; min-width: 0; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

/* ===================== 居中 Toast（替代页面顶 flash） ===================== */
.toast-stack {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 80vw;
}
.toast {
  background: #fff; color: #1f2329;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  border-left: 4px solid #2563eb;
  pointer-events: auto; max-width: 100%;
}
.toast-success { border-left-color: #16a34a; background: #f0fdf4; }
.toast-error   { border-left-color: #dc2626; background: #fef2f2; }
.toast-message { border-left-color: #2563eb; background: #eff6ff; }

/* ===================== 居中 Modal（替代 confirm/alert） ===================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  animation: modal-fade-in .12s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal-dialog {
  background: #fff; border-radius: 10px;
  padding: 20px 24px; min-width: 320px; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: modal-pop-in .12s ease-out;
}
.modal-message {
  font-size: 14px; line-height: 1.7; color: #1f2329;
  white-space: pre-wrap; word-break: break-word; margin-bottom: 18px;
}
.modal-input-row { margin: -8px 0 16px; }
.modal-input {
  width: 100%; padding: 8px 12px; font-size: 14px;
  border: 1px solid #d1d5db; border-radius: 6px; box-sizing: border-box;
}
.modal-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.modal-list-row { margin: -8px 0 12px; }
.modal-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 360px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: 6px;
}
.modal-list-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f1f3f5;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 13px; line-height: 1.4;
}
.modal-list-item:last-child { border-bottom: none; }
.modal-list-item:hover { background: #eff6ff; }
.modal-list-item .mli-label { color: #1f2329; font-weight: 500; }
.modal-list-item .mli-sub { color: #6b7280; font-size: 12px; }
.modal-list-empty { padding: 16px; text-align: center; color: #9ca3af; font-size: 13px; }

/* 多选列表项（appMultiSelect）：checkbox + 文字 */
.modal-list-item.multi { flex-direction: row; align-items: center; gap: 8px; }
.modal-list-item .mli-check {
  width: 16px; height: 16px; flex: none;
  border: 1px solid #cbd5e1; border-radius: 4px;
  background: #fff; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
}
.modal-list-item.selected .mli-check { background: #2563eb; border-color: #2563eb; }
.modal-list-item.selected .mli-check::after { content: '✓'; color: #fff; font-size: 11px; line-height: 1; }
.modal-list-item .mli-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* 题库页：body 不滚，.main 是唯一滚动容器；h1/过滤条/KP 树都 sticky，q-list 滚动 */
body.page-questions { overflow: hidden; height: 100vh; }
body.page-questions .main { height: 100vh; overflow-y: auto; }
body.page-questions .container > h1 {
  position: sticky; top: 0; z-index: 13;
  background: #f7f8fa; margin: 0;
  height: 50px; line-height: 50px; font-size: 20px; font-weight: 600;
  box-sizing: border-box;
  border-bottom: 1px solid #e5e7eb;
}
body.page-questions form.filter {
  top: 50px; z-index: 12;
  border-radius: 0; margin-bottom: 0;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
body.page-questions .questions-sidebar { top: 50px; max-height: calc(100vh - 50px); }
/* 题库列表页：容器撑满可用宽度（不再 max-width 居中留白），树列宽度不变 */
body.page-questions .container {
  max-width: none;
  padding: 16px 12px 24px;
}

/* ============== 知识点库列表页：整页主滚动 + 过滤框 sticky ==============
   采用与 page-questions 同款「main 自滚」模型：避免列内部 overflow 在 grid 嵌套
   flex 链路里高度算不出来的问题。整页只有 main 滚，body 不滚；filter 跟随 main
   在其顶部 sticky。侧栏 .questions-sidebar 在 main 滚的同时也 sticky 在视口左侧。
   这种结构比「列内独立滚」浅——浏览器兼容性最稳。*/
body.page-knowledge_points {
  overflow: hidden;          /* 锁 body 整体不滚，让 main 独滚 */
}
/* main 撑满视高，自滚 */
body.page-knowledge_points .layout {
  height: 100vh;
}
body.page-knowledge_points main.main {
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* h1 吸顶在 main 顶端 */
body.page-knowledge_points main.main > .container > h1 {
  position: sticky;
  top: 0;
  z-index: 14;
  background: #f7f8fa;
  margin: 0 -16px 12px;
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 600;
  box-sizing: border-box;
  border-bottom: 1px solid #e5e7eb;
}
/* layout grid：左栏 340px，右列固定 720px（容纳 2 卡片并排） */
body.page-knowledge_points .questions-layout {
  flex: 1 1 auto;
  min-height: 0;
  align-items: start;
  grid-template-columns: 340px auto;
}
/* 主列固定宽度 ≈ 720px，能放下 2 张 320px 卡片并排 + 间距 + padding
   关键设计：filter form 上方宽度 = 720px；卡片 grid 用 2 列时无论 1 张还是 2 张
   每张都正好占主列一半（≈344px），视觉一致。 */
body.page-knowledge_points .questions-main {
  width: 720px;
  min-width: 720px;
  max-width: 720px;
  flex: 0 0 720px;
}
/* 侧栏：给个显式 min-width 防内容溢出 */
body.page-knowledge_points .questions-sidebar {
  min-width: 340px;
}
/* 表单输入框：用 min-content，避免 flex: 1 + min-width: 0 在窄列里变细 */
body.page-knowledge_points form.filter input[type="search"] {
  min-width: 200px;
}
body.page-knowledge_points form.filter select {
  min-width: 80px;
}
/* 侧栏：sticky 到视口顶；当 main 滚时跟随 */
body.page-knowledge_points .questions-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
}
/* filter 吸顶：随 main 滚 跟随滚动 */
body.page-knowledge_points .questions-main > .filter {
  position: sticky;
  top: 0;
  z-index: 11;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  margin: 0 0 12px;
  padding: 12px 14px;
}

/* 树栏搜索框下方的 学科/教材 选择条 —— 与 .tree-filter 视觉协调 */
.tree-scope-form {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tree-scope-form select {
  font-size: 12px;
  padding: 4px 6px;
}

.flashes { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  border-left: 4px solid;
}
.flash-success { background: #f0fdf4; border-color: #16a34a; color: #166534; }
.flash-error   { background: #fef2f2; border-color: #dc2626; color: #991b1b; }
.flash-info    { background: #eff6ff; border-color: #2563eb; color: #1e40af; }

h1 { margin: 0 0 16px; font-size: 22px; }
h2 { margin: 24px 0 12px; font-size: 18px; border-bottom: 1px solid #e5e7eb; padding-bottom: 4px; }
h3 { margin: 16px 0 8px; font-size: 15px; }

.muted { color: #6b7280; font-weight: normal; font-size: 14px; }
.meta { color: #6b7280; font-size: 13px; margin-bottom: 16px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.1s, box-shadow 0.1s;
  color: #1f2329;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); text-decoration: none; }
.card .num { font-size: 32px; font-weight: 700; color: #2563eb; }
.card .lbl { color: #6b7280; margin-top: 4px; }

/* ============ 概览页 Dashboard ============ */
.dash-head { margin-bottom: 20px; }
.dash-head h1 { margin: 0 0 4px; }
.dash-sub { color: #6b7280; font-size: 13px; margin: 0; }

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.dash-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.dash-card::before {           /* 左侧彩色竖条 accent */
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent, #2563eb);
}
.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.10);
  text-decoration: none;
}
.dash-card-icon {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--accent-soft, #eff6ff);
}
.dash-card-body { min-width: 0; }
.dash-card-num { font-size: 26px; font-weight: 700; line-height: 1.1; color: #1f2329; }
.dash-card-lbl { font-size: 12px; color: #6b7280; margin-top: 2px; }
.dash-card-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.dash-card--blue   { --accent: #2563eb; --accent-soft: #eff6ff; }
.dash-card--violet { --accent: #7c3aed; --accent-soft: #f5f3ff; }
.dash-card--amber  { --accent: #d97706; --accent-soft: #fffbeb; }
.dash-card--rose   { --accent: #dc2626; --accent-soft: #fef2f2; }

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.dash-panel h2 {
  font-size: 15px;
  margin: 0 0 16px;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 10px;
}

/* 题型分布：横向条形 */
.type-bars { display: flex; flex-direction: column; gap: 12px; }
.type-bar-row { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 12px; }
.type-bar-label { font-size: 13px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-bar-track { background: #f3f4f6; border-radius: 4px; height: 10px; overflow: hidden; }
.type-bar-fill { height: 100%; background: #2563eb; border-radius: 4px; transition: width .3s; }
.type-bar-count { font-size: 13px; color: #6b7280; text-align: right; font-variant-numeric: tabular-nums; }

/* 快捷操作 */
.dash-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.dash-actions .btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; }
.dash-actions form { margin: 0; }

.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #d1d5db;
  color: #1f2329;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.tiny { padding: 1px 6px; font-size: 11px; line-height: 1.6; }
.btn.big { padding: 12px 20px; font-size: 15px; }

.badge {
  display: inline-block;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  margin-right: 4px;
}
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.info { background: #dbeafe; color: #1d4ed8; }

table.data {
  width: 100%;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border-collapse: collapse;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
table.data th,
table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
}
table.data th { background: #f9fafb; font-weight: 600; color: #4b5563; }
table.data tr:last-child td { border-bottom: none; }

form label { display: block; margin-bottom: 12px; color: #4b5563; }
form label.inline { display: inline-block; margin-right: 12px; }
form input[type="text"],
form input[type="password"],
form input[type="number"],
form input[type="search"],
form textarea,
form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}
form textarea { font-family: ui-monospace, monospace; resize: vertical; }

form.filter {
  background: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  position: sticky;
  top: 50px;
  z-index: 12;
  border-radius: 0;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
form.filter .row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
form.filter .row:last-child { margin-bottom: 0; }
form.filter .row-search input[type="search"] {
  flex: 1 1 auto; width: 100%; min-width: 0;
  height: 42px; padding: 10px 16px; font-size: 16px;
}
form.filter .row-selects select {
  flex: 1; min-width: 0; height: 32px; padding: 4px 8px; font-size: 13px;
}
form.filter .type-chip { font-size: 12px; padding: 3px 8px; gap: 3px; }
form.filter .type-chip input { margin: 0; }
/* 按钮维持 .btn 原样式，不在 filter 内压小 */
form.filter .btn { height: auto; }

.type-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: #f3f4f6; border-radius: 4px; cursor: pointer; }
.type-chip input { width: auto; }

.actions { margin: 16px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.upload { background: #fff; padding: 20px; border-radius: 8px; text-align: center; margin-bottom: 24px; }

.empty { color: #9ca3af; padding: 20px; text-align: center; }

.q-block { background: #fff; padding: 16px; border-radius: 8px; margin-bottom: 12px; }
/* 题目详情页：紧凑布局 */
.qd-layout { max-width: 900px; }
.qd-header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 0 10px; border-bottom: 1px solid #e5e7eb; margin-bottom: 14px;
}
.qd-header h1 { margin: 0; font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.qd-diff { font-size: 13px; color: #6b7280; font-weight: normal; }
.qd-header-actions { display: flex; gap: 6px; margin-left: auto; }
.qd-body { display: flex; flex-direction: column; gap: 12px; }
.qd-section { padding: 0; }
.qd-label {
  display: inline-block; font-size: 12px; font-weight: 600; color: #4b5563;
  margin-right: 8px; padding: 2px 6px; background: #f3f4f6; border-radius: 4px;
  vertical-align: middle;
}

/* 题干 */
.qd-stem-section .q-stem { font-size: 16px; line-height: 1.7; color: #1f2329; }

/* 选项 */
.qd-section .options { list-style: none; padding: 0; margin: 0; }
.qd-section .options li {
  padding: 6px 10px; margin: 4px 0; border-radius: 4px; line-height: 1.6;
  border: 1px solid #f1f3f5;
}
.qd-section .options li.is-correct {
  background: #f0fdf4; border-color: #bbf7d0; color: #166534; font-weight: 500;
}

/* 小问 */
.sub-q { padding: 6px 0; border-bottom: 1px dashed #f1f3f5; }
.sub-q:last-child { border-bottom: none; }
.sq-ans { color: #16a34a; font-size: 13px; margin-top: 4px; }

/* 答案 + 解析 */
.qd-answer-section { display: flex; flex-direction: column; gap: 8px; }
.qd-answer-block { line-height: 1.7; }
.qd-ans-text { color: #16a34a; font-weight: 500; white-space: pre-wrap; word-break: break-word; }
.qd-analysis { color: #4b5563; line-height: 1.7; }
.qd-analysis-text { white-space: pre-wrap; word-break: break-word; }
.qd-analysis-text mjx-container,
.qd-analysis-text svg { overflow: visible; max-width: 100%; }

/* 易错提醒（醒目的警告样式：橙色背景 + 左边框 + 警示图标 + 加粗） */
.qd-warning {
  margin-top: 12px;
  padding: 10px 14px 10px 14px;
  background: #fff7ed;
  border-left: 4px solid #f97316;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.7;
  color: #7c2d12;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(249, 115, 22, 0.08);
}
.qd-warning::before {
  content: "⚠";
  font-size: 18px;
  color: #f97316;
  flex-shrink: 0;
  line-height: 1.5;
}
.qd-warning .qd-label-warn {
  background: #f97316;
  color: #fff;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.qd-warning > div:last-child {
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.qd-warning-text mjx-container,
.qd-warning-text svg { overflow: visible; max-width: 100%; }

/* 标签 */
.qd-tags-section {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb;
}
.qd-tags-section .tag-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.qd-tags-section .tag-add-row { display: inline-flex; gap: 4px; margin-left: auto; }
.qd-tags-section .tag-add-row input {
  width: 180px; height: 26px; padding: 3px 8px; font-size: 12px;
  border: 1px solid #d1d5db; border-radius: 4px;
}

/* 题图管理（折叠） */
.qd-imgs-section {
  background: #f9fafb; padding: 8px 12px; border-radius: 6px; font-size: 12px;
}
.qd-imgs-section summary { cursor: pointer; color: #6b7280; user-select: none; }
.qd-imgs-section[open] summary { margin-bottom: 8px; }
.qd-imgs-section .img-list { display: flex; flex-wrap: wrap; gap: 6px; }
.qd-imgs-section .img-card { background: #fff; padding: 4px; border: 1px solid #e5e7eb; border-radius: 4px; max-width: 160px; }
.qd-imgs-section .img-card img { max-width: 150px; max-height: 100px; display: block; }
.qd-imgs-section .img-card small { font-size: 10px; color: #9ca3af; display: block; max-width: 150px; word-break: break-all; }
.qd-imgs-section .upload-form { margin-top: 8px; }

.q-stem { font-size: 16px; line-height: 1.8; }
.options { padding-left: 24px; }
.ans { color: #16a34a; }
.analysis { color: #4b5563; }
.sub-q { padding: 8px 0; border-bottom: 1px dashed #e5e7eb; }

fieldset { border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 16px; background: #fff; }
legend { padding: 0 8px; font-weight: 600; color: #4b5563; }

.paper-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; margin: 16px 0; }
.page-nav { background: #fff; padding: 12px; border-radius: 8px; position: sticky; top: 80px; height: fit-content; }
.page-nav ul { list-style: none; padding: 0; margin: 0; }
.page-nav li { padding: 4px 0; }
.pages .page { background: #fff; padding: 16px; margin-bottom: 12px; border-radius: 8px; }
.pages img { max-width: 100%; border: 1px solid #e5e7eb; }

/* ===================== 试卷详情页 ===================== */
.paper-detail-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; margin: 14px 0 0; }
.paper-detail-left {
  position: sticky;
  top: calc(var(--header-h, 100px) + 12px);
  max-height: calc(100vh - var(--header-h, 100px) - 28px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-right: 2px;   /* 给滚动条留一点间隙 */
}
.paper-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* 选页栏 */
.paper-pages-nav { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px; margin-top: 12px; }
.paper-pages-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.paper-pages-head .t { font-size: 13px; font-weight: 600; color: #374151; }
.paper-pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.paper-page-tile {
  display: flex; align-items: center; justify-content: center;
  height: 32px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 12px; color: #4b5563; text-decoration: none; background: #f9fafb;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.paper-page-tile:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }

@media (max-width: 900px) {
  .paper-detail-grid { grid-template-columns: 1fr; }
  .paper-detail-left { position: static; max-height: none; overflow: visible; }
}

/* 试卷打印预览文档 */
.paper-print-document {
  background: #fff;
  padding: 32px 40px;
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  position: relative;   /* 手写批注画布的定位参照（跟 .handout-document 一样） */
}
.paper-print-document .paper-print-cover {
  text-align: center;
  border-bottom: 2px solid #1f2329;
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.paper-print-document .paper-print-cover h1 {
  font-size: 24px; margin: 0 0 8px 0; color: #1f2329;
}
.paper-print-document .cover-meta { color: #6b7280; font-size: 13px; }
.paper-print-page { margin-bottom: 20px; }
.paper-print-page img {
  display: block; max-width: 100%; height: auto; margin: 0 auto;
  border: 1px solid #e5e7eb;
}

/* 作业里的扫描件原卷：整页铺满，学生直接在卷面上手写 */
.hw-scan-tip { margin: 0 0 12px 0; }
.hw-scan-page { margin-bottom: 18px; }
.hw-scan-page img {
  display: block; width: 100%; max-width: 100%; height: auto; margin: 0 auto;
  border: 1px solid #e5e7eb; border-radius: 2px;
}
.hw-linked-qs { margin-top: 28px; border-top: 1px dashed #d1d5db; padding-top: 16px; }

.fav-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.folder-tree { list-style: none; padding: 0; margin: 12px 0; background: #fff; border-radius: 8px; padding: 8px; }
.folder-tree li { padding: 6px 8px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; }
.folder-tree li.active { background: #eff6ff; }
.fav-list { background: #fff; border-radius: 8px; padding: 16px 16px 16px 36px; }

.stats { display: flex; gap: 8px; margin: 12px 0; }
.stats .badge { font-size: 14px; padding: 6px 12px; }

table.rule { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.rule td { padding: 6px 8px; }
table.rule input, table.rule select { padding: 4px 8px; }

.gen-result { background: #fff; padding: 16px 16px 16px 36px; border-radius: 8px; }
.gen-result li { padding: 4px 0; }

footer.footer { text-align: center; color: #9ca3af; padding: 16px; margin-top: 40px; font-size: 12px; }

.notes { background: #fff; padding: 12px 16px 12px 36px; border-radius: 8px; color: #4b5563; }
.notes li { padding: 4px 0; }

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand, .sidebar-foot { padding: 12px 8px; font-size: 12px; text-align: center; }
  .side-nav a { padding: 10px 8px; text-align: center; font-size: 12px; }
  .paper-layout, .fav-layout, .questions-layout { grid-template-columns: 1fr; }
  .page-nav { position: static; }
}

/* 题图缩略图 */
.thumb { max-height: 40px; vertical-align: middle; margin-right: 4px; border: 1px solid #ddd; border-radius: 2px; }

/* Crop 页面 */
.q-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.q-images img { max-width: 200px; max-height: 200px; border: 1px solid #e5e7eb; border-radius: 4px; }
.q-stem { white-space: pre-wrap; line-height: 1.8; font-size: 15px; }

/* ============ 预览区题干：单列布局（题图功能已移除，不再预留右侧图片位） ============ */
.preview-pane .q-stem {
  min-width: 0;
  word-break: break-word;
}
.options { list-style: none; padding-left: 0; }

/* 题图管理 */
.img-mgr { background: #f9fafb; padding: 12px; border-radius: 6px; margin-top: 12px; }
.img-mgr h4 { margin: 0 0 8px; font-size: 13px; color: #6b7280; }
.img-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.img-card { background: #fff; padding: 6px; border: 1px solid #e5e7eb; border-radius: 4px; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; max-width: 220px; }
.img-card img { max-width: 200px; max-height: 140px; display: block; }
.img-card small { font-size: 11px; color: #9ca3af; word-break: break-all; max-width: 200px; }
.upload-form { display: flex; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px dashed #e5e7eb; }
.auto-fig-suggestion { background: #f0fdf4; border: 1px solid #86efac; border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.auto-fig-suggestion h4 { margin: 0 0 6px; font-size: 13px; color: #15803d; }
.crop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1080px) { .crop-layout { grid-template-columns: 1fr; } }

.canvas-area {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-config {
  display: flex; gap: 14px; flex-wrap: wrap;
  padding: 10px 12px; background: #f8fafc; border-radius: 8px;
}
.toolbar-config label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: #64748b; margin: 0;
}
.toolbar-config select {
  min-width: 160px; padding: 6px 8px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
}
.status {
  font-size: 13px; color: #1e40af;
  padding: 8px 12px; background: #eff6ff; border: 1px solid #dbeafe;
  border-radius: 6px; min-height: 18px;
}

.canvas-scroll {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  overflow: auto;
  text-align: center;
}
.canvas-wrap { position: relative; display: inline-block; line-height: 0; user-select: none; }
.canvas-wrap img { max-width: 100%; display: block; }
.canvas-wrap #rect, .canvas-wrap #rect-stem {
  position: absolute;
  border: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.1);
  display: none;
  pointer-events: none;
  top: 0; left: 0;
}
.rect-figure-temp { position: absolute !important; pointer-events: none; }

.figure-section { margin-top: 14px; }
.figure-list { display: flex; flex-wrap: wrap; gap: 10px; }
.figure-list .img-card {
  background: #fff; padding: 6px;
  border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  max-width: 180px;
}
.figure-list .img-card img { max-width: 160px; max-height: 120px; display: block; border-radius: 4px; }
.figure-list .img-card small { font-size: 11px; color: #9ca3af; }
.figure-list .img-card .btn { margin-top: 2px; }

.result-area {
  background: #fff; border-radius: 10px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  max-height: calc(100vh - 32px); overflow-y: auto;
  position: sticky; top: 16px;
}
.result-area h3 { margin: 0 0 12px; font-size: 15px; }
#crop-preview img { max-width: 100%; border: 1px solid #e5e7eb; border-radius: 6px; margin-bottom: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .field { margin: 0; min-width: 0; }
.form-grid .field.full { grid-column: 1 / -1; }
.form-grid .field label { margin-bottom: 4px; font-size: 12px; color: #64748b; }
.form-grid .field .hint { color: #9ca3af; font-weight: normal; }
.form-grid textarea, .form-grid select, .form-grid input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px; font-family: inherit;
}
.form-grid textarea { font-family: ui-monospace, monospace; resize: vertical; }

/* 上传页 */
.lead { font-size: 15px; color: #4b5563; margin: -4px 0 16px; }
.dropzone {
  background: #fff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 20px;
}
.dropzone.dragover { border-color: #2563eb; background: #eff6ff; }
.dropzone-inner { cursor: pointer; }
.dropzone-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.dropzone-title { font-size: 15px; color: #1f2329; margin: 0 0 4px; }
.dropzone-sub { font-size: 12px; color: #9ca3af; margin: 0; }
.file-preview { max-height: 220px; max-width: 100%; border-radius: 8px; margin: 10px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.crop-upload-actions { margin-top: 18px; display: flex; justify-content: center; }

.crop-help { background: #fff; border-radius: 10px; padding: 16px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.crop-help h2 { margin-top: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { position: relative; padding-left: 38px; color: #4b5563; line-height: 1.7; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 2px;
  width: 24px; height: 24px; line-height: 24px;
  background: #2563eb; color: #fff; border-radius: 50%;
  text-align: center; font-size: 13px; font-weight: 600;
}

/* 题库：左侧知识树 + 右侧列表 */
.questions-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .questions-layout { grid-template-columns: 1fr; } }

.questions-sidebar {
  background: #fff; border-radius: 10px; padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: sticky; top: 16px;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.questions-sidebar > .filter,
.questions-sidebar > .sidebar-title:first-of-type,
.questions-sidebar > form[method="get"] {
  flex: 0 0 auto;
}
.questions-sidebar > .tree-list,
.questions-sidebar > .tree-subject,
.questions-sidebar > a.btn {
  flex: 0 0 auto;
}
/* 树容器：可滚动（同时支持 .sidebar-scroll 包裹式 与 .tree-pane 直接子节点式） */
.questions-sidebar .sidebar-scroll,
.questions-sidebar > .tree-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 4px;
  padding-right: 4px;
}
/* 编辑页场景：去掉白底圆角,跟 form/preview 平齐 */
.edit-layout > .questions-sidebar {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  top: 24px;
  box-shadow: none;
}
.sidebar-title { font-weight: 600; font-size: 13px; color: #4b5563; padding: 4px 6px 6px; }
.questions-sidebar .btn.small { margin: 0 6px 10px; }

.tree-tabs { display: flex; gap: 4px; margin: 0 6px 10px; }
.tree-tab {
  flex: 1; padding: 5px 0; border: 1px solid #d1d5db; background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: #4b5563;
}
.tree-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 树内搜索框 */
.tree-filter { margin: 0 6px 10px; }
.tree-filter input[type="search"] {
  width: 100%; box-sizing: border-box;
  padding: 5px 8px; font-size: 13px;
  border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
  outline: none;
}
.tree-filter input[type="search"]:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

/* 搜索命中态：精确匹配节点黄色高亮 */
.tree-pane li.tree-filter-match > .tree-row > .tree-link,
.tree-pane li.tree-filter-match > details > summary > .tree-link {
  background: #fef3c7; box-shadow: inset 0 0 0 2px #f59e0b;
}

.tree-subject { margin-bottom: 12px; }
.tree-subject-head { display: flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.tree-subject-head .tree-subject-link { flex: 1; margin-bottom: 0; }
.tree-subject-link {
  display: block; padding: 6px 8px; border-radius: 6px;
  font-weight: 600; font-size: 14px; color: #1f2329;
  background: #f8fafc;
}
.tree-subject-link:hover { background: #eff6ff; text-decoration: none; }
.tree-subject-link.active { background: #2563eb; color: #fff; }

.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { padding-left: 20px; }  /* 仅左侧缩进，右边让徽章对齐 sidebar 右边界 */

.tree-row { display: flex; align-items: center; }
.tree-row .tree-link { flex: 1; }

.tree-node > summary {
  display: flex; align-items: center; cursor: pointer;
  list-style: none; padding: 2px 0;
}
.tree-node > summary::-webkit-details-marker { display: none; }
.tree-node > summary::before {
  content: "▸"; flex: none; width: 14px; color: #9ca3af; font-size: 11px; text-align: center;
}
.tree-node[open] > summary::before { content: "▾"; }
/* 链接占满剩余宽度，徽章绝对定位到容器右边界（所有节点统一对齐） */
.tree-node,
.tree-node > summary,
.tree-list > li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 !important;  /* 强制清零所有浏览器默认 padding */
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}
.tree-node { display: block; }  /* details 仍需 block 让内部 ul 正常换行 */
.tree-node > summary {
  display: flex;
}
.tree-node > summary::before {
  content: "▸"; flex: none; width: 14px; color: #9ca3af; font-size: 11px; text-align: center;
  padding-left: 0;
}
.tree-node[open] > summary::before { content: "▾"; }
.tree-node > summary .tree-link,
.tree-list > li > .tree-link {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 6px;
  padding-right: 32px;  /* 给徽章留 32px 空间 */
}
/* 徽章绝对定位到容器最右 */
.tree-node > summary .kp-count-badge,
.tree-list > li > .kp-count-badge {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.tree-link {
  display: inline-block; padding: 5px 8px; border-radius: 5px;
  color: #4b5563; font-size: 13px;
  border-left: 2px solid transparent;
}
.tree-link:hover { background: #f3f4f6; text-decoration: none; }
.tree-link.active { background: #eff6ff; color: #2563eb; border-left-color: #2563eb; font-weight: 500; }

.tree-add {
  flex: none; width: 20px; height: 20px; line-height: 18px;
  border: 1px solid transparent; background: transparent; color: #9ca3af;
  border-radius: 4px; cursor: pointer; font-size: 14px; padding: 0; margin-right: 4px;
  text-align: center;
}
.tree-add:hover { background: #e5e7eb; color: #2563eb; border-color: #d1d5db; }

.tree-del {
  flex: none; width: 20px; height: 20px; line-height: 18px;
  border: 1px solid transparent; background: transparent; color: #d1d5db;
  border-radius: 4px; cursor: pointer; font-size: 14px; padding: 0; margin-right: 4px;
  text-align: center;
}
.tree-del:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

/* 树节点操作按钮：默认淡出，hover 到行上才显示，减少视觉噪音 */
.tree-add, .tree-del { opacity: 0; transition: opacity .12s ease; }
.tree-node:hover .tree-add, .tree-node:hover .tree-del,
.tree-row:hover .tree-add, .tree-row:hover .tree-del,
.tree-subject-head:hover .tree-add, .tree-subject-head:hover .tree-del { opacity: 1; }
.sidebar-actions { display: flex; gap: 6px; margin: 0 6px 10px; flex-wrap: wrap; }

/* 选中节点操作面板（替代树里的行内 +/×） */
.selection-panel {
  margin: 0 6px 10px; padding: 8px 10px;
  background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 6px;
}
.selection-label { font-size: 12px; color: #4b5563; margin-bottom: 6px; line-height: 1.4; }
.selection-label b { color: #1e40af; font-weight: 600; }
.selection-actions { display: flex; gap: 12px; }

/* 纯文字按钮（新增节点 / 删除节点） */
.btn-link {
  background: none; border: none; padding: 0;
  color: #2563eb; cursor: pointer; font-size: 13px;
  font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: #dc2626; }

/* 去掉 <details> 的三角图标 —— 整个 summary 自身可点 */
.tree-node > summary { list-style: none; cursor: pointer; }
.tree-node > summary::-webkit-details-marker { display: none; }
.tree-node > summary::marker { content: ''; }

/* 题库：题目卡片列表 */
.q-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.q-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: #fff; border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.q-card-body { flex: 1; min-width: 0; }
/* ===================== 题干+选项+题图统一容器 =====================
 * 列表 / 详情 / 讲义三个场景共用同一个 class，集中维护样式，
 * 让详情页编辑题图 (DX/DY/W) 后，其余两处自动同步（共享 SVG data-layout-* + 同一组 CSS）。
 * 详情页的"答案 / 解析 / 易错"用 .kp-render-formula 等其他容器，不在此列。
 */
.q-stem-area {
  max-width: 720px;
  overflow: visible;
}

.q-card-stem {
  display: block; font-size: 14px; line-height: 1.7; color: #1f2329;
  white-space: pre-wrap; word-break: break-word;
}
.q-card-stem:hover { color: #2563eb; }
.q-card-options { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.q-card-options .opt { font-size: 13px; color: #4b5563; }
.q-card-tags { margin-top: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.q-card-kps { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* 标签 chip — 通用样式（详情 / 列表 / 过滤 都用） */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; line-height: 1.4;
  padding: 2px 8px; border-radius: 12px;
  border: 1px solid #e5e7eb; background: #f3f4f6; color: #4b5563;
  white-space: nowrap;
}
.tag-chip .tag-remove {
  border: none; background: transparent; padding: 0 0 0 2px;
  font-size: 14px; line-height: 1; cursor: pointer; color: inherit; opacity: 0.6;
}
.tag-chip .tag-remove:hover { opacity: 1; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-add-row { display: flex; gap: 6px; margin-top: 10px; }
.tag-add-row input[type="text"] { flex: 1; padding: 5px 10px; font-size: 13px; }

/* 列表卡片的易错提醒（与详情页 qd-warning 风格一致，缩小版） */
.q-card-warning {
  margin-top: 6px;
  padding: 4px 8px 4px 8px;
  background: #fff7ed;
  border-left: 3px solid #f97316;
  border-radius: 3px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
  color: #7c2d12;
  font-size: 12px;
}
.q-card-warning::before {
  content: "⚠";
  font-size: 13px;
  color: #f97316;
  flex-shrink: 0;
  line-height: 1.5;
}
.q-card-warning-label {
  background: #f97316;
  color: #fff;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 10px;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  line-height: 1.5;
}
.q-card-warning-text {
  flex: 1;
}

/* 知识点（左侧树关联） */
.qd-kp-section { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.qd-kp-section .qd-label { margin-right: 4px; }
.kp-list { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.kp-chip {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 12px; line-height: 1.5;
  padding: 2px 4px 2px 8px; border-radius: 4px;
  background: #eef2ff; border: 1px solid #c7d2fe; color: #4338ca;
  white-space: nowrap;
}
.kp-chip .kp-sep { color: #94a3b8; font-size: 10px; padding: 0 1px; }
.kp-chip .kp-node.kp-d1 { font-weight: 700; color: #312e81; }
.kp-chip .kp-node.kp-d2 { font-weight: 600; }
.kp-chip .kp-node.kp-d3 { color: #6366f1; }
.kp-chip .kp-remove {
  border: none; background: transparent; padding: 0 0 0 4px;
  font-size: 14px; line-height: 1; cursor: pointer; color: inherit; opacity: 0.6;
}
.kp-chip .kp-remove:hover { opacity: 1; }
/* 右侧信息列宽度必须封顶：原来 flex:none 会让这一列按 max-content 撑开，
   一串长 badge（如试卷「册别」第Ⅰ卷…）累加到几百 px，把左边正文挤成 0 宽
   （标题一个字一行）而且 badge 还溢出卡片。封顶后 badge 自己换行。 */
.q-card-side { flex: 0 1 auto; min-width: 0; max-width: 46%; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.q-card-badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: flex-end; max-width: 100%; }
.q-card-badges .badge { max-width: 100%; overflow-wrap: break-word; }
/* 右侧列收窄后，chip / 标签的 nowrap 会顶出卡片 → 允许换行 */
.q-card-side .tag-chip,
.q-card-side .kp-chip { max-width: 100%; white-space: normal; }
.q-id { font-size: 12px; color: #9ca3af; }
.q-card-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* 批量选择 + 批量删除 */
.q-check { flex: none; display: flex; align-items: center; padding-top: 3px; }
.q-check input { width: 16px; height: 16px; cursor: pointer; }
.batch-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; margin-bottom: 12px;
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
}
.batch-select-all { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #7f1d1d; cursor: pointer; }
.batch-select-all input { width: 15px; height: 15px; cursor: pointer; }
#batch-count { font-size: 13px; font-weight: 600; color: #b91c1c; }
#btn-batch-delete { margin-left: auto; }
@media (max-width: 640px) {
  .q-card { flex-direction: column; }
  .q-card-side { align-items: flex-start; max-width: 100%; }
  .q-card-badges { justify-content: flex-start; }
}
/* ============ 编辑/新建页三栏布局（知识树 + 表单 + 预览） ============ */
/* 全局 .sidebar 宽 200px；编辑/新建页容器左移 280px 给 fixed 知识树留位置 */
body.page-question_new .container { padding-left: 280px; max-width: none; }
/* 详情页（编辑页）：容器撑满可用宽度，编辑栏 560px 不变，左侧不留大留白 */
body.page-question_edit .container { max-width: none; padding: 16px 12px 24px; }
.edit-layout {
  display: grid;
  grid-template-columns: 560px minmax(0, 1fr);  /* form 固定 560px，preview 填满剩余 */
  gap: 0;                /* 完全挨着，用右边框视觉分隔 */
  align-items: start;
}
.edit-pane { min-width: 0; padding-right: 16px; }
.edit-pane form { display: flex; flex-direction: column; gap: 16px; }
.edit-pane label { display: block; }
.edit-pane .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* 1100px 以下：堆叠成单列 */
@media (max-width: 1100px) {
  body.page-question_new .container { padding-left: 24px; }
  .edit-layout { grid-template-columns: 1fr; }
}

/* 基本信息 6 字段（科目/年级/题型/难度/来源/年份）— 2 列网格布局 */
.edit-pane .form-grid-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  background: #f9fafb;
  padding: 14px 16px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.edit-pane .form-grid-info label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: #4b5563; }
.edit-pane .form-grid-info label > select,
.edit-pane .form-grid-info label > input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
}
.edit-pane .form-grid-info label > input[type=number] { flex: 0 0 80px; }
.edit-pane .form-grid-info label > select:focus,
.edit-pane .form-grid-info label > input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* 主要内容字段（题干/答案/解析/易错）— 单列占满 form 宽度 */
.edit-pane .form-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 14px;
}
.edit-pane .form-section > label { display: block; margin: 0; }
.edit-pane .form-section textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.edit-pane .form-section textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.edit-pane .form-section > label > small.muted { display: block; margin-bottom: 4px; }

.preview-pane {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #f7f8fa;
  border: 1px solid #e5e7eb;
  border-left: 0;          /* 跟 form 挨着，左边不要 border */
  border-radius: 8px;
  padding: 16px;
}
.preview-pane-header {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e5e7eb;
}
/* 解除详情页 900px 限制，让预览能撑满 */
.preview-pane .qd-layout { max-width: none; }

@media (max-width: 1100px) {
  .edit-layout { grid-template-columns: 1fr; }
  .preview-pane { position: static; max-height: none; }
}

/* ============ 编辑页顶部固定区（h1 + 操作栏，一起 sticky） ============ */
.edit-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: #f7f8fa;
  padding: 12px 0 10px;
  margin: 0 0 16px;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.edit-topbar h1 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  color: #1f2329;
  line-height: 1.3;
}

/* ============ 操作按钮栏（在 edit-topbar 内一起 sticky，不再单独 sticky） ============ */
.edit-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.edit-header-actions form { display: inline; }
.edit-header-actions .btn.small { padding: 4px 10px; font-size: 13px; }
.edit-header-divider {
  width: 1px;
  height: 20px;
  background: #d1d5db;
  margin: 0 4px;
}

/* ============ 标签 chip 移除交互 ============ */
.tag-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tag-input-row input[name=tag_names] {
  flex: 1;
  min-width: 0;
}
.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  min-height: 4px;
}
.tag-chip.editable {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
}
.tag-chip.editable .tag-remove {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  opacity: 0.6;
  line-height: 1;
}
.tag-chip.editable .tag-remove:hover { opacity: 1; }

/* ============ 题图管理(从详情页迁来,折叠在 form 内) ============ */
.edit-imgs-section {
  margin-top: 12px;
  background: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.edit-imgs-section summary { cursor: pointer; color: #6b7280; user-select: none; padding: 2px 0; }
.edit-imgs-section[open] summary { margin-bottom: 8px; }
.edit-imgs-section .img-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.edit-imgs-section .img-card {
  background: #fff; padding: 4px; border: 1px solid #e5e7eb; border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 160px;
}
.edit-imgs-section .img-card img { max-width: 150px; max-height: 100px; display: block; }
.edit-imgs-section .img-card small { font-size: 10px; color: #9ca3af; word-break: break-all; max-width: 150px; }
.edit-imgs-section .upload-form { margin-top: 4px; }

/* ============ 全局隐藏滚动条 — 视觉净化，滚动行为保留 ============ */
/* 覆盖 WebKit / Firefox / IE 三家 */
*::-webkit-scrollbar { width: 0; height: 0; background: transparent; }
* { scrollbar-width: none; -ms-overflow-style: none; }

/* ============ 绘图 modal（Excalidraw iframe） ============ */
.drawing-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.drawing-modal[hidden] { display: none; }
.drawing-modal-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #1e293b;
  color: #fff;
  font-size: 13px;
}
.drawing-modal-header .btn {
  background: #334155;
  color: #fff;
  border-color: #475569;
}
.drawing-modal iframe {
  flex: 1;
  width: 100%;
  border: 0;
}
.drawing-modal-footer {
  flex: none;
  padding: 12px 16px;
  background: #f7f8fa;
  border-top: 1px solid #e5e7eb;
}
.drawing-modal-footer .upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawing-modal-footer .upload-form small { flex: 1; }

/* ============ 物理示意图绘图工具（自建 SVG） ============ */
.pd-modal {
  position: fixed; inset: 0; z-index: 9000; background: #fff;
  display: flex; flex-direction: column;
}
.pd-modal[hidden] { display: none; }
.pd-toolbar {
  flex: none;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 8px 16px;
  background: #f7f8fa;
  border-bottom: 1px solid #e5e7eb;
}
.pd-toolbar .btn { background: #fff; border-color: #d1d5db; color: #1f2329; }
.pd-toolbar .btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.pd-toolbar .pd-sep { width: 1px; height: 22px; background: #e5e7eb; margin: 0 4px; flex: none; }
.pd-canvas-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: #eef1f5;
  overflow: auto;
}
.pd-canvas-wrap svg {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  user-select: none;
}
.pd-hint { font-size: 12px; color: #6b7280; }
.pd-color-label { font-size: 12px; color: #6b7280; margin-left: 2px; }
.pd-toolbar input[type="color"] {
  width: 30px; height: 26px; padding: 0; border: 1px solid #d1d5db;
  border-radius: 4px; background: #fff; cursor: pointer; flex: none;
}

/* 作图工具弹窗：只和画布一样大，居中显示，不全屏 */
#pd-modal {
  inset: auto;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 840px; max-width: 96vw; max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28);
  overflow: hidden;
}
#pd-modal .pd-canvas-wrap { flex: none; padding: 16px; }
#pd-modal .pd-canvas-wrap svg { max-width: 100%; height: auto; }

/* 详情页示意图展示 */
.kp-diagram { margin-top: 12px; }
.kp-diagram svg { max-width: 100%; height: auto; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; }
.kp-diagram-empty { font-size: 12px; color: #9ca3af; }
.kp-diagram-name { font-size: 12px; color: #6b7280; margin: 4px 0; }

/* 详情页右栏「示意图」多图列表 */
.kp-diagram-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.kp-diagram-item { border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; padding: 8px; }
.kp-diagram-thumb svg { max-width: 150px; max-height: 100px; height: auto; display: block; }
.kp-diagram-actions { display: flex; gap: 6px; margin-top: 6px; }

/* 示意图嵌入内容：float 环绕，文字包着图（{{diagram}} 标记处注入） */
.kp-diagram-inline {
  float: none; display: block; width: 160px; margin: 12px auto 16px;
  max-width: 100%; position: relative;
}
.kp-diagram-inline svg {
  display: block; width: 100%; height: auto;
  background: none;
}

/* 同一物理行多个示意图标记 → flex 行容器，图块并排居中（编辑态可拖拽排版） */
.kp-diagram-row {
  display: flex; flex-wrap: wrap; justify-content: center;
  align-items: flex-start; gap: 12px; margin: 8px 0;
}
.kp-diagram-row .kp-diagram-inline { margin: 0; flex-shrink: 0; }

/* —— 拖拽排版（编辑态）：拖动调位置、右下角手柄调大小、左上角 ↺ 复位 —— */
.kp-diagram-inline .kp-dg-handle,
.kp-diagram-inline .kp-dg-reset {
  position: absolute; display: none; z-index: 5; user-select: none;
}
.kp-diagram-inline.layout-editing {
  outline: 1px dashed #3b82f6; outline-offset: 2px; cursor: move;
}
.kp-diagram-inline.layout-editing .kp-dg-handle {
  display: block; right: -6px; bottom: -6px; width: 14px; height: 14px;
  background: #2563eb; border: 2px solid #fff; border-radius: 3px;
  cursor: nwse-resize; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.kp-diagram-inline.layout-editing .kp-dg-reset {
  display: block; top: -10px; left: -2px; width: 18px; height: 18px;
  line-height: 16px; text-align: center; font-size: 12px;
  background: #fff; border: 1px solid #cbd5e1; border-radius: 50%;
  cursor: pointer; color: #475569;
}
.kp-diagram-inline.layout-editing .kp-dg-reset:hover { background: #f1f5f9; border-color: #94a3b8; }

/* 拓展栏 */
.kp-extension-panel { margin-top: 4px; }

/* ============ 批量导入 modal ============ */
/* HTML 的 hidden 属性默认 display:none,但如果元素被 CSS 给了 display:flex/block,
   那 CSS 会赢,hidden 就失效了。批量导入 modal 里 empty-hint/canvas-wrap
   都需要切换显隐,所以这里加全局兜底:[hidden] 永远不显示。 */
[hidden] { display: none !important; }

/* modal 用 grid 而非 flex —— batch-body 是 grid 容器,在 flex 子项里 flex:1 不生效,
   必须靠外层 grid-template-rows: auto 1fr 让第二行撑满剩余高度 */
.batch-import-modal { position: fixed; inset: 0; z-index: 9000; background: #fff;
                       display: grid; grid-template-rows: auto 1fr; }
.batch-import-modal[hidden] { display: none; }
.batch-header { background: #1e293b; color: #fff; padding: 8px 16px; display: flex; justify-content: space-between; align-items: center; }
.batch-header .btn { background: #334155; color: #fff; border-color: #475569; }

/* 左右分栏 */
.batch-body { display: grid; grid-template-columns: 260px 1fr; min-height: 0; overflow: hidden; }
.batch-side { background: #f7f8fa; border-right: 1px solid #e5e7eb; padding: 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.batch-main { display: flex; flex-direction: column; min-height: 0; background: #fff; overflow: hidden; }
.batch-main-body { padding: 16px; flex: 1 1 0; overflow-y: auto; min-height: 0; }

/* canvas:图片在右栏水平居中;rects/drawing-rect 都以 img 边缘为定位基准(包一层 wrapper) */
#batch-canvas-wrap { display: block; width: 100%; text-align: center; padding: 8px; box-sizing: border-box; }
.canvas-img-wrap { display: inline-block; position: relative; line-height: 0; }
#batch-display-img { max-width: 100%; max-height: calc(100vh - 220px); display: block; user-select: none; cursor: crosshair; }
#batch-rects { position: absolute; inset: 0; pointer-events: none; }
#batch-drawing-rect { position: absolute; pointer-events: none; border: 2px dashed #2563eb;
                       background: rgba(37,99,235,0.1); box-sizing: border-box; }

/* 左栏卡片 */
.upload-card, .uploaded-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.upload-card-title { font-size: 13px; font-weight: 600; color: #1f2329; }
.upload-card form { display: flex; flex-direction: column; gap: 10px; }
.upload-pick { display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 10px 14px; }
.upload-pick input[type=file] { display: none; }
.upload-hint { font-size: 12px; color: #6b7280; }
.upload-status { font-size: 12px; min-height: 16px; word-break: break-all; }
.file-name { font-size: 13px; font-weight: 500; color: #1f2329; word-break: break-all; padding: 4px 0; }
.page-info { font-size: 12px; }

/* 页码切换器 */
.page-nav { display: flex; align-items: center; justify-content: space-between;
            padding: 6px 4px; border-top: 1px solid #f3f4f6; border-bottom: 1px solid #f3f4f6; margin: 4px 0; }
.page-nav-current { font-size: 13px; font-weight: 500; color: #4b5563; }
.page-nav .btn[disabled] { opacity: .4; cursor: not-allowed; }

/* 右栏 toolbar 吸顶 */
.batch-toolbar { flex: none; padding: 10px 16px; display: flex; gap: 8px; align-items: center;
                 background: #f7f8fa; border-bottom: 1px solid #e5e7eb; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.batch-toolbar .muted { margin-left: auto; color: #92400e; font-weight: 500; }
.batch-toolbar .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* 空状态 */
.empty-hint { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 240px; }

.canvas-area { position: relative; display: inline-block; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px; }
.batch-rect { position: absolute; border: 3px solid #2563eb; background: rgba(37,99,235,0.15); pointer-events: auto; }
.batch-rect-label { position: absolute; top: -22px; left: 0; background: #2563eb; color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 3px; line-height: 1.3; }
.batch-rect.error { border-color: #dc2626; background: rgba(220,38,38,0.15); }
.batch-rect.error .batch-rect-label { background: #dc2626; }
.batch-rect.has-result .batch-rect-label { background: #16a34a; }

#batch-stem-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 4px; }
#batch-stem-list li { padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 4px; background: #fafafa; display: flex; align-items: center; gap: 8px; font-size: 13px; }
#batch-stem-list li.has-result { background: #f0fdf4; border-color: #86efac; }
#batch-stem-list li.error { background: #fef2f2; border-color: #fca5a5; }
#batch-stem-list li .stem-stem { flex: 1; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ 批量编辑 modal（二级） ============ */
.batch-edit-modal { position: fixed; inset: 0; z-index: 9100; background: #f7f8fa; display: grid; grid-template-columns: 280px 1fr; grid-template-rows: 1fr 56px; }
.batch-edit-modal[hidden] { display: none; }
.batch-edit-side { background: #fff; border-right: 1px solid #e5e7eb; padding: 16px; overflow-y: auto; }
.batch-edit-side h3 { font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: #4b5563; text-transform: uppercase; letter-spacing: 0.5px; }
.batch-edit-side h3:first-child { margin-top: 0; }
.batch-edit-side label { display: block; margin-bottom: 8px; font-size: 13px; color: #4b5563; }
.batch-edit-side label input, .batch-edit-side label select { display: block; width: 100%; margin-top: 2px; padding: 4px 8px; font-size: 13px; border: 1px solid #d1d5db; border-radius: 4px; box-sizing: border-box; }
.batch-edit-side #batch-stats { padding: 8px 10px; background: #f9fafb; border-radius: 4px; font-size: 13px; line-height: 1.6; }
.batch-edit-side #batch-stats .stat-item { display: inline-block; margin-right: 12px; }

.batch-edit-main { padding: 16px; overflow-y: auto; }
.batch-edit-main h3 { font-size: 14px; margin: 0 0 12px; color: #1f2329; }
.batch-edit-layout { display: grid; grid-template-columns: 480px minmax(0, 1fr); gap: 20px; align-items: start; }

.batch-edit-footer { grid-column: 1 / -1; background: #fff; border-top: 1px solid #e5e7eb; padding: 10px 16px; display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

#batch-question-picker { list-style: none; padding: 0; margin: 0; }
#batch-question-picker li { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; line-height: 1.4; display: flex; align-items: flex-start; gap: 6px; border-bottom: 1px solid #f3f4f6; }
#batch-question-picker li:hover { background: #f3f4f6; }
#batch-question-picker li.active { background: #eff6ff; border-left: 3px solid #2563eb; padding-left: 5px; }
#batch-question-picker li input[type=checkbox] { margin-top: 2px; }
#batch-question-picker li .q-stem-preview { color: #6b7280; overflow: hidden; text-overflow: ellipsis; }

/* 批量编辑右侧表单 — 复用 .form-grid-info / .form-section 样式 */
#batch-edit-form .form-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; }
#batch-edit-form .form-section label { display: block; font-size: 13px; color: #4b5563; }
#batch-edit-form textarea { width: 100%; margin-top: 4px; padding: 6px 8px; font-size: 13px; line-height: 1.6; border: 1px solid #d1d5db; border-radius: 4px; resize: vertical; font-family: inherit; box-sizing: border-box; }
#batch-edit-form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }

@media (max-width: 1100px) {
  .batch-edit-modal { grid-template-columns: 1fr; grid-template-rows: auto 1fr 56px; }
  .batch-edit-side { max-height: 280px; }
  .batch-edit-layout { grid-template-columns: 1fr; }
}

/* ===================== 讲义库 ===================== */
.handouts-edit-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1200px) {
  .handouts-edit-layout { grid-template-columns: 1fr; }
}

.handouts-sidebar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.handouts-edit-meta {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
}

.handout-tree, .handout-blocks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.handout-section {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}
.handout-section.target-section {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.handout-section-head {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.handout-section-title-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  border-radius: 4px;
}
.handout-section-title-input:hover { background: #fff; }
.handout-section-title-input:focus { background: #fff; border-color: #2563eb; outline: none; }

.handout-objectives {
  width: 100%;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px dashed #d1d5db;
  border-radius: 4px;
  resize: vertical;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.handout-block {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  padding: 6px;
  margin-bottom: 4px;
  border: 1px dashed #e5e7eb;
  border-radius: 4px;
  background: #fff;
}
.handout-block.block-text { background: #fefce8; border-color: #fde047; }
.handout-block.block-question { background: #eff6ff; border-color: #93c5fd; }

.handout-block .block-body { flex: 1; min-width: 0; }
.handout-block .block-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.handout-block .block-actions { display: flex; gap: 4px; margin-top: 4px; }
.handout-block .handout-block-md {
  width: 100%; font-family: ui-monospace, monospace;
  resize: vertical; min-height: 60px;
  padding: 4px 6px; border: 1px solid #e5e7eb; border-radius: 4px;
  box-sizing: border-box;
}
.handout-block .q-stem-preview {
  font-size: 12px; color: #4b5563;
  padding: 4px 6px; background: #fff; border-radius: 3px;
  margin: 4px 0;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.handout-block .role-select { padding: 2px 4px; font-size: 12px; border-radius: 4px; }

.drag-handle {
  cursor: grab;
  color: #94a3b8;
  padding: 2px 4px;
  user-select: none;
  font-weight: bold;
}
.drag-handle:active { cursor: grabbing; }

.role-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.role-example     { background: #fee2e2; color: #b91c1c; }
.role-practice    { background: #dbeafe; color: #1d4ed8; }
.role-consolidate { background: #d1fae5; color: #065f46; }
.role-extra       { background: #f3e8ff; color: #6b21a8; }

.handout-meta { font-size: 12px; margin-bottom: 8px; }
.handout-block-add { padding: 4px 0; }

/* KP 树：节 <li> 也右对齐 */
.tree-list > li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tree-list > li > .tree-link {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-list > li > .kp-count-badge {
  flex: 0 0 auto;
  margin-left: auto;
}

/* KP 树计数徽章：章 vs 节 不同色 */
/* ===================== 知识点详情页 ===================== */
.kp-detail-header {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.kp-breadcrumb {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 8px;
}
.kp-breadcrumb a { color: #2563eb; text-decoration: none; }
.kp-breadcrumb a:hover { text-decoration: underline; }
.kp-breadcrumb .sep { margin: 0 6px; color: #9ca3af; }
.kp-detail-title {
  margin: 0 0 12px 0;
  font-size: 28px;
  font-weight: 700;
  color: #0c4a6e;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.kp-detail-title small { font-size: 14px; font-weight: 400; }
.kp-detail-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-chip {
  display: inline-block;
  padding: 3px 10px;
  background: #fff;
  border: 1px solid #bae6fd;
  color: #075985;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
}
.meta-chip-ok { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.meta-chip-warn { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

.kp-detail-grid {
  display: grid;
  grid-template-columns: 560px minmax(0, 1fr);  /* 编辑栏固定 560px，渲染栏填满剩余（参照题库详情页） */
  gap: 20px;
  align-items: start;
}
.kp-detail-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
/* 顶部操作栏在左栏内 sticky；flex 的 gap 已提供间距，去掉 topbar 自带下边距 */
.kp-detail-left > .edit-topbar { margin-bottom: 0; }
@media (max-width: 1100px) {
  .kp-detail-grid { grid-template-columns: 1fr; }
}

/* ===================== 知识点详情页：标题固定 + 左右两栏独立滚动 ===================== */
body.page-knowledge_point_detail { overflow: hidden; height: 100vh; }
body.page-knowledge_point_detail .main { height: 100vh; overflow: hidden; }
body.page-knowledge_point_detail .container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.page-knowledge_point_detail .kp-detail-header { flex: none; }
body.page-knowledge_point_detail .kp-detail-grid {
  flex: 1;
  min-height: 0;
  align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
}
body.page-knowledge_point_detail .kp-detail-left,
body.page-knowledge_point_detail .kp-detail-side {
  min-height: 0;
  overflow-y: auto;
}
body.page-knowledge_point_detail .kp-detail-left > *,
body.page-knowledge_point_detail .kp-detail-side > * { flex-shrink: 0; }

@media (max-width: 1100px) {
  body.page-knowledge_point_detail { overflow: auto; height: auto; }
  body.page-knowledge_point_detail .main { height: auto; overflow: visible; }
  body.page-knowledge_point_detail .container { height: auto; display: block; overflow: visible; }
  body.page-knowledge_point_detail .kp-detail-grid { flex: none; min-height: auto; align-items: start; }
  body.page-knowledge_point_detail .kp-detail-left,
  body.page-knowledge_point_detail .kp-detail-side { overflow: visible; }
}

/* ===================== 题目详情页：与知识点详情页同款 header 固定 + 左右两栏独立滚动 ===================== */
body.page-question_edit { overflow: hidden; height: 100vh; }
body.page-question_edit .main { height: 100vh; overflow: hidden; }
body.page-question_edit .container {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.page-question_edit .kp-detail-header { flex: none; }
body.page-question_edit .kp-detail-grid {
  flex: 1;
  min-height: 0;
  align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
}
body.page-question_edit .kp-detail-left,
body.page-question_edit .kp-detail-side {
  min-height: 0;
  overflow-y: auto;
}
body.page-question_edit .kp-detail-left > *,
body.page-question_edit .kp-detail-side > * { flex-shrink: 0; }

@media (max-width: 1100px) {
  body.page-question_edit { overflow: auto; height: auto; }
  body.page-question_edit .main { height: auto; overflow: visible; }
  body.page-question_edit .container { height: auto; display: block; overflow: visible; }
  body.page-question_edit .kp-detail-grid { flex: none; min-height: auto; align-items: start; }
  body.page-question_edit .kp-detail-left,
  body.page-question_edit .kp-detail-side { overflow: visible; }
}

.kp-form {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
}
.form-section { margin-bottom: 20px; }
.form-section:last-of-type { margin-bottom: 0; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.form-input-lg,
.form-input,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}
.form-input-lg { font-size: 18px; font-weight: 600; padding: 10px 14px; }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.kp-formula-input { font-family: ui-monospace, "SF Mono", Consolas, monospace; background: #f9fafb; }
.form-hint { display: block; margin-top: 4px; font-size: 12px; color: #6b7280; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}

.kp-detail-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.info-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
}
.info-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
/* 卡片标题栏带操作按钮（示意图卡的「＋上传」）：标题在左，按钮在右 */
.info-card h3.info-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.info-card h3.info-card-head .btn {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.info-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.info-card dt { color: #6b7280; font-weight: 500; }
.info-card dd { color: #1f2329; margin: 0; word-break: break-word; }
.kp-ref-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.kp-ref-list li { padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
.kp-ref-list li:last-child { border-bottom: none; }
.kp-ref-list a { color: #2563eb; text-decoration: none; font-weight: 500; }
.kp-ref-list a:hover { text-decoration: underline; }

/* 编辑区 label 行：label 与按钮同行 */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.form-label-row .form-label { margin-bottom: 0; }

/* ===================== 渲染区（实时预览） ===================== */
.kp-render-card {
  border-color: #bae6fd;
  background: linear-gradient(180deg, #f0f9ff 0%, #f8fafc 80px);
}
.kp-render-summary {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.75;
  color: #1f2329;
  word-break: break-word;
  margin-bottom: 12px;
}
/* 【定义】【易错】等小节标题：胶囊徽章 + 主色 */
.kp-heading {
  display: inline-block;
  color: #0369a1;
  font-weight: 700;
  font-size: 12.5px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  padding: 2px 11px;
  margin: 12px 0 6px;
  letter-spacing: 0.5px;
}
/* ## 分节标题：左侧主色条 + 渐变底 */
.kp-h2 {
  display: block;
  color: #0c4a6e;
  font-weight: 700;
  font-size: 14px;
  margin: 16px 0 6px;
  padding: 6px 10px 6px 13px;
  border-left: 4px solid #0284c7;
  background: linear-gradient(90deg, #e0f2fe 0%, rgba(224, 242, 254, 0.35) 60%, rgba(224, 242, 254, 0) 100%);
  border-radius: 0 6px 6px 0;
}
.kp-heading:first-child,
.kp-h2:first-child { margin-top: 0; }
/* ### 三级标题：前导圆点 */
.kp-h3 {
  display: block;
  color: #075985;
  font-weight: 600;
  font-size: 13px;
  margin-top: 10px;
  margin-bottom: 4px;
  padding-left: 16px;
  position: relative;
}
.kp-h3::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
}
/* 引用块（注意/易错/提示）：琥珀色提示条 */
.kp-quote {
  border-left: 4px solid #f59e0b;
  padding: 8px 12px;
  margin: 8px 0;
  color: #78350f;
  background: #fffbeb;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  line-height: 1.7;
}
/* 列表项：主色小方块 */
.kp-li {
  position: relative;
  padding-left: 18px;
  margin: 3px 0;
  line-height: 1.7;
}
.kp-li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #0284c7;
}
/* 缩进块：+ 行首 → 纯文字右移，无项目符号 */
.kp-indent {
  padding-left: 2em;
  margin: 3px 0;
  line-height: 1.7;
}
/* 分隔线：渐变细线 */
.kp-hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, #e0f2fe, #94a3b8, #e0f2fe);
  margin: 14px 0;
}
/* 公式区：主色左边条 + 浅蓝底 */
.kp-render-formula {
  font-size: 14px;
  line-height: 1.8;
  color: #0f172a;
  padding: 10px 12px;
  background: linear-gradient(180deg, #f0f9ff, #ffffff 45%);
  border: 1px solid #bae6fd;
  border-left: 4px solid #0284c7;
  border-radius: 8px;
  min-height: 20px;
  word-break: break-word;
  margin-bottom: 8px;
}
.kp-render-formula .muted,
.kp-render-summary .muted { font-size: 12px; color: #9ca3af; }
/* display 公式：收紧 MathJax 默认的上下 1em 留白，让公式列表紧凑 */
.kp-render-formula mjx-container[display="true"],
.kp-render-summary mjx-container[display="true"] {
  margin: 0.35em 0;
}
/* 超长 display 公式（如整条平衡链）不溢出容器：横向滚动兜底 */
.preview-pane mjx-container[display="true"],
.kp-render-formula mjx-container[display="true"],
.kp-render-summary mjx-container[display="true"],
.q-card-stem mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ===================== 典型例题 ===================== */
.kp-examples {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px 24px;
}
.kp-examples-title {
  margin: 0 0 14px 0;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}
.kp-examples-title small { font-size: 13px; font-weight: 400; }
.kp-examples-list { margin: 0; padding: 0; list-style: none; }
.kp-example-item { border-bottom: 1px solid #f3f4f6; }
.kp-example-item:last-child { border-bottom: none; }
.kp-example-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  text-decoration: none;
  color: inherit;
}
.kp-example-link:hover { background: #f8fafc; }
.kp-example-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.kp-example-stem {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  color: #374151;
}

.kp-count-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  line-height: 1.6;
}
/* 章徽章：蓝色（突出整章进度） */
.tree-node > summary > .kp-count-badge {
  background: #dbeafe;
  color: #1d4ed8;
}
/* 节徽章：紫色（与章区分） */
.tree-list > li > .kp-count-badge {
  background: #ede9fe;
  color: #6d28d9;
}
/* 0 个时变灰 */
.kp-count-badge:empty,
.kp-count-badge[data-zero="1"] {
  background: #f3f4f6 !important;
  color: #9ca3af !important;
}

/* 试卷库树节点份数徽章 */
.tree-count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
  min-width: 16px;
  text-align: center;
  background: #eef2ff;
  color: #6366f1;
}

/* KP 块（讲义中引用的知识点） */
.handout-block.block-kp { background: #f0f9ff; border-color: #7dd3fc; }
.kp-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  background: #e0f2fe;
  color: #075985;
  margin-right: 6px;
}
.kp-summary-preview {
  font-size: 12px;
  color: #4b5563;
  margin: 4px 0;
  padding: 4px 6px;
  background: #fff;
  border-radius: 3px;
}
.kp-formula-preview {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: #fff;
  border-radius: 3px;
}
.handout-kp-note {
  width: 100%;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  margin-top: 4px;
  box-sizing: border-box;
  resize: vertical;
}

/* KP 块（预览 / PDF）*/
.kp-block {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f0f9ff;
  border-left: 3px solid #38bdf8;
  border-radius: 4px;
  page-break-inside: avoid;
}
.kp-block .kp-head { margin-bottom: 6px; }
/* 内容排版复用详情页渲染区样式（.kp-render-summary / .kp-render-formula / .kp-heading / .kp-diagram），
   保证讲义里的知识点段落与知识点详情页一致 */

/* 讲义编辑侧栏：知识点块附带内容开关标签 */
.kp-include-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 5px; }
.kp-include-tag {
  font-size: 11px; padding: 1px 7px; border-radius: 9px;
  border: 1px solid #cbd5e1; color: #6b7280; background: #fff;
}
.kp-include-tag.on { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.btn-edit-kp-includes { margin-left: 2px; }

/* 新增知识点：名称 + 创建按钮同行 */
.kp-new-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.kp-new-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.kp-new-row button {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* KP 列表卡片 */
a.kp-card {
  display: block;
  text-decoration: none;
  color: inherit;
  text-align: left;
  /* 对齐详情页渲染卡的大小：紧凑内边距 + 圆角 + 边框（去掉 .card 的阴影与居中） */
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  box-shadow: none;
  transform: none;
}
a.kp-card:hover {
  text-decoration: none;
  background: #f9fafb;
  border-color: #bae6fd;
  transform: none;
  box-shadow: none;
}
/* KP 列表页：固定 2 列（与 .questions-main { width:720px } 配套），
   - 1 张卡片 = 第 1 列 = 主列宽一半
   - 2 张卡片 = 各占一半并排
   - 多于 2 张换行 */
.kp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: stretch;
}
.kp-grid a.kp-card { margin: 0; height: 100%; }
.kp-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kp-card-title { font-weight: 600; font-size: 16px; color: #1f2329; }
.kp-card-meta { font-size: 12px; color: #6b7280; display: flex; gap: 8px; }
/* 内容区复用详情页渲染区样式（.kp-render-summary / .kp-render-formula） */

/* 列表页行卡片（包 checkbox + 内容链接），与题库 .q-card 风格对齐 */
.kp-card-row {
  position: relative;          /* 锚点，让 checkbox 绝对定位左上角 */
  padding: 14px 16px 14px 38px; /* 左侧留出 38px 给左上角 checkbox */
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  transition: background .15s, border-color .15s;
}
.kp-card-row:hover {
  background: #f9fafb;
  border-color: #bae6fd;
}
.kp-card-row .q-check {
  /* 卡片左上角的勾选框：用户要求"勾选框呈现在左上角" */
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  padding: 0;
}
.kp-card-row .kp-card {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-decoration: none;
  color: inherit;
}
.kp-card-row .kp-card:hover {
  background: transparent;
  border-color: transparent;
  text-decoration: none;
}
/* 批量选中行高亮 */
.kp-card-row.kp-card-row-selected {
  background: #eff6ff;
  border-color: #93c5fd;
}
/* kp-grid：取消 a.kp-card 自身的 padding/border（已搬到外层 row），同时让 grid cell 内联自适应 */
.kp-grid .kp-card-row { margin: 0; }
.kp-grid .kp-card-row .kp-card-row { height: 100%; }

.inline-form { display: inline-block; margin: 0; }

/* 讲义预览 / 打印样式（与 PDF 视觉对齐） */
.handout-document {
  background: #fff;
  padding: 32px 40px;
  max-width: 800px;
  min-width: 800px;  /* 讲义设计宽固定 800，viewport 窄时父容器水平滚动，不让讲义缩 */
  margin: 0 auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  position: relative;   /* 手写批注画布的定位参照 */
}
body.page-handout_preview .main { overflow-x: auto; }  /* 让讲义窄 viewport 时水平滚 */
.handout-document .handout-cover {
  text-align: center;
  border-bottom: 2px solid #1f2329;
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.handout-document .handout-cover h1 {
  font-size: 28px; margin: 0 0 8px 0;
}
.handout-document .handout-cover .cover-meta {
  color: #6b7280; font-size: 13px;
}
.handout-document .handout-intro {
  font-size: 14px; line-height: 1.7;
  color: #4b5563; margin-bottom: 24px;
  padding: 12px 16px; background: #f9fafb;
  border-left: 3px solid #d1d5db; border-radius: 4px;
}
.handout-document .handout-section {
  margin-top: 16px; padding: 10px 0;
  border-top: 1px solid #e5e7eb;
}
.handout-document .handout-section h2 {
  font-size: 20px; margin: 0 0 4px 0;
  color: #1f2329;
}
.handout-document .objectives {
  color: #6b7280; font-size: 13px;
  margin: 0 0 12px 0; padding-left: 16px;
}
.handout-document .text-block {
  padding: 8px 12px; background: #fefce8;
  border-left: 3px solid #facc15;
  border-radius: 3px; margin-bottom: 12px;
  white-space: pre-wrap;
}
.handout-document .q-block {
  margin-bottom: 0; padding: 2px 0;
}
.handout-document .q-stem {
  font-weight: 400; margin-bottom: 2px; line-height: 1.55;
  /* 容器层不要用 pre-wrap：q_stem 过滤器和模板输出里的排版换行
     在 pre-wrap 下会各占一行高度（每题白吃 2 行 ≈ 46px）。
     题干正文 / 选项值下面各自再开 pre-wrap，保留题目里有意为之的换行。 */
  white-space: normal;
}
.handout-document .q-title-body,
.handout-document .q-opt-v { white-space: pre-wrap; }
.handout-document .q-title { margin-bottom: 3px; column-gap: 6px; }
/* 讲义里的选项：收紧行距与行间距，题目之间才显得紧凑 */
.handout-document .q-options { gap: 3px 16px; margin: 2px 0 0; }
.handout-document .q-opt { line-height: 1.5; padding: 1px 6px 1px 2px; }
.handout-document .q-opt-k { line-height: 1.5; }
.handout-document .q-title > .q-options { margin: 2px 0 0; }
/* MathJax SVG 用预计算 path 描黑字形，font-weight 改不了笔画粗细。
   改让选项走 \\text{} 路线：整段塞进 \\( ... \\)，中文 \\text{} 包，公式原样。
   这样视觉上由 MathJax 统一渲染，笔画粗细通过 SVG path 自带的字形决定，
   不会出现"中文细、公式粗"的违和感。CSS 兜底：保证 \\text{} 用系统字体渲染。 */
.handout-document mjx-container {
  font-weight: 400 !important;
}
.handout-document mjx-container * {
  font-weight: inherit !important;
}
.handout-document .q-opt-v mjx-container text {
  /* \\text{} 内的中文字符走 SVG <text> 元素，让它用父级（q-opt-v）字体，
     这样与同段落正文（也是系统字体）粗细一致，不再"加粗"。 */
  font-family: inherit;
}
/* 打印时公式字形被"加粗"的根因：MathJax SVG 会给每个公式外层 <g> 打
   stroke="currentColor" fill="currentColor" stroke-width="0"（前者是 Firefox
   的 currentColor 兼容补丁，stroke-width=0 本意是不可见描边）。屏幕渲染会
   尊重 stroke-width=0，但 Chrome/Edge 打印成 PDF 时把这条 0 宽描边误算成
   一条发丝线，fill + 描边叠加 = 字形看起来变粗。打印态直接把这条 workaround
   描边的 paint 关掉即可（字形靠 fill 渲染，分数横线是 <rect> 填充不受影响）。 */
@media print {
  .handout-document mjx-container svg [stroke="currentColor"] {
    stroke: none !important;
  }
}
.handout-document .q-answer {
  margin-top: 3px; padding: 4px 10px;
  background: #f0fdf4; border-left: 3px solid #16a34a;
  color: #166534; border-radius: 3px;
}
.handout-document .q-analysis {
  margin-top: 3px; padding: 4px 10px;
  background: #f9fafb; border-left: 3px solid #9ca3af;
  color: #4b5563; border-radius: 3px;
}
.handout-document .latex-svg svg { max-width: 100%; height: auto; vertical-align: middle; }
.handout-document .latex-fallback {
  background: #f3f4f6; padding: 1px 4px; border-radius: 3px;
  font-family: ui-monospace, monospace;
}

@media print {
  /* === 讲义库 / 预览打印 === */
  body.page-handout_edit .sidebar,
  body.page-handout_preview .sidebar,
  body.handouts-print .sidebar { display: none !important; }
  body.page-handout_edit .handouts-sidebar { display: none !important; }

  /* 顶栏 h1 + 按钮 + 任何 .no-print 元素全部隐藏 */
  body.page-handout_preview h1,
  body.handouts-print h1,
  .no-print { display: none !important; }

  /* 讲义文档：占满整页（去掉 .container 的边距限制） */
  body.page-handout_preview .container,
  body.handouts-print .container { padding: 0; max-width: none; }
  body.page-handout_preview .main,
  body.handouts-print .main { margin-left: 0; }

  body.handouts-print .handout-document,
  body.page-handout_preview .handout-document {
    border: none; padding: 0; max-width: none;
    box-shadow: none; background: #fff;
  }
  body.handouts-print .handout-section,
  body.page-handout_preview .handout-section {
    page-break-inside: avoid;
  }
  body.handouts-print .handout-section h2,
  body.page-handout_preview .handout-section h2 {
    page-break-after: avoid;
  }
  body.handouts-print .q-block,
  body.page-handout_preview .q-block { page-break-inside: avoid; }
  body.handouts-print .text-block,
  body.page-handout_preview .text-block { page-break-inside: avoid; }

  /* MathJax SVG 在打印时清晰 */
  body.page-handout_preview mjx-container svg,
  body.handouts-print mjx-container svg { max-width: 100% !important; }

  /* === 试卷打印预览 === */
  body.page-paper_preview .sidebar { display: none !important; }
  body.page-paper_preview .container { padding: 0; max-width: none; }
  body.page-paper_preview .main { margin-left: 0; }
  body.page-paper_preview .paper-print-document {
    border: none; padding: 0; max-width: none;
    box-shadow: none; background: #fff;
  }
  body.page-paper_preview .paper-print-page {
    page-break-after: always;
    margin-bottom: 0;
  }
  body.page-paper_preview .paper-print-page:last-child { page-break-after: auto; }
  body.page-paper_preview .paper-print-page img {
    border: none; max-width: 100%; max-height: 24.7cm;
  }

  @page { size: A4; margin: 2cm 1.5cm; }
}

/* =========== 讲义编辑页：顶部元信息 sticky + 左结构/右预览两栏 =========== */
body.page-handout_edit .main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;             /* 锁视口高，避免与 body 共滚动 → 「页面到底端晃动」根因 */
  overflow-y: auto;          /* 主滚动条由 main 自滚承担 */
  overscroll-behavior: contain;   /* 滚到 main 顶/底不再冒泡到 body */
}
body.page-handout_edit .main > .container {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
}
.handout-meta-header {
  position: sticky;
  top: 0;
  z-index: 14;
  background: #f7f8fa;
  padding: 10px 16px 8px;
  border-bottom: 1px solid #e5e7eb;
  margin: 0 -16px 16px;
}
.handout-meta-header .handout-meta-header-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.handout-meta-header .handout-meta-breadcrumb { flex: 0 0 auto; font-size: 16px; }
.handout-meta-header #handout-meta-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; flex: 1 1 600px; min-width: 0; }
.handout-meta-header .hf { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: #4b5563; }
.handout-meta-header .hf input,
.handout-meta-header .hf select,
.handout-meta-header .hf textarea { padding: 4px 6px; font-size: 13px; border: 1px solid #d1d5db; border-radius: 4px; min-width: 0; }
.handout-meta-header .hf input { min-width: 140px; }
.handout-meta-header .hf-wide { flex: 1 1 240px; }
.handout-meta-header .hf-save { align-self: flex-end; }
.handout-meta-toolbar { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.handout-meta-toolbar .inline-form { display: inline; }
.handouts-edit-layout { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1fr); gap: 16px; align-items: start; flex: 1 1 auto; min-height: 0; overflow: visible; }
.handouts-edit-layout .handouts-sidebar { min-width: 0; }
.handouts-edit-preview { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 0; display: flex; flex-direction: column; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 1px solid #e5e7eb; background: #f9fafb; position: sticky; top: 0; z-index: 1; }
.preview-root-inner { padding: 24px; flex: 1 1 auto; }
.hb-modal[hidden] { display: none; }
.hb-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.hb-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.hb-modal-dialog { position: relative; width: min(960px, 92vw); max-height: 84vh; background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); display: flex; flex-direction: column; }
.hb-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid #e5e7eb; }
.hb-modal-body { padding: 14px 18px; overflow-y: auto; flex: 1 1 auto; }
.hb-modal-body .q-list { max-height: 56vh; overflow-y: auto; padding-right: 4px; }
.hb-modal-body #hb-q-empty { margin: 12px 0; }
@media (max-width: 900px) {
  .handouts-edit-layout { grid-template-columns: 1fr; }
  .handouts-edit-preview { position: static; max-height: none; }
}


/* ============== 讲义编辑页 v7：main 整体滚（参考 questions 列表页的版式） ==============
   与 v6 的关键差异：v6 把 body 锁 + 两列各自 overflow-y: auto，结果整个页面没 1 个外层
   滚动条，讲义结构很长时只能滚左列。用户反馈「讲义编辑栏可以滚动，全部挤在一起干嘛」——
   期望：整页连贯滚。
   v7 改为「main 整体滚」，讲义结构与预览都跟 main 一起滚；header / 工具栏 / 预览工具栏用
   sticky 浮顶。这是大多数管理后台的标准模式。 */
/* body 锁 + main 唯一滚动源，避免「整页在底端晃动」 */
body.page-handout_edit { overflow: hidden; height: 100vh; }
body.page-handout_edit .main {
  height: 100vh;
  overflow-y: auto;          /* main 整体滚 */
  display: block;
}
body.page-handout_edit .main > .container {
  display: block;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 0 40px;        /* 底部留白，避免最末一个元素贴边 */
}

/* 顶部讲义信息卡：sticky 吸顶 */
.handout-edit-header {
  position: sticky;
  top: 0;
  z-index: 12;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-bottom: 1px solid #bae6fd;
  padding: 14px 22px 12px;
  margin: 0 0 12px;
}
.handout-edit-header .kp-breadcrumb { font-size: 13px; color: #6b7280; }
.handout-edit-header .kp-breadcrumb a { color: #6b7280; text-decoration: none; }
.handout-edit-header .kp-breadcrumb a:hover { color: #2563eb; }
.handout-edit-header .kp-breadcrumb .sep { color: #9ca3af; padding: 0 4px; }
.handout-edit-header .kp-detail-title { font-size: 22px; font-weight: 600; color: #1f2937; margin: 6px 0 8px; }
.handout-edit-header .kp-detail-title small { font-size: 14px; font-weight: 400; color: #9ca3af; margin-left: 6px; }
.handout-edit-header .kp-detail-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.handout-edit-header .meta-chip {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #bae6fd;
  border-radius: 4px;
  color: #075985;
}

/* 两栏 grid：左 30% / 右 70% */
.handouts-edit-grid {
  display: grid;
  grid-template-columns: 3fr 7fr;
  gap: 14px;
  align-items: start;          /* 不再 stretch：两列内容各自自然撑高 */
  padding: 0 0;
}
/* 两列自身不再 overflow-y: auto，由外层 main 统一滚 */
.handouts-edit-left,
.handouts-edit-preview {
  display: flex;
  flex-direction: column;
}

/* ===== 左：编辑栏 ===== */

/* 工具栏：sticky 在 main 顶部（紧跟 header 之后） */
.handouts-edit-left .edit-topbar {
  position: sticky;
  top: var(--header-h, 100px);
  z-index: 11;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.handouts-edit-left .edit-topbar .edit-header-actions {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.handouts-edit-left .edit-topbar .edit-header-divider {
  display: inline-block; width: 1px; height: 18px; background: #e5e7eb; margin: 0 4px;
}
.handouts-edit-left .edit-topbar .inline-form { display: inline; }

/* 元信息表单卡 */
.handout-meta-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px 14px;
  margin: 0 0 12px;
}
/* 5 行：每行一个字段，cap 在框前面，编辑栏可滚没必要挤 */
.handout-meta-section .handout-meta-row {
  display: block;
  margin-bottom: 6px;
}
.handout-meta-section .handout-meta-row:last-child { margin-bottom: 0; }
.handout-meta-section .hf {
  display: flex; flex-direction: row; align-items: center;
  gap: 0; min-width: 0; min-height: 30px;
  width: 100%;
}
.handout-meta-section .hf-grow { flex: 1; }
.handout-meta-section .hf-cap {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: flex-end;
  height: 30px;
  font-size: 11px; color: #4b5563; font-weight: 600;
  white-space: nowrap; line-height: 30px; padding: 0;
  margin-right: 6px;
  text-align: right;
}
.handout-meta-section .hf input,
.handout-meta-section .hf select,
.handout-meta-section .hf textarea {
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  background: #fff; color: #1f2937;
  flex: 1 1 auto; min-width: 0;
  font-weight: normal; line-height: 30px;
  vertical-align: middle;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
.handout-meta-section .hf textarea { height: 30px; line-height: 1.4; padding: 4px 8px; resize: vertical; font-family: inherit; }
.handout-meta-section .hf select {
  padding-right: 24px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px;
}
.handout-meta-section .hf input:focus,
.handout-meta-section .hf select:focus,
.handout-meta-section .hf textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 0;
  border-color: #2563eb;
}

/* 讲义结构块 */
.handouts-edit-left .handouts-sidebar { display: contents; }
.handouts-edit-left .sidebar-title { display: none; }
.handouts-edit-left .handout-meta { display: none; }
.handouts-edit-left .handout-tree {
  list-style: none; margin: 0; padding: 0;
}

/* ===== 右：讲义打印预览 ===== */
.handouts-edit-preview {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  padding: 0;
  position: sticky;
  top: var(--header-h, 100px);
}
.handouts-edit-preview .preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 12px;
  color: #6b7280;
}
.handouts-edit-preview .preview-root-inner { padding: 18px 24px; background: #fafafa; }

/* 「+ 加题」模态 */
.hb-modal[hidden] { display: none; }
.hb-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.hb-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.hb-modal-dialog {
  position: relative;
  width: min(960px, 92vw);
  max-height: 84vh;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
}
.hb-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
}
.hb-modal-body { padding: 14px 18px; overflow-y: auto; flex: 1 1 auto; }
.hb-modal-body .q-list { max-height: 56vh; overflow-y: auto; padding-right: 4px; }
.hb-modal-body #hb-q-empty { margin: 12px 0; }

@media (max-width: 1100px) {
  .handouts-edit-grid { grid-template-columns: minmax(200px, 3fr) minmax(280px, 7fr); }
}
@media (max-width: 800px) {
  body.page-handout_edit { overflow: auto; height: auto; }
  body.page-handout_edit .main { height: auto; overflow: visible; }
  .handouts-edit-grid { grid-template-columns: 1fr; }
  .handouts-edit-left .edit-topbar,
  .handouts-edit-preview { position: static; }
}


/* ============ 知识点库列表布局优化（v20251013c） ============ */
/* 主列不再固定 720px：宽屏充分利用剩余宽度，左树 300px、右列自适应 */
body.page-knowledge_points .questions-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}
body.page-knowledge_points .questions-main {
  width: auto;
  min-width: 0;
  max-width: none;
  flex: 1 1 auto;
}
/* 卡片网格：宽屏 3 列、中等屏 2 列、窄屏 1 列，卡片宽度自适应不再溢出 */
.kp-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
/* 卡片标题与元信息留白更舒展，摘要限高 + 底部淡出，避免整篇渲染把卡片撑爆 */
.kp-card-row {
  padding: 16px 18px 16px 42px;
}
.kp-card-head {
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.kp-card-title {
  font-size: 15px;
  line-height: 1.4;
}
.kp-card-row .kp-render-summary {
  max-height: 168px;
  overflow: hidden;
  position: relative;
  margin-bottom: 0;
  mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 98%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 62%, transparent 98%);
}
/* 树面板微调：更紧凑、选中高亮带左侧圆点 */
body.page-knowledge_points .questions-sidebar {
  min-width: 280px;
}
.tree-row {
  padding: 3px 0;
}
.tree-link.active {
  position: relative;
}
.tree-link.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0284c7;
}
/* 单行筛选条：按钮间距、弹性分隔 */
form.filter.kp-filter .row-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
form.filter.kp-filter .filter-spacer {
  flex: 1 1 8px;
  min-width: 8px;
}

/* ============ 知识点正文内嵌示意图：居中独立成块（v20251013d） ============
   render_diagram 生成 .kp-diagram-inline（默认 float:right 160px，题库题干用），
   知识点正文（summary/formula）里的图改为居中整块显示，宽度由 {{diagram:gN:宽度}} 控制，
   与对应小节内容呼应；题库题干排版不受影响。 */
.kp-render-summary .kp-diagram-inline,
.kp-render-formula .kp-diagram-inline {
  float: none;
  display: block;
  max-width: 100%;
  margin: 12px auto 16px;
}
.kp-render-summary .kp-diagram-inline svg,
.kp-render-formula .kp-diagram-inline svg {
  display: block;
  margin: 0 auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
}

/* ============ Markdown 表格（题干 / 子题 / 解析 / 知识点正文） ============
   正文里的表格用 Markdown 管道表书写（| a | b | + 分隔行），由 mdtable.py /
   md-table.js 渲染成 <div class="md-table-wrap"><table class="md-table">。
   题干容器是 white-space:pre-wrap，故单元格内需重置为 normal。 */
.md-table-wrap {
  display: block;
  max-width: 100%;
  margin: 8px 0 12px;
  overflow-x: auto;
}
table.md-table {
  border-collapse: collapse;
  width: auto;
  max-width: 100%;
  font-size: 0.96em;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  background: #fff;
}
table.md-table th,
table.md-table td {
  border: 1px solid #d5dae0;
  padding: 4px 10px;
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
}
table.md-table th {
  background: #f4f6f8;
  font-weight: 600;
  color: #374151;
  text-align: center;
}
table.md-table tbody tr:nth-child(even) { background: #fafbfc; }
table.md-table mjx-container { vertical-align: middle; }
/* 文本填充型表格（实验现象表等）拉满可用宽度 */
.kp-render-summary table.md-table,
.kp-render-formula table.md-table { width: 100%; }
/* 列表卡片里的表格：控制纵向占用 */
.q-card-stem .md-table-wrap { margin: 6px 0; }
.q-card-stem table.md-table { font-size: 13px; }


/* ============ 题库渲染优化（2026-10）：列表卡 + 详情预览 层次化 ============ */

/* ---- 题型徽标按类型上色（列表 + 详情预览共用） ---- */
.badge.type-single   { background:#d1fae5; color:#047857; }
.badge.type-multi    { background:#dbeafe; color:#1d4ed8; }
.badge.type-fill     { background:#ede9fe; color:#6d28d9; }
.badge.type-calc     { background:#ffedd5; color:#c2410c; }
.badge.type-calculate{ background:#ffedd5; color:#c2410c; }
.badge.type-diagram  { background:#cffafe; color:#0e7490; }
.badge.type-other    { background:#f3f4f6; color:#374151; }

/* ---- 题干内小节标题（【典例1】等，服务端加 <strong class="kp-heading">） ---- */
.kp-heading {
  color:#4338ca; font-weight:700; letter-spacing:.2px;
}

/* ---- 列表页：题目卡片 ---- */
.q-list { gap:12px; }
.q-card {
  border:1px solid #e6e9ef;
  border-radius:12px;
  padding:16px 18px;
  background:linear-gradient(180deg,#ffffff,#fbfcfe);
  box-shadow:0 1px 2px rgba(16,24,40,.04), 0 4px 12px -6px rgba(16,24,40,.06);
  transition:border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.q-card:hover {
  border-color:#c7d2fe;
  box-shadow:0 2px 4px rgba(16,24,40,.05), 0 10px 24px -8px rgba(79,70,229,.16);
  transform:translateY(-1px);
}
.q-check { padding-top:6px; }
.q-check input { width:17px; height:17px; accent-color:#6366f1; }
.q-card-stem { font-size:15px; line-height:1.8; color:#1f2329; }
.q-card-stem:hover { color:#4338ca; }
/* 题干首行小节标题与正文衔接自然 */
.q-card-stem .kp-heading + * ,
.q-card-stem .kp-heading { margin-right:2px; }
/* 易错块更精致 */
.q-card-warning {
  border-radius:6px; padding:6px 10px;
  background:#fff8f0; border-left:3px solid #f97316;
}
/* 卡片底部信息行：知识点在前、标签在后，垂直间距更清楚 */
.q-card-kps { margin-top:10px; }
.q-card-tags { margin-top:8px; gap:6px; }
/* 侧栏操作按钮轻量化 */
.q-card-side { gap:10px; }
.q-card-actions .btn.small {
  padding:3px 10px; font-size:12px; border-radius:6px;
  background:#fff; border-color:#e5e7eb; color:#4b5563;
}
.q-card-actions .btn.small:hover { color:#4338ca; border-color:#c7d2fe; background:#f8f9ff; }
.q-card-actions .btn.small.danger:hover { color:#dc2626; border-color:#fecaca; background:#fff7f7; }
.q-id { font-size:12px; color:#9ca3af; background:#f3f4f6; padding:1px 7px; border-radius:10px; }

/* ---- 详情页实时预览：整卡 + 区块层次 ---- */
#preview-root.qd-layout {
  max-width:none;
  background:#ffffff;
  border:1px solid #e6e9ef;
  border-radius:14px;
  padding:22px 24px 24px;
  box-shadow:0 1px 2px rgba(16,24,40,.04), 0 6px 18px -8px rgba(16,24,40,.08);
}
.qd-header h1 { font-size:20px; font-weight:700; }
.qd-header .badge { font-size:13px; padding:2px 10px; border-radius:8px; }
.qd-diff { font-size:13px; color:#9ca3af; background:#f3f4f6; padding:2px 10px; border-radius:8px; font-weight:600; }
.qd-body { gap:14px; }

/* 题干区：独立卡片式，左侧主题色条 */
.qd-stem-section {
  background:#fafbfe;
  border:1px solid #eef1f6;
  border-left:4px solid #6366f1;
  border-radius:10px;
  padding:14px 18px;
}
.qd-stem-section .q-stem { font-size:16px; line-height:1.8; }

/* 答案：绿色强调块 */
.qd-answer-block {
  display:flex; align-items:center; gap:10px;
  background:#f0fdf4; border:1px solid #bbf7d0; border-radius:8px;
  padding:8px 14px;
}
.qd-answer-block .qd-label { color:#15803d; }
.qd-ans-text { color:#15803d; font-weight:600; font-size:15px; }

/* 解析：浅灰区块 */
.qd-analysis {
  background:#f8fafc; border:1px solid #eef1f5; border-left:3px solid #94a3b8;
  border-radius:8px; padding:10px 14px; margin-top:2px;
}
.qd-warning {
  border-radius:8px; padding:8px 14px; border:1px solid #fed7aa;
}

/* 区块标题胶囊化 */
.qd-label {
  display:inline-flex; align-items:center;
  font-size:12px; font-weight:600; letter-spacing:.4px;
  background:#eef2ff; color:#4338ca;
  border-radius:6px; padding:2px 9px;
  margin-bottom:6px;
}
.qd-answer-block .qd-label, .qd-analysis .qd-label, .qd-warning .qd-label {
  margin-bottom:0; background:transparent; padding:0;
}
.qd-label-warn { color:#c2410c; }

/* 底部信息行：标签/知识点/章节 */
.qd-tags-section, .qd-kp-section, .qd-chapter-section {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px;
  padding:4px 2px;
}
.qd-tags-section .qd-label, .qd-kp-section .qd-label, .qd-chapter-section .qd-label { margin-bottom:0; }

/* 示意图栏卡片 */
#q-diagram-card {
  margin-top:16px !important; border:1px dashed #dbe3ec; border-radius:12px;
  background:#fafbfc; padding:14px 16px;
}
#q-diagram-card h3 { font-size:14px; color:#374151; margin-bottom:10px; }
.kp-diagram-item {
  border:1px solid #e6e9ef; border-radius:10px; box-shadow:0 1px 3px rgba(16,24,40,.05);
}
.kp-diagram-name { font-size:12px; color:#6b7280; }

/* ============ 结构化题干：标题徽标 / 选项网格 / 小问缩进 ============
   由 rtext.py（服务端）/ rich-text.js（前端预览）生成，二者逻辑一致：
   · 行首【例1·…】      → .q-title > .q-title-tag 徽标 + 正文
   · 连续 A./B./C./D.   → .q-options 网格（列数按选项长度 4/2/1 自适应）
   · 行首（1）/①        → .q-sub 缩进块
   题干容器为 white-space:pre-wrap，块级元素内部需重置为 normal。 */
/* 题号行：两列 grid（题号徽标列 + 正文列）。选项块合并进本行时放第 2 列，
   与题干正文左对齐（不贴题号徽标）。 */
.q-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: baseline;
  margin: 0 0 6px;
  white-space: normal;
}
.q-title-tag {
  grid-column: 1;
  justify-self: start;
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
}
.q-title-body { grid-column: 2; min-width: 0; }
/* 合并进题号行的选项块：与正文同列 */
.q-title > .q-options {
  grid-column: 2;
  margin: 6px 0 2px;
}
/* 移进题号行的插图行：与正文同列 */
.q-title > .kp-diagram-row {
  grid-column: 2;
  justify-content: flex-start;
}

.q-options {
  display: grid;
  gap: 5px 20px;
  margin: 8px 0 6px;
  white-space: normal;
}
.q-options-cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.q-options-cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.q-options-cols1 { grid-template-columns: minmax(0, 1fr); }

.q-opt {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  padding: 2px 6px 2px 2px;
  border-radius: 6px;
  line-height: 1.7;
  transition: background 0.12s;
}
.q-opt:hover { background: #f8fafc; }
.q-opt-k {
  flex: 0 0 auto;
  color: inherit;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.7;
}
.q-opt-k::after { content: "．"; }
.q-opt-v { min-width: 0; }
.q-opt mjx-container { vertical-align: middle; }

.q-sub {
  display: flex;
  gap: 8px;
  margin: 3px 0;
  padding: 1px 0;
  white-space: normal;
}
.q-sub-k { flex: 0 0 auto; color: #6b7280; font-weight: 600; }
.q-sub-v { min-width: 0; }

/* 编辑页/详情页预览区：题干块内的间距收紧 */
.qd-stem .q-options { margin: 7px 0 5px; }
/* 列表卡片：更紧凑，避免单卡过高 */
.q-card-stem .q-options { gap: 3px 16px; margin: 6px 0 3px; }
.q-card-stem .q-opt { padding: 1px 4px; line-height: 1.65; }
.q-card-stem .q-opt-k { font-size: 11px; margin-top: 3px; white-space: nowrap; }
.q-card-stem .q-title { margin-bottom: 4px; }
.q-card-stem .q-title-tag { font-size: 11.5px; padding: 0 7px; }
.q-card-stem .q-sub { margin: 2px 0; }

/* 窄屏：多列选项降级，保证可读 */
@media (max-width: 720px) {
  .q-options-cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .q-options-cols2 { grid-template-columns: minmax(0, 1fr); }
}

/* ============ 编辑页：结构化写法速查面板 ============ */
.stem-hint {
  margin-top: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafbfc;
  font-size: 13px;
}
.stem-hint > summary {
  cursor: pointer;
  padding: 7px 12px;
  color: #4b5563;
  font-weight: 600;
  user-select: none;
}
.stem-hint > summary:hover { color: #4f46e5; }
.stem-hint-body { padding: 4px 12px 12px; }
.stem-hint-table { width: 100%; border-collapse: collapse; }
.stem-hint-table td {
  padding: 4px 8px 4px 0;
  vertical-align: top;
  border-bottom: 1px dashed #eceff3;
  color: #4b5563;
  line-height: 1.65;
}
.stem-hint-table td:first-child {
  width: 46%;
  color: #1f2937;
  white-space: nowrap;
}
.stem-hint-table code {
  background: #eef2ff;
  border: 1px solid #dbe3ff;
  border-radius: 4px;
  padding: 0 4px;
  color: #4338ca;
  font-size: 12px;
}
.stem-hint-actions { margin-top: 10px; display: flex; gap: 8px; }


/* ============ 列表卡片 v3（2026-10）：题目区框式 + 无 hover + 侧栏信息 ============ */
.q-card-stem {
  display:block;
  border:1px solid #eef1f5;
  border-radius:8px;
  padding:8px 12px;
  background:#fafbfc;
  transition:none;
}
.q-card-stem:hover,
.q-card-stem:visited:hover {
  color:#1f2329;
  background:#fafbfc;
  border-color:#eef1f5;
}
/* 侧栏：知识点与标签右对齐、随功能按钮下方排列 */
.q-card-side .q-card-kps,
.q-card-side .q-card-tags {
  justify-content:flex-end;
  margin-top:2px;
}
@media (max-width: 640px) {
  .q-card-side .q-card-kps,
  .q-card-side .q-card-tags { justify-content:flex-start; }
}


/* ============ 列表卡片 v4（2026-10）：易错入侧栏 + 知识点竖排 ============ */
/* 侧栏整体左对齐：让「查看」按钮与易错/知识点左边缘对齐 */
.q-card-side { align-items: flex-start; }
.q-card-side .q-card-actions { justify-content: flex-start; }
.q-card-side .q-card-badges { justify-content: flex-start; }
/* 易错块：左对齐、宽度受控 */
.q-card-side .q-card-warning {
  align-self: flex-start;
  max-width: 320px;
  margin-top: 8px;
  width: auto;
}
/* 知识点竖排：一行一个知识点（面包屑） */
.q-card-side .q-card-kps {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 8px;
}
.q-card-side .q-card-kps .kp-chip {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.q-card-side .q-card-tags { margin-top: 8px; }
@media (max-width: 640px) {
  .q-card-side .q-card-warning { max-width: 100%; }
}


/* ============ 列表卡片 v4.1（2026-10）：去掉题目链接下划线（含 hover） ============ */
.q-card-stem,
.q-card-stem:hover,
.q-card-stem:visited,
.q-card-stem:visited:hover {
  text-decoration: none;
}


/* ============ 每排控件：自定义数量输入框（2026-10） ============ */
.diagram-perrow-input {
  width: 42px;
  height: 24px;
  margin-left: 4px;
  padding: 0 4px;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  color: #4338ca;
  background: #fff;
  outline: none;
  -moz-appearance: textfield;
}
.diagram-perrow-input::-webkit-inner-spin-button,
.diagram-perrow-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.diagram-perrow-input:focus { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99, 102, 241, .15); }


/* ============ 题库列表页：功能按钮紧凑 + 到底部/到顶部（2026-10） ============ */
form.filter.q-filter .row-actions .btn {
  padding: 4px 10px;
  font-size: 12.5px;
  line-height: 1.35;
}
form.filter.q-filter .row-types { margin-bottom: 3px; }
form.filter.q-filter .row-actions { margin-top: 0; }


/* ============ 列表页多图行：按容器宽度自动压缩（2026-10） ============ */
.q-card .kp-diagram-row.kp-row-multi {
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 6px;
}
.q-card .kp-diagram-row.kp-row-multi .kp-diagram-inline {
  flex: 1 1 0;
  min-width: 0;
  margin-left: 0 !important;
  margin-top: 0 !important;
}
.q-card .kp-diagram-row.kp-row-multi .kp-diagram-inline svg {
  width: 100% !important;
  height: auto;
  max-width: none !important;
  margin: 0 !important;
}

/* ============ 讲义预览：紧凑排版（opt-in 开关，默认关闭，不影响原排版） ============ */
.handout-document.compact .handout-cover { padding-bottom: 10px; margin-bottom: 14px; }
.handout-document.compact .handout-cover h1 { font-size: 22px; }
.handout-document.compact .handout-intro { margin-bottom: 12px; padding: 8px 12px; font-size: 13px; }
.handout-document.compact .handout-section { margin-top: 10px; padding: 6px 0; }
.handout-document.compact .handout-section h2 { font-size: 17px; margin-bottom: 4px; }
.handout-document.compact .text-block { margin-bottom: 5px; padding: 5px 10px; }
.handout-document.compact .q-block { margin-bottom: 1px; padding: 2px 0; }
.handout-document.compact .q-stem { font-size: 13.5px; line-height: 1.45; margin-bottom: 2px; }
.handout-document.compact .q-answer,
.handout-document.compact .q-analysis { margin-top: 2px; padding: 3px 8px; font-size: 13px; }
.handout-document.compact .kp-block { margin-bottom: 5px; }
.handout-document.compact .kp-diagram-row { margin: 2px 0; }
.handout-document.compact .kp-diagram-inline { max-width: 200px; }
@media print {
  /* 紧凑模式下允许 section / q-block 跨页，实现一页多题 */
  body.page-handout_preview.compact-mode .handout-section,
  body.handouts-print.compact-mode .handout-section { page-break-inside: auto; }
  body.page-handout_preview.compact-mode .q-block,
  body.handouts-print.compact-mode .q-block { page-break-inside: auto; }
  body.page-handout_preview.compact-mode .text-block,
  body.handouts-print.compact-mode .text-block { page-break-inside: auto; }
}

/* ============ 学生端窄屏（手机）适配 ============
   手机上题目显示不全的两个原因：
   1) 题图带用户设定的固定宽度（render_diagram 会写 max-width:none），在窄屏上撑破容器；
   2) 超长 LaTeX 公式是一整块 SVG，不会自己换行，也撑破容器。
   这两条都限制在学生端 —— 教师端的编辑页要靠固定宽度拖拽调大小，不能动。 */
@media (max-width: 900px) {
  .student-page .kp-diagram-inline,
  .student-page .kp-diagram-row .kp-diagram-inline { max-width: 100% !important; }
  .student-page mjx-container svg { max-width: 100%; height: auto; }

  /* 错题标题独占一行，别被徽章挤成竖排 */
  .student-page .st-wrong-head { flex-wrap: wrap; }
  .student-page .st-wrong-title { flex: 1 1 100%; min-width: 0; word-break: break-word; }
  .student-page .st-wrong-actions { flex-wrap: wrap; }

  /* 表格别撑破（化学数据表那种） */
  .student-page .st-wrong-stem table,
  .student-page .q-stem table { max-width: 100%; }
  .student-page .q-stem { word-break: break-word; }

  /* MathJax 给读屏软件准备的 MathML 副本：默认宽 auto，会把页面撑宽几十像素。
     改成 1px 的裁剪盒（内容还在 DOM 里，读屏不受影响）。 */
  .student-page mjx-assistive-mml {
    width: 1px !important; height: 1px !important;
    overflow: hidden !important; clip-path: inset(50%) !important;
  }
}

/* ===================== 学生端（student-page）=====================
   学生端继承 base.html，只把左侧教师导航换成学生导航。
   窄屏（iPad 竖屏 / 手机）时侧栏变顶栏，主区占满宽度。 */
.student-page .sidebar-brand { background: #1e40af; border-bottom-color: #1e3a8a; }
.student-page .side-nav a.active { border-left-color: #60a5fa; }

/* 窄屏：侧栏 → 顶栏（1100 = iPad 横屏 1194 / 竖屏 834 都算"窄"） */
@media (max-width: 1100px) {
  .student-page .layout { flex-direction: column; }
  .student-page .sidebar {
    width: auto; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 8px;
  }
  .student-page .sidebar-brand {
    border-bottom: none; border-right: 1px solid #334155;
    padding: 12px 14px; white-space: nowrap;
  }
  .student-page .side-nav { flex-direction: row; padding: 0; }
  .student-page .side-nav a {
    border-left: none; border-bottom: 3px solid transparent;
    padding: 12px 14px; white-space: nowrap;
  }
  .student-page .side-nav a.active {
    border-left-color: transparent; border-bottom-color: #60a5fa;
  }
  .student-page .sidebar-foot {
    border-top: none; border-left: 1px solid #334155;
    margin-left: auto; display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
  }
  .student-page .sidebar-foot form { margin: 0; }
}

/* ---- 登录页 ---- */
.st-login-wrap { max-width: 420px; margin: 48px auto; }
.st-login-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 28px 26px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.st-login-card h1 { font-size: 20px; margin: 0 0 4px; }
.st-login-card .st-hint { color: #6b7280; font-size: 13px; margin: 0 0 18px; }
.st-login-card .st-field { margin-bottom: 14px; }
.st-login-card label { display: block; font-size: 13px; color: #374151; margin-bottom: 4px; }
.st-login-card input[type="text"] {
  width: 100%; padding: 9px 11px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: 15px; box-sizing: border-box;
}
.st-login-card input.st-code {
  font-size: 24px; letter-spacing: 4px; text-align: center;
  text-transform: uppercase; font-weight: 600;
}
.st-login-card .btn { width: 100%; padding: 10px; font-size: 15px; }

/* ---- 我的课堂 ---- */
.st-group { margin-bottom: 22px; }
.st-group-title {
  font-size: 15px; font-weight: 600; color: #0f172a;
  margin: 18px 0 8px; display: flex; align-items: center; gap: 8px;
}
.st-item {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; color: inherit;
}
.st-item:hover { border-color: #93c5fd; text-decoration: none; }
.st-item-icon { font-size: 22px; width: 34px; text-align: center; flex: none; }
.st-item-main { flex: 1; min-width: 0; }
.st-item-title { font-size: 14px; color: #0f172a; font-weight: 500; }
.st-item-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.st-item-note { font-size: 12px; color: #64748b; margin-top: 3px; }

/* ---- 错题本 ---- */
.st-wrong {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
}
.st-wrong.is-mastered { background: #f0fdf4; border-color: #bbf7d0; }
.st-wrong-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.st-wrong-title { font-size: 14px; font-weight: 600; color: #0f172a; flex: 1; min-width: 0; }
.st-wrong-stem { font-size: 13px; color: #334155; line-height: 1.6; }
.st-wrong-cause {
  font-size: 12px; color: #92400e; background: #fffbeb;
  border-left: 3px solid #fbbf24; padding: 6px 9px; border-radius: 0 6px 6px 0;
  margin-top: 8px; white-space: pre-wrap;
}
.st-wrong-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.st-wrong-imgs img {
  max-width: 190px; max-height: 190px; border-radius: 8px;
  border: 1px solid #e5e7eb; display: block;
}
.st-wrong-actions { margin-top: 9px; display: flex; gap: 8px; align-items: center; }

/* 题库选题弹层里的结果列表 */
.st-pick-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 340px; overflow: auto; }
.st-pick-item {
  padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; font-size: 13px; line-height: 1.55;
}
.st-pick-item:hover { border-color: #93c5fd; background: #f8fafc; }
.st-pick-item .st-pick-id { color: #94a3b8; font-size: 11px; margin-right: 6px; }

/* 学生端动画页 */
.st-anim-stage { height: calc(100vh - 150px); min-height: 420px; }

/* 左对齐卡片（.card 默认 text-align:center，学生端表单要左对齐） */
.st-card {
  background: #fff; padding: 16px; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb; text-align: left;
}
.st-card .sidebar-title { text-align: left; }

/* 分发页侧栏表单：标签在上、输入框在下 */
.st-form label {
  display: block; font-size: 13px; color: #374151; margin: 0 0 10px;
}
.st-form label > input,
.st-form label > select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid #d1d5db; border-radius: 6px; box-sizing: border-box;
  font-size: 13px;
}
.st-form .btn { width: 100%; margin-top: 4px; }
.st-form .btn + .btn { margin-top: 8px; }

/* ==================== 学生端：拍照框选识别 ==================== */
/* 卷子照片 + 框选层 */
.sw-canvas-wrap {
  position: relative; display: inline-block; max-width: 100%;
  background: #f1f5f9; border: 1px solid #e5e7eb; border-radius: 8px;
  overflow: hidden; touch-action: none; user-select: none;
}
.sw-canvas-wrap canvas { display: block; max-width: 100%; max-height: 68vh; }
.sw-canvas-wrap #rect-layer { position: absolute; inset: 0; pointer-events: none; }

.sw-rect {
  position: absolute; border: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.14); border-radius: 3px;
}
.sw-rect-temp { border-style: dashed; }
.sw-rect-done { border-color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.sw-rect-no {
  position: absolute; top: -9px; left: -9px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 9px; background: #2563eb; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}

.sw-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px;
}

/* 每块区域一张校对卡 */
.sw-region {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
}
.sw-region-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sw-region-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.sw-region-body { margin-top: 10px; }
.sw-region-body label {
  display: block; font-size: 12px; color: #6b7280; margin-bottom: 8px;
}
.sw-region-body textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px;
  border: 1px solid #d1d5db; border-radius: 8px; font-size: 13px;
  font-family: inherit; resize: vertical;
}

/* 错题列表：文字优先，图片只做存档 */
.st-wrong-options { margin-top: 6px; }
.st-wrong-option { font-size: 13px; color: #334155; line-height: 1.6; }
.st-wrong-answer { margin-top: 8px; font-size: 13px; }
.st-wrong-answer summary {
  cursor: pointer; color: #2563eb; font-size: 12px;
}
.st-wrong-line { margin-top: 6px; color: #334155; line-height: 1.6; }

/* 存档核对弹层 */
.sw-archive-box {
  position: fixed; inset: 0; z-index: 9999; background: rgba(15, 23, 42, 0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; cursor: zoom-out;
}
.sw-archive-box[hidden] { display: none; }
.sw-archive-box img {
  max-width: 92vw; max-height: 82vh; background: #fff; border-radius: 8px;
}
.sw-archive-box .muted { color: #e2e8f0; }

/* ==================== 学生端：错题「重做」画布 ==================== */
/* 题目底稿：隐藏起来，只用来量尺寸 + 光栅化到画布 */
.redo-source {
  position: absolute; left: -10000px; top: 0; visibility: hidden;
  font-size: 15px; line-height: 1.8; color: #1f2329;
}
.redo-canvas-wrap {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  overflow: auto; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  -webkit-overflow-scrolling: touch;
}
#redo-canvas {
  display: block; width: 100%; height: auto;
  touch-action: none; cursor: crosshair; background: #fff;
  /* 书写时别选中文字，也别弹出长按菜单（iOS） */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.redo-bar { position: sticky; top: 0; z-index: 20; }
.pen-btn.primary { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; }

/* ==================== 通用画板（PhysicsBoard） ==================== */
/* 笔迹层：叠在页面内容上，跟内容同一坐标系。
   页面上只展示（不吃指针事件），弹窗画板里才可写。 */
.pb-canvas {
  position: absolute; left: 0; top: 0;
  pointer-events: none;
  z-index: 6;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pb-modal .pb-canvas { pointer-events: auto; cursor: crosshair; }
/* 画板里只写不选：手写时两笔挨得近容易被判成双击 → 浏览器自动框选文字 */
body.pb-open, body.pb-open .pb-modal, body.pb-open .pb-modal * {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* 讲义底部的空白草稿区：试卷正文太满时，追加一块横线空白区写批注 */
.pb-draft {
  margin-top: 12px;
  border-top: 1px dashed #cbd5e1;
  background-image: repeating-linear-gradient(to bottom,
    transparent, transparent 27px, #eef2f7 27px, #eef2f7 28px);
  background-position: 0 10px;
  background-repeat: repeat;
}
.pb-size-label { min-width: 56px; }
/* 侧边留白：正文锁宽在左边，右边一条横线空白栏（讲题时在题旁边写） */
.pb-col { position: relative; }
.pb-margin {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px dashed #cbd5e1;
  background-image: repeating-linear-gradient(to bottom,
    transparent, transparent 27px, #eef2f7 27px, #eef2f7 28px);
  background-position: 0 10px;
  background-repeat: repeat;
}
.pb-space { position: relative; margin: 0 auto; }
.pb-page { background: #fff; }
.pb-blank { box-shadow: 0 2px 18px rgba(0, 0, 0, .18); border-radius: 4px; }

/* ==================== 画板弹窗（GoodNote 式） ==================== */
.pb-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: #eef1f5;   /* 桌面灰底 + 白色纸张 */
}
.pb-modal[hidden] { display: none; }
.pb-modal-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 14px; background: #fff; border-bottom: 1px solid #e5e7eb;
}
.pb-modal-hint { margin-left: auto; }
.pb-stage {
  flex: 1; overflow: auto; position: relative;
  touch-action: none; overscroll-behavior: contain;
}
.pb-palette {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: #fff; border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
}
.pb-pal-group { display: flex; align-items: center; gap: 6px; }
.pb-pal-group + .pb-pal-group { border-left: 1px solid #e5e7eb; padding-left: 10px; }
.pb-pal-right { margin-left: auto; }

/* 形状工具条（直线/箭头/矩形/圆…）：点「📐 形状」展开 */
.pb-shape-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 14px; background: #f8fafc; border-top: 1px solid #e5e7eb;
}
.pb-shape-bar[hidden] { display: none; }
.pb-shape-bar .pb-pal-btn { font-size: 13px; height: 30px; }
.pb-pal-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: 8px; border: 1px solid #d1d5db; background: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.pb-pal-btn:hover { background: #f3f4f6; }
.pb-pal-btn.primary { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; }
.pb-dot {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; background: var(--c, #111827); cursor: pointer;
}
.pb-dot.pb-size { background: #374151; }
.pb-dot.primary { border-color: #2563eb; box-shadow: 0 0 0 2px #dbeafe; }
.pb-count, .pb-zoom { min-width: 48px; text-align: center; }
body.pb-open { overflow: hidden; }

/* 讲义批注工具栏（页面上的入口） */
.ha-toolbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 8px 10px; margin: 0 0 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}
.ha-toolbar .ha-sep { width: 1px; height: 20px; background: #e5e7eb; margin: 0 4px; }
.ha-toolbar .ha-pen.primary { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; }

/* ==================== 作业 ==================== */
.asg-picker {
  margin: 8px 0; padding: 10px; border: 1px dashed #d1d5db; border-radius: 8px;
  background: #f9fafb;
}
.asg-picker .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.asg-chosen { margin-top: 8px; }
.hw-do { cursor: pointer; }

/* 讲义列表上的「讲解版 / 有批注」标记 */
.ha-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  font-size: 12px; border-radius: 999px; white-space: nowrap;
  background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff;
}
.ha-badge.anno { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* 打印时不要打印手写覆盖层：它是整页一张画布，跨页会被裁得七零八落。
   手写内容请通过「存为讲解版」分发给学生（屏幕上笔迹与正文严丝合缝）。 */
@media print {
  .pb-canvas { display: none !important; }
  .pb-modal { display: none !important; }
  /* 打印版恢复原版式：不要侧边留白 / 草稿区 */
  .pb-margin { display: none !important; }
  .pb-col { width: auto !important; }
  .handout-document {
    width: 800px !important; max-width: 800px !important; min-width: 800px !important;
  }
}

/* ===================== 平板 / PWA 适配 =====================
   iPad 横屏 1194×834、竖屏 834×1194；Android 平板 800~1280。
   目标：① 侧栏别在平板上白占 200px；② 触摸目标够大（≥44px）；
        ③ 画板全屏时避开刘海/圆角（safe-area）；④ 双击别放大页面。 */

/* 双击不要触发页面放大（写字时最容易误触） */
button, a, .btn, .pb-pal-btn, input, select, textarea, .side-nav a {
  touch-action: manipulation;
}

/* 触摸设备：按钮和导航项点得准一点 */
@media (pointer: coarse) {
  .btn, .pb-pal-btn, .pb-dot { min-height: 44px; }
  .side-nav a { padding-top: 14px; padding-bottom: 14px; }
  .pb-pal-btn { min-width: 44px; }
}

/* 教师端侧栏：平板上收窄，把横向空间让给内容 */
@media (max-width: 1100px) {
  .sidebar { width: 156px; }
  .sidebar .side-nav a { font-size: 13px; padding-left: 12px; padding-right: 12px; }
  .sidebar .sidebar-brand { font-size: 15px; }
}

/* 画板弹窗：避开 iPad 的刘海/圆角；工具栏要能横向滚动，别被挤爆 */
.pb-modal-head {
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
.pb-palette {
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  overflow-x: auto;
}
.pb-shape-bar {
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  overflow-x: auto;
}

/* 平板横屏：工具栏别太高（竖屏时太占地方） */
@media (max-height: 500px) {
  .pb-modal-head { padding-top: 4px; padding-bottom: 4px; }
  .pb-pal-btn { height: 40px; min-height: 40px; }
}

/* ===================== 典例分析：【析】折叠 =====================
   题面一直显示，解析收在 <details> 里，点「👀 查看解析」才展开。 */
.kp-ex-q { margin: 8px 0 4px; }
.kp-fold {
  margin: 4px 0 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
  overflow: hidden;
}
.kp-fold > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  color: #1d4ed8;
  list-style: none;
  user-select: none; -webkit-user-select: none;
}
.kp-fold > summary::-webkit-details-marker { display: none; }
.kp-fold > summary::before { content: "▸ "; }
.kp-fold[open] > summary::before { content: "▾ "; }
.kp-fold > summary:hover { background: #eff6ff; }
.kp-fold-body {
  padding: 6px 12px 10px;
  border-top: 1px dashed #dbeafe;
  font-size: 14px;
}
