/* ============================================================
   公众号排版工具 · 全新界面（苹果极简风 · 双主题）
   ============================================================ */
:root{
  --bg:#f5f5f7; --panel:#ffffff; --ink:#1d1d1f; --ink-2:#6e6e73; --ink-3:#a1a1a6;
  --line:#ececee; --line-2:#e3e3e6; --fill:#f0f0f2; --fill-2:#e8e8ea;
  --brand:#DC2626; --brand-soft:#FEF2F2; --wx:#07c160; --wx-2:#08cc66;
  --r-lg:18px; --r:12px; --r-s:8px; --r-pill:980px;
  --shadow:0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --shadow-lg:0 12px 40px rgba(0,0,0,.14);
  --t-fast:150ms; --t:300ms;
}
html[data-theme="dark"]{
  --bg:#000000; --panel:#1c1c1e; --ink:#f5f5f7; --ink-2:#a1a1a6; --ink-3:#6e6e73;
  --line:#38383a; --line-2:#48484a; --fill:#2c2c2e; --fill-2:#3a3a3c;
  --brand:#F05252; --brand-soft:#3a1414; --wx:#07c160;
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg:0 12px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; font-size: 14px;
}
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ========================= 顶部栏 ========================= */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); border-top: 3px solid var(--brand); z-index: 20;
}
html[data-theme="dark"] .topbar { background: rgba(28,28,30,.72); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand .logo { width: 32px; height: 32px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.10)); border-radius: 50%; }
.brand b { font-weight: 800; letter-spacing: .4px; color: var(--ink); }
.brand .sub { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.doc-meta { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.doc-meta .sep { color: var(--ink-3); }
.spacer { flex: 1; }

/* 分段控制：编辑 / 预览 */
.seg { display: flex; background: var(--fill); border-radius: var(--r-pill); padding: 3px; }
.seg button {
  border: none; background: transparent; padding: 6px 14px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: var(--t-fast); display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.seg button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
html[data-theme="dark"] .seg button.active { background: #3a3a3c; }

/* 按钮 */
.btn {
  border: none; border-radius: var(--r-pill); padding: 7px 14px; font-size: 12.5px;
  font-weight: 500; cursor: pointer; background: var(--fill); color: var(--ink);
  transition: var(--t-fast); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { background: var(--fill-2); }
.btn:active { transform: scale(.97); }
.btn.icon { padding: 7px 10px; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--fill); }
.btn.full { width: 100%; justify-content: center; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.wx { background: var(--wx); color: #fff; }
.btn.wx:hover { background: var(--wx-2); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }

/* 发布下拉菜单 */
.publish { position: relative; }
.publish-menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 210px; display: none; z-index: 50;
}
.publish-menu.show { display: block; animation: pop var(--t-fast) ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.publish-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
  border: none; background: transparent; padding: 10px 12px; border-radius: var(--r-s);
  font-size: 13px; color: var(--ink); cursor: pointer; transition: var(--t-fast);
}
.publish-menu button:hover { background: var(--fill); }
.publish-menu .mi { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; background: var(--brand-soft); color: var(--brand); flex: 0 0 auto; }
.publish-menu .sub { font-size: 11px; color: var(--ink-3); }

/* ========================= 主体 ========================= */
.body { display: flex; flex: 1; overflow: hidden; }

/* ========================= 左侧控制台 ========================= */
.side {
  width: 360px; min-width: 360px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden;
}
.side-head { padding: 18px 18px 12px; }
.side-head h1 { font-size: 16px; margin: 0 0 3px; font-weight: 600; letter-spacing: -.01em; }
.side-head p { font-size: 12px; color: var(--ink-3); margin: 0; line-height: 1.5; }

/* 上传区 */
.dropzone {
  margin: 4px 18px 6px; padding: 22px 16px; border: 1.5px dashed var(--line-2);
  border-radius: var(--r); text-align: center; color: var(--ink-2); font-size: 13px;
  cursor: pointer; transition: var(--t-fast); background: #fafafc; position: relative;
}
html[data-theme="dark"] .dropzone { background: #161618; }
.dropzone .plus { font-size: 24px; font-weight: 300; display: block; margin-bottom: 4px; color: var(--ink-3); }
.dropzone:hover, .dropzone.hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone strong { color: var(--ink); font-weight: 600; }
.dropzone.imported {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 13px 15px;
  border-style: solid; border-color: var(--line); background: var(--fill); cursor: default;
}
.dropzone.imported .file-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 16px; flex: 0 0 auto; }
.dropzone.imported .file-info { flex: 1; min-width: 0; }
.dropzone.imported .file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropzone.imported .file-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.dropzone.imported .replace { font-size: 12px; color: var(--brand); font-weight: 600; cursor: pointer; flex: 0 0 auto; }

.side-status { font-size: 11px; color: var(--ink-3); text-align: center; margin: 0 18px 6px; min-height: 14px; }

/* 选项卡 */
.tabs { display: flex; gap: 4px; margin: 4px 18px 0; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; border: none; background: transparent; padding: 11px 0; font-size: 13px;
  font-weight: 500; color: var(--ink-3); cursor: pointer; position: relative; transition: var(--t-fast);
}
.tabs button.active { color: var(--ink); }
.tabs button.active::after { content: ""; position: absolute; left: 25%; right: 25%; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }

/* 可滚动面板 */
.panel { flex: 1; overflow-y: auto; padding: 14px 18px 32px; }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #dcdce0; border-radius: 4px; border: 2px solid var(--panel); }
html[data-theme="dark"] .panel::-webkit-scrollbar-thumb { background: #48484a; }

/* 模板画廊 */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tpl { border: 1.5px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; background: var(--panel); transition: var(--t-fast); position: relative; }
.tpl:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tpl.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,113,227,.15); }
.tpl .swatch { height: 62px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 0 12px; }
.tpl .sw-row { height: 5px; border-radius: 3px; background: rgba(255,255,255,.55); }
.tpl .sw-row.s { width: 60%; }
.tpl .sw-dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.7); margin-top: 2px; }
.tpl .name { padding: 9px 12px; font-size: 12.5px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; }
.tpl .badge { font-size: 10px; font-weight: 600; color: var(--brand); opacity: 0; }
.tpl.selected .badge { opacity: 1; }
.tpl .check { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; display: none; align-items: center; justify-content: center; font-size: 12px; }
.tpl.selected .check { display: flex; }

/* ========================= 配置手风琴（buildPanel 生成） ========================= */
.group { border: 1px solid var(--line); border-radius: var(--r-s); margin-bottom: 8px; overflow: hidden; background: var(--panel); }
.group > h3 {
  font-size: 13px; font-weight: 600; color: var(--ink); margin: 0;
  padding: 11px 14px; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; transition: background .15s;
}
.group > h3:hover { background: #fafafc; }
html[data-theme="dark"] .group > h3:hover { background: #232325; }
.group > h3::after { content: "⌄"; font-size: 14px; color: var(--ink-3); transition: transform .2s; transform: translateY(-2px); }
.group.open > h3::after { transform: rotate(180deg) translateY(-1px); }
.group-body { padding: 4px 14px 12px; display: none; border-top: 1px solid var(--line); }
.group.open .group-body { display: block; }

.field { display: flex; align-items: center; justify-content: space-between; margin: 9px 0; gap: 10px; }
.field label { font-size: 13px; color: var(--ink-2); flex: 1 1 auto; }
.field input[type=text] { width: 108px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: var(--r-s); font-size: 13px; text-align: right; background: #fafafc; transition: .15s; flex: 0 0 auto; }
html[data-theme="dark"] .field input[type=text] { background: #2c2c2e; }
.field input[type=text]:focus { border-color: var(--brand); outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(0,113,227,.12); }
.field input[type=color] { width: 34px; height: 26px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: #fff; padding: 2px; cursor: pointer; flex: 0 0 auto; }
.field input[type=color]:hover { border-color: var(--brand); }
.field select { width: 108px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: var(--r-s); font-size: 13px; background: #fafafc; cursor: pointer; flex: 0 0 auto; }
html[data-theme="dark"] .field select { background: #2c2c2e; }
.field select:focus { border-color: var(--brand); outline: none; }
.field input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--brand); flex: 0 0 auto; }

/* ========================= 右侧预览 ========================= */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.preview-wrap { flex: 1; overflow-y: auto; padding: 32px 24px; display: flex; justify-content: center; align-items: flex-start;
  background: radial-gradient(1200px 500px at 50% -10%, #eef1f6 0%, transparent 60%), var(--bg); }
html[data-theme="dark"] .preview-wrap { background: radial-gradient(1200px 500px at 50% -10%, #11131a 0%, transparent 60%), var(--bg); }
.preview-wrap::-webkit-scrollbar { width: 10px; }
.preview-wrap::-webkit-scrollbar-thumb { background: #d4d4d9; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }

/* 手机框 */
.phone { width: 100%; max-width: 460px; background: #fff; border-radius: 22px; box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,.04); min-height: calc(100% - 0px); position: relative; color: #1d1d1f; }
.phone::before { content: ""; display: block; height: 30px; background: linear-gradient(180deg,#fbfbfd,#f4f4f6); border-radius: 22px 22px 0 0; border-bottom: 1px solid var(--line); }
.phone-inner { padding: 22px 20px 30px; }
.empty-preview { color: var(--ink-3); font-size: 14px; text-align: center; margin-top: 72px; line-height: 1.9; }

/* 内联编辑 / 图片替换 */
.edit { outline: none; border-radius: 4px; transition: background var(--t-fast); cursor: text; }
.edit:hover { background: rgba(0,113,227,.06); }
.edit:focus { background: rgba(0,113,227,.1); box-shadow: inset 0 0 0 1px rgba(0,113,227,.3); }
.phone-inner.no-edit .edit { cursor: default; }
.phone-inner.no-edit .edit:hover, .phone-inner.no-edit .edit:focus { background: transparent; box-shadow: none; }
.img-wrap { position: relative; display: inline-block; line-height: 0; border-radius: 8px; }
.img-replace { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(29,29,31,.78); color: #fff; font-size: 12px; font-weight: 500; padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer; opacity: 0; transition: opacity var(--t-fast); white-space: nowrap; }
.img-wrap:hover .img-replace { opacity: 1; }
.phone-inner.no-edit .img-replace { display: none; }

/* 空态引导 */
.empty { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; }
.empty.show { display: flex; }
.empty .big { width: 84px; height: 84px; border-radius: 24px; background: linear-gradient(135deg,#DC2626,#F87171); display: flex; align-items: center; justify-content: center; font-size: 38px; color: #fff; box-shadow: 0 8px 24px rgba(220,38,38,.3); margin-bottom: 20px; }
.empty h2 { font-size: 21px; margin: 0 0 6px; font-weight: 600; }
.empty p { font-size: 13px; color: var(--ink-2); margin: 0 0 24px; max-width: 360px; line-height: 1.6; }
.steps { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; width: 150px; text-align: left; }
.step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.step .t { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.step .d { font-size: 11px; color: var(--ink-3); line-height: 1.5; }

/* ========================= 弹窗 Modal ========================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; opacity: 0; pointer-events: none; transition: opacity var(--t); }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--panel); border-radius: 20px; width: 480px; max-width: 90vw; max-height: 85vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); transform: scale(.96) translateY(8px); transition: transform var(--t); }
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 14px; }
.modal-header h2 { font-size: 17px; font-weight: 600; margin: 0; color: var(--ink); letter-spacing: -.01em; }
.modal-close { background: var(--fill); border: none; font-size: 15px; cursor: pointer; color: var(--ink-2); width: 28px; height: 28px; border-radius: 50%; transition: .15s; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--fill-2); color: var(--ink); }
.modal-body { padding: 6px 24px 20px; overflow-y: auto; flex: 1; }
.modal-tip { background: var(--brand-soft); border: 1px solid #fecaca; border-radius: var(--r-s); padding: 11px 14px; font-size: 12px; color: #b91c1c; line-height: 1.6; margin-bottom: 16px; }
html[data-theme="dark"] .modal-tip { color: #fca5a5; }
.modal-tip a { color: var(--brand); }
.modal-warning { background: #fff8f0; border: 1px solid #ffe0bf; border-radius: var(--r-s); padding: 11px 14px; font-size: 12px; color: #9a5a12; line-height: 1.6; margin-bottom: 16px; }
.modal-warning a { color: #ea8a1e; font-weight: 600; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.modal-field label .label-text { flex: 1 1 auto; min-width: 0; }
.modal-field label .hint { font-weight: 400; font-size: 11px; color: var(--ink-2); }

/* 字节计数器：微信按 UTF-8 字节校验字段长度，一个汉字 = 3 字节 */
.byte-counter { flex: 0 0 auto; font-weight: 500; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; transition: color var(--t-fast); }
.byte-counter.is-warn { color: #b45309; }                    /* 白底 5.9:1，满足 WCAG AA */
.byte-counter.is-over { color: #c92a2a; font-weight: 700; }  /* 白底 6.3:1，满足 WCAG AA */
html[data-theme="dark"] .byte-counter.is-warn { color: #fbbf24; }
html[data-theme="dark"] .byte-counter.is-over { color: #ff8f85; }
.modal-field.is-over input[type=text], .modal-field.is-over textarea { border-color: #c92a2a; background: #fff5f5; }
.modal-field.is-over input[type=text]:focus, .modal-field.is-over textarea:focus { border-color: #c92a2a; box-shadow: 0 0 0 3px rgba(201,42,42,.15); }
html[data-theme="dark"] .modal-field.is-over input[type=text], html[data-theme="dark"] .modal-field.is-over textarea { border-color: #ff8f85; background: #3a2020; }
.field-alert { background: #fff5f5; border: 1px solid #ffd6d6; border-radius: var(--r-s); padding: 10px 13px; font-size: 12px; line-height: 1.6; color: #a32020; margin-bottom: 14px; }
html[data-theme="dark"] .field-alert { background: #2a1a1a; border-color: #5a2e2e; color: #ff9d94; }
.modal-field input[type=text], .modal-field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r-s); font-size: 13px; font-family: inherit; background: #fafafc; transition: .15s; }
html[data-theme="dark"] .modal-field input[type=text], html[data-theme="dark"] .modal-field textarea { background: #2c2c2e; }
.modal-field input[type=text]:focus, .modal-field textarea:focus { border-color: var(--brand); outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(0,113,227,.12); }
.modal-field textarea { resize: vertical; min-height: 44px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-test-result { margin-top: 10px; font-size: 13px; line-height: 1.6; min-height: 20px; }
.modal-divider { height: 1px; background: var(--line); margin: 18px 0; }
.modal-footer { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-footer .btn { padding: 9px 20px; font-size: 13px; }

/* 同步进度 */
.sync-progress { margin-top: 16px; }
.sync-progress-bar { width: 100%; height: 6px; background: var(--fill); border-radius: 3px; overflow: hidden; }
.sync-progress-fill { height: 100%; background: linear-gradient(90deg, var(--wx), #10b981); border-radius: 3px; width: 0%; transition: width .4s ease; }
.sync-progress-text { margin-top: 8px; font-size: 12px; color: var(--ink-2); text-align: center; }
.sync-result { margin-top: 16px; text-align: center; }

/* ========================= 分享预览弹窗 ========================= */
.share-qr-wrap { text-align: center; padding: 6px 0 16px; }
.share-qr {
  width: 300px; height: 300px; object-fit: contain; border-radius: 12px;
  background: #fff; padding: 12px; box-shadow: var(--shadow);
}
.share-url { display: flex; gap: 8px; align-items: stretch; }
.share-url input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: var(--r-s); font-size: 12.5px; color: var(--ink-2);
  background: var(--fill); font-family: inherit;
}
.share-url input:focus { outline: none; border-color: var(--brand); }
.share-actions { margin-top: 10px; }
.share-actions .btn { width: 100%; justify-content: center; text-decoration: none; }
.share-note { margin-top: 12px; font-size: 12px; color: var(--ink-3); line-height: 1.6; text-align: center; }

/* ========================= Toast ========================= */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: rgba(29,29,31,.92); color: #fff; padding: 11px 22px; border-radius: 12px; font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: var(--t); z-index: 200; box-shadow: 0 8px 28px rgba(0,0,0,.22); max-width: 90vw; text-align: center; line-height: 1.5; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ========================= 行内文字样式工具条 ========================= */
/* 编辑模式下选中某行文字时浮出，提供 字号 / 加粗 / 颜色 编辑 */
.edit.sel {
  background: rgba(0,113,227,.14);
  box-shadow: inset 0 0 0 1.5px var(--brand);
}
.inline-toolbar {
  position: fixed;
  z-index: 90;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--ink);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.inline-toolbar.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.it-group { display: flex; align-items: center; gap: 4px; }
.it-sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 2px; }
.it-select {
  border: 1px solid var(--line-2);
  background: var(--fill);
  color: var(--ink);
  border-radius: var(--r-s);
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.it-select:focus-visible { box-shadow: 0 0 0 2px var(--brand); }
.it-btn {
  width: 30px; height: 28px;
  border: 1px solid var(--line-2);
  background: var(--fill);
  color: var(--ink);
  border-radius: var(--r-s);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background var(--t-fast), color var(--t-fast);
}
.it-btn:hover { background: var(--fill-2); }
.it-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--brand); }
.it-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.it-btn.mixed { background: var(--brand-soft); color: var(--brand); }
.it-swatch {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line-2);
  background: var(--c);
  cursor: pointer;
  padding: 0;
  transition: box-shadow var(--t-fast);
}
.it-swatch:hover { box-shadow: 0 0 0 1px var(--ink-3); }
.it-swatch.active { box-shadow: 0 0 0 2px var(--brand); }
.it-color-custom {
  position: relative;
  width: 24px; height: 24px;
  border-radius: var(--r-s);
  overflow: hidden;
  border: 1px solid var(--line-2);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
}
.it-color-custom input[type=color] {
  position: absolute;
  inset: -6px;
  width: 200%; height: 200%;
  border: none; padding: 0;
  cursor: pointer;
  background: none;
}
.it-color-custom input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.it-color-custom input[type=color]::-webkit-color-swatch { border: none; }
.it-clear {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-s);
  flex: 0 0 auto;
}
.it-clear:hover { background: var(--fill); color: var(--ink); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 纯静态托管模式（无后端）：隐藏依赖公众号 API / 后端的功能入口，
   保留「复制到公众号」「下载 HTML」「分享预览（二维码浏览器端生成）」等纯前端能力 */
.no-backend #settingsBtn { display: none !important; }
.no-backend [data-act="sync"] { display: none !important; }

/* ============================================================
   分享预览：纯净公众号文章页（短链 #p= 或 hash #v= 打开时启用）
   ============================================================ */
.article-preview { display: none; min-height: 100vh; flex-direction: column; background: var(--bg); }
body.preview-mode .article-preview { display: flex; }
body.preview-mode .app,
body.preview-mode .modal-overlay,
body.preview-mode .toast { display: none !important; }

.ap-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  position: sticky; top: 0; z-index: 10;
}
html[data-theme="dark"] .ap-bar { background: rgba(28,28,30,.85); }
.ap-brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.ap-brand img.ap-logo { width: 28px; height: 28px; border-radius: 50%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.10)); }
.ap-brand b { font-weight: 800; letter-spacing: .4px; color: var(--ink); }
.ap-sub { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.ap-edit { margin-left: auto; color: var(--brand); text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; }
.ap-edit:hover { background: var(--brand-soft); text-decoration: none; }

.ap-main { flex: 1; padding: 32px 20px 12px; display: flex; justify-content: center; }
.ap-article {
  width: 100%; max-width: 720px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 36px 40px;
  box-shadow: var(--shadow);
  font-size: 16px; line-height: 1.8; color: var(--ink);
  word-break: break-word;
}
html[data-theme="dark"] .ap-article { box-shadow: var(--shadow); }
.ap-article img { max-width: 100%; height: auto; border-radius: 6px; }
.ap-article h1, .ap-article h2, .ap-article h3 { color: var(--ink); }

.ap-foot { padding: 24px 20px 28px; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.ap-foot b { color: var(--brand); font-weight: 600; }

@media (max-width: 640px) {
  .ap-bar { padding: 10px 14px; }
  .ap-main { padding: 18px 12px 10px; }
  .ap-article { padding: 24px 20px; font-size: 15px; border-radius: 10px; }
}
