:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e2e6ec;
  --line-strong: #cdd4de;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #e8f0fe;
  --ok: #059669;
  --ok-soft: #e6f6ef;
  --warn: #d97706;
  --danger: #dc2626;
  --violet: #7c3aed;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

/* 保证 hidden 属性始终生效（避免被 display 样式覆盖） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.muted { color: var(--muted); }

/* ---------- topbar ---------- */
.topbar {
  flex: 0 0 auto;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  width: 26px; height: 26px;
  display: block;
  object-fit: contain;
  flex: none;
}

.brand-text { font-size: 15px; font-weight: 600; white-space: nowrap; }

.project-name {
  width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: #fbfcfe;
}
.project-name:focus { outline: none; border-color: var(--brand); background: #fff; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-sep { width: 1px; height: 22px; background: var(--line); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #f3f6fb; border-color: #b9c3d1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #047857; border-color: #047857; }

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef1f6; color: var(--text); }

.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.icon { padding: 4px 9px; font-size: 14px; line-height: 1.1; }

/* ---------- layout ---------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 208px minmax(420px, 1fr) 400px;
  /* 行高锁定为可用高度：面板内部各自滚动，不会被内容撑高或压扁 */
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 13px;
}
.panel-head .muted { font-weight: 400; font-size: 12px; margin-left: auto; }
.panel-head-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }

/* 「排序 ⬇️」点开的小菜单：按题号升序 / 按题号降序 / 按题型。
   用 fixed 定位摆在按钮正下方，编辑栏裁不到它；位置由 ui.js 每次打开时算 */
