* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: #222;
  background: #f5f6f8;
  line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 600; font-size: 16px; color: #111; }
.logout button {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.logout button:hover { background: #f3f4f6; }

/* ---- category nav ---- */
.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  max-width: 900px;
  margin: 0 auto;
}
.cats a {
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 13px;
}
.cats a.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.cats a small { opacity: 0.6; }

/* ---- date filter + article search ---- */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 10px;
}
.date-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.date-chips a {
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 13px;
}
.date-chips a.active { background: #16a34a; border-color: #16a34a; color: #fff; }
.date-chips a small { opacity: 0.65; }
.article-search { display: flex; gap: 6px; align-items: center; }
.article-search input[type='search'] {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  width: 180px;
}
.article-search button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.clear-search { font-size: 12px; color: #6b7280; }

/* ---- article list ---- */
.list { max-width: 900px; margin: 0 auto; padding: 0 20px; }
.row {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.row .title { font-size: 16px; font-weight: 600; color: #111; }
.row .meta {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.empty { text-align: center; color: #9ca3af; padding: 40px; }

/* ---- pager ---- */
.pager {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 14px;
}
.pageinfo { color: #6b7280; }

/* ---- article back button (workspace left pane) ---- */
.back-bar {
  max-width: 760px;
  margin: 12px auto 0;
  padding: 0 20px;
  position: sticky;
  top: 8px;
  z-index: 5;
}
.back-bar a {
  display: inline-block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: #374151;
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}
.back-bar a:hover { text-decoration: none; background: #f3f4f6; }

/* ---- article page ---- */
.article {
  max-width: 760px;
  margin: 20px auto;
  padding: 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.article h1 { margin-top: 0; font-size: 24px; line-height: 1.35; }
.article .meta {
  font-size: 13px;
  color: #6b7280;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
}
.article .content { font-size: 16px; }
.article .content img { max-width: 100%; height: auto; border-radius: 4px; }
.article .content pre {
  background: #f3f4f6;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
}

/* ---- login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.beian { margin: 16px 0 0; font-size: 13px; }
.beian a { color: #94a3b8; text-decoration: none; }
.beian a:hover { text-decoration: underline; }
.login-box {
  background: #fff;
  padding: 32px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  width: 300px;
  text-align: center;
}
.login-box h1 { margin: 0 0 20px; font-size: 20px; }
.login-box input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}
.login-box button:hover { background: #1d4ed8; }
.login-box .error { color: #dc2626; font-size: 13px; margin-bottom: 12px; }
.login-box .remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 14px;
  cursor: pointer;
}
.login-box .remember input { width: auto; margin: 0; }

/* ---- drafts ---- */
.topbar-right { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.drafts-head { display: flex; justify-content: space-between; align-items: center; }
.btn-primary {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-danger {
  background: #fff;
  border: 1px solid #fecaca;
  color: #dc2626;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}
.btn-danger:hover { background: #fef2f2; }
.row .meta form { display: inline; }

/* ---- hidden function rail (workspace right edge) ---- */
.func-rail {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  border-left: 1px solid #e5e7eb;
  background: #fff;
}
.func-rail.open { display: flex; }
.func-rail button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 64px;
  padding: 10px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}
.func-rail button span { font-size: 11px; color: #6b7280; }
.func-rail button:hover { background: #eff6ff; border-color: #bfdbfe; }
#btn-funcs {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* ---- drafts tabs / search / actions ---- */
.draft-tabs { display: flex; gap: 8px; margin: 14px 0 4px; }
.draft-tabs a {
  padding: 6px 16px;
  border-radius: 8px 8px 0 0;
  border: 1px solid #e5e7eb;
  border-bottom: none;
  background: #f3f4f6;
  color: #374151;
  font-size: 14px;
}
.draft-tabs a.active { background: #fff; font-weight: 600; color: #111; }
.draft-search { display: flex; gap: 6px; }
.draft-search input[type='search'] {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  width: 220px;
}
.draft-search button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
}
.btn-done {
  background: #fff;
  border: 1px solid #bbf7d0;
  color: #16a34a;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}
.btn-done:hover { background: #f0fdf4; }

/* ---- editor (split view: news left, writing right) ---- */
.editor-split {
  display: flex;
  width: 100%;
  height: calc(100vh - 44px);
  overflow: hidden;
}
.news-pane {
  flex: 0 0 45%;
  min-width: 320px;
  max-width: 60%; /* on wide screens the writing pane always keeps >= 40% */
  border-right: 1px solid #e5e7eb;
  background: #fff;
}
.news-pane.hidden { display: none; }
.news-pane iframe { width: 100%; height: 100%; border: none; }
.pane-divider {
  flex: 0 0 6px;
  cursor: col-resize;
  background: #f5f6f8;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  touch-action: none;
}
.pane-divider:hover, .pane-divider.dragging { background: #2563eb; }
.pane-divider.hidden { display: none; }
.work-pane {
  flex: 1;
  min-width: 520px;
  background: #fff;
}
.work-pane iframe { width: 100%; height: 100%; border: none; }
/* WeChat-style editor layout: content sidebar left, writing area right */
.edit-wrap { display: flex; min-height: calc(100vh - 44px); }
.edit-side {
  flex: 0 0 180px;
  background: #f7f7f7;
  border-right: 1px solid #e5e7eb;
  padding: 12px 10px;
  overflow-y: auto;
}
.side-new {
  width: 100%;
  padding: 9px 0;
  border: 1px dashed #b6bcc6;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  margin-bottom: 14px;
}
.side-new:hover { border-color: #2563eb; color: #2563eb; }
.side-group { margin-bottom: 12px; }
.side-label {
  font-size: 12px;
  color: #9ca3af;
  margin: 6px 2px;
  cursor: pointer;
  user-select: none;
}
.side-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-card:hover { text-decoration: none; border-color: #93c5fd; }
.side-card.active { border-color: #16a34a; box-shadow: 0 0 0 1px #16a34a inset; }
.side-empty { font-size: 12px; color: #c0c4cc; padding: 4px 2px; }
.edit-wrap.side-hidden .edit-side { display: none; }
#btn-side {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.editor {
  flex: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 24px 64px;
  min-width: 0;
}
.title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.title-row #draft-title { margin-bottom: 0; }
#title-count { font-size: 12px; color: #c0c4cc; white-space: nowrap; }
#draft-author {
  width: 100%;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: transparent;
  padding: 6px 4px 10px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #576b95;
  outline: none;
}
.pv-author { font-size: 13px; color: #576b95; margin-bottom: 14px; }
#btn-toggle-news {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
@media (max-width: 900px) {
  .news-pane { display: none; }
  .pane-divider { display: none; }
  #btn-toggle-news { display: none; }
  .work-pane { min-width: 0; }
}
/* hide page chrome when embedded in the workspace panes */
.in-frame .topbar { display: none; }
.in-frame .cats { padding-top: 10px; }
/* ...except the editor's action bar (save/copy), which must stay usable */
.in-frame .topbar.editor-topbar { display: flex; }
#draft-title {
  width: 100%;
  font-size: 22px;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  background: transparent;
  padding: 10px 4px;
  margin-bottom: 12px;
  outline: none;
}
/* WeChat article body defaults: 17px / 1.6 */
#quill-editor { background: #fff; min-height: 60vh; }
#quill-editor .ql-editor { font-size: 17px; line-height: 1.6; }
#quill-editor hr { border: none; border-top: 1px solid #d1d5db; margin: 16px 0; }
#word-count { font-size: 12px; color: #9ca3af; }

/* size / lineheight / letterspacing pickers show their values */
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
.ql-snow .ql-picker.ql-size .ql-picker-item::before { content: '17px'; }
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value]::before,
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value]::before { content: attr(data-value); }
.ql-snow .ql-picker.ql-lineheight { width: 70px; }
.ql-snow .ql-picker.ql-lineheight .ql-picker-label::before,
.ql-snow .ql-picker.ql-lineheight .ql-picker-item::before { content: '行距'; }
.ql-snow .ql-picker.ql-lineheight .ql-picker-item[data-value]::before { content: attr(data-value); }
.ql-snow .ql-picker.ql-lineheight .ql-picker-label[data-value]::before { content: '行距 ' attr(data-value); }
.ql-snow .ql-picker.ql-letterspacing { width: 70px; }
.ql-snow .ql-picker.ql-letterspacing .ql-picker-label::before,
.ql-snow .ql-picker.ql-letterspacing .ql-picker-item::before { content: '字距'; }
.ql-snow .ql-picker.ql-letterspacing .ql-picker-item[data-value]::before { content: attr(data-value); }
.ql-snow .ql-picker.ql-letterspacing .ql-picker-label[data-value]::before { content: '字距 ' attr(data-value); }

/* 段前距/段后距/列表样式 pickers */
.ql-snow .ql-picker.ql-margintop,
.ql-snow .ql-picker.ql-marginbottom { width: 82px; }
.ql-snow .ql-picker.ql-margintop .ql-picker-label::before,
.ql-snow .ql-picker.ql-margintop .ql-picker-item::before { content: '段前距'; }
.ql-snow .ql-picker.ql-margintop .ql-picker-item[data-value]::before { content: attr(data-value); }
.ql-snow .ql-picker.ql-margintop .ql-picker-label[data-value]::before { content: '段前 ' attr(data-value); }
.ql-snow .ql-picker.ql-marginbottom .ql-picker-label::before,
.ql-snow .ql-picker.ql-marginbottom .ql-picker-item::before { content: '段后距'; }
.ql-snow .ql-picker.ql-marginbottom .ql-picker-item[data-value]::before { content: attr(data-value); }
.ql-snow .ql-picker.ql-marginbottom .ql-picker-label[data-value]::before { content: '段后 ' attr(data-value); }
.ql-snow .ql-picker.ql-liststyle { width: 76px; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-label::before,
.ql-snow .ql-picker.ql-liststyle .ql-picker-item::before { content: '列表样式'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='disc']::before { content: '● 实心圆'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='circle']::before { content: '○ 空心圆'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='square']::before { content: '■ 方块'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='decimal']::before { content: '1. 数字'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='lower-alpha']::before { content: 'a. 小写'; }
.ql-snow .ql-picker.ql-liststyle .ql-picker-item[data-value='upper-alpha']::before { content: 'A. 大写'; }

/* custom list markers: hide Quill's drawn marker, use the native one */
#quill-editor li[style*='list-style-type'] { list-style-position: inside; }
#quill-editor li[style*='list-style-type'] > .ql-ui { display: none; }

/* tables inside the editor */
#quill-editor table { border-collapse: collapse; width: 100%; margin: 10px 0; }
#quill-editor td { border: 1px solid #dfdfdf; padding: 4px 8px; min-width: 40px; }

/* emoji panel */
.emoji-panel {
  position: fixed;
  top: 120px;
  right: 24px;
  z-index: 60;
  width: 264px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
}
.emoji-panel[hidden] { display: none; }
.emoji-panel button {
  border: none;
  background: none;
  font-size: 20px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 4px;
}
.emoji-panel button:hover { background: #f3f4f6; }

/* bottom status bar (like the WeChat editor) */
.editor-statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 6px 16px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  gap: 16px;
  z-index: 40;
}

/* text-glyph toolbar buttons */
.ql-snow .ql-divider { width: 28px; }
.ql-snow .ql-divider::after { content: '—'; font-weight: 700; }
.ql-snow .ql-undo::after { content: '↶'; font-size: 16px; }
.ql-snow .ql-redo::after { content: '↷'; font-size: 16px; }
.ql-snow .ql-formatpainter::after { content: '刷'; font-size: 13px; }
.ql-snow .ql-formatpainter.ql-active { color: #06c; }
.ql-snow .ql-textindent::after { content: '缩'; font-size: 13px; }
.ql-snow .ql-inserttable::after { content: '⊞'; font-size: 16px; }
.ql-snow .ql-emoji::after { content: '😊'; font-size: 14px; }

/* phone preview overlay */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.preview-overlay[hidden] { display: none; }
.phone {
  width: 390px;
  max-height: 86vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgb(0 0 0 / 30%);
}
.phone-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  color: #6b7280;
}
.phone-bar button { border: none; background: none; cursor: pointer; font-size: 14px; }
.phone-body { overflow-y: auto; padding: 16px 18px 30px; }
.phone-body h2 { font-size: 20px; line-height: 1.4; margin: 0 0 12px; }
.phone-body .content { font-size: 16px; line-height: 1.75; }
.phone-body .content img { max-width: 100%; height: auto; }
.ql-toolbar.ql-snow { border-color: #e5e7eb; background: #fff; border-radius: 8px 8px 0 0; }
.ql-container.ql-snow { border-color: #e5e7eb; border-radius: 0 0 8px 8px; }
.editor-actions { display: flex; gap: 10px; align-items: center; }
#save-status { font-size: 12px; color: #6b7280; }
#btn-copy {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.write-cta { max-width: 760px; margin: 16px auto; padding: 0 20px; text-align: center; }
.write-cta button {
  background: #16a34a;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
