/* ============================================================
   墨格 · 公众号图文排版
   视觉令牌：暖纸质中性色 + 唯一强调色朱砂
   ============================================================ */

:root {
  --bg: #eaeae1;
  --rail: #f4f4ec;
  --panel: #fbfbf7;
  --panel-2: #f7f7f1;
  --field: #f1f1e8;
  --line: #e3e3d6;
  --line-soft: #ececE0;
  --ink: #17171a;
  --ink-2: #4a4b50;
  --ink-3: #8a8b83;
  --ink-4: #a0a199;
  --accent: #b4693c;
  /* 主题派生色：paintPaper 会按当前主题重算，这里给根级兜底，
     避免任何未挂上变量的容器出现透明边框 */
  --accent-06: rgba(180, 105, 60, 0.07);
  --accent-12: rgba(180, 105, 60, 0.12);
  --accent-15: rgba(180, 105, 60, 0.2);
  --accent-16: rgba(180, 105, 60, 0.22);
  --accent-40: rgba(180, 105, 60, 0.42);
  --dark: #1b1b1f;
  --radius: 10px;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --shadow-paper: 0 1px 2px rgba(23, 23, 26, 0.04), 0 18px 40px -18px rgba(23, 23, 26, 0.22);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input, textarea, select { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(23, 23, 26, 0.14);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(23, 23, 26, 0.26); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================== 顶栏 ============================== */

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

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

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--dark);
  color: #f6f5ef;
  font-family: var(--font-serif);
  font-size: 18px;
  display: grid;
  place-items: center;
  letter-spacing: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tb-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex: none;
}

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

.doc-title {
  border: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--ink);
  width: 260px;
  padding: 4px 6px;
  border-radius: 6px;
  text-overflow: ellipsis;
  outline: none;
}
.doc-title:hover { background: var(--field); }
.doc-title:focus { background: #fff; box-shadow: 0 0 0 1px var(--line); }

.doc-sub {
  font-size: 11.5px;
  color: var(--ink-4);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.doc-sub .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #6f8f5f;
}
.doc-sub.is-saving .dot { background: var(--accent); }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--field);
  border-radius: 9px;
  flex: none;
}

.seg-btn {
  padding: 6px 16px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink-3);
  transition: 0.16s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink-2); }
