:root {
  --primary: #4f6ef7;
  --primary-dark: #3b55e0;
  --primary-light: #eef1ff;
  --accent: #7c5cff;
  --text: #1c2333;
  --text-2: #5b6478;
  --text-3: #8a93a8;
  --bg: #ffffff;
  --bg-soft: #f6f8fc;
  --border: #e6eaf2;
  --radius: 12px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  flex: 0 0 auto;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 20px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 11px; color: var(--text-3); }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  border: none; cursor: pointer; border-radius: 9px;
  font-size: 13px; font-weight: 600; padding: 8px 14px; transition: .18s;
  white-space: nowrap;
}
.btn-ghost { background: #fff; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-doc { background: var(--primary); color: #fff; }
.btn-doc:hover { background: var(--primary-dark); }
.btn-doc:disabled { opacity: .55; cursor: default; }
.divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* ---------- Workspace ---------- */
.workspace {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 20px 20px;
  min-height: 0;
}
.pane {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pane-head {
  flex: 0 0 auto;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: #fafbfe;
}
.pane-title { font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.hint { font-size: 11.5px; color: var(--text-3); text-align: right; }
.pane-tools { display: flex; align-items: center; gap: 8px; }
.btn-mini {
  font-size: 12px; padding: 5px 10px; background: #fff; border: 1px solid var(--border);
  color: var(--text-2); border-radius: 8px; cursor: pointer; font-weight: 600; transition: .15s;
  white-space: nowrap;
}
.btn-mini:hover { border-color: var(--primary); color: var(--primary); }

#input {
  flex: 1 1 auto;
  border: none; outline: none; resize: none;
  padding: 16px; font-family: var(--mono); font-size: 13.5px; line-height: 1.7;
  color: var(--text); background: #fff;
}
.preview { flex: 1 1 auto; overflow: auto; padding: 28px 32px; background: #fff; }

/* ---------- Markdown preview（贴近 DeepSeek 富文本风格） ---------- */
.markdown-body {
  font-size: 15.5px; color: var(--text); line-height: 1.75;
  max-width: 820px; margin: 0 auto; word-wrap: break-word;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1 { font-size: 27px; font-weight: 800; margin: 8px 0 18px; line-height: 1.3; }
.markdown-body h2 { font-size: 21px; font-weight: 700; margin: 30px 0 12px; line-height: 1.35; }
.markdown-body h3 { font-size: 17.5px; font-weight: 700; margin: 22px 0 8px; }
.markdown-body h4 { font-size: 15.5px; font-weight: 700; margin: 16px 0 6px; }
.markdown-body p { margin: 12px 0; }
.markdown-body strong { font-weight: 700; }
.markdown-body ul, .markdown-body ol { margin: 12px 0 12px 24px; }
.markdown-body li { margin: 5px 0; }
.markdown-body li::marker { color: var(--text-3); }
.markdown-body blockquote {
  border-left: 4px solid var(--primary); background: var(--primary-light);
  margin: 14px 0; padding: 10px 16px; border-radius: 0 10px 10px 0; color: var(--text-2);
}
.markdown-body a { color: var(--primary); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
/* 行内代码（浅色，贴近 DeepSeek） */
.markdown-body code:not(pre code) {
  background: #f2f3f5; padding: 2px 6px; border-radius: 5px;
  font-family: var(--mono); font-size: .88em; color: #d6336c;
}
/* 代码块（浅灰底 + 圆角 + 语法高亮） */
.markdown-body pre.code-block {
  background: #f6f8fa; color: #24292f; border: 1px solid #eaecef; border-radius: 10px;
  padding: 14px 16px; overflow: auto; margin: 14px 0; font-size: 13px; line-height: 1.6;
}
.markdown-body pre.code-block code { font-family: var(--mono); background: none; padding: 0; color: inherit; }
/* 表格 */
.markdown-body table {
  border-collapse: collapse; margin: 16px 0; width: 100%; font-size: 14.5px;
  overflow: hidden; border-radius: 8px; box-shadow: 0 0 0 1px var(--border);
}
.markdown-body th, .markdown-body td {
  border: none; padding: 9px 13px; text-align: left;
}
.markdown-body th { background: #f3f5fb; color: var(--text); font-weight: 700; border-bottom: 2px solid #e3e8f2; }
.markdown-body td { border-bottom: 1px solid #eef1f6; }
.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body tr:nth-child(even) td { background: #fafbfe; }
/* 流程图 / 图表 */
.mermaid-block { margin: 18px 0; text-align: center; }
.mermaid-block svg { max-width: 100%; height: auto; }
.katex-display { margin: 18px 0; overflow-x: auto; overflow-y: hidden; }
.katex { font-size: 1.05em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #1c2333; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 用户区 ---------- */
#userArea { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 12px;
  font-size: 12.5px;
}
.user-chip .u-name { font-weight: 600; color: var(--text); }
.user-chip .u-plan {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.u-plan.free { background: #eef1ff; color: var(--primary-dark); }
.u-plan.pro { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }
.user-chip .u-quota { color: var(--text-3); }
.user-chip .u-logout {
  background: #f0f2f7; border: none; border-radius: 999px; width: 26px; height: 26px;
  cursor: pointer; color: var(--text-2); font-size: 13px;
}
.user-chip .u-logout:hover { background: #e2e6ef; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(20,28,50,.45);
  display: none; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(3px); padding: 16px;
}
.modal.show { display: flex; }
.modal-card {
  position: relative; background: #fff; border-radius: 16px; padding: 28px;
  width: 380px; max-width: 100%; box-shadow: 0 24px 60px rgba(20,28,50,.25);
  animation: pop .2s ease;
}
.modal-card.wide { width: 720px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; border: none; background: #f0f2f7;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 14px;
}
.modal-close:hover { background: #e2e6ef; }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.modal-tabs .tab {
  flex: 1; border: none; background: #f0f2f7; padding: 9px; border-radius: 9px;
  cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 14px;
}
.modal-tabs .tab.active { background: var(--primary); color: #fff; }
.modal-body label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.modal-body input {
  display: block; width: 100%; margin-top: 5px; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; outline: none;
}
.modal-body input:focus { border-color: var(--primary); }
.modal-body .submit { width: 100%; margin-top: 4px; padding: 12px; }
.form-error { color: #e0394f; font-size: 12.5px; min-height: 16px; margin-bottom: 6px; }
.modal-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 14px; }

/* ---------- Plans ---------- */
.plans-title { text-align: center; font-size: 20px; margin-bottom: 20px; }
.plans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.plan-card {
  border: 1.5px solid var(--border); border-radius: 14px; padding: 22px; text-align: center; transition: .2s;
}
.plan-card.recommended { border-color: var(--primary); box-shadow: 0 10px 30px rgba(79,110,247,.15); }
.plan-card .p-name { font-size: 17px; font-weight: 700; }
.plan-card .p-price { font-size: 30px; font-weight: 800; margin: 10px 0; color: var(--text); }
.plan-card .p-price small { font-size: 13px; font-weight: 500; color: var(--text-3); }
.plan-card ul { list-style: none; text-align: left; margin: 14px 0 18px; }
.plan-card li { font-size: 13px; color: var(--text-2); padding: 5px 0 5px 22px; position: relative; }
.plan-card li::before { content: "✓"; position: absolute; left: 0; color: #2bb673; font-weight: 700; }
.plan-card .btn { width: 100%; }
.badge-rec { display: inline-block; background: linear-gradient(135deg,var(--primary),var(--accent)); color:#fff; font-size:11px; font-weight:700; padding:2px 10px; border-radius:999px; margin-bottom:8px; }

/* ---------- 支付弹窗 ---------- */
.pay-qr {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; margin: 14px 0;
}
.pay-qr img, .pay-qr canvas { width: 200px !important; height: 200px !important; border: 1px solid var(--border); border-radius: 10px; }
.pay-status { text-align: center; font-weight: 600; color: var(--text); margin: 6px 0; }
.pay-status.done { color: #2bb673; }
.pay-status.pending { color: var(--text-2); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  body { overflow: auto; height: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .pane { min-height: 360px; }
  .actions .btn-ghost { display: none; }
}

/* ---------- 导出文件名输入框 ---------- */
.fname-wrap { display: inline-flex; align-items: center; gap: 4px; }
.fname-wrap input {
  width: 170px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 12.5px; outline: none; color: var(--text); background: #fff;
}
.fname-wrap input:focus { border-color: var(--primary); }
.fname-wrap .btn-paste {
  padding: 7px 9px; line-height: 1; font-size: 13px;
}
@media (max-width: 1080px) { .fname-wrap { display: none; } }

/* ---------- 顶部导航：会员 ---------- */

/* ---------- 注册邮箱验证码 ---------- */
.code-row { display: flex; gap: 8px; margin-top: 5px; }
.code-row input { flex: 1; margin-top: 0; }
.code-row .btn { white-space: nowrap; padding: 0 12px; font-size: 12.5px; }

/* 支付按钮（品牌色 + 图标） */
.btn-wechat, .btn-alipay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #fff !important;
  border: none;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.btn-wechat { background: #09BB07; }
.btn-wechat:hover { background: #07a206; }
.btn-alipay { background: #1677FF; }
.btn-alipay:hover { background: #0e63e6; }
.pay-ico {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
}
.pay-ico-dark { width: 20px; height: 20px; }
.pay-title-wrap { display: inline-flex; align-items: center; gap: 8px; }

/* ========== 新布局：中部导出工具栏 / 草稿条 / A4 模拟预览 / 页脚（仅限带 .with-dock 的转换页） ========== */
.workspace.with-dock { grid-template-columns: 1fr 96px 1fr; gap: 0; }
.with-dock .editor-pane { border-radius: var(--radius) 0 0 var(--radius); border-right: none; }
.with-dock .preview-pane { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }
.export-dock {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 4px; padding: 10px 6px; background: #fff;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  z-index: 5;
}
.dock-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: none; cursor: pointer;
  padding: 9px 8px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: .15s; white-space: nowrap; justify-content: flex-start;
}
.dock-item svg { width: 20px; height: 20px; flex: 0 0 auto; }
.dock-item:hover { background: #f2f5ff; color: var(--primary); }
.dock-item.active {
  background: #eef2ff; color: var(--primary);
  box-shadow: 0 2px 8px rgba(59,85,224,.18); border: 1px solid #dfe6ff;
}
.dock-item.active .dock-arrow { display: inline-block; }
.dock-arrow { display: none; margin-left: auto; font-style: normal; color: var(--primary); font-size: 14px; }
.dock-loading { font-size: 12px; font-weight: 600; color: var(--primary); }
.draft-bar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 16px; background: #eaf3ff; border-bottom: 1px solid #cfe0ff;
  font-size: 13px; color: #1d4ed8;
}
.draft-btns { display: flex; gap: 6px; }
.editor-hint {
  flex: 0 0 auto; padding: 6px 16px; border-top: 1px dashed var(--border);
  background: #fafbfe; text-align: left;
}
.pane-title { display: inline-flex; align-items: center; gap: 6px; }
.eye-ico { width: 15px; height: 15px; color: #1d4ed8; }
.pane-subhint {
  flex: 0 0 auto; padding: 6px 16px; font-size: 11.5px; color: var(--text-3);
  border-bottom: 1px solid var(--border); background: #fafbfe;
}

/* 分页文档预览（Word/PDF/A4/PPT） */
body.preview-mode .preview { background: #e8eaef; padding: 24px 0; }
.doc-pages { transform-origin: top center; }
.doc-page {
  width: 794px; min-height: 1123px; margin: 0 auto 20px;
  background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.14);
  padding: 64px; box-sizing: border-box; position: relative;
  border-radius: 2px; overflow: hidden;
}
.doc-page.slide { min-height: 446px; padding: 26px 30px; }
.doc-page-foot {
  position: absolute; bottom: 16px; left: 0; right: 0;
  text-align: center; color: #9aa2b1; font-size: 11px;
}

/* Excel 预览 */
.excel-view { max-width: 900px; margin: 0 auto; }
.excel-sheet { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.excel-sheet-name { font-size: 13px; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.excel-tab { background: #1E7145; color: #fff; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.excel-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.excel-table th, .excel-table td { border: 1px solid #d5dae3; padding: 6px 10px; text-align: left; }
.excel-table th { background: #eef6f0; color: #14532d; font-weight: 700; }
.excel-table tr:nth-child(even) td { background: #fafbfc; }

/* 公众号预览 */
.gzh-view { max-width: 578px; margin: 0 auto; background: #fff; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.10); overflow: hidden; }
.gzh-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: #f7f7f7; border-bottom: 1px solid #eee; font-size: 12.5px; color: #888; }
.gzh-dot { width: 8px; height: 8px; border-radius: 50%; background: #07C160; }
.gzh-body { padding: 20px 18px; font-size: 15px; line-height: 1.8; color: #333; }

/* 页脚 */
.foot-links { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: center; }
.foot-links .sep { color: var(--border); }
.foot-icp { font-size: 11.5px; opacity: .85; }

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .export-dock {
    flex-direction: row; justify-content: flex-start; overflow-x: auto;
    border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  }
  .editor-pane, .preview-pane { border-radius: var(--radius); border: 1px solid var(--border); }
  }

/* 个人中心 */
.uc-profile {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
  background: #fafbfe; margin-bottom: 14px;
}
.uc-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.uc-row span { color: var(--text-3); }
.uc-sub { font-size: 14px; margin: 6px 0 10px; color: var(--text-2); }
.uc-orders { max-height: 320px; overflow: auto; }
.uc-loading { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 0; }
.uc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.uc-table th, .uc-table td { border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: left; white-space: nowrap; }
.uc-table th { color: var(--text-3); font-weight: 600; background: #fafbfe; position: sticky; top: 0; }
.uc-table td.ok { color: #16a34a; font-weight: 600; }
.uc-table td.pend { color: #d97706; font-weight: 600; }
.uc-table td.mono { font-family: var(--mono); font-size: 11.5px; }

.pane-tools .btn-mini.active { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.mode-sep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }
