/* 编辑后台样式 */
body.editor-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ---------------- 顶栏 ---------------- */
.ed-header {
  flex: 0 0 auto;
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.ed-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ed-back {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: color .18s;
}

.ed-back:hover {
  color: var(--accent);
}

.ed-crumb {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dir-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 230px;
  font-size: 12.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dir-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: 0 0 auto;
}

.dir-state.is-on {
  color: var(--accent);
}

.dir-state.is-on::before {
  background: var(--accent);
}

/* ---------------- 布局 ---------------- */
.ed-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.ed-side {
  width: 262px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.side-head {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-new {
  padding: 7px 16px;
  font-size: 13.5px;
}

.side-count {
  font-size: 12px;
  color: var(--ink-faint);
}

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

.side-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background .16s, border-color .16s;
}

.side-item:hover {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.side-item.is-active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.side-title {
  font-size: 13.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.side-meta {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-faint);
}

.badge-draft {
  padding: 0 5px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 10.5px;
  line-height: 1.5;
}

.badge-pin {
  color: var(--accent);
  font-size: 11px;
}

.side-foot {
  flex: 0 0 auto;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
}

.ghost-btn {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .16s;
}

.ghost-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ed-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.ed-pane {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 30px 32px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------------- 表单 ---------------- */
.title-input {
  width: 100%;
  padding: 8px 0 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.01em;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-faint);
  opacity: .72;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 16px 0 4px;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field > span {
  font-size: 12.5px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.field input,
.field textarea {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.field input:focus,
.field textarea:focus,
.content-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 14px 0 0;
}

.field-block > span {
  font-size: 12.5px;
  color: var(--ink-faint);
}

.field-block input,
.field-block textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  resize: vertical;
}

.field-hint {
  font-size: 11.5px;
  color: var(--ink-faint);
  font-family: var(--mono);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

/* ---------------- 编辑器主体 ---------------- */
.editor-tabs {
  display: inline-flex;
  gap: 2px;
  width: fit-content;
  margin: 16px 0 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
}

.editor-tabs button {
  padding: 5px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: pointer;
  transition: all .16s;
}

.editor-tabs button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.workbench {
  flex: 1;
  display: grid;
  gap: 16px;
  min-height: 420px;
}

.workbench.view-split { grid-template-columns: 1fr 1fr; }
.workbench.view-write { grid-template-columns: 1fr; }
.workbench.view-write .preview { display: none; }
.workbench.view-preview { grid-template-columns: 1fr; }
.workbench.view-preview .content-input { display: none; }

.content-input {
  width: 100%;
  min-height: 440px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.9;
  resize: vertical;
  outline: none;
}

.preview {
  min-height: 440px;
  max-height: 72vh;
  padding: 4px 4px 4px 22px;
  border-left: 1px dashed var(--line);
  overflow-y: auto;
}

.workbench.view-preview .preview {
  border-left: 0;
  padding: 4px 0;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.status-hint {
  font-size: 12.5px;
  color: var(--ink-faint);
}

.status-hint.is-dirty {
  color: var(--accent);
}

.action-right {
  display: flex;
  gap: 10px;
}

.soft-btn.danger:hover {
  border-color: #c0392b;
  color: #c0392b;
}

/* ---------------- 站点设置 ---------------- */
.pane-title {
  font-family: var(--serif);
  font-size: 24px;
}

.pane-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-faint);
}

.pane-desc code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 12px;
}

.form-grid {
  max-width: 640px;
}

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 99;
  transform: translate(-50%, 12px);
  max-width: min(560px, calc(100vw - 40px));
  padding: 11px 20px;
  border-radius: 10px;
  background: #1f2229;
  color: #f4f2ee;
  font-size: 13.5px;
  line-height: 1.6;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  opacity: 0;
  transition: opacity .22s, transform .22s;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: #8c2f22;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .ed-body {
    flex-direction: column;
  }

  .ed-side {
    width: 100%;
    max-height: 152px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-head {
    padding: 10px 12px;
  }

  .side-list {
    padding: 0 12px 10px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .side-item {
    min-width: 190px;
    margin-bottom: 0;
  }

  .side-foot {
    display: none;
  }

  .ed-pane {
    padding: 20px 18px 26px;
  }

  .title-input {
    font-size: 24px;
  }

  .workbench.view-split {
    grid-template-columns: 1fr;
  }

  .preview {
    border-left: 0;
    padding-left: 0;
    border-top: 1px dashed var(--line);
    padding-top: 18px;
  }

  .dir-state {
    display: none;
  }
}

@media (max-width: 560px) {
  .ed-header {
    padding: 0 12px;
  }

  .ed-header-right .soft-btn:nth-of-type(2),
  #importBtn {
    display: none;
  }

  .ed-crumb {
    display: none;
  }
}