/* doc.71mi.com —— 论坛排版工具 编辑器界面样式 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 6px 24px rgba(15, 23, 42, .10);
  --radius: 10px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7d2e0; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #9fb0c4; border: 2px solid transparent; background-clip: content-box; }

/* ===================== 顶栏 ===================== */
.topbar {
  height: 54px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: 4px; white-space: nowrap; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--faint); margin-left: 2px; }

.topbar-spacer { flex: 1; }

.topbar-group { display: flex; align-items: center; gap: 6px; }
.topbar-divider { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font-size: 13px; padding: 7px 13px; border-radius: 8px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s ease; white-space: nowrap; line-height: 1; font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); color: var(--text); background: var(--panel); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent; color: #fff; font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-dark), var(--accent-dark)); color: #fff; border-color: transparent; }

.btn-icon { padding: 7px 9px; font-size: 14px; }

/* 主题色圆点 */
.theme-dots { display: flex; align-items: center; gap: 5px; padding: 0 2px; }
.theme-dots .dots-label { font-size: 12px; color: var(--faint); margin-right: 2px; }
.dot {
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform .12s ease, box-shadow .12s ease; padding: 0;
}
.dot:hover { transform: scale(1.15); }
.dot.active { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.1); }

/* ===================== 工作区三栏 ===================== */
.workbench { display: flex; height: calc(100vh - 54px); }