.seg-btn.is-active {
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(23, 23, 26, 0.08);
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: 0.16s;
}
.icon-btn:hover { background: var(--field); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.ghost-btn {
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  transition: 0.16s;
  margin-left: 4px;
}
.ghost-btn:hover { background: var(--field); border-color: #d6d6c8; }

.primary-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: #f8f7f2;
  background: var(--dark);
  transition: 0.18s;
}
.primary-btn:hover { background: #2c2c33; }
.primary-btn:active { transform: translateY(0.5px); }

/* ============================== 主体 ============================== */

.body {
  display: flex;
  height: calc(100vh - 64px);
  min-height: 0;
}

/* ---------- 图标 rail ---------- */

.rail {
  width: 64px;
  flex: none;
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 2px;
}

.rail-item {
  width: 50px;
  padding: 8px 0 7px;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  transition: 0.16s;
}
.rail-item:hover { background: #ebebdf; color: var(--ink-2); }
.rail-item svg { width: 19px; height: 19px; }
.rail-item span { font-size: 10px; letter-spacing: 0.02em; }
.rail-item.is-active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(23, 23, 26, 0.07); }
.rail-item.is-active span { font-weight: 500; }

.rail-spacer { flex: 1; }

/* ---------- 左侧主题面板 ---------- */

.panel-themes {
  width: 268px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ph {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
}
.ph h2 { font-size: 13.5px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
.ph-count {
  margin-left: auto;
  margin-right: 9px;
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.03em;
}

.ph-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--ink-3);
  transition: 0.16s;
}
.chip:hover { background: var(--field); color: var(--ink-2); }
.chip.is-active { background: var(--ink); color: #f7f6f1; }

.ai-theme {
  width: 100%;
  text-align: left;
  padding: 12px 13px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fbf2ea 0%, #f7f5ee 100%);
  border: 1px solid #eee0d4;
  margin-bottom: 16px;
  transition: 0.18s;
}
.ai-theme:hover { border-color: #e2cbb8; transform: translateY(-1px); }
.ai-theme b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.ai-theme small { font-size: 11px; color: var(--ink-3); line-height: 1.5; }

.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 10px;
}

.theme-card {
  border-radius: 9px;
  padding: 6px 6px 7px;
  background: var(--panel-2);
  border: 1px solid transparent;
  text-align: left;
  transition: 0.16s;
}
.theme-card:hover { border-color: #deded0; transform: translateY(-1px); }
.theme-card.is-active {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.tc-thumb {
  height: 74px;
  border-radius: 6px;
  padding: 9px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid rgba(23, 23, 26, 0.06);
  position: relative;
}

.tc-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: block;
}

.tc-bar { height: 4px; border-radius: 2px; }

.tc-name {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1px;
}
.tc-name em {
  font-style: normal;
  font-size: 9px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}

.panel-foot {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line-soft);
  flex: none;
}
.link-btn {
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 5px;
}
.link-btn:hover { color: var(--accent); }

.current-card {
  margin: 0 16px 14px;
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  flex: none;
}
.current-card span { font-size: 10.5px; color: var(--ink-4); letter-spacing: 0.06em; }
.current-card b { display: block; font-size: 12px; font-weight: 500; margin: 4px 0 2px; }
.current-card small { font-size: 10.5px; color: var(--ink-4); }

/* ---------- 中间舞台 ---------- */

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

.stage-bar {
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid rgba(23, 23, 26, 0.07);
}

.sb-left, .sb-right { display: flex; align-items: center; gap: 8px; }

.size-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.size-chip i { font-style: normal; color: var(--ink-4); }

.theme-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-2);
}
.theme-chip .sw { width: 9px; height: 9px; border-radius: 50%; }

.tiny-btn {
  font-size: 11px;
  color: var(--ink-3);
  padding: 4px 8px;
  border-radius: 6px;
}
.tiny-btn:hover { background: rgba(255, 255, 255, 0.8); color: var(--ink-2); }
.tiny-btn.is-on { color: var(--accent); background: rgba(255, 255, 255, 0.9); }

.stage-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 26px 24px 60px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.stage-scroll.is-fit .paper { width: 375px; }

/* ---------- 稿纸 ---------- */

.paper {
  width: 480px;
  flex: none;
  background: var(--paper, #fff);
  padding: 38px 32px 46px;
  border-radius: 3px;
  box-shadow: var(--shadow-paper);
  outline: none;
  min-height: 620px;
  position: relative;
  transition: width 0.2s ease;
  font-size: var(--fs, 15px);
  line-height: var(--lh, 1.8);
  letter-spacing: var(--ls, 0.5px);
  color: var(--ink-2);
  word-break: break-word;
}

.paper ::selection { background: rgba(180, 105, 60, 0.22); }

.paper:empty::before {
  content: "把公众号里的正文粘进来，或点右下角「开始排版」";
  color: var(--ink-4);
  font-size: 13px;
}

/* ---------- 文章元素 ---------- */

.art-tag {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  margin: 0 0 14px;
  line-height: 1.4;
  text-transform: uppercase;
}

.art-title {
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1.42;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 12px;
}

.art-meta {
  font-size: 12px;
  color: var(--ink-4);
  letter-spacing: 0.05em;
  margin: 0 0 24px;
  line-height: 1.7;
}
.art-meta em { font-style: normal; color: var(--ink-3); }

.art-lead {
  background: var(--accent-06);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 15px 17px;
  margin: 0 0 22px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
  letter-spacing: 0.5px;
}

.paper p:not([class]) {
  margin: var(--ps, 16px) 0;
  font-size: var(--fs, 15px);
  line-height: var(--lh, 1.8);
  letter-spacing: var(--ls, 0.5px);
  color: var(--ink-2);
}

.art-h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--ink);
  margin: 30px 0 12px;
  letter-spacing: 0.01em;
}
.art-h2 .art-num {
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-right: 8px;
  vertical-align: 2px;
}

.art-fig { margin: 22px 0; }
.art-fig img {
  width: 100%;
  display: block;
  border-radius: 5px;
  background: var(--accent-06);
}
.art-fig figcaption {
  font-size: 11px;
  color: var(--ink-4);
  text-align: center;
  margin-top: 9px;
  letter-spacing: 0.04em;
}

.art-quote {
  margin: 26px 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent-40);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.9;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.art-card {
  background: var(--accent-06);
  border: 1px solid var(--accent-15);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 22px 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
}
.art-card > :first-child { margin-top: 0; }
.art-card > :last-child { margin-bottom: 0; }

