:root {
  --green: #058e3e;
  --green-d: #046b2f;
  --green-l: #eaf5ee;
  --green-line: #cbe4d5;
  --bg: #f5f7f4;
  --card: #ffffff;
  --line: #e3e6e1;
  --text: #1f2421;
  --muted: #6b7370;
  --muted-2: #98a09c;
  --amber: #b26a00;
  --red: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

button { cursor: pointer; }

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 左侧 ---------- */

.side {
  width: 268px;
  flex: 0 0 268px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-top {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  margin-bottom: 14px;
}

.brand .mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--green);
  position: relative;
}

.brand .mark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 9px;
  width: 10px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  box-shadow: 0 -4px 0 #fff, 0 4px 0 #fff;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 0;
}

.item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.item:hover { background: #f7f9f6; }

.item.active {
  background: var(--green-l);
  border-color: var(--green-line);
}

.item-title {
  font-size: 13.5px;
  line-height: 1.45;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted-2);
}

.chips {
  display: flex;
  gap: 3px;
  margin-left: auto;
}

.chip {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d8ddd7;
}

.chip.ok { background: var(--green); }
.chip.fail { background: var(--red); }

.side-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

/* ---------- 主区 ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ed-head {
  padding: 20px 28px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.4;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.title-input::placeholder { color: #c3c9c2; font-weight: 500; }

.ed-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted-2);
}

.ed-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.col-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--card);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.content-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}

/* ---------- Quill 富文本 ---------- */

#editor-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

#editor-container .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 8px 16px;
  font-family: inherit;
}

#editor-container .ql-container {
  border: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-family: inherit;
}

.ql-editor {
  padding: 20px 26px 60px;
  font-size: 14.5px;
  line-height: 1.9;
  color: #2a2f2c;
}

.ql-editor.ql-blank::before {
  left: 26px;
  font-style: normal;
  color: #b8bfb8;
}

/* 正文排版：编辑区和预览区保持一致 */

.ql-editor h2,
#preview h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 26px 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--green);
  line-height: 1.5;
}

.ql-editor h3,
#preview h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 20px 0 8px;
  line-height: 1.5;
}

.ql-editor p,
#preview p {
  margin: 0 0 13px;
  line-height: 1.9;
}

.ql-editor ul,
.ql-editor ol,
#preview ul,
#preview ol {
  margin: 0 0 14px;
  padding-left: 24px;
}

.ql-editor li,
#preview li {
  margin-bottom: 6px;
  line-height: 1.85;
}

.ql-editor img,
#preview img {
  max-width: 100%;
  border-radius: 8px;
  margin: 10px 0;
  display: block;
}

.ql-editor blockquote,
#preview blockquote {
  margin: 0 0 15px;
  padding: 10px 16px;
  border-left: 3px solid var(--green-line);
  color: #4d5651;
  background: #f8faf7;
  border-radius: 0 8px 8px 0;
}

.ql-editor blockquote p:last-child,
#preview blockquote p:last-child { margin-bottom: 0; }

.ql-editor a,
#preview a { color: var(--green); }

.ql-editor pre,
#preview pre {
  background: #f4f6f3;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  overflow-x: auto;
}

#preview {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
}

.content-area.previewing #editor-container { display: none; }
.content-area.previewing #preview { display: block; }

/* Quill 工具栏配色微调 */
#editor-container .ql-toolbar button:hover .ql-stroke { stroke: var(--green); }
#editor-container .ql-toolbar button.ql-active .ql-stroke { stroke: var(--green); }
#editor-container .ql-toolbar .ql-picker-label.ql-active { color: var(--green); }

.col-side {
  width: 300px;
  flex: 0 0 300px;
  background: var(--card);
  overflow-y: auto;
  padding: 18px 20px 40px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input[type=text],
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  outline: none;
  background: #fff;
  transition: border-color .15s;
}

.field input[type=text]:focus,
.field textarea:focus,
.field select:focus { border-color: var(--green); }

.field textarea { resize: vertical; min-height: 74px; line-height: 1.6; }

.field .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }

.sec-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .3px;
  margin: 22px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.site-target {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 8px;
}