/* ---- 左侧：分类竖导航 ---- */
.cat-rail {
  width: 64px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 8px 6px; gap: 2px; overflow-y: auto; flex-shrink: 0;
}
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px; border-radius: 8px; cursor: pointer; border: none; background: none;
  color: var(--muted); transition: all .15s ease; font-family: inherit;
}
.cat-item .ci-icon { font-size: 17px; line-height: 1; }
.cat-item .ci-name { font-size: 11px; line-height: 1.2; transform: scale(.95); white-space: nowrap; }
.cat-item:hover { background: #f1f5f9; color: var(--text); }
.cat-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---- 模块面板 ---- */
.mod-panel {
  width: 252px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.mod-search { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.mod-search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; outline: none; background: #f8fafc; color: var(--text); font-family: inherit;
  transition: border-color .15s ease;
}
.mod-search input:focus { border-color: var(--accent); background: #fff; }

.mod-list { flex: 1; overflow-y: auto; padding: 8px 10px 60px; }
.mod-group-title {
  font-size: 12px; color: var(--faint); font-weight: 600;
  margin: 12px 4px 6px; display: flex; align-items: center; gap: 6px;
}
.mod-group-title:first-child { margin-top: 4px; }

.mod-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; margin-bottom: 7px; cursor: grab; background: #fff;
  transition: all .15s ease; user-select: none;
}
.mod-card:hover {
  border-color: var(--accent); box-shadow: var(--shadow-sm);
  transform: translateY(-1px); background: var(--accent-soft);
}
.mod-card:active { cursor: grabbing; }
.mod-card.dragging { opacity: .45; }
.mc-icon {
  width: 34px; height: 34px; border-radius: 8px; background: #f1f5f9;
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.mod-card:hover .mc-icon { background: #fff; }
.mc-meta { min-width: 0; }
.mc-name { font-size: 13px; font-weight: 600; color: var(--text); }
.mc-desc { font-size: 11.5px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-empty { text-align: center; color: var(--faint); font-size: 13px; padding: 30px 0; }

/* ---- 画布区 ---- */
.canvas-area { flex: 1; overflow-y: auto; padding: 22px 28px 80px; position: relative; }

.canvas-hint {
  max-width: 860px; margin: 0 auto 14px; font-size: 12.5px; color: var(--faint);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 0 4px;
}
.canvas-hint span { display: inline-flex; align-items: center; gap: 4px; }

.paper {
  max-width: 860px; margin: 0 auto; background: #fff; border-radius: 14px;
  box-shadow: var(--shadow-md); padding: 36px 40px 48px; min-height: calc(100vh - 220px);
}

/* 空画布提示 */
.canvas-empty {
  border: 2px dashed var(--line-strong); border-radius: 12px;
  padding: 70px 20px; text-align: center; color: var(--faint);
}
.canvas-empty .ce-icon { font-size: 40px; margin-bottom: 12px; }
.canvas-empty .ce-text { font-size: 15px; line-height: 2; }
.canvas-empty.drag-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---- 画布内的块 ----
 * 用 outline 而不是 border：outline 不占布局、也不会阻断相邻模块的
 * margin 合并，保证编辑器里的块间距与论坛发布后的真实效果一致。 */
.doc-block { position: relative; outline: 1px dashed transparent; outline-offset: 3px; border-radius: 2px; transition: outline-color .12s ease; }
.doc-block:hover { outline-color: var(--line-strong); }
.doc-block.selected { outline: 2px solid var(--accent); }
.doc-block.drag-src { opacity: .35; }

/* min-height 兜底：内容被删空（仅剩 <br>）时块不至于缩成一条线、无法悬停操作 */
.blk-body { outline: none; min-height: 18px; }
.blk-body:focus { outline: none; }
.blk-body:empty::before { content: '（空模块，可悬停右上角删除）'; color: var(--faint); font-size: 12px; }

/* 块工具条（悬停出现） */
.blk-chip, .blk-tools {
  position: absolute; top: -14px; z-index: 10;
  display: flex; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm); opacity: 0; pointer-events: none;
  transition: opacity .12s ease; user-select: none;
}
.doc-block:hover .blk-chip, .doc-block:hover .blk-tools,
.doc-block.selected .blk-chip, .doc-block.selected .blk-tools { opacity: 1; pointer-events: auto; }

.blk-chip { left: 8px; padding: 3px 10px 3px 8px; gap: 5px; cursor: grab; font-size: 12px; color: var(--muted); }
.blk-chip:active { cursor: grabbing; }
.blk-chip .bc-grip { font-size: 13px; color: var(--faint); letter-spacing: -1px; }
.blk-chip .bc-name { font-weight: 600; }

.blk-tools { right: 8px; padding: 2px; gap: 1px; }
.blk-tools button {
  width: 26px; height: 24px; border: none; background: none; border-radius: 999px;
  cursor: pointer; font-size: 13px; color: var(--muted); line-height: 1;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
  transition: all .12s ease;
}
.blk-tools button:hover { background: var(--accent-soft); color: var(--accent); }
.blk-tools button.bt-del:hover { background: #fef2f2; color: var(--danger); }

/* 块宽度拉伸手柄 */
.blk-resize {
  position: absolute; top: 50%; right: -7px; transform: translateY(-50%);
  width: 14px; height: 44px; max-height: 80%;
  cursor: ew-resize; z-index: 9;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s ease;
}
.blk-resize::before {
  content: ''; width: 4px; height: 100%;
  background: var(--accent); border-radius: 4px; opacity: .55;
}
.blk-resize:hover::before { opacity: 1; }
.doc-block:hover .blk-resize, .doc-block.selected .blk-resize,
.doc-block.resizing .blk-resize { opacity: 1; }
.doc-block.resizing { outline: 2px solid var(--accent); }
body.col-resizing, body.col-resizing * { cursor: ew-resize !important; user-select: none !important; }

.resize-tip {
  position: fixed; z-index: 120; background: #0f172a; color: #fff;
  font-size: 12px; padding: 4px 10px; border-radius: 6px; pointer-events: none;
}
.resize-tip.hidden { display: none; }

/* ===================== 选中文字浮动样式条 ===================== */
.text-bar {
  position: fixed; z-index: 95;
  display: flex; align-items: center; gap: 2px;
  background: #0f172a; border-radius: 10px; padding: 5px 7px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .35);
}
.text-bar.hidden { display: none; }
.text-bar button {
  border: none; background: none; color: #cbd5e1; font-size: 13px;
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 6px; cursor: pointer;
  font-family: inherit; line-height: 1; white-space: nowrap;
  transition: all .12s ease;
}
.text-bar button:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.text-bar button b, .text-bar button i, .text-bar button u, .text-bar button s { font-size: 13.5px; }
.tb-divider { width: 1px; height: 18px; background: rgba(255, 255, 255, .18); margin: 0 3px; }

.tb-color {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 13px;
  color: #cbd5e1; transition: background .12s ease;
}
.tb-color:hover { background: rgba(255, 255, 255, .14); }
.tb-color input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: none; padding: 0;
}

.tb-panel {
  position: fixed; z-index: 96; min-width: 150px; max-height: 320px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 5px;
}
.tb-panel.hidden { display: none; }
.tb-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  font-size: 13.5px; color: var(--text); padding: 7px 12px; border-radius: 7px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.tb-item:hover { background: var(--accent-soft); color: var(--accent); }
.tb-fonts { min-width: 190px; }
.tb-fonts .tb-item { font-size: 14.5px; }

/* 拖放指示线 */
.drop-indicator {
  height: 4px; border-radius: 2px; margin: 4px 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  box-shadow: 0 0 8px rgba(37, 99, 235, .55);
  pointer-events: none;
}

/* ===================== 弹窗 ===================== */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
.overlay.hidden { display: none; }

.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  width: 100%; max-width: 920px; max-height: 86vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; }
.modal-close {
  width: 30px; height: 30px; border: none; background: #f1f5f9; border-radius: 8px;
  font-size: 15px; cursor: pointer; color: var(--muted); font-family: inherit;
}
.modal-close:hover { background: #fef2f2; color: var(--danger); }

.modal-body { overflow-y: auto; padding: 0; }

/* 预览弹窗：模拟论坛白底 */
.preview-body { padding: 30px 34px; }

/* 源码弹窗 */
.source-body { padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.source-tip { font-size: 12.5px; color: var(--faint); line-height: 1.7; }
.source-body textarea {
  width: 100%; height: 52vh; resize: vertical; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 12.5px; line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  color: #334155; background: #f8fafc; outline: none; white-space: pre;
}
.source-body textarea:focus { border-color: var(--accent); background: #fff; }

/* ===================== 块级配色弹层 ===================== */
.color-pop {
  position: fixed; z-index: 90; width: 248px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-md); padding: 12px 14px;
}
.color-pop.hidden { display: none; }
.cp-title { font-size: 13px; font-weight: 700; margin-bottom: 9px; }
.cp-presets { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 11px; }
.cp-presets .dot { width: 22px; height: 22px; }
.cp-custom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cp-pick {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text);
  cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px;
  transition: border-color .15s ease;
}
.cp-pick:hover { border-color: var(--accent); }
.cp-pick input[type="color"] {
  width: 22px; height: 22px; border: none; padding: 0; background: none; cursor: pointer;
}
.cp-pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.cp-pick input[type="color"]::-webkit-color-swatch { border: 1px solid var(--line-strong); border-radius: 5px; }
.cp-follow {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font-size: 12px; padding: 6px 9px; border-radius: 8px; cursor: pointer; font-family: inherit;
  white-space: nowrap; transition: all .15s ease;
}
.cp-follow:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cp-note { font-size: 11.5px; color: var(--faint); line-height: 1.6; margin-top: 10px; }

/* 边框样式选择区 */
.cp-sec { border-top: 1px solid var(--line); margin-top: 11px; }
.cp-sec.cp-disabled { opacity: .38; pointer-events: none; }
.cp-borders { display: flex; gap: 6px; }
.cp-bs {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 2px 6px; cursor: pointer; font-size: 11.5px; color: var(--muted);
  font-family: inherit; transition: all .15s ease;
}
.cp-bs i {
  display: block; width: 26px; height: 0;
  border-bottom: 2px solid currentColor;
}
.cp-bs:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cp-bs.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ===================== Toast ===================== */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: #0f172a; color: #fff; font-size: 13.5px; padding: 11px 22px;
  border-radius: 999px; box-shadow: 0 10px 30px rgba(15, 23, 42, .35);
  opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 200;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== 响应式 ===================== */
@media (max-width: 1080px) {
  .mod-panel { width: 220px; }
  .brand-sub { display: none; }
}
@media (max-width: 920px) {
  .topbar { overflow-x: auto; }
  .canvas-area { padding: 16px 12px 60px; }
  .paper { padding: 22px 18px 36px; }
}