.art-hr {
  height: 22px;
  margin: 26px 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='22' viewBox='0 0 120 22'%3E%3Cpath d='M2 13 Q 12 3 22 12 T 42 12 T 62 12 T 82 12 T 102 12 T 118 11' fill='none' stroke='%23b4693c' stroke-opacity='0.4' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: left center;
}

.art-follow {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 28px 0 4px;
  padding: 15px 16px;
  border-radius: 8px;
  background: var(--accent-06);
  border: 1px solid var(--accent-15);
}
.art-follow .qr {
  width: 50px;
  height: 50px;
  flex: none;
  border-radius: 4px;
  background: #fff;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-15);
  overflow: hidden;
}
.art-follow .qr img, .art-follow .qr svg { width: 100%; height: 100%; display: block; }
.art-follow b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.art-follow small { font-size: 11px; color: var(--ink-3); line-height: 1.6; }

.art-em {
  background: var(--accent-16);
  padding: 1px 3px;
  border-radius: 3px;
  color: var(--ink);
}

/* ---------- 分段书签 ---------- */

.art-bookmark {
  margin: 30px 0 20px;
  position: relative;
}

/* 缎带书签：横贯色带 + 右侧燕尾 */
.bm-ribbon {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
}
.bm-ribbon .bm-body {
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 9px 16px;
  border-radius: 3px 0 0 3px;
  white-space: nowrap;
}
.bm-ribbon .bm-tail {
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 11px solid var(--accent);
}

/* 标签书签：左侧竖条 + 文字，像挂签 */
.bm-tag {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bm-tag .bm-bar {
  width: 4px;
  height: 30px;
  background: var(--accent);
  border-radius: 2px;
  flex: none;
}
.bm-tag .bm-body {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  padding: 5px 12px;
  background: var(--accent-06);
  border-radius: 0 4px 4px 0;
  border-left: 1px solid var(--accent-15);
}

/* 编号书签：方块序号 + 标题 */
.bm-index {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bm-index .bm-no {
  width: 30px;
  height: 30px;
  flex: none;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bm-index .bm-body {
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--accent-15);
  padding-bottom: 4px;
  flex: 1;
}

/* 便笺书签：带折角的便签纸 */
.bm-note {
  position: relative;
  background: var(--accent-12);
  border: 1px solid var(--accent-40);
  border-radius: 4px;
  padding: 14px 17px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.bm-note .bm-corner {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 0;
  height: 0;
  border-top: 20px solid var(--paper);
  border-left: 20px solid transparent;
}
.bm-note .bm-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}

.art-bookmark .bm-body:empty::before { content: "书签文字"; color: var(--ink-4); }

/* ---------- 文字边框 ---------- */

.paper .bd-line {
  border: 1px solid var(--accent-40);
  border-radius: 4px;
  padding: 14px 16px;
}
.paper .bd-dash {
  border: 1px dashed var(--accent-40);
  border-radius: 4px;
  padding: 14px 16px;
}
.paper .bd-double {
  border: 3px double var(--accent-40);
  border-radius: 4px;
  padding: 13px 15px;
}
.paper .bd-round {
  border: 1px solid var(--accent-15);
  border-radius: 14px;
  padding: 15px 17px;
  background: var(--accent-06);
}
.paper .bd-left {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 15px;
}
.paper .bd-solid {
  border: 1px solid var(--accent-15);
  border-radius: 4px;
  padding: 14px 16px;
  background: var(--accent-06);
}

/* ---------- 图片边框 ---------- */

.paper .bd-img-line img {
  border: 1px solid var(--accent-40);
}
.paper .bd-img-round img {
  border-radius: 14px;
}
.paper .bd-img-shadow img {
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(23, 23, 26, 0.16);
}
.paper .bd-img-frame img {
  border-radius: 3px;
  padding: 9px;
  background: #fff;
  border: 1px solid var(--accent-15);
  box-shadow: 0 2px 10px rgba(23, 23, 26, 0.08);
}
.paper .bd-img-tape img {
  border-radius: 4px;
  box-shadow: 0 8px 22px rgba(23, 23, 26, 0.14);
  border-top: 3px solid var(--accent-40);
  border-bottom: 3px solid var(--accent-40);
}

/* ---------- 面板里的缩略预览 ---------- */

.bm-thumb {
  display: block;
  width: 30px;
  height: 22px;
  margin: 0 auto;
  position: relative;
}
.bmt-ribbon {
  position: absolute;
  left: 2px;
  top: 8px;
  width: 20px;
  height: 7px;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}
.bmt-ribbon::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 0;
  width: 0;
  height: 0;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  border-left: 5px solid var(--accent);
}
.bmt-tag {
  position: absolute;
  left: 3px;
  top: 5px;
  width: 3px;
  height: 13px;
  background: var(--accent);
  border-radius: 1px;
  box-shadow: 6px 0 0 -1px var(--accent-15);
}
.bmt-index {
  position: absolute;
  left: 3px;
  top: 6px;
  width: 11px;
  height: 11px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 14px 2px 0 -3px var(--ink-4);
}
.bmt-note {
  position: absolute;
  left: 2px;
  top: 4px;
  width: 24px;
  height: 15px;
  background: var(--accent-06);
  border: 1px solid var(--accent-15);
  border-radius: 2px;
}

.bd-prev {
  display: block;
  width: 26px;
  height: 18px;
  margin: 0 auto;
  border: 1px solid var(--accent-40);
  border-radius: 2px;
}
.bd-prev-t.is-none { border-style: dotted; border-color: #d3d3c6; }
.bd-prev-i { background: var(--accent-06); }
.bd-prev-i.is-none { border-style: dotted; border-color: #d3d3c6; background: none; }

/* 各类边框在预览小图上体现差异 */
.bd-card[data-tb="dash"] .bd-prev { border-style: dashed; }
.bd-card[data-tb="double"] .bd-prev { border-width: 3px; border-style: double; }
.bd-card[data-tb="round"] .bd-prev { border-radius: 8px; background: var(--accent-06); border-color: var(--accent-15); }
.bd-card[data-tb="left"] .bd-prev { border-width: 0; border-left-width: 3px; border-color: var(--accent); }
.bd-card[data-tb="solid"] .bd-prev { background: var(--accent-06); border-color: var(--accent-15); }
.bd-card[data-ib="round"] .bd-prev { border-radius: 9px; }
.bd-card[data-ib="shadow"] .bd-prev { box-shadow: 0 3px 8px rgba(23, 23, 26, 0.28); border-color: transparent; }
.bd-card[data-ib="frame"] .bd-prev { background: #fff; border-color: var(--accent-15); padding: 3px; }
.bd-card[data-ib="tape"] .bd-prev { border-width: 3px 0; border-color: var(--accent-40); border-radius: 2px; }

/* ---------- 浮动选择工具条 ---------- */

.sel-toolbar {
  position: fixed;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 5px 6px;
  border-radius: 9px;
  background: var(--dark);
  box-shadow: 0 8px 24px -8px rgba(23, 23, 26, 0.5);
}
.sel-toolbar.is-on { display: flex; }

.st-btn {
  width: 27px;
  height: 27px;
  border-radius: 6px;
  color: #d8d8d2;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  transition: 0.14s;
}
.st-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.st-btn.is-active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.st-sep { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.16); margin: 0 4px; }
.st-tag-btn {
  padding: 0 9px;
  height: 27px;
  border-radius: 6px;
  font-size: 11.5px;
  color: #e6e4dd;
  white-space: nowrap;
}
.st-tag-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* ---------- 右侧属性面板 ---------- */

.panel-props {
  width: 300px;
  flex: none;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tabs {
  height: 52px;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  padding: 0 18px;
  flex: none;
  border-bottom: 1px solid var(--line-soft);
}
.tab {
  padding: 0 0 11px;
  font-size: 12.5px;
  color: var(--ink-3);
  position: relative;
}
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--ink); font-weight: 500; }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.props-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.sec { margin-bottom: 22px; }

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}
.sec-head h3 {
  font-size: 11.5px;
  font-weight: 600;
  margin: 0;
  color: var(--ink-2);
  letter-spacing: 0.03em;
}
.sec-head .mini {
  font-size: 10.5px;
  color: var(--ink-4);
}
.sec-head .mini:hover { color: var(--accent); }

.align-row { display: flex; gap: 6px; }
.align-btn {
  width: 64px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: 0.14s;
}
.align-btn:hover { border-color: #d4d4c5; color: var(--ink-2); }
.align-btn.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-06); }
.align-btn svg { width: 14px; height: 14px; }

.swatch-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 10px; }
.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(23, 23, 26, 0.12);
  transition: 0.14s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--ink); }
.swatch-add {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px dashed #c9c9ba;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  position: relative;
  overflow: hidden;
}
.swatch-add input {
  position: absolute;
  inset: -6px;
  opacity: 0;
  cursor: pointer;
  width: 40px; height: 40px;
}

.hexline {
  font-size: 10.5px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  margin-top: 8px;
  text-transform: uppercase;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
}
.row label { font-size: 12px; color: var(--ink-3); }
.row .val { display: flex; align-items: center; gap: 3px; }
.row input[type="number"] {
  width: 46px;
  text-align: right;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  outline: none;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  -moz-appearance: textfield;
}
.row input[type="number"]::-webkit-outer-spin-button,
.row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row input[type="number"]:hover { border-bottom-color: var(--line); }
.row input[type="number"]:focus { border-bottom-color: var(--accent); }
.row .unit { font-size: 11px; color: var(--ink-4); width: 16px; }

.tag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.tag-card {
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 11.5px;
  color: var(--ink-2);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: 0.14s;
}
.tag-card:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-06); }
.tag-card i {
  width: 13px; height: 13px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.tag-card svg { width: 13px; height: 13px; }

.ai-card {
  margin: 8px 18px 18px;
  padding: 15px 16px;
  border-radius: 11px;
  background: var(--dark);
  color: #efeee8;
  flex: none;
}
.ai-card b { font-size: 12.5px; font-weight: 600; display: block; margin-bottom: 5px; }
.ai-card small { font-size: 10.5px; color: #93938c; line-height: 1.6; display: block; margin-bottom: 12px; }
.ai-card button {
  padding: 6px 13px;
  border-radius: 7px;
  background: #f5f3ec;
  color: var(--dark);
  font-size: 11.5px;
  font-weight: 500;
  transition: 0.16s;
}
.ai-card button:hover { background: #fff; }

/* ---------- 标签弹出菜单 ---------- */

.tag-pop {
  position: fixed;
  z-index: 61;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 6px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 40px -12px rgba(23, 23, 26, 0.4), 0 0 0 1px var(--line);
  width: 196px;
}
.tag-pop.is-on { display: grid; }
.tag-pop button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  text-align: left;
}
.tag-pop button:hover { background: var(--accent-06, #f6efe9); color: var(--accent); }
.tag-pop i { display: grid; place-items: center; width: 13px; height: 13px; color: var(--accent); }
.tag-pop svg { width: 13px; height: 13px; }

/* ============================== 弹层 ============================== */

.mask {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 26, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
}
.mask.is-on { display: flex; }

.modal {
  width: 560px;
  max-height: 86vh;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 30px 70px -20px rgba(23, 23, 26, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 18px 22px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal-head h3 { margin: 0 0 5px; font-size: 15px; font-weight: 600; }
.modal-head p { margin: 0; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; }
.modal-body { padding: 0 22px; }
.modal-foot {
  padding: 16px 22px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.paste-area {
  width: 100%;
  height: 260px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 13px 14px;
  font-size: 12.5px;
  line-height: 1.85;
  background: #fff;
  color: var(--ink-2);
  outline: none;
}
.paste-area:focus { border-color: var(--accent); }

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  transition: 0.16s;
}
.btn:hover { border-color: #d4d4c5; }
.btn-primary {
  background: var(--dark);
  border-color: var(--dark);
  color: #f6f5ef;
  font-weight: 500;
}
.btn-primary:hover { background: #2c2c33; border-color: #2c2c33; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-mini { padding: 5px 11px; font-size: 11.5px; border-radius: 7px; }

/* ---------------------------- 模型状态 ---------------------------- */

.model-row {
  margin: 12px 22px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mr-state {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
  min-width: 0;
}
.mr-state span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mr-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9b9b0;
  flex: 0 0 6px;
}
.mr-state.is-on { color: #4a6b41; }
.mr-state.is-on .mr-dot { background: #6b9159; box-shadow: 0 0 0 3px rgba(107, 145, 89, 0.16); }
.mr-state.is-off .mr-dot { background: #b98a45; }
.mr-state.is-bad { color: #8c2f22; }
.mr-state.is-bad .mr-dot { background: #b4453a; }

.mr-toggle {
  font-size: 11.5px;
  color: var(--ink-3);
  border-bottom: 1px dashed rgba(23, 23, 26, 0.22);
  padding-bottom: 1px;
  background: none;
  flex: 0 0 auto;
}
.mr-toggle:hover { color: var(--ink); }

.ai-cfg {
  display: none;
  margin: 10px 22px 0;
  padding: 14px;
  border-radius: 10px;
  background: #f4f4ec;
  border: 1px solid var(--line);
}
.ai-cfg.is-on { display: block; }
.cfg-field { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cfg-field label {
  width: 62px;
  flex: 0 0 62px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.cfg-field input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
  color: var(--ink-2);
  outline: none;
}
.cfg-field input:focus { border-color: var(--accent); }
.cfg-note {
  margin: 10px 0 0;
  font-size: 10.5px;
  line-height: 1.75;
  color: #a0a199;
}
.cfg-actions { display: flex; gap: 8px; margin-top: 10px; }

.run-hint {
  margin-right: auto;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.run-hint .spin {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.6px solid rgba(23, 23, 26, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex: 0 0 11px;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ============================== 预览 ============================== */

.preview-mask {
  position: fixed;
  inset: 0;
  background: rgba(23, 23, 26, 0.62);
  backdrop-filter: blur(5px);
  display: none;
  z-index: 90;
  padding: 28px;
}
.preview-mask.is-on { display: flex; align-items: center; justify-content: center; gap: 34px; }

.preview-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #efeee8;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.preview-close:hover { background: rgba(255, 255, 255, 0.2); }

.phone {
  width: 375px;
  height: min(760px, calc(100vh - 120px));
  border-radius: 28px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  flex: none;
  border: 7px solid #14141a;
}

.phone-nav {
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid #f0f0ee;
  background: #fff;
}
.phone-nav .back { font-size: 15px; color: #17171a; }
.phone-nav .ttl {
  flex: 1;
  font-size: 12.5px;
  color: #17171a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #fff;
}
.phone-scroll .paper {
  width: 100%;
  box-shadow: none;
  border-radius: 0;
  padding: 20px 20px 30px;
  min-height: 100%;
}

.phone-bar {
  height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid #f0f0ee;
  color: #c8c8c4;
  font-size: 11px;
  letter-spacing: 0.16em;
  background: #fff;
}
.phone-bar::after {
  content: "";
  width: 108px; height: 3px;
  border-radius: 2px;
  background: #d9d9d5;
}

.share-panel {
  width: 344px;
  flex: none;
  background: var(--panel);
  border-radius: 14px;
  padding: 20px;
  max-height: min(760px, calc(100vh - 120px));
  overflow-y: auto;
}
.sp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sp-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.sp-head span { font-size: 11px; color: var(--ink-4); }
.sp-sub { font-size: 11px; color: var(--ink-3); margin: 0 0 16px; line-height: 1.6; }

.qr-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.qr-box {
  width: 150px; height: 150px;
  display: grid;
  place-items: center;
  background: #fff;
}
.qr-box svg, .qr-box img, .qr-box canvas { width: 100%; height: 100%; display: block; }
.qr-cap { font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; }
.qr-card.dark { background: #17171a; border-color: #17171a; }
.qr-card.dark .qr-cap { color: #9a9a94; }

.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}
.link-row .u {
  flex: 1;
  font-size: 11px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.link-row button { font-size: 10.5px; color: var(--accent); flex: none; }

.action-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 8px;
  transition: 0.14s;
  width: 100%;
  text-align: left;
}
.action-row:hover { background: var(--field); }
.action-row svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.action-row span { flex: 1; font-size: 12px; color: var(--ink-2); }
.action-row em { font-style: normal; font-size: 10.5px; color: var(--ink-4); }

.toggle {
  width: 30px; height: 18px;
  border-radius: 10px;
  background: #dcdcd2;
  position: relative;
  flex: none;
  transition: 0.18s;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.toggle.is-on { background: var(--accent); }
.toggle.is-on::after { left: 14px; }

/* ============================== Toast ============================== */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 9px 16px;
  border-radius: 20px;
  background: var(--dark);
  color: #f3f1ea;
  font-size: 12px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s ease both;
  display: flex;
  align-items: center;
  gap: 7px;
}
.toast.err { background: #8c2f22; }
.toast .tick { color: #9ec98a; }
.toast-act {
  pointer-events: auto;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 11px;
  font-size: 11.5px;
  color: #f3f1ea;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.toast-act:hover { background: rgba(255, 255, 255, 0.24); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================== 草稿/加载态 ============================== */

.skeleton {
  color: var(--ink-4);
  font-size: 12.5px;
  padding: 40px 0;
  text-align: center;
}

@media (max-width: 1180px) {
  .panel-themes { width: 232px; }
  .panel-props { width: 268px; }
  .doc-title { width: 190px; }
}
