/* ============================================================
   AI 文档图解工作台 — 样式
   浅色主题
   ============================================================ */

:root {
  --bg:        #f5f7fb;
  --bg-soft:   #eef1f7;
  --paper:     #ffffff;
  --line:      #e3e8f0;
  --line-2:    #d3dae6;
  --text:      #1f2733;
  --text-2:    #5b6675;
  --text-3:    #8b95a5;
  --brand:     #2f6bff;
  --brand-dk:  #1f4fd8;
  --brand-lt:  #eaf0ff;
  --ok:        #16a34a;
  --warn:      #d97706;
  --err:       #dc2626;
  --shadow-sm: 0 1px 2px rgba(20,32,60,.06), 0 1px 3px rgba(20,32,60,.05);
  --shadow-md: 0 6px 20px rgba(20,32,60,.10), 0 2px 6px rgba(20,32,60,.06);
  --shadow-lg: 0 18px 50px rgba(20,32,60,.16);
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 20px;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

/* 今日 AI 免费额度用完的醒目提示（额度按天重置，不是功能坏了） */
.quota-banner {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 1100px; margin: 12px auto 0;
  padding: 11px 14px;
  border: 1px solid #ffd8a8; border-radius: 10px;
  background: #fff7e8; color: #8a4b00;
  font-size: 13px; line-height: 1.6;
}
.quota-banner .qb-ico { flex: none; font-size: 15px; line-height: 1.5; }
.quota-banner .qb-text { flex: 1 1 auto; }
.quota-banner .qb-text b { color: #a03d00; }
.quota-banner .qb-close {
  flex: none; border: 0; background: transparent; color: inherit;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; opacity: .7;
}
.quota-banner .qb-close:hover { opacity: 1; }

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b7bff, #7a5cff);
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 3px 10px rgba(59,123,255,.34);
}

.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text p {
  margin: 0; font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw;
}

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none; border: 1px solid var(--line-2);
  background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; font-family: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(47,107,255,.28);
}
.btn.primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.big { padding: 11px 30px; font-size: 15px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 28px; height: 28px; border-radius: 6px;
  font-size: 15px; color: var(--text-3); cursor: pointer; line-height: 1;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

/* 导出下拉 */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 268px; padding: 6px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  z-index: 80;
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 10px; border-radius: 7px; font-family: inherit;
  font-size: 13.5px; color: var(--text);
}
.menu button:hover { background: var(--brand-lt); }
.menu button b { display: block; font-weight: 600; }
.menu button span { display: block; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------------- 欢迎页 ---------------- */
.welcome {
  max-width: 900px; margin: 0 auto; padding: 52px 20px 70px;
}

.drop {
  background: var(--paper);
  border: 2px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 46px 28px 40px;
  text-align: center;
  transition: border-color .18s, background .18s, transform .18s;
}
.drop.over { border-color: var(--brand); background: var(--brand-lt); transform: scale(1.008); }
.drop-icon { color: var(--brand); margin-bottom: 8px; }
.drop h2 { margin: 6px 0 8px; font-size: 20px; font-weight: 650; }
.drop-sub { margin: 0 0 22px; color: var(--text-2); font-size: 13.5px; }
.drop-sub b { color: var(--text); }
.drop-hint { min-height: 20px; margin: 14px 0 0; font-size: 12.5px; color: var(--text-3); }

.steps {
  list-style: none; margin: 34px 0 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.steps li {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.steps .num {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-lt); color: var(--brand);
  font-size: 12.5px; font-weight: 700; margin-top: 2px;
}
.steps b { font-size: 14px; }
.steps p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }

/* ---------------- 工作区 ---------------- */
.workspace { max-width: 900px; margin: 0 auto; padding: 28px 20px 90px; }

/* 纸张外面的滚动盒：放大后可横向滚动，缩小后自动居中 */
.paper-scroll {
  display: flex;
  justify-content: safe center;
  overflow: auto;
  padding-bottom: 2px;
}

.paper {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  padding: 54px 60px 60px;
  min-height: 50vh;
  width: 860px;
  flex: 0 0 auto;
}
@media (max-width: 940px) { .paper { width: 100%; } }

.doc { outline: none; }

.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 {
  line-height: 1.4; margin: 1.5em 0 .6em; font-weight: 650;
}
.doc h1 { font-size: 25px; margin-top: 0; }
.doc h2 { font-size: 20px; }
.doc h3 { font-size: 17px; }
.doc h4, .doc h5, .doc h6 { font-size: 15px; }
.doc p { margin: 0 0 1em; }
.doc ul, .doc ol { margin: 0 0 1em; padding-left: 1.6em; }
.doc li { margin-bottom: .35em; }
.doc blockquote {
  margin: 0 0 1em; padding: 6px 16px;
  border-left: 3px solid var(--line-2); color: var(--text-2);
  background: var(--bg-soft); border-radius: 0 6px 6px 0;
}
.doc code {
  font-family: var(--mono); font-size: .88em;
  background: var(--bg-soft); padding: 2px 5px; border-radius: 4px;
}
.doc pre {
  background: #f7f9fc; border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 8px; overflow-x: auto;
}
.doc pre code { background: none; padding: 0; }
.doc img { max-width: 100%; }
.doc table { border-collapse: collapse; margin: 0 0 1em; width: 100%; font-size: 14px; }
.doc th, .doc td { border: 1px solid var(--line-2); padding: 6px 10px; text-align: left; }
.doc th { background: var(--bg-soft); font-weight: 600; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

/* ---------------- 分页预览（WPS 风格多页视图） ---------------- */
/* 每一个 .doc-page = 原文档的一页：纸张尺寸 / 页边距 / 字号 / 行距都取自原文档，
   正文只放这一页本该有的内容（按原文档的分页符切）。
   分页只是预览层，导出时 buildExportClone 会去掉外壳、并把跨页段落拼回一段。 */

/* 页面容器：每行显示几页由 JS 按「缩放比例 ÷ 可视宽度」算好写进 --pg-cols，
   所以缩小后一行自动排下 2/4/6/8 页，且永远不会横向裁掉半页 */
.doc-paged {
  display: grid;
  justify-content: center;
  justify-content: safe center;
  align-items: start;
  gap: 20px;
  grid-template-columns: repeat(var(--pg-cols, 1), var(--pg-w, 794px));
}

.doc-paged .doc-page {
  position: relative;
  box-sizing: border-box;
  width: var(--pg-w, 794px);
  min-height: var(--pg-h, 1123px);
  padding: var(--pg-pt, 96px) var(--pg-pr, 96px) var(--pg-pb, 96px) var(--pg-pl, 96px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  font-size: var(--pg-font, 16px);
  line-height: var(--pg-lh, 1.5);
}
.doc-paged .doc-page-body {
  flex: 1 1 auto;
  width: 100%;
  min-height: var(--pg-ch, 900px);
}
/* 还原 Word 的正文段落模型：段前段后为 0，靠行距撑开 */
.doc-paged .doc-page-body p,
.doc-paged .doc-page-body li { margin: 0; text-align: var(--pg-align, start); }
.doc-paged .doc-page-body > p { text-indent: var(--pg-indent, 0); }
.doc-paged .doc-page-body ul,
.doc-paged .doc-page-body ol { margin: 0; }
.doc-paged .doc-page-body h1 { font-size: 1.6em; margin: .8em 0 .4em; }
.doc-paged .doc-page-body h2 { font-size: 1.35em; margin: .8em 0 .4em; }
.doc-paged .doc-page-body h3 { font-size: 1.15em; margin: .7em 0 .35em; }
.doc-paged .doc-page-body h4,
.doc-paged .doc-page-body h5,
.doc-paged .doc-page-body h6 { font-size: 1em; margin: .6em 0 .3em; }
.doc-paged .doc-page-body table { font-size: 1em; }
.doc-paged .doc-page-foot {
  flex: none;
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-2);
}

/* 量尺页：和真实页完全同尺寸，不可见地挂在文档里，用来量「这一页还能不能再放一段」 */
.doc-paged .doc-measure {
  position: absolute !important;
  left: 0;
  top: 0;
  z-index: -1;
  margin: 0;
  visibility: hidden;
  box-shadow: none;
}
.doc-paged .doc-measure .doc-page-body {
  height: var(--pg-ch, 900px);
  min-height: 0;
  overflow: hidden;
}

/* 分页时「纸」退成工作区背景，白纸由每一页自己画 */
.paper.is-paged {
  flex: 1 1 100%;
  width: auto;
  min-width: 0;
  padding: 6px 12px 48px;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.doc [data-block] { position: relative; }
.doc [data-block]:hover::before {
  content: ""; position: absolute; left: -34px; top: 4px; bottom: 4px;
  width: 3px; border-radius: 2px; background: var(--brand-lt);
}

/* ---------------- 多选段落模式 ---------------- */
.doc.multi [data-block]:not(.insert) {
  position: relative;
  padding-left: 30px;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  border-radius: 6px;
  transition: background .12s, box-shadow .12s;
}
.doc.multi [data-block]:not(.insert):hover { background: #f3f7ff; }
.doc.multi [data-block]:not(.insert)::after {
  content: ""; position: absolute; left: 6px; top: 6px;
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--line-2); background: #fff;
  transition: background .12s, border-color .12s;
}
.doc.multi [data-block]:not(.insert):hover::after { border-color: var(--brand); }
.doc.multi [data-block].blk-picked:not(.insert) {
  background: #eaf0ff;
  box-shadow: inset 3px 0 0 var(--brand);
}
.doc.multi [data-block].blk-picked:not(.insert)::after { background: var(--brand); border-color: var(--brand); }
.doc.multi [data-block].blk-picked:not(.insert)::before {
  content: ""; position: absolute; left: 11px; top: 11px; z-index: 1;
  width: 10px; height: 5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

/* ---------------- 插入的图解块 ---------------- */
.insert {
  position: relative;
  margin: 14px 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fcfdff;
  overflow: hidden;
}
.insert[data-state="loading"] { background: #fbfcff; }
.insert[data-state="error"] { border-color: #f5c2c2; background: #fff7f7; }

.insert-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 10px 7px 12px;
  background: linear-gradient(180deg,#f7f9fe,#f2f5fc);
  border-bottom: 1px solid var(--line);
}
.insert-title {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 7px; min-width: 0;
}
.insert-title .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand); flex: none;
}
.insert-title .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.insert-tools { display: flex; gap: 2px; flex: none; }
.insert-tools button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--text-3);
  padding: 4px 8px; border-radius: 5px; white-space: nowrap;
}
.insert-tools button:hover { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.insert-tools button[data-act="del"]:hover { color: var(--err); }

.insert-body { padding: 16px 14px; text-align: center; overflow-x: auto; }
.insert-body svg { max-width: 100%; height: auto; }
.insert-body img { max-width: 100%; border-radius: 8px; display: block; margin: 0 auto; }

.insert-src {
  padding: 8px 14px 12px; font-size: 11.5px; color: var(--text-3);
  border-top: 1px dashed var(--line); line-height: 1.6;
  text-align: left;
}
.insert-src b { color: var(--text-2); font-weight: 600; }

.insert-loading { padding: 30px 0; color: var(--text-3); font-size: 13px; }
.insert-loading .spinner { margin: 0 auto 10px; }
.insert-err { color: var(--err); font-size: 12.5px; padding: 12px; text-align: left; word-break: break-word; max-height: 240px; overflow: auto; }

.insert-note {
  margin: 0 0 12px; padding: 9px 12px; text-align: left;
  background: #fff8e6; border: 1px solid #f0dda0; border-radius: 8px;
  font-size: 12px; color: #8a6d1f; line-height: 1.65;
}
.insert-note summary { cursor: pointer; color: #9a7b28; margin-top: 4px; }
.insert-note pre {
  margin: 6px 0 0; padding: 8px 10px; background: #fffdf5;
  border: 1px solid #f0e3b8; border-radius: 6px;
  font-size: 11.5px; white-space: pre-wrap; word-break: break-word;
  max-height: 160px; overflow: auto; font-family: var(--mono);
}
.src-prompt { margin-top: 5px; color: var(--text-3); }
.src-prompt b { color: var(--text-2); }

/* ---------------- 多选段落工具条 ---------------- */
.multi-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 9px 18px;
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(20,32,60,.10);
  animation: pop .16s ease-out;
}
.mb-left, .mb-right { display: flex; align-items: center; gap: 8px; flex: none; }
.mb-mid {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap; justify-content: center; flex: 1; min-width: 0;
}
.mb-tip { font-size: 12px; color: var(--text-3); white-space: nowrap; margin-right: 4px; }
.mb-mid button {
  appearance: none; border: 1px solid var(--line-2); background: #fff; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  transition: background .13s, color .13s, border-color .13s;
}
.mb-mid button:hover:not(:disabled) { background: var(--brand); border-color: var(--brand); color: #fff; }
.mb-mid button:disabled { opacity: .45; cursor: not-allowed; }
/* 已预约的「下一批样式」：常态高亮 + 小徽标，悬停反色 */
.mb-mid button.mk-armed,
.mb-mid button.mk-armed:disabled {
  background: var(--brand-lt); border-color: var(--brand); color: var(--brand);
  font-weight: 700; opacity: 1;
  box-shadow: 0 0 0 2px rgba(47,107,255,.15);
}
.mb-mid button.mk-armed::after {
  content: "下一批"; display: inline-block; margin-left: 5px; padding: 0 5px;
  font-size: 10px; font-weight: 700; line-height: 15px; vertical-align: 1px;
  border-radius: 999px; background: var(--brand); color: #fff;
}
.mb-mid button.mk-armed:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.mb-mid button.mk-armed:hover::after { background: #fff; color: var(--brand); }
.mb-count { font-size: 12.5px; font-weight: 600; color: var(--brand); white-space: nowrap; }
.mb-progress {
  font-size: 12px; color: #fff; background: var(--brand);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mb-merge {
  display: flex; align-items: center; gap: 5px; margin-left: 6px;
  font-size: 12.5px; color: var(--text-2); white-space: nowrap; cursor: pointer;
}
.mb-merge input { accent-color: var(--brand); }
.btn.ghost.active { background: var(--brand-lt); color: var(--brand); font-weight: 600; }

body.multi-on .toast { bottom: 106px; }
body.multi-on .workspace { padding-bottom: 140px; }

.doc-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; padding: 0 4px;
  font-size: 12.5px; color: var(--text-3);
}

/* ---------------- 选区工具条 ---------------- */
.sel-toolbar {
  position: absolute; z-index: 90;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow-lg);
  animation: pop .13s ease-out;
  max-width: min(92vw, 620px);
}
.st-label {
  font-size: 11.5px; color: var(--text-3); white-space: nowrap;
  border-right: 1px solid var(--line); padding-right: 10px;
}
.st-btns { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; }
.st-btns button {
  appearance: none; border: 0; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
  background: transparent; transition: background .13s, color .13s;
}
.st-btns button:hover { background: var(--brand); color: #fff; }
.st-btns button.st-multi {
  margin-left: 4px; font-weight: 600;
  color: #fff; background: var(--brand);
  box-shadow: 0 1px 4px rgba(47,111,237,.35);
}
.st-btns button.st-multi:hover { background: var(--brand-dk); }

/* ---------------- 忙碌遮罩 ---------------- */
.busy {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  background: rgba(240,243,250,.72);
  backdrop-filter: blur(3px);
}
.busy-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 26px 34px; text-align: center; min-width: 240px;
}
.busy-card p { margin: 14px 0 12px; font-size: 13.5px; color: var(--text-2); }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--brand-lt); border-top-color: var(--brand);
  animation: spin .75s linear infinite;
}
.spinner.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 130;
  display: grid; place-items: center;
  background: rgba(22,30,45,.42);
  padding: 20px;
}
.modal-card {
  width: min(760px, 100%);
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column; max-height: 86vh;
}
.modal-card.small { width: min(560px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.modal-tip { margin: 12px 16px 0; font-size: 12.5px; color: var(--text-2); }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.modal-foot.right { justify-content: flex-end; }
#codeArea {
  flex: 1; min-height: 300px; border: 0; outline: none; resize: none;
  padding: 14px 16px; font-family: var(--mono); font-size: 13px;
  line-height: 1.65; color: #1f2733; background: #fbfcfe; tab-size: 2;
}
#promptArea {
  margin: 10px 16px 0; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--line-2); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; outline: none; line-height: 1.6;
}
#promptArea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lt); }
.err { color: var(--err); font-size: 12.5px; }

/* ---------------- 设置抽屉 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(22,30,45,.34);
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 110;
  width: min(430px, 94vw);
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.22,.7,.3,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.drawer-body { flex: 1; overflow-y: auto; padding: 6px 18px 40px; }

.field { margin: 16px 0; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.field .val { float: right; font-weight: 500; color: var(--brand); font-family: var(--mono); }
.field input[type="text"], .field input[type="url"],
.field input[type="password"], .field input[type="number"], .field select {
  width: 100%; padding: 8px 11px; font-family: inherit; font-size: 13.5px;
  color: var(--text); background: #fff;
  border: 1px solid var(--line-2); border-radius: 8px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lt);
}
.field input[type="range"] { width: 100%; accent-color: var(--brand); }
.hint { margin: 6px 0 0; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }

.warn { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: #b00020; font-weight: 600; min-height: 0; }
.warn:empty { display: none; }
.hint code, .faq code {
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; color: #3c4a5e;
}
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

.test-result { margin-left: 10px; font-size: 12.5px; }
.test-result.ok { color: var(--ok); }
.test-result.bad { color: var(--err); }

/* ---------------- 配图版式侧边栏 ---------------- */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 110;
  width: min(380px, 92vw);
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.22,.7,.3,1);
  display: flex; flex-direction: column;
}
.side-panel.open { transform: none; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.side-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.side-tip { margin: 0; padding: 12px 18px 4px; font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
.side-list {
  flex: 1; overflow-y: auto; padding: 10px 16px 36px;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px;
}
.side-chip {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px;
  font-family: inherit; color: var(--text); transition: border-color .15s, background .15s, box-shadow .15s;
}
.side-chip:hover { border-color: var(--brand); background: var(--brand-lt); }
.side-chip .sc-name { font-size: 13px; font-weight: 600; }
.side-chip .sc-sub { font-size: 10.5px; color: var(--text-3); }
.side-chip.active {
  border-color: var(--brand); background: var(--brand-lt);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.side-chip.active::after {
  content: "✓"; position: absolute; top: 8px; right: 10px;
  font-size: 12px; font-weight: 700; color: var(--brand);
}
.side-group-label {
  grid-column: 1 / -1; margin: 6px 0 0; font-size: 11px; font-weight: 600;
  color: var(--text-2); letter-spacing: .04em;
}

.faq {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 13px; margin: 14px 0; background: #fbfcfe;
}
.faq summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "▸ "; color: var(--text-3); }
.faq[open] summary::before { content: "▾ "; }
.faq ol, .faq ul { margin: 10px 0 6px; padding-left: 20px; font-size: 12.5px; color: var(--text-2); line-height: 1.85; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 200;
  transform: translate(-50%, 24px);
  padding: 10px 18px; border-radius: 999px;
  background: #1f2733; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #b91c1c; }
.toast.ok { background: #15803d; }

/* ---------------- 打印 ---------------- */
/* ---------------- 文档缩放条（WPS 风格） ---------------- */
.zoom-bar {
  position: fixed; right: 18px; bottom: 18px; z-index: 92;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text-2);
  animation: pop .16s ease-out;
}
.zb-btn {
  appearance: none; border: 1px solid var(--line-2); background: #fff; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  width: 26px; height: 26px; line-height: 1; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .13s, color .13s, border-color .13s;
}
.zb-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.zb-btn.zb-preset { width: auto; padding: 0 9px; font-weight: 500; font-size: 12px; }
.zb-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.zb-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 3px; }
.zb-cols-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.zb-val { display: inline-flex; align-items: center; gap: 1px; }
.zb-val input {
  width: 44px; text-align: right; font-family: inherit; font-size: 12.5px; color: var(--text);
  border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 3px 2px;
  font-variant-numeric: tabular-nums;
}
.zb-val input:hover { border-color: var(--line-2); }
.zb-val input:focus { outline: none; border-color: var(--brand); background: #fff; }
.zb-pct { font-size: 12px; color: var(--text-3); }
.zb-range { width: 96px; accent-color: var(--brand); }
body.multi-on .zoom-bar { bottom: 62px; }
@media (max-width: 720px) {
  .zoom-bar { right: 10px; bottom: 10px; gap: 4px; padding: 5px 8px; }
  .zb-range { display: none; }
  body.multi-on .zoom-bar { bottom: 96px; }
}

@media print {
  .topbar, .sel-toolbar, .doc-foot, .insert-tools, .toast,
  .mask, .drawer, .modal, .busy, .multi-bar, .zoom-bar { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .workspace { max-width: none; padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .paper.is-paged { padding: 0; }
  /* 打印时：一页一纸，去掉网格与阴影 */
  .doc-paged { display: block !important; }
  .doc-paged .doc-page {
    width: auto; box-shadow: none; border: 0; border-radius: 0;
    min-height: 0; padding: 0; margin: 0; break-after: page; page-break-after: always;
  }
  .doc-paged .doc-page:last-child { break-after: auto; page-break-after: auto; }
  .doc-paged .doc-page-foot { border-top: 0; }
  .insert { break-inside: avoid; page-break-inside: avoid; page-break-before: auto; }
  .insert-head { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc [data-block]:hover::before,
  .doc.multi [data-block]::after,
  .doc.multi [data-block]::before { display: none !important; }
  .doc.multi [data-block] { background: none !important; box-shadow: none !important; }
  .insert-body svg { max-width: 100% !important; }
}

/* ---------------- 窄屏 ---------------- */
@media (max-width: 720px) {
  .paper { padding: 28px 20px 34px; }
  .workspace, .welcome { padding-left: 12px; padding-right: 12px; }
  .brand-text p { max-width: 30vw; }
  .top-actions .btn.ghost { display: none; }
  .doc h1 { font-size: 21px; }
  .sel-toolbar { border-radius: 14px; flex-wrap: wrap; }
  .multi-bar { padding: 8px 10px; gap: 8px; justify-content: center; }
  .mb-tip { display: none; }
  .mb-mid { order: 3; width: 100%; }
  .doc.multi [data-block]::after { left: -24px; width: 16px; height: 16px; }
  .doc.multi [data-block].blk-picked::before { left: -20px; top: 9px; }
}
