/* =========================================================
   排版工坊 · 界面样式（仅作用于工具本身，不影响复制出去的 HTML）
   ========================================================= */
:root {
  --bg: #f5f2ec;
  --panel: #ffffff;
  --line: #e7e2da;
  --line-2: #d8d1c6;
  --ink: #24211d;
  --ink-2: #5d574f;
  --ink-3: #9a938a;
  --accent: #16624f;
  --accent-dark: #114f40;
  --accent-soft: #e6f0ec;
  --shadow-sm: 0 1px 2px rgba(36, 33, 29, .06);
  --shadow-md: 0 6px 24px rgba(36, 33, 29, .10);
  --radius: 10px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

/* 手机浏览器地址栏会吃掉高度，用动态视口单位兜底，否则底部被截掉且滚不到 */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ------------------------- 顶栏 ------------------------- */
.topbar {
  flex: 0 0 auto;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; }

.logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, #1c7a62, #0f4c3e);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  display: grid;
  place-items: center;
  letter-spacing: 0;
  box-shadow: 0 2px 6px rgba(16, 76, 62, .28);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: var(--ink-3); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------- 按钮 ------------------------- */
.btn {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { background: #fbfaf7; border-color: var(--line-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #f7f5f0; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(16, 76, 62, .3);
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.tiny { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn.full { width: 100%; justify-content: center; }

.icon-btn {
  width: 26px; height: 26px;
  border: none; background: transparent;
  color: var(--ink-3); font-size: 13px;
  border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { background: #f2efe9; color: var(--ink); }

/* ------------------------- 主区 ------------------------- */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  transition: padding-right .26s cubic-bezier(.22, .68, .35, 1);
}

body.drawer-open .workspace { padding-right: 344px; }

.pane { min-width: 0; display: flex; flex-direction: column; }

.pane-editor {
  flex: 0 0 46%;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

/* 工具栏 */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid #f1ede6;
}
.tb-group { display: flex; gap: 2px; flex-wrap: wrap; flex: 0 0 auto; }
.tb-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }

.tb {
  flex: 0 0 auto;
  white-space: nowrap;
  height: 28px;
  min-width: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #4a453e;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.tb:hover { background: #f4f1ea; border-color: var(--line); color: var(--ink); }
.tb:active { background: var(--accent-soft); }
.tb.bold { font-weight: 700; }
.tb.italic { font-style: italic; }
.tb.strike { text-decoration: line-through; }

.compbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 12px;
  background: #faf8f4;
  border-bottom: 1px solid #f1ede6;
}
.comp-label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 1px;
  margin-right: 2px;
  flex: 0 0 auto;
}
.chip {
  flex: 0 0 auto;
  white-space: nowrap;
  height: 25px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .14s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: #f3faf7; }
.chip-cfg {
  margin-left: 2px;
  border-style: dashed;
  color: var(--ink-3);
}
.chip-cfg:hover { border-style: solid; }

/* 编辑区 */
.editor-wrap { flex: 1 1 auto; position: relative; min-height: 0; }

#editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 20px 22px 40px;
  border: none;
  outline: none;
  resize: none;
  background: #fdfdfb;
  color: #2c2926;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14.5px;
  line-height: 1.95;
  letter-spacing: .2px;
  tab-size: 2;
}
#editor::placeholder { color: #b6afa4; }

.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 16px;
  border-top: 1px solid #f1ede6;
  font-size: 11.5px;
  color: var(--ink-3);
  background: #fdfcfa;
}
.statusbar .dot { opacity: .5; }
.statusbar .grow { flex: 1; }
#saveState { transition: color .2s; }
#saveState.saved { color: var(--accent); }

/* 分隔条 */
.divider {
  flex: 0 0 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
}
.divider::after {
  content: '';
  position: absolute;
  inset: 0 2px;
  background: var(--line);
  border-radius: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.divider:hover::after { opacity: 1; background: var(--accent); }

/* 预览区 */
.pane-preview {
  flex: 1 1 auto;
  background: #efece5;
  background-image: radial-gradient(rgba(120, 110, 95, .10) 1px, transparent 1px);
  background-size: 16px 16px;
}

.preview-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(6px);
}
.pb-title { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.pb-title em { font-style: normal; color: var(--ink-3); font-weight: 400; font-size: 11.5px; }
.grow { flex: 1; }

.segmented {
  display: inline-flex;
  padding: 2px;
  background: #ece8e0;
  border-radius: 8px;
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  height: 24px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
}

.preview-scroll {
  flex: 1 1 auto;
  overflow: auto;
  padding: 26px 20px 60px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 预览宽度调节 */
.device-btn {
  min-width: 54px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.device-btn.open { background: #fff; border-color: var(--line-2); color: var(--ink); }

.width-pop {
  position: fixed;
  width: 218px;
  padding: 12px 13px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  z-index: 82;
}
.wp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 9px;
}
.wp-head span { font-size: 12px; color: var(--ink-2); }
.wp-head b {
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
}
.wp-presets { display: flex; gap: 4px; margin-bottom: 10px; }
.wp-presets button {
  flex: 1;
  height: 25px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: all .13s;
}
.wp-presets button:hover { border-color: var(--line-2); color: var(--ink); }
.wp-presets button.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-dark);
  font-weight: 600;
}
#wpRange {
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#wpRange::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: #e9e4db;
}
#wpRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(36, 33, 29, .3);
}
#wpRange::-moz-range-track { height: 4px; border-radius: 3px; background: #e9e4db; }
#wpRange::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(36, 33, 29, .3);
}
.wp-tip { margin-top: 7px; font-size: 11px; line-height: 1.6; color: var(--ink-3); }
.wp-tip.warn { color: #b06a1f; }

.device {
  width: var(--device-w, 400px);
  max-width: 100%;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(60, 52, 40, .07), 0 18px 40px -12px rgba(60, 52, 40, .22);
  overflow: hidden;
  padding: 0;
}

.article { padding: 24px 20px 40px; }

/* 空状态 */
.empty-tip {
  color: #b6afa4;
  font-size: 14px;
  line-height: 2;
  text-align: center;
  padding: 60px 0;
}

.source-view {
  width: 100%;
  max-width: 820px;
  margin: 0;
  padding: 20px 22px;
  background: #1e211f;
  color: #d7e2dc;
  border-radius: 12px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------- 抽屉 ------------------------- */
.drawer {
  position: fixed;
  /* 从顶栏下方开始，避免盖住「复制到公众号」 */
  top: var(--topbar-h, 58px);
  right: 0; bottom: 0;
  width: 344px;
  max-width: 88vw;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(40, 34, 26, .10);
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.22, .68, .35, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: none; }

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--line);
}
.drawer-head strong { font-size: 14px; }

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 20px 24px;
}

.set-group { padding: 14px 0; border-bottom: 1px solid #f4f1eb; }
.set-group:last-of-type { border-bottom: none; }
.set-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 10px;
  letter-spacing: .3px;
}
.set-title b { color: var(--accent); font-weight: 600; font-size: 12px; }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card {
  text-align: left;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  transition: all .15s;
}
.theme-card:hover { border-color: var(--line-2); background: #fbfaf7; }
.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: #fbfdfc;
}
.theme-card .swatch { display: flex; gap: 4px; margin-bottom: 7px; }
.theme-card .swatch i { display: block; width: 13px; height: 13px; border-radius: 4px; }
.theme-card b { display: block; font-size: 13px; color: var(--ink); font-weight: 600; }
.theme-card span { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }

.font-tabs {
  display: flex;
  padding: 3px;
  background: #f4f1eb;
  border-radius: 8px;
}
.font-tabs button {
  flex: 1;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.font-tabs button.active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

input[type=range] {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.switch-row input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.drawer-foot { padding: 16px 0 4px; }
.drawer-foot .btn + .btn { margin-top: 8px; }

/* ------------------------- 预览 ↔ 编辑 联动 ------------------------- */
#wx-content [data-line] { cursor: pointer; }
#wx-content [data-line]:hover {
  outline: 1px dashed rgba(22, 98, 79, .38);
  outline-offset: 4px;
}
#wx-content .sync-hit { animation: syncHit 1.4s ease-out; }
@keyframes syncHit {
  0% { box-shadow: 0 0 0 3px rgba(22, 98, 79, .28); }
  100% { box-shadow: 0 0 0 3px rgba(22, 98, 79, 0); }
}

/* ------------------------- 标题样式面板 ------------------------- */
.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
}
.link-btn:hover { background: var(--accent-soft); }

.h-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.h-tabs button {
  flex: 1;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .14s;
}
.h-tabs button:hover { border-color: var(--line-2); }
.h-tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

#headingPanel { display: flex; flex-direction: column; gap: 9px; }
.h-row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.h-label { flex: 0 0 44px; width: 44px; font-size: 12px; color: var(--ink-3); }
.h-ctrl { display: flex; align-items: center; gap: 3px; }