.site-target.on { border-color: var(--green-line); background: #fbfdfb; }

.site-target .head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.site-target input[type=checkbox] {
  accent-color: var(--green);
  width: 15px;
  height: 15px;
  margin: 0;
}

.site-target .name { font-size: 13px; font-weight: 500; }

.site-target .state {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-2);
}

.site-target select {
  margin-top: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  background: #fff;
}

.site-target .last {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted-2);
}

.site-target .last a { color: var(--green); text-decoration: none; }

/* ---------- 底栏 ---------- */

.ed-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--card);
  border-top: 1px solid var(--line);
}

.ed-foot .spacer { flex: 1; }

/* ---------- 通用控件 ---------- */

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  line-height: 1.4;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.btn:hover { background: #f7f9f6; border-color: #d5dad4; }

.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn.primary:hover { background: var(--green-d); border-color: var(--green-d); }

.btn.ghost { color: var(--green); border-color: var(--green-line); background: #fbfdfb; }
.btn.ghost:hover { background: var(--green-l); }

.btn.danger { color: var(--red); }
.btn.danger:hover { background: #fdf3f2; border-color: #f0d3ce; }

.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  background: #f0f2ef;
  color: var(--muted);
}

.badge.published { background: var(--green-l); color: var(--green-d); }
.badge.partial { background: #fdf4e6; color: var(--amber); }
.badge.failed { background: #fdf0ee; color: var(--red); }
.badge.publishing { background: #eef2f8; color: #3b5b7a; }
.badge.scheduled { background: #eef2f8; color: #3b5b7a; }

.muted { color: var(--muted-2); }

/* ---------- 空状态 ---------- */

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted-2);
}

.empty .big { font-size: 15px; color: var(--muted); }

/* ---------- 抽屉 ---------- */

.drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(24, 30, 26, .28);
  z-index: 40;
}

.drawer-mask.show { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: -520px;
  width: 520px;
  max-width: 92vw;
  height: 100%;
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 41;
  display: flex;
  flex-direction: column;
  transition: right .22s ease;
}

.drawer.show { right: 0; }

.drawer-head {
  display: flex;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.drawer-head .close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--muted-2);
  line-height: 1;
  padding: 2px 6px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px 60px;
}

.site-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  margin-bottom: 12px;
}

.site-card .row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.site-card .row label { width: 62px; font-size: 12px; color: var(--muted); flex: 0 0 62px; }
.site-card .row input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; outline: none; }
.site-card .row input:focus { border-color: var(--green); }

.site-card .acts { display: flex; gap: 8px; margin-top: 4px; }

.log-line {
  font-size: 12px;
  color: var(--muted);
  padding: 7px 0;
  border-bottom: 1px solid #f2f4f1;
  display: flex;
  gap: 10px;
}

.log-line .t { color: var(--muted-2); flex: 0 0 88px; font-variant-numeric: tabular-nums; }

/* ---------- 弹窗 ---------- */

.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(24, 30, 26, .32);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-mask.show { display: flex; }

.modal {
  background: var(--card);
  border-radius: 12px;
  width: 560px;
  max-width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(20, 30, 24, .16);
}

.modal-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-head .close { margin-left: auto; border: none; background: none; font-size: 20px; color: var(--muted-2); }

.modal-body { padding: 18px 22px; overflow-y: auto; }

.modal-foot {
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(12px);
  background: #232a26;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
  max-width: 80vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #8d2b22; }

.spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sp .7s linear infinite;
  vertical-align: -1px;
  margin-right: 6px;
}

@keyframes sp { to { transform: rotate(360deg); } }

/* ---------------- 登录与用户 ---------------- */

.login-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 19, .45);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-mask.show { display: flex; }

.login-card {
  width: 330px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 26px 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}

.login-card .field { margin-bottom: 12px; }

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--green-line);
}

.user-name {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--green-line);
  font-size: 13px;
}

.user-row:last-child { border-bottom: none; }

.user-row .un { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .un em { font-style: normal; color: var(--muted); font-size: 12px; }
.user-row .ur { font-size: 12px; color: var(--muted); }