.sort-wrap { display: inline-flex; }
.sort-menu {
  position: fixed; z-index: 70; display: none; flex-direction: column;
  min-width: 132px; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 26px rgba(16,24,40,.18);
}
.sort-wrap.open .sort-menu { display: flex; }
.sort-item {
  border: none; background: transparent; cursor: pointer; text-align: left;
  font-size: 12.5px; color: var(--text); padding: 7px 10px; border-radius: 6px; white-space: nowrap;
}
.sort-item:hover { background: #eef3fb; color: var(--brand); }
.sort-item.active { color: var(--brand); font-weight: 600; background: #f2f6ff; }
.sort-item.active::after { content: ' ✓'; }

/* 「清空题目」是破坏性的：红色提醒 + 点击后还要确认 */
#btn-clear-questions { color: var(--danger); }
#btn-clear-questions:hover { background: #fdeaea; color: var(--danger); }

/* 题目栏右上角按钮多了（新题目 / 排序 / 清空题目 / 收起），
   栏变窄时让它们换行，别被裁掉 */
.content-panel .panel-head { height: auto; min-height: 40px; padding: 6px 12px; flex-wrap: wrap; row-gap: 6px; }

.panel-foot { flex: 0 0 auto; padding: 8px 10px; border-top: 1px solid var(--line); }

/* ---------- pages panel ---------- */
.pages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
  align-items: stretch;
}
/* 列表项不要被压缩：内容高过面板时应当滚动，而不是把每一项挤扁 */
.pages > .page-item { flex: 0 0 auto; }

.page-item {
  position: relative;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f7f9fc;
  padding: 4px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.page-item:hover { background: #eef3fb; }
.page-item.active { border-color: var(--brand); background: var(--brand-soft); }
.page-item img { display: block; width: 100%; border-radius: 5px; background: #fff; }
.page-item .page-label {
  display: block;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 3px 0 1px;
}
.page-item .page-del {
  position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: rgba(17, 24, 39, .55);
  color: #fff; font-size: 11px; line-height: 1; cursor: pointer;
  display: none;
}
.page-item:hover .page-del { display: block; }
.page-item .page-del:hover { background: var(--danger); }

/* ---------- canvas panel ---------- */
.toolbar {
  flex: 0 0 auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar-sep { width: 1px; height: 20px; background: var(--line); }
.toolbar-spacer { flex: 1 1 auto; }

.tool-group { display: flex; background: #f1f4f9; border-radius: 8px; padding: 3px; gap: 2px; }
.tool-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 5px 11px; border-radius: 6px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tool-btn:hover { background: #e4eaf4; color: var(--text); }
.tool-btn.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.12); }

.zoom-group { display: flex; align-items: center; gap: 5px; }
.zoom-label { font-size: 12px; color: var(--muted); min-width: 52px; text-align: center; }
.page-nav { display: flex; align-items: center; gap: 6px; }
#page-indicator { font-size: 12px; color: var(--muted); min-width: 48px; text-align: center; }

.canvas-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(45deg, #eceff4 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(-45deg, #eceff4 25%, transparent 25%) -10px 0/20px 20px,
    linear-gradient(45deg, transparent 75%, #eceff4 75%) -10px 0/20px 20px,
    linear-gradient(-45deg, transparent 75%, #eceff4 75%) -10px 0/20px 20px,
    #f6f8fb;
  padding: 16px;
  display: flex;
  /* 别用 justify-content: center —— 画布比容器宽时，居中会把左边顶到滚动区外面，
     滚不回去（只能看到右半边）。改成让子元素自己 margin:auto 居中：
     放得下时居中，放不下时自动靠左，左右都能滚到。 */
  align-items: flex-start;
  min-width: 0;
}

.canvas-panel { min-width: 0; }
.canvas-stage { position: relative; display: inline-block; line-height: 0; margin: 0 auto; }
#page-canvas {
  display: block;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .16);
  max-width: none;
}
.canvas-stage.has-page { cursor: crosshair; }
.canvas-stage.browse { cursor: default; }

.overlay-layer { position: absolute; inset: 0; pointer-events: none; }

.overlay-region {
  /* 位置改成百分比之后，特别小的一块也要能看见 / 点到 */
  min-width: 3px; min-height: 3px;
  position: absolute;
  border: 1.5px solid;
  border-radius: 3px;
  font-size: 10px;
}
/* 选中的那道题：紫色、加粗、压在最上面——色块叠在一起时也能点到它的 ✕ */
.overlay-region.focused {
  border-width: 3px;
  z-index: 6;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 0 0 4px rgba(124, 58, 237, .35);
}
/* 浏览模式下色块可以点：右上角那个 ✕ 用来删掉这道题 */
.overlay-region.clickable { pointer-events: auto; }
.overlay-region.clickable:hover { box-shadow: 0 0 0 2px rgba(37, 99, 235, .45); }
.overlay-region .overlay-edit {
  position: absolute; right: 10px; top: -8px;
  width: 16px; height: 16px; padding: 0; line-height: 14px;
  border: 1px solid #fff; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 10px; cursor: pointer;
  opacity: .8; display: none;
}
.overlay-region.clickable:hover .overlay-edit { display: block; }
.overlay-region .overlay-del {
  position: absolute; right: -8px; top: -8px;
  width: 16px; height: 16px; padding: 0; line-height: 14px;
  border: 1px solid #fff; border-radius: 50%;
  background: #ef4444; color: #fff; font-size: 10px; cursor: pointer;
  opacity: .75; display: none;
}
.overlay-region.clickable:hover .overlay-del { display: block; }

.lasso-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lasso-layer path {
  fill: rgba(37, 99, 235, .14); stroke: var(--brand);
  stroke-width: 1.5; stroke-dasharray: 5 3; stroke-linejoin: round;
}

.selection-box {
  position: absolute;
  border: 1.5px dashed var(--brand);
  background: rgba(37, 99, 235, .12);
  border-radius: 3px;
  pointer-events: none;
}
/* 框完留在画面上的那个框：可以拖、可以拉边，停手 3 秒自动重新识别 */
.selection-box.pick {
  min-width: 10px; min-height: 10px;
  pointer-events: auto;
  cursor: move;
  border-style: solid;
  border-width: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8) inset;
}
.selection-box .pick-handle {
  position: absolute; width: 11px; height: 11px;
  background: #fff; border: 2px solid var(--brand); border-radius: 3px;
  box-sizing: border-box;
}
.selection-box .pick-handle.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.selection-box .pick-handle.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.selection-box .pick-handle.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.selection-box .pick-handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.selection-box .pick-handle.n { left: 50%; margin-left: -6px; top: -6px; cursor: ns-resize; }
.selection-box .pick-handle.s { left: 50%; margin-left: -6px; bottom: -6px; cursor: ns-resize; }
.selection-box .pick-handle.w { left: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.selection-box .pick-handle.e { right: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.selection-box .pick-tip {
  position: absolute; left: 0; top: -24px;
  padding: 2px 7px; border-radius: 4px;
  background: var(--brand); color: #fff; font-size: 11px; line-height: 16px;
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .28);
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); text-align: center; padding: 40px; margin: auto;
}
.empty-icon { font-size: 40px; }
.empty-state p { margin: 0; }

.status-bar {
  flex: 0 0 auto;
  height: 34px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  font-size: 12px;
  color: var(--muted);
}
.spinner {
  width: 13px; height: 13px;
  border: 2px solid #d3dae6;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- questions panel ---------- */
.questions {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 10px;
  align-items: stretch;
}
/* 关键：题目卡片按内容高度显示，超出就滚动，绝不压缩 */
.questions > .question-card { flex: 0 0 auto; }

.q-empty { color: var(--muted); text-align: center; padding: 30px 16px; line-height: 1.9; }

.question-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  overflow: hidden;
}
.question-card.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }

.q-head {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
}
.q-index { font-weight: 600; font-size: 12px; color: var(--brand); white-space: nowrap; }
.q-number {
  width: 52px; padding: 3px 6px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.q-type {
  padding: 3px 4px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted);
}
.q-head .q-spacer { flex: 1 1 auto; }
.q-tool {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 5px;
  white-space: nowrap; flex: 0 0 auto;
}
.q-tool:hover { background: #e7ecf5; color: var(--text); }
.q-tool.danger:hover { background: #fdeaea; color: var(--danger); }

.q-blocks { padding: 8px; display: flex; flex-direction: column; gap: 7px; align-items: stretch; }
.q-blocks > .block { flex: 0 0 auto; }

.block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdff;
  overflow: hidden;
}
.block-head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 7px;
  background: #f4f7fb;
  border-bottom: 1px solid var(--line);
}
.badge { font-size: 11px; padding: 1px 6px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge.text { background: var(--brand-soft); color: var(--brand); }
.badge.formula { background: var(--ok-soft); color: var(--ok); }
.badge.image { background: #fef3e2; color: var(--warn); }
.block-src { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-tools { margin-left: auto; display: flex; gap: 2px; flex: 0 0 auto; }

.block-input, .q-answer, .q-analysis {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 8px 9px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  background: #fff;
  resize: vertical;
  font-family: inherit;
}
.block-input:focus, .q-answer:focus, .q-analysis:focus { outline: none; background: #fffef8; }
.block-input { min-height: 0; }
.block-input.formula { font-family: "SFMono-Regular", Consolas, "Courier New", monospace; font-size: 12px; color: #0f5132; }

/* ---------- 内容块输入框：默认折成一行，右边箭头点开看全部 ---------- */
.block-input-row {
  display: flex; align-items: stretch; gap: 4px;
  margin: 6px 7px; padding: 0 2px 0 0;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.block-input-row:focus-within { border-color: var(--brand); }
.block-input-row .block-input {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  border: none; border-radius: 7px; background: transparent;
  padding: 5px 9px; height: 29px; line-height: 1.5; overflow: hidden; resize: none;
}
/* 展开后跟着内容长，不用在小框里来回滚 */
.block-input-row.open .block-input { height: auto; resize: vertical; }
.block-fold {
  flex: 0 0 auto; align-self: flex-start;
  width: 22px; height: 22px; margin: 3px 3px 0 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 5px; background: #eef2f8; color: #5b6b83;
  font-size: 10px; line-height: 1; cursor: pointer;
}
.block-fold:hover { background: var(--brand-soft); color: var(--brand); }

/* ---------- 文字预览：默认展开，点标题栏或箭头收起 ---------- */
.block-preview-head {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 7px 2px 9px;
  border-top: 1px dashed var(--line); background: #f8fafd;
  cursor: pointer; user-select: none;
}
.block-preview-head .block-fold { align-self: center; margin: 0; }
.block-preview-title { flex: 1 1 auto; font-size: 11px; color: #8f9aab; }
/* 预览收起时标题栏压暗一点，一眼看得出是收着的 */
.block-preview-head.folded { background: #f1f4f9; }

.block-image { display: block; max-width: 100%; margin: 0 auto; padding: 6px; }

.block-preview {
  padding: 7px 9px;
  border-top: 1px dashed var(--line);
  background: #fff;
  font-size: 13px;
  line-height: 1.9;
  overflow-x: auto;
  min-height: 26px;
}
/* 上面已经有预览标题栏那条虚线了，这里别再画一条 */
.block-preview { border-top: none; }
.block-preview:empty { display: none; }
.block-preview .preview-label {
  display: block; font-size: 11px; color: #9aa4b2; margin-bottom: 3px;
}
/* 预览里的表格（卷面上的表格识别成 Markdown 表格后，这里排成真表格） */
.block-preview .block-table-wrap { overflow-x: auto; margin: 4px 0; }
.block-preview table.block-table {
  border-collapse: collapse; font-size: 12px; line-height: 1.6;
}
.block-preview table.block-table th,
.block-preview table.block-table td {
  border: 1px solid #a8b0bd; padding: 2px 7px; text-align: left; vertical-align: top;
}
.block-preview table.block-table th { background: #f2f5fa; font-weight: 600; }
.block-preview .block-preview-text { white-space: normal; }

.q-actions { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; }
.q-extra { padding: 0 8px 8px; }
.q-extra summary { font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px 0; }
.q-extra .extra-label { font-size: 11px; color: #9aa4b2; margin: 6px 0 2px; display: block; }

/* ---------- 答案 / 解析：和题干一样能放文字、公式、配图 ---------- */
.qa-section { margin: 4px 0 10px; }
.qa-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.qa-title { font-size: 12px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.qa-tools { display: flex; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.qa-blocks { display: flex; flex-direction: column; gap: 7px; align-items: stretch; }
.qa-blocks:empty { display: none; }
.qa-blocks > .block { flex: 0 0 auto; }
/* ---------- 「编辑图像」弹窗：拉平 / 裁剪转正 两个标签 ---------- */
.edit-tabs { display: flex; gap: 4px; margin: 0 0 10px; border-bottom: 1px solid var(--line); }
.edit-tab {
  border: none; background: transparent; cursor: pointer; font-size: 13px;
  padding: 7px 12px; color: var(--muted); margin-bottom: -1px;
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.edit-tab:hover { color: var(--text); background: #f4f7fc; }
.edit-tab.active { color: var(--brand); font-weight: 600; border-bottom-color: var(--brand); }
.edit-pane { display: block; }
/* 切到另一个标签时整页藏起来：别用 display:flex 之类，那样 [hidden] 盖不住 */
.edit-pane[hidden] { display: none; }
/* 底栏里的两组按钮，按当前标签显示其中一组 */
/* ---------- 擦除（涂白）：拖框把不要的东西擦成白的 ---------- */
.erase-viewport {
  position: relative;
  display: block;
  margin: 0 auto;
  text-align: center;
  touch-action: none;
}
#er-canvas {
  display: inline-block;
  max-width: 100%;
  max-height: 56vh;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}
.erase-marquee {
  position: absolute;
  border: 1px dashed #2563eb;
  background: rgba(37, 99, 235, .16);
  pointer-events: none;
  border-radius: 2px;
}
.erase-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.erase-bar #er-state { margin-right: auto; }
.erase-mode { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.erase-mode select { width: auto; }
.erase-thr { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.erase-thr input[type="range"] { width: 132px; }
.erase-thr #er-thr-val { min-width: 34px; color: var(--text); font-variant-numeric: tabular-nums; }
.erase-thr.off { opacity: .4; }
.erase-thr.off #er-thr-val { color: var(--muted); }

.ei-tools { display: inline-flex; align-items: center; gap: 6px; }
.ei-tools.off { display: none; }
.ei-enhance { margin: 0 8px 0 0; white-space: nowrap; }
/* 这个弹窗底栏按钮多：窄窗口让它换行，中间的提示语可以先缩 */
.modal.edit-image-modal .modal-foot { flex-wrap: wrap; row-gap: 8px; }
.modal-foot #ei-hint { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 拍照矫正：四个角拖动 ---------- */
/* 视口固定大小，里面的画布可以缩放 / 拖动，这样放大以后四个角也都能拖到 */
.deskew-viewport {
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  background: #232a35;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
}
.deskew-viewport.panning { cursor: grabbing; }
.deskew-zoombar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.deskew-zoombar .btn { min-width: 34px; }
.deskew-wrap {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  background: #fff;
  touch-action: none;
}
.deskew-wrap img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.deskew-quad { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.deskew-handle {
  position: absolute;
  width: 18px; height: 18px;
  /* 居中交给下面的 transform 做：这里再用负外边距会多挪半个把手，
     结果蓝点画在真正位置的左上方一点点（裁剪框的把手同理） */
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: grab;
  touch-action: none;
}
.deskew-handle:hover { background: #1d4ed8; }
.deskew-handle:active { cursor: grabbing; }
/* 放大时角点不能跟着变大，否则精修时挡住鼠标 */
.deskew-handle { transform: translate(-50%, -50%); }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 660px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .3);
}
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 14px; display: flex; align-items: center;
}
.modal-head .modal-close {
  margin-left: auto; border: none; background: transparent; font-size: 17px;
  color: var(--muted); cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.modal-head .modal-max {
  margin-left: auto; border: none; background: transparent; font-size: 14px;
  color: var(--muted); cursor: pointer; line-height: 1; padding: 3px 7px; border-radius: 6px;
}
.modal-head .modal-max:hover { background: #eef1f6; color: var(--text); }
.modal-head .modal-max + .modal-close { margin-left: 4px; }
/* 最大化：把整块遮罩铺满（GGB 画板画起来才够地方）。
   宽度必须带上 .wide 一起写，不然会被上面 .modal.wide 的 1000px 压回去（一样重、它在后）。 */
.modal.max,
.modal.wide.max {
  width: 100%; max-width: none;
  height: 100%; max-height: none;
}
.modal.wide.max .ggb-frame-box iframe { height: calc(100vh - 250px); }
/* 画板最大化：不再靠「100vh 减掉一个估出来的数」算高度——上面那段说明文字一换行、
   窗口一变，算出来的数就对不上，画板下半截直接被切掉。
   改成：工具栏自动高，下面画布自己撑满剩下的地方。 */
.modal.ggb-modal.max .modal-body {
  /* flex:1 是这里的命根子：少了它，body 只按内容高，画板被顶在上面、下面空一大片，
     还整块盖住后面的页面（用户看到的就是「下面一大半挡住了所有页面」） */
  flex: 1 1 auto; min-height: 0;
  padding: 8px; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal.ggb-modal.max .ggb-panes { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.modal.ggb-modal.max .ggb-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.modal.ggb-modal.max .ggb-wrap { flex: 1 1 auto; min-height: 0; }
/* 让 iframe 靠 flex 长高，别靠 height:100%（父级没写死高度的时候百分比不一定算得出来） */
.modal.ggb-modal.max .ggb-frame-box { display: flex; flex-direction: column; min-height: 0; }
.modal.ggb-modal.max .ggb-frame-box iframe { flex: 1 1 auto; height: auto; min-height: 0; }
.modal.ggb-modal.max .ggb-web-stage { flex: 1 1 auto; min-height: 0; }
.modal-head .modal-close:hover { background: #eef1f6; color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
/* 《使用说明》弹窗（打开网页先弹的那份，也是右上角「帮助」里的内容）：三条提示 + 三张步骤图 */
.usage-list { margin: 4px 0 10px; padding-left: 22px; }
.usage-list li { margin: 0 0 5px; line-height: 1.6; }
.usage-img {
  display: block; max-width: 100%; margin: 6px 0 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
}

.field { margin-bottom: 13px; position: relative; }
.field > label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.6; }
.field input[type=text], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 7px 9px; font-size: 12.5px;
  border: 1px solid var(--line-strong); border-radius: 7px; background: #fff;
  font-family: inherit; color: var(--text);
}
.field textarea { min-height: 70px; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1 1 0; }
.checkbox-row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; margin-bottom: 9px; }
/* ---------- 设置里的「题型设置」：拖动排序的列表 ---------- */
.type-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.type-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.type-row.dragging { opacity: .45; }
.type-row.drop-here { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(37,99,235,.16); }
.type-grip { cursor: grab; color: var(--muted); font-size: 15px; user-select: none; line-height: 1; }
.type-grip:active { cursor: grabbing; }
.type-row .type-name {
  flex: 1 1 auto; min-width: 0; border: none; background: transparent;
  font-size: 12.5px; color: var(--text); padding: 3px 2px;
}
.type-row .type-name:focus { outline: none; background: #f4f7fc; border-radius: 5px; }
.type-add { display: flex; gap: 6px; align-items: center; }
.type-add input { flex: 1 1 auto; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-title {
  font-size: 12px; font-weight: 700; color: var(--brand);
  margin: 4px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}

/* 设置里的分类（「入学测设置」这种）：同一类卷子的设置装在一块，外面套个框、
   左边一道色条。以后加「真题集设置」「真题卷设置」，照抄一块 .set-group 就行。 */
.set-group {
  margin: 14px 0 6px; padding: 8px 10px 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 8px; background: #fbfcfe;
}
.set-group-head { font-size: 13px; font-weight: 700; color: var(--brand); margin: 0 0 3px; }
.set-group-tip { margin: 0 0 4px; }
.set-group > .section-title { margin: 12px 0 8px; color: var(--text); }
.set-group > .section-title:first-of-type { margin-top: 8px; }
.crop-thumb {
  border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc;
  padding: 8px; text-align: center; max-height: 200px; overflow: auto;
}
.crop-thumb img { max-width: 100%; display: block; margin: 0 auto; }
.formula-preview {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 10px; min-height: 60px; overflow-x: auto; font-size: 15px;
}
.formula-preview .placeholder { color: #b4bcc8; font-size: 12px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 9px 14px; border-radius: 8px;
  font-size: 12.5px; box-shadow: 0 10px 26px rgba(16,24,40,.28);
  animation: toast-in .2s ease-out;
  max-width: 380px; line-height: 1.6;
}
.toast.error { background: #b91c1c; }
.toast.ok { background: #047857; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.lib-warning {
  flex: 0 0 auto;
  background: #fff4e0; color: #92400e; border-bottom: 1px solid #fbd9a5;
  padding: 8px 16px; font-size: 12.5px;
}

.guide-box {
  margin-top: 8px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.9;
}
.guide-box .steps-title { font-weight: 600; margin-bottom: 2px; }
.guide-box ol, .guide-box ul { margin: 4px 0 0; padding-left: 20px; }
.guide-box li { margin-bottom: 4px; }
.guide-box a { color: var(--brand); text-decoration: none; }
.guide-box a:hover { text-decoration: underline; }
.guide-box code {
  background: #eef2f8; padding: 1px 4px; border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 11.5px;
}

/* 视觉模型：测试 / 列出可用模型 */
.vision-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.model-picks {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 190px; overflow: auto; margin-top: 6px;
}
.model-pick {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px; line-height: 1.5;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-pick:hover { border-color: var(--brand); color: var(--brand); }
.model-pick.good { border-color: #a7d3b8; background: #f2fbf5; color: #046c4e; font-weight: 600; }

.measure-box {
  position: fixed; left: -10000px; top: 0;
  font-size: 16px; line-height: normal; visibility: hidden;
}

/* ---------- 图形处理弹窗 ---------- */
.fig-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.fig-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 6px; }

/* 图形块下面的三个切换按钮 */
.fig-switch { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 8px 4px; align-items: center; }
.fig-switch-btn {
  font: inherit; font-size: 11.5px; padding: 3px 11px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 20px;
  transition: background .12s, border-color .12s, color .12s;
}
.fig-switch-btn:hover { border-color: var(--brand); color: var(--brand); }
.fig-switch-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.fig-switch-btn.ghost { margin-left: auto; border-style: dashed; }
.fig-switch-btn.ghost:hover { border-style: solid; }
.fig-mode {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; font: inherit; transition: border-color .12s, background .12s;
}
.fig-mode:hover { border-color: var(--brand); }
.fig-mode.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.fig-mode-title { font-size: 13px; font-weight: 600; color: var(--text); }
.fig-mode-tip { font-size: 11px; color: var(--muted); line-height: 1.45; }
.fig-mode.active .fig-mode-title { color: var(--brand-dark); }
.fig-mode.active .fig-mode-tip { color: var(--brand); }
.fig-exports { margin-top: 12px; }
@media (max-width: 900px) { .fig-modes, .fig-pick { grid-template-columns: 1fr; } }

/* ---------- 图形重绘 ---------- */
.q-tool.redraw-btn { width: auto; padding: 0 7px; font-size: 11px; }
.block .redraw-note {
  margin: 0 8px 8px; padding: 5px 8px; border-radius: 6px;
  background: #f5f7fa; color: var(--muted); font-size: 11.5px; line-height: 1.5;
}
.block .redraw-note.on { background: var(--ok-soft); color: var(--ok); }
.block .redraw-note.warn { background: #fef3e2; color: var(--warn); }

.redraw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.redraw-side { min-width: 0; }
.redraw-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.redraw-preview {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  height: 260px; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 6px;
}
.redraw-preview img, .redraw-preview svg { max-width: 100%; max-height: 100%; }
.redraw-preview img { object-fit: contain; }
.redraw-preview svg { width: auto; height: auto; }
.redraw-empty { color: var(--muted); font-size: 12px; }

.redraw-stats { margin-top: 10px; font-size: 12.5px; color: var(--text); }
.redraw-note-box { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.redraw-stats:empty, .redraw-note-box:empty { display: none; }
#rd-export:not(:empty) { margin-top: 10px; }

.redraw-exports { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.redraw-export {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; font: inherit;
}
.redraw-export:hover { border-color: var(--brand); background: var(--brand-soft); }
.redraw-export-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.redraw-export-desc { font-size: 11px; color: var(--muted); }

@media (max-width: 900px) {
  .redraw-grid, .redraw-exports { grid-template-columns: 1fr; }
}

@media (max-width: 1280px) {
  .layout { grid-template-columns: 180px minmax(360px, 1fr) 340px; }
}

/* ---------- 右侧编辑栏：可拖宽、可折叠 ---------- */
.content-panel { position: relative; }
.pages-panel { position: relative; }
/* 「页面」栏的分隔条在它自己的右边 */
.panel-resizer.right { left: auto; right: -3px; }
.panel-resizer.right::after { left: auto; right: 3px; }

/* 「页面」栏收起后只剩一条窄边，点 › 再展开 */
body.pages-collapsed .pages-panel .panel-head > span,
body.pages-collapsed .pages-panel .pages,
body.pages-collapsed .pages-panel .panel-foot { display: none; }
body.pages-collapsed .pages-panel .panel-head { justify-content: center; padding: 6px 2px; }
body.pages-collapsed .pages-panel .panel-head .muted { display: none; }
body.pages-collapsed .panel-resizer.right { right: -5px; }
.panel-resizer {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 9px;
  cursor: col-resize; z-index: 6; border-radius: 4px;
}
.panel-resizer::after {
  content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 46px; border-radius: 3px; background: var(--line);
  transition: background .15s;
}
.panel-resizer:hover::after, .panel-resizer:focus::after, body.resizing .panel-resizer::after {
  background: var(--brand); height: 72px;
}
.panel-resizer:focus { outline: 2px solid var(--brand-soft); outline-offset: -2px; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { cursor: col-resize !important; }

/* 折叠后只剩一条窄边，点 › 再展开 */
body.q-collapsed .content-panel .questions,
body.q-collapsed .content-panel .panel-head > span,
body.q-collapsed .content-panel .panel-head-actions .btn:not(#btn-collapse-qpanel) { display: none; }
body.q-collapsed .content-panel .panel-head { justify-content: center; padding: 6px 2px; }
body.q-collapsed .panel-resizer { left: -5px; }

/* ---------- 内容块：可折叠 + 输入框自动长高 ---------- */
.block-head { cursor: pointer; user-select: none; }
.block-head .q-tool.fold { font-size: 11px; padding: 0 4px; color: var(--muted); }
.block-summary { display: none; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.block.collapsed .block-summary { display: none; }
.block.collapsed .block-src { display: none; }
.block.collapsed .block-body { display: none; }
.block.collapsed { background: #f9fbfe; }
.block-body { display: block; }

.block-input { overflow: hidden; }

/* 识别出来的文字，下面挂一份原图，方便逐字核对 */
.block-source { border-top: 1px dashed var(--line); }
.block-source > summary {
  font-size: 11.5px; color: var(--muted); cursor: pointer; padding: 5px 9px;
  list-style: none;
}
.block-source > summary::-webkit-details-marker { display: none; }
.block-source > summary::before { content: '▸ '; color: #9aa4b2; }
.block-source[open] > summary::before { content: '▾ '; }
.block-source > summary:hover { color: var(--brand); }
.block-source > img { display: block; max-width: 100%; padding: 6px 9px 10px; }

/* ---------- 对照原图弹窗 ---------- */
.modal.wide { width: 1000px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.compare-col { min-width: 0; }
.compare-label { font-size: 11.5px; color: #9aa4b2; margin-bottom: 4px; }
.compare-img {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 6px; max-height: 60vh; overflow: auto;
}
.compare-img img { display: block; max-width: 100%; }
#cmp-text { border: 1px solid var(--line); border-radius: 8px; min-height: 300px; }

/* ---------- 试卷整体预览 ---------- */
/* 一张「纸」把导出的样子摆出来：字体、行距、题号和 Word 里对得上才方便校对 */
.paper-body {
  background: #eef1f6; border-radius: 10px; padding: 14px;
  max-height: 62vh; overflow: auto;
}
.paper-sheet {
  background: #fff; margin: 0 auto; max-width: 720px; padding: 30px 34px 40px;
  border-radius: 3px; box-shadow: 0 2px 10px rgba(16, 24, 40, .13);
  font-family: "SimSun", "宋体", "Songti SC", serif; font-size: 14px;
  line-height: 1.8; color: #111; word-break: break-word;
}
.paper-sheet .pp-title { text-align: center; font-size: 19px; font-weight: 700; margin: 0 0 16px; }
.paper-sheet .pp-line { margin: 0 0 4px; }
/* 一行摆好几个选项：按四等分格切开，第二列（B/D）落在同一竖线上 */
.paper-sheet .pp-cols { display: flex; align-items: baseline; }
.paper-sheet .pp-cols .pp-cell { min-width: 0; }
.paper-sheet .pp-center { text-align: center; }
.paper-sheet .pp-num { font-weight: 700; margin-right: 4px; }
.paper-sheet .pp-click { cursor: pointer; border-radius: 3px; }
.paper-sheet .pp-click:hover { background: #eef4ff; }
.paper-sheet .pp-num[title] { cursor: pointer; color: #1d4ed8; }
.paper-sheet .pp-num[title]:hover { text-decoration: underline; }
.paper-sheet .pp-line svg { vertical-align: middle; max-width: 100%; }
.paper-sheet img.pp-img { display: block; max-width: 100%; margin: 6px 0; }
.paper-sheet .pp-table-wrap { overflow-x: auto; margin: 6px 0; }
.paper-sheet table.pp-table { border-collapse: collapse; width: auto; max-width: 100%; }
.paper-sheet table.pp-table th,
.paper-sheet table.pp-table td {
  border: 1px solid #8a8a8a; padding: 3px 7px; font-size: 13px; text-align: left;
}
.paper-sheet table.pp-table th { background: #f4f6fa; font-weight: 600; }
.paper-sheet .pp-sep {
  margin: 20px 0 14px; padding-top: 12px; border-top: 1px dashed #cfd6e0;
  text-align: center; font-size: 12px; color: #9aa4b2;
}
.paper-sheet .pp-subtitle { text-align: center; font-size: 15px; font-weight: 700; margin: 0 0 12px; }
/* 题型小标题（一、选择题…）：模板里 #题目标题# 那一行，预览也照着排一行 */
.paper-sheet .pp-sechead { font-weight: 700; margin: 10px 0 4px; }

/* 公式插入条：点一下就插到光标处，不用自己敲 LaTeX */
.formula-bar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  margin: 0 0 6px; padding: 5px 6px;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
}
.fs-btn {
  font: inherit; font-size: 12px; line-height: 1;
  padding: 4px 6px; min-width: 26px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #334155;
  cursor: pointer;
}
.fs-btn:hover { border-color: var(--brand); color: var(--brand); background: #f5f8ff; }
.fs-btn:active { transform: translateY(1px); }
.fs-hint { font-size: 11px; color: #9aa4b2; margin-left: auto; }
.formula-preview {
  margin-top: 6px; padding: 6px 9px; min-height: 24px;
  border: 1px dashed var(--line); border-radius: 8px; background: #fff;
  font-size: 13px; line-height: 1.9; overflow-wrap: anywhere;
}
.formula-preview:empty { display: none; }

/* ---------- 图片「更多」：透明背景 / 裁剪 / 标注 ---------- */
.img-tools-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.img-tool-btn {
  font: inherit; font-size: 12.5px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #334155; cursor: pointer;
}
.img-tool-btn:hover { border-color: var(--brand); color: var(--brand); }
.img-tool-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.img-tools-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.img-tools-row .it-label { font-size: 11.5px; color: #9aa4b2; margin-left: 6px; }
.anno-color {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0;
}
.anno-color:hover { box-shadow: 0 0 0 2px var(--brand); }
.anno-width {
  font: inherit; font-size: 12px; padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #334155; cursor: pointer;
}
.anno-width:hover { border-color: var(--brand); color: var(--brand); }
.img-tools-stage {
  border: 1px solid var(--line); border-radius: 8px; background: #f8fafc;
  padding: 6px; max-height: 52vh; overflow: auto; text-align: center;
}
.img-tools-stage canvas {
  max-width: 100%; cursor: crosshair; touch-action: none;
  background-image:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.img-tools-row input[type=range] { width: 160px; }
.img-tools-row .it-val {
  font-size: 12px; color: #334155; min-width: 22px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.img-tools-row .it-note { font-size: 11.5px; color: #9aa4b2; }
.img-tools-dead {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line);
}
.img-tools-dead .it-label { font-size: 11.5px; color: #9aa4b2; }

/* ---------- GGB 绘制：AI-GGB 画板 + 浮在旁边的原图 ---------- */
/* 取回来的图是抠过底的，垫棋盘格才看得出来哪块透明 */
.ggb-checker {
  background-image:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
/* 整条工具栏就一行：说明 + 标签 + 网页操作键 + ⋯（零碎设置收进那个菜单） */
.ggb-bar { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; margin-bottom: 8px; }
.ggb-bar .ggb-tabs { flex: 1 1 auto; min-width: 110px; }
.ggb-more { position: relative; flex: 0 0 auto; }
.ggb-more-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 200px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .18);
  display: flex; flex-direction: column; gap: 2px;
}
.ggb-more-menu[hidden] { display: none; }
.ggb-more-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; color: var(--text); cursor: pointer;
  font-size: 12.5px; font-family: inherit; text-align: left;
  padding: 6px 8px; border-radius: 6px; margin: 0; white-space: nowrap;
}
.ggb-more-item:hover { background: #f1f5f9; }
.ggb-more-item input[type=checkbox] { margin: 0; }
.ggb-bar .ggb-hint {
  flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ggb-bar .checkbox-row { margin-bottom: 0; flex: 0 0 auto; white-space: nowrap; }
/* 用法说明：默认收起来，点「说明」才展开。以前这一大段一直摊在最上面，把画板挤没了 */
.ggb-help {
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
  padding: 10px 12px; margin-bottom: 8px;
}
.ggb-help[hidden] { display: none; }
.ggb-help p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.85; color: #475569; }
.ggb-help p:last-child { margin-bottom: 0; }
.ggb-help b { color: var(--text); }
.ggb-ai-box {
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
  padding: 10px 12px; margin-bottom: 8px;
}
.ggb-ai-box .ggb-ai-sub { font-weight: 400; color: #9aa4b2; }
.ggb-ai-note { margin: 6px 0 0; font-size: 12px; color: #475569; min-height: 16px; line-height: 1.7; }
.ggb-ai-note:empty { display: none; }
.ggb-ai-box .vision-actions { margin-top: 8px; }
/* ---------- 弹窗小窗化 ---------- */
/* GGB 画板这种要来回看的，缩成右下角一个小窗最合适：点回去画板上画到一半的东西还在
   （只是换了一组 CSS，iframe 一直没被销毁）。
   遮罩这时候要「透明 + 不吃点击」，不然背后整个页面都点不动。 */
.modal-mask.dock {
  background: transparent;
  pointer-events: none;
  padding: 0;
}
.modal.dock,
.modal.wide.dock {
  position: fixed; right: 16px; bottom: 16px; left: auto; top: auto;
  width: 520px; height: 400px;
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px);
  margin: 0; pointer-events: auto;
  box-shadow: 0 16px 44px rgba(16, 24, 40, .38);
}
/* 小窗里那点地方就别摆说明了，把画面全留给画板 */
.modal.dock .modal-body {
  flex: 1 1 auto; min-height: 0;
  padding: 6px; overflow: hidden; display: flex; flex-direction: column;
}
.modal.dock .ggb-help,
.modal.dock .ggb-ai-box,
.modal.dock .ggb-result { display: none; }
/* 标签栏在小窗里留着：缩成小窗还得能换标签 */
.modal.dock .ggb-bar { margin-bottom: 4px; }
.modal.dock .ggb-bar .ggb-hint { display: none; }
.modal.dock .ggb-panes { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.modal.dock .ggb-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.modal.dock .ggb-wrap { flex: 1 1 auto; min-height: 0; }
.modal.dock .ggb-frame-box { display: flex; flex-direction: column; min-height: 0; }
.modal.dock .ggb-frame-box iframe { flex: 1 1 auto; height: auto; min-height: 0; }
.modal.dock .ggb-web-stage { flex: 1 1 auto; min-height: 0; }
.modal.dock .ggb-web-desc { display: none; }
.modal.dock .ggb-tab-io { padding: 3px 8px; font-size: 11.5px; }
.modal.dock .modal-foot { padding: 6px 8px; }
.modal.dock .modal-foot .btn { font-size: 12px; padding: 5px 10px; }
.modal.dock .modal-head { padding: 6px 8px 6px 12px; font-size: 12.5px; cursor: move; touch-action: none; }
/* 小窗右下角那根把手：按住能改大小 */
.modal-dock-grip {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; touch-action: none;
}
.modal-dock-grip::after {
  content: ''; position: absolute; right: 3px; bottom: 3px; width: 9px; height: 9px;
  border-right: 2px solid rgba(148, 163, 184, .85);
  border-bottom: 2px solid rgba(148, 163, 184, .85);
}
.modal-head .modal-dock {
  margin-left: auto; border: none; background: transparent; font-size: 12px;
  color: var(--muted); cursor: pointer; line-height: 1; padding: 3px 7px; border-radius: 6px;
}
.modal-head .modal-dock:hover { background: #eef1f6; color: var(--text); }
.modal-head .modal-dock + .modal-max { margin-left: 4px; }

/* ---------- GGB 绘制弹窗上的标签栏 ---------- */
/* 标签这一段自己横向滚：标签再多也不会把右边的操作键挤走
   （注意：.ggb-tab-row 是上面「标签设置」列表里的一行，别拿来当容器用） */
.ggb-tabs {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden;
}
.ggb-tabs::-webkit-scrollbar { height: 5px; }
.ggb-zoom { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.ggb-zoom-val {
  font-size: 11.5px; color: var(--muted); min-width: 34px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.ggb-web-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.ggb-web-actions:empty { display: none; }
.ggb-tab-io {
  flex: 0 0 auto; border: 1px solid var(--line-strong); background: #fff; color: #475569;
  font-size: 12px; font-family: inherit; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  white-space: nowrap;
}
.ggb-tab-io:hover { background: #f1f5f9; }
.ggb-tab-io.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.ggb-tab-io.primary:hover { filter: brightness(1.08); background: var(--brand); }
.ggb-tab {
  flex: 0 0 auto; border: 1px solid var(--line-strong); background: #fff; color: #475569;
  font-size: 12px; font-family: inherit; padding: 4px 12px; border-radius: 999px; cursor: pointer;
}
.ggb-tab:hover { background: #f1f5f9; }
.ggb-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.ggb-tab-setup-btn {
  flex: 0 0 auto; border: 1px solid var(--line-strong); background: #fff;
  color: #475569; font-size: 12px; font-family: inherit; padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.ggb-tab-setup-btn:hover { background: #f1f5f9; }
.ggb-pane[hidden] { display: none; }
.ggb-tab-setup {
  border: 1px solid var(--line); border-radius: 8px; background: #f8fafc;
  padding: 10px 12px; margin: 0 0 8px;
}
.ggb-tab-setup[hidden] { display: none; }
.ggb-tab-setup-head {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.ggb-tab-setup-head span { flex: 1 1 auto; min-width: 0; line-height: 1.6; }
.ggb-tab-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  border-bottom: 1px dashed var(--line); font-size: 12.5px;
}
.ggb-tab-row:last-of-type { border-bottom: 0; }
.ggb-tab-row input[type=checkbox] { margin: 0; }
.ggb-tab-row-name { flex: 0 0 auto; font-weight: 600; }
.ggb-tab-row-url {
  flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ggb-tab-del {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 6px; border-radius: 5px;
}
.ggb-tab-del:hover { background: #fee2e2; color: var(--danger); }
.ggb-tab-add-row { display: flex; gap: 6px; margin-top: 8px; }
.ggb-tab-add-row input {
  flex: 1 1 auto; min-width: 0; padding: 5px 8px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--text);
}
.ggb-tab-add-row input.ggb-tab-new-name { flex: 0 0 120px; }
/* 网页版 AI：只剩一行说明（完整原因挪进上面的「说明」里了） */
/* 完整原因在「说明」里，也在「内嵌」按钮的悬停提示里 */
.ggb-web-desc {
  margin: 0 0 6px; font-size: 11.5px; line-height: 1.6; color: var(--muted);
}
.ggb-web-desc[hidden] { display: none; }
.ggb-web-desc code {
  background: #eef2f7; border-radius: 4px; padding: 1px 4px;
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 11.5px;
}
/* 嵌进来的那块：iframe 跨域碰不到里面，缩放靠整块 transform:scale，
   所以要有个 overflow:hidden 的外框把放大出来的部分裁住 */
.ggb-web-stage {
  position: relative; overflow: hidden;
  flex: 1 1 auto; min-height: 320px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.ggb-web-stage[hidden] { display: none; }
.ggb-web-frame {
  display: block; position: absolute; left: 0; top: 0;
  width: 100%; height: 100%; border: 0; background: #fff;
}

.ggb-wrap { position: relative; display: flex; }
.ggb-frame-box {
  flex: 1 1 auto; min-width: 0; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: #fff;
}
.ggb-frame-box iframe { display: block; width: 100%; height: 60vh; min-height: 420px; border: 0; }
.ggb-float {
  position: absolute; top: 12px; right: 12px; width: 262px; z-index: 3;
  max-width: calc(100% - 24px);
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .97);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .22); overflow: hidden;
}
.ggb-float-head {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  background: #f1f5f9; cursor: move; touch-action: none;
}
.ggb-float-title {
  flex: 1 1 auto; min-width: 0; font-size: 11.5px; color: #64748b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ggb-float-min {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: #64748b; font-size: 12px; line-height: 1; padding: 3px 6px; border-radius: 5px;
}
.ggb-float-min:hover { background: #e2e8f0; color: var(--text); }
/* 关掉原图浮窗的那个叉 */
.ggb-float-x { font-size: 11px; padding: 3px 5px; }
.ggb-float-x:hover { background: #fee2e2; color: #b91c1c; }
/* 大小 / 透明：两行三列，别把 240px 宽的小窗挤爆 */
.ggb-float-ctl {
  display: grid; grid-template-columns: auto 1fr auto; gap: 3px 6px;
  align-items: center; padding: 6px 8px;
  border-bottom: 1px solid var(--line); background: #f8fafc;
}
.ggb-float-ctl input[type=range] { min-width: 0; width: 100%; }
.ggb-float-ctl .ggb-float-label { font-size: 11px; color: #94a3b8; }
.ggb-float-ctl .ggb-float-val {
  font-size: 11px; color: #475569; min-width: 24px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.ggb-float { transition: opacity .12s linear; }
.ggb-float-body {
  padding: 6px; max-height: 56vh; overflow: auto; text-align: center;
  background-image:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
/* 宽度由「大小」滑块直接给（inline style），这里别再用 max-width 卡着 */
.ggb-float-body img { display: block; height: auto; margin: 0 auto; }
/* 题目浮窗里的公式：交给 MathJax 画成正常样子，所以别再按等宽代码那样排版，
   只要给它一条能横向滚的容器（公式长了不会把浮窗撑破） */
.ggb-qfloat-body .q-line.formula {
  font-family: inherit; font-size: inherit;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 7px; overflow-x: auto;
}
.ggb-qfloat-body .q-line.formula svg { max-width: none; }

/* 题目文字悬浮窗：一边看题一边画。
   默认摆在原图小窗左边（右边是 AI 对话区，摆过去就看不见了），能拖、能收。 */
.ggb-qfloat {
  position: absolute; top: 12px; right: 286px; width: 300px; z-index: 3;
  max-width: calc(100% - 24px);
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .97);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .22); overflow: hidden;
}
.ggb-qfloat[hidden] { display: none; }
.ggb-qfloat-head {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  background: #eef6ff; cursor: move; touch-action: none;
}
.ggb-qfloat-title {
  flex: 1 1 auto; min-width: 0; font-size: 11.5px; color: #475569; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ggb-float-txt {
  flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  color: #64748b; font-size: 12px; line-height: 1; padding: 3px 6px; border-radius: 5px;
}
.ggb-float-txt:hover { background: #e2e8f0; color: var(--text); }
.ggb-float-txt.on { background: var(--brand); color: #fff; }
.ggb-qfloat-body {
  padding: 8px 10px; max-height: 52vh; overflow: auto; background: #fff;
  font-size: 12.5px; line-height: 1.75; color: var(--text);
}
.ggb-qfloat-body .q-line { margin: 0 0 6px; white-space: pre-wrap; word-break: break-word; }
.ggb-qfloat-body .q-line.fig { color: var(--muted); font-size: 12px; }
.ggb-qfloat-body .q-meta { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.ggb-qfloat-body .q-empty { color: var(--muted); }

.ggb-result {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #f8fafc;
}
.ggb-result img { max-height: 90px; max-width: 220px; }
.ggb-shot-info { font-size: 12px; color: var(--muted); }
.fig-switch-btn.ggb { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.fig-switch-btn.ggb:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 勾选要插入的图形 ---------- */
.fig-pick-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.fig-pick-bar .muted { font-size: 11.5px; }
.fig-pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.fig-pick-item {
  display: flex; flex-direction: column; gap: 5px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: #fbfcfe; cursor: pointer;
}
.fig-pick-item:hover { border-color: var(--brand); }
.fig-pick-item img { max-width: 100%; max-height: 190px; display: block; margin: 0 auto; background: #fff; }

@media (max-width: 900px) {
  .compare-grid { grid-template-columns: 1fr; }
  .panel-resizer { display: none; }
}

/* 整道题也能收起来 */
.q-head { cursor: pointer; }
.q-head .q-tool.fold { font-size: 11px; padding: 0 4px; color: var(--muted); }
.question-card.collapsed .q-blocks,
.question-card.collapsed .q-actions,
.question-card.collapsed .q-extra { display: none; }
.question-card.collapsed { background: #f9fbfe; }

/* 整页识别里的「手动分栏」：拖线定卷头 + 栏缝（栏缝可以拉斜，给拍歪的照片用） */
.col-editor-wrap {
  border: 1px solid var(--line); border-radius: 8px; background: #f8fafc;
  padding: 6px; max-height: 320px; overflow: auto; text-align: center; margin-bottom: 8px;
}
.col-editor-wrap canvas {
  max-width: 100%; background: #fff; cursor: crosshair; touch-action: none;
  box-shadow: 0 0 0 1px var(--line);
}

/* 设置里的 Word 模板列表：一行一个模板，点一行就换一个，右边 ✕ 删掉 */
.tpl-list { margin: 6px 0 2px; display: flex; flex-direction: column; gap: 4px; }
.tpl-list .hint { margin: 0; }
.tpl-group-head {
  margin: 8px 0 2px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--muted); text-transform: none;
}
.tpl-list > .tpl-group-head:first-child { margin-top: 0; }
.tpl-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 3px 6px;
}
.tpl-item.active { border-color: var(--brand); background: #eff6ff; }
.tpl-item .tpl-pick {
  flex: 1 1 auto; min-width: 0; text-align: left;
  border: 0; background: transparent; cursor: pointer; padding: 3px 2px;
  font: inherit; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tpl-item .tpl-pick:hover { color: var(--brand); }
.tpl-item .tpl-mark { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
.tpl-item.active .tpl-mark { color: var(--brand); }
.tpl-item .tpl-del {
  flex: 0 0 auto; width: 18px; height: 18px; padding: 0; line-height: 16px;
  border: 1px solid var(--line); border-radius: 50%; background: #fff;
  color: #ef4444; font-size: 10px; cursor: pointer;
}
.tpl-item .tpl-del:hover { background: #fef2f2; border-color: #ef4444; }
/* 右边那个 ⬇：把模板存回自己电脑（跟 ✕ 一样大小，别把行撑高） */
.tpl-item .tpl-dl {
  flex: 0 0 auto; width: 18px; height: 18px; padding: 0; line-height: 16px;
  border: 1px solid var(--line); border-radius: 50%; background: #fff;
  color: var(--brand); font-size: 10px; cursor: pointer;
}
.tpl-item .tpl-dl:hover { background: #eff6ff; border-color: var(--brand); }
/* 设置顶上那行「站点自带模板装好没有」 */
.builtin-tpl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 10px; }
.builtin-tpl-row .hint { margin: 0; flex: 1 1 240px; }
/* 「这次导出用模板吗？」那个弹窗里整行都能点：点一行 = 选中它（导出还得按「确认导出」） */
#tpl-ask-list .tpl-item { cursor: pointer; }
#tpl-ask-list .tpl-item:hover { border-color: var(--brand); }

/* 导出弹窗（「导出试卷」/「导出答案」）：一行「标题」，一行「模板」，下面模板列表 + 导入按钮 */
.exp-row { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.exp-row .exp-label { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.exp-title-input {
  flex: 1 1 auto; min-width: 0; padding: 5px 8px; font: inherit; color: inherit;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.exp-title-input:focus { outline: none; border-color: var(--brand); }
.exp-tpl-bar { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; }

/* 模板里认出的 #…# 占位符：一行小字 + 小圆角标签，不占地方 */
.tpl-slots-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  margin: 2px 0 4px; font-size: 11px; color: var(--muted); }
.tpl-slots-row.none { color: #9aa1ab; }
.tpl-slots-row .tpl-chip {
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px;
  background: #f8fafc; color: #334155; font-family: var(--mono, monospace); font-size: 11px;
}
.tpl-slots-row .tpl-chip-to { color: #9aa1ab; }

/* 中间的「试卷预览」面板：卷面区那块地方拿来摆套完模板的样子 */
.doc-preview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: #eef1f6; }
.doc-preview-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line);
}
.doc-preview-title { font-weight: 600; }
.doc-preview #doc-preview-hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-preview #doc-preview-zoom { font-size: 12px; min-width: 38px; text-align: center; }
.doc-preview-head .btn.small { padding: 2px 8px; }
/* 预览照哪个模板画：自动 / 不用模板 / 点名某一个（两组模板分块列出来） */
.tpl-pick {
  max-width: 190px; font: inherit; font-size: 12px; padding: 2px 4px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: inherit;
}
.paper-tpl-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #fff; border-bottom: 1px solid var(--line);
}
.paper-tpl-bar .muted { font-size: 12px; }
.doc-preview .paper-body { flex: 1 1 auto; overflow: auto; max-height: none; }
.canvas-panel { position: relative; }

/* 从 Word 导入的行内公式图：跟着文字走，别把行高撑开 */
.inline-img { vertical-align: middle; margin: 0 1px; }

/* 这一格没有功能按钮时，小「?」钉在右上角（跟标题同一行），不单独占一行 */
.field > .hint-toggle { position: absolute; top: 0; right: 0; margin: 0; }
/* 塞在功能按钮那一行里的小「?」：跟按钮对齐 */
.vision-actions .hint-toggle { margin: 0 0 0 2px; }

/* 设置里的说明太长太占地方：收成一个小「?」，悬停看全文，点一下展开 */
.hint-toggle {
  width: 18px; height: 18px; padding: 0; margin: 0 6px 4px 0;
  border: 1px solid #c3c9d2; border-radius: 50%; background: #fff; color: #6b7280;
  font-size: 12px; line-height: 16px; text-align: center; cursor: pointer; vertical-align: middle;
}
.hint-toggle:hover { border-color: #2563eb; color: #2563eb; }
.hint-toggle.on { background: #2563eb; border-color: #2563eb; color: #fff; }

/* 「去手写」弹窗里的三张卡：点一下就选中 */
.pick-card {
  display: block; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.pick-card:hover { border-color: #2563eb; background: #f8fbff; }
.pick-card.on { border-color: #2563eb; background: #f2f7ff; }
.pick-card b { display: block; font-size: 13px; margin-bottom: 4px; }
.pick-card span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.pick-card .tag-free, .pick-card .tag-pay {
  display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 999px;
  font-size: 11px; font-weight: 400; vertical-align: 1px;
}
.pick-card .tag-free { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.pick-card .tag-pay { background: #fff7ed; color: #d97706; border: 1px solid #fed7aa; }
/* 工具栏「去手写」开着的时候是蓝的 */
#btn-unhand.on { background: #2563eb; border-color: #2563eb; color: #fff; }
#btn-unhand.on:hover { background: #1d4ed8; border-color: #1d4ed8; }