.val { display: inline-flex; align-items: center; gap: 2px; }
.set-title .val { color: var(--accent); }
.val input, .h-ctrl input {
  width: 58px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  text-align: right;
  -moz-appearance: textfield;
}
.val input::-webkit-outer-spin-button,
.val input::-webkit-inner-spin-button,
.h-ctrl input::-webkit-outer-spin-button,
.h-ctrl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.val input:focus, .h-ctrl input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.val i, .h-ctrl i { font-style: normal; font-size: 11px; color: var(--ink-3); }

.sw-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sw {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: box-shadow .14s;
}
.sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); border-color: var(--accent); }
.sw.auto {
  width: auto;
  padding: 0 8px;
  font-size: 11px;
  color: var(--ink-2);
  background: #fbfaf7;
  line-height: 19px;
}
.sw.auto.on { color: var(--accent); border-color: var(--accent); }
.sw-custom {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
}
.sw-custom input[type=color] {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.sw-custom input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
.sw-custom input[type=color]::-webkit-color-swatch { border: none; border-radius: 4px; }

.segmented.tiny button { height: 22px; padding: 0 11px; font-size: 11.5px; }
.switch-row.tight { padding: 1px 0; font-size: 12.5px; }
.switch-row.tight input { width: 15px; height: 15px; }

.set-hint { margin: 9px 0 0; font-size: 11px; line-height: 1.7; color: var(--ink-3); }

.btn.smart {
  border-color: #cfe0d8;
  background: var(--accent-soft);
  color: #16564a;
  font-weight: 500;
}
.btn.smart:hover { background: #dcece5; border-color: var(--accent); color: var(--accent-dark); }

/* ------------------------- 一键排版 ------------------------- */
.modal-card.wide { max-width: 1000px; max-height: 90vh; }

.smart-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 22px 18px;
  overflow-y: auto;
}
.smart-body .lead { margin: 0; font-size: 13px; }
.smart-body .lead strong { color: var(--ink); }

.smart-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.smart-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.smart-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .5px;
}
.smart-label em { font-style: normal; color: var(--accent); font-size: 11px; }
.smart-col textarea {
  height: 290px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fdfdfb;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.9;
  outline: none;
}
.smart-col textarea::placeholder { color: #b6afa4; }
#smartPreview {
  background: #fcfbf8;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.8;
}
.smart-col textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.smart-opts { display: flex; flex-wrap: wrap; gap: 7px 18px; font-size: 12.5px; color: var(--ink-2); }
.smart-opts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.smart-opts input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.smart-styles { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 4px; border-top: 1px dashed #eee9e0; }
.style-row { display: flex; gap: 6px; flex-wrap: wrap; }
.style-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: all .14s;
}
.style-chip i { display: block; width: 10px; height: 10px; border-radius: 50%; }
.style-chip:hover { border-color: var(--accent); color: var(--ink); }
.style-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.modal-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: #fcfbf8;
}


/* ------------------------- 菜单 ------------------------- */
.menu {
  position: fixed;
  min-width: 190px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 80;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.menu button:hover { background: #f5f3ee; color: var(--ink); }
.menu button.danger { color: #b4433c; }
.menu button.danger:hover { background: #fdf1f0; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 6px; }

/* ------------------------- 弹窗 ------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 18, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(20, 16, 10, .3);
  overflow: hidden;
}
.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 14px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head strong { font-size: 15px; }
.modal-body { padding: 18px 22px 26px; overflow-y: auto; font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.modal-body .lead { margin: 0 0 20px; color: var(--ink-2); }
.modal-card.narrow { max-width: 520px; }

.draft-list { display: flex; flex-direction: column; gap: 8px; }
.draft-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  transition: all .15s;
}
.draft-item:hover { border-color: var(--accent); background: #fbfdfc; }
.draft-item .di-main { flex: 1; min-width: 0; cursor: pointer; }
.draft-item b { display: block; font-size: 13.5px; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-item span { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.draft-item .di-del {
  flex: 0 0 auto;
  border: none; background: transparent;
  color: var(--ink-3); font-size: 12px; cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
}
.draft-item .di-del:hover { background: #fdf1f0; color: #b4433c; }
.draft-empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 28px 0; }
.modal-body h4 {
  margin: 24px 0 10px;
  font-size: 13.5px;
  color: var(--ink);
  padding-left: 9px;
  border-left: 3px solid var(--accent);
  line-height: 1.4;
}
.modal-body .hint { color: var(--ink-3); font-size: 12.5px; margin: 8px 0 12px; }

table.cheat { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.cheat td { padding: 7px 10px; border-bottom: 1px dashed #eee9e0; vertical-align: top; }
table.cheat td:first-child { width: 40%; color: var(--ink); white-space: nowrap; }
table.cheat code, .modal-body p code {
  background: #f4f1ea;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #9a4a2f;
}
pre.code-demo {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: #f7f5f0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.8;
  color: #3f4a44;
  white-space: pre-wrap;
}
ol.flow, ul.flow { margin: 0; padding-left: 20px; }
ol.flow li, ul.flow li { margin-bottom: 5px; }

/* ------------------------- Toast ------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  max-width: min(560px, 88vw);
  padding: 11px 20px;
  background: rgba(28, 30, 28, .93);
  color: #fff;
  font-size: 13px;
  line-height: 1.7;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 200;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: rgba(18, 76, 60, .95); }
.toast.err { background: rgba(150, 44, 38, .95); }

/* ------------------------- 滚动条 ------------------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(120, 110, 95, .26); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 110, 95, .42); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------- 组件样式配置 ------------------------- */
.comp-card { max-width: 880px; height: 80vh; }
.comp-head-hint { margin-left: 10px; font-size: 11.5px; color: var(--ink-3); }

.comp-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.comp-list {
  flex: 0 0 132px;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  background: #faf8f4;
  overflow-y: auto;
}
.comp-list button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}
.comp-list button:hover { background: #f1ede4; color: var(--ink); }
.comp-list button.active { background: var(--accent); color: #fff; }
.comp-list button i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  flex: 0 0 auto;
}
.comp-list button.on i { opacity: .85; }

.comp-panel {
  flex: 1 1 auto;
  min-width: 0;
  padding: 14px 20px 20px;
  overflow-y: auto;
}
.comp-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.comp-panel-head b { font-size: 14px; color: var(--ink); }
.comp-tag {
  padding: 1px 7px;
  border-radius: 5px;
  background: #f1ede4;
  color: var(--ink-3);
  font-size: 11px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

.comp-panel .h-row { margin-top: 10px; }
.comp-panel .h-label { flex: 0 0 46px; }

.set-mini { font-size: 11px; color: var(--ink-3); line-height: 1.6; }

.comp-tpl-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.comp-tpl-head .set-mini { font-weight: 400; }

#compTpl {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
  outline: none;
}
#compTpl:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.comp-preview {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 260px;
  overflow-y: auto;
}

@media (max-width: 720px) {
  .comp-card { height: 86vh; }
  .comp-layout { flex-direction: column; }
  .comp-list {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .comp-list button { width: auto; white-space: nowrap; flex: 0 0 auto; }
  .comp-list button i { display: none; }
  .comp-panel { padding: 12px 14px 18px; }
  .comp-panel .h-label { flex: 0 0 40px; }
}

/* ------------------------- 违规检测 ------------------------- */
.risk-btn { position: relative; }
.risk-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 15px; height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: #c8392f;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
  letter-spacing: 0;
  box-shadow: 0 0 0 2px #fff;
}
.risk-badge.warn { background: #c2761a; }

.risk-pill {
  flex: 0 0 auto;
  height: 19px;
  padding: 0 8px;
  margin-right: 4px;
  border: none;
  border-radius: 10px;
  background: #fdecec;
  color: #b2372e;
  font-size: 11px;
  line-height: 19px;
  cursor: pointer;
  white-space: nowrap;
}
.risk-pill:hover { background: #fbdcdc; }
.risk-pill.ok { background: #e9f3ee; color: #1b6b52; }
.risk-pill.warn { background: #fdf2e2; color: #96601a; }

/* 检测结果做成右侧抽屉：跳转时左边编辑器仍然可见、可改 */
.risk-drawer {
  position: fixed;
  top: var(--topbar-h, 58px);
  right: 0; bottom: 0;
  width: 420px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(40, 34, 26, .10);
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.22, .68, .35, 1);
  z-index: 62;
}
.risk-drawer.open { transform: none; }
body.risk-open .workspace { padding-right: 420px; }

.risk-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--line);
}
.risk-head-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.risk-head-title strong { font-size: 14px; }
.risk-head-title span {
  font-size: 10.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.risk-head-tools { display: flex; align-items: center; gap: 4px; }

.risk-hl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 8px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.risk-hl input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.risk-sum {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 22px 12px;
  background: #fcfbf8;
  border-bottom: 1px solid var(--line);
}
.rs-row { display: flex; align-items: baseline; gap: 16px; }
.rs-item { display: flex; align-items: baseline; gap: 4px; }
.rs-num { font-size: 20px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.rs-label { font-size: 11.5px; color: var(--ink-3); }
.rs-item.h .rs-num { color: #c8392f; }
.rs-item.m .rs-num { color: #c2761a; }
.rs-item.l .rs-num { color: #5b7fa3; }
.rs-item.zero .rs-num { color: #cfc8bd; }
.rs-verdict {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
}
.rs-verdict b { color: #b2372e; }
.rs-verdict.ok { color: #1b6b52; }

.risk-filter {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
}
.rf-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.rf-row > .rf-hint { font-size: 11px; color: var(--ink-3); margin-right: 2px; }
.rf-tab, .rf-cat {
  height: 23px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink-2);
  font-size: 11.5px;
  cursor: pointer;
  transition: all .13s;
}
.rf-tab:hover, .rf-cat:hover { border-color: var(--accent); color: var(--accent); }
.rf-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.rf-cat.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.rf-tab em, .rf-cat em { font-style: normal; opacity: .65; margin-left: 3px; }
.rf-custom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  padding: 0 4px 0 9px;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: #fdfcf9;
}
.rf-custom button {
  width: 16px; height: 16px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.rf-custom button:hover { background: #fbe6e4; color: #b2372e; }

.risk-list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 22px 18px;
}

.risk-item {
  position: relative;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: 9px;
  padding: 9px 11px 10px;
  background: #fff;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.risk-item:hover { box-shadow: var(--shadow-sm); }
.risk-item.jumpable { cursor: pointer; }
.risk-item.jumpable:hover { border-color: var(--line-2); background: #fdfdfb; }
.risk-item.lv3 { border-left-color: #d94a42; }
.risk-item.lv2 { border-left-color: #d98324; }
.risk-item.lv1 { border-left-color: #7d9dbb; }

.ri-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-right: 48px; }
.ri-lv {
  flex: 0 0 auto;
  height: 19px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 19px;
  font-weight: 600;
  letter-spacing: .3px;
}
.ri-lv.lv3 { background: #fdeaea; color: #b2372e; }
.ri-lv.lv2 { background: #fdf2e2; color: #96601a; }
.ri-lv.lv1 { background: #eaf1f8; color: #4d6f92; }
.ri-cat { font-size: 11px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; line-height: 17px; }
.ri-word {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  background: #f6f3ec;
  border-radius: 3px;
  padding: 1px 4px;
}
.risk-item.lv3 .ri-word { background: #fdeaea; color: #a5302a; }
.risk-item.lv2 .ri-word { background: #fdf2e2; color: #8a5716; }
.risk-item.lv1 .ri-word { background: #eaf1f8; color: #456688; }
.ri-count { font-size: 11px; color: var(--ink-3); }
.ri-line {
  border: none;
  background: transparent;
  padding: 0 2px;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border-bottom: 1px dashed #d5cec3;
  line-height: 1.5;
}
.ri-line:hover { color: var(--accent); border-bottom-color: var(--accent); }
.ri-ignore {
  position: absolute;
  top: 7px;
  right: 8px;
}
.ri-btn {
  height: 23px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-2);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.ri-btn:hover { border-color: var(--accent); color: var(--accent); background: #f6fbf9; }
.ri-btn.ghost:hover { border-color: #e2b3ae; color: #b2372e; background: #fdf6f5; }

.ri-ctx {
  margin-top: 7px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #faf8f4;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  word-break: break-all;
}
.ri-ctx b { color: #a5302a; background: #fbe3e1; padding: 0 2px; border-radius: 2px; }
.ri-ctx .ri-ell { color: #bdb5a9; }
.ri-tip { margin-top: 5px; font-size: 11.5px; color: var(--ink-3); line-height: 1.65; }
.ri-tip b { color: var(--ink-2); font-weight: 600; }

.risk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 46px 0 52px;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
}
.risk-empty .re-mark {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #eaf4ee;
  color: #1b6b52;
  font-size: 20px;
  line-height: 42px;
}
.risk-empty b { color: var(--ink-2); font-size: 14px; }

.risk-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-top: 1px solid var(--line);
  background: #fcfbf8;
}
.risk-add { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; }
.risk-add input {
  flex: 1 1 auto;
  min-width: 60px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.risk-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.risk-add select {
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  outline: none;
}
.risk-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 22px 14px;
  font-size: 11px;
  line-height: 1.7;
  color: #aaa297;
  background: #fcfbf8;
}

@media (max-width: 900px) {
  body.risk-open .workspace { padding-right: 0; }
  .risk-drawer { width: 100%; max-width: 100%; }
}
@media (max-width: 720px) {
  .risk-head-title span { display: none; }
  .risk-sum { gap: 12px; padding: 10px 14px; }
  .rs-verdict { font-size: 11.5px; }
  .risk-filter, .risk-list { padding-left: 14px; padding-right: 14px; }
  .risk-foot { flex-wrap: wrap; padding: 10px 14px; }
  .risk-add input { width: 150px; }
  .risk-note { padding: 0 14px 12px; }
}

/* ------------------------- 响应式 ------------------------- */
@media (max-width: 900px) {
  :root { --topbar-h: 52px; }
  .topbar { height: 52px; padding: 0 10px; gap: 8px; }
  .brand-text span { display: none; }
  .workspace { flex-direction: column; }
  .pane-editor { flex: 0 0 46%; border-right: none; border-bottom: 1px solid var(--line); }
  .pane-preview { flex: 1 1 54%; }
  .divider { display: none; }
  .preview-scroll { padding: 16px 10px 40px; }
  .pb-title em { display: none; }
  .toolbar, .compbar { padding-left: 8px; padding-right: 8px; }
  .toolbar, .toolbar .tb-group, .compbar { flex-wrap: nowrap; }
  .toolbar, .compbar { overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar, .compbar::-webkit-scrollbar { display: none; }
  body.drawer-open .workspace { padding-right: 0; }
  .modal { padding: 12px; }
  .smart-cols { grid-template-columns: 1fr; }
  .smart-col textarea { height: 170px; }
  .smart-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 8px; gap: 6px; }
  /* 品牌字和「文件」让位给真正要点的按钮 */
  .brand-text { display: none; }
  #btnMore { display: none; }
  #btnSmart span { display: none; }
  .brand { gap: 7px; }
  .logo { width: 26px; height: 26px; font-size: 13px; border-radius: 8px; }
  .brand-text strong { font-size: 13px; }
  .topbar-right { gap: 5px; min-width: 0; }
  .btn { height: 30px; padding: 0 9px; font-size: 12px; gap: 4px; }
  .btn svg { display: none; }
  #btnSmart svg { display: inline-block; }
  #btnHelp { display: none; }
  .pb-title { display: none; }
}

/* ------------------------- 窄屏单栏（编辑 / 预览二选一） ------------------------- */
.mobile-switch {
  display: none;
  flex: 0 0 auto;
  gap: 4px;
  padding: 7px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.mobile-switch button {
  flex: 1 1 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mobile-switch button.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-dark);
  font-weight: 600;
}
/* 预览区右上角的切换提示，只在单栏模式出现 */
.mobile-switch .ms-hint {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  padding-right: 4px;
  font-size: 11.5px;
  color: var(--ink-3);
}

@media (max-width: 760px), (max-height: 620px) {
  .mobile-switch { display: flex; }
  .workspace { flex-direction: column; }
  .divider { display: none; }

  /* 一次只显示一个，各自占满。flex-basis 必须是 0 + min-height:0，
     否则纵向 flex 子项会按内容高度（整篇文章）撑开，预览就不再滚动了 */
  .pane-editor {
    flex: 1 1 0%;
    min-height: 0;
    border-right: none;
    border-bottom: none;
  }
  .pane-preview {
    display: none;
    flex: 1 1 0%;
    min-height: 0;
  }
  body.show-preview .pane-editor { display: none; }
  body.show-preview .pane-preview { display: flex; }

  .preview-scroll { padding: 14px 10px 32px; }
  .pb-title, .pb-title em { display: none; }
}

/* 手机上宽度控件没意义，腾出位置 */
@media (max-width: 560px) {
  #widthTabs, .device-btn { display: none; }
  .preview-bar { justify-content: flex-end; }
}

/* 键盘弹起：视口变矮，先把非必要的条让出来 */
@media (max-height: 470px) {
  .compbar, .statusbar { display: none; }
  .mobile-switch { padding: 5px 8px; }
  .mobile-switch button { height: 30px; }
}
body.kbd-open .compbar,
body.kbd-open .statusbar,
body.kbd-open .mobile-switch { display: none; }
/* iOS 键盘盖住页面时，把工作区缩到键盘上方 */
body.kbd-open .workspace { padding-bottom: var(--kbd, 0px); }
