/* ========== Article Editor (CSDN Creation Center style) ========== */
.page-editor {
  background: var(--bg-page);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.editor-header {
  height: 56px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-header-divider {
  color: var(--border);
}

.editor-header-title {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
}

.draft-status {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-left: 8px;
}

.draft-status.saved {
  color: #2e7d32;
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-editor {
  padding: 7px 18px;
  border-radius: 4px;
  font-size: var(--font-md);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-secondary);
}

.btn-editor:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-publish {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-publish:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.editor-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  margin-left: 8px;
  border-radius: 4px;
  transition: all var(--transition);
}

.editor-close:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* Layout */
.editor-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-white);
  overflow: hidden;
}

/* Title */
.editor-title {
  width: 100%;
  border: none;
  outline: none;
  padding: 24px 32px 16px;
  font-size: 24px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
}

.editor-title::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* Content area – Vditor */
.editor-content-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-content-wrap .vditor {
  border: none !important;
  flex: 1;
  min-height: 0;
}

.editor-content-wrap .vditor-toolbar {
  border-left: none;
  border-right: none;
  background: #fafafa;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.editor-content-wrap .vditor-toolbar::-webkit-scrollbar {
  height: 4px;
}

.editor-content-wrap .vditor-toolbar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.editor-content-wrap .vditor-content {
  font-size: var(--font-base);
}

.editor-content-wrap .vditor-ir pre.vditor-reset,
.editor-content-wrap .vditor-wysiwyg pre.vditor-reset {
  padding: 16px 32px;
}

.editor-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-white);
  color: var(--text-muted);
  font-size: var(--font-sm);
  z-index: 2;
}

.editor-loading.is-hidden {
  display: none;
}

.editor-content-wrap #vditor.is-ready {
  opacity: 1;
}

.editor-content-wrap #vditor {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.editor-footer-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 32px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  font-size: var(--font-sm);
  color: var(--text-muted);
  flex-shrink: 0;
}

.word-count strong {
  color: var(--text-primary);
}

/* Right sidebar */
.editor-sidebar {
  flex: 0 0 320px;
  background: var(--bg-page);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px;
}

.sidebar-panel {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: var(--font-base);
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.form-field {
  margin-bottom: 18px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: var(--font-md);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: var(--font-md);
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
  background: var(--bg-white);
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--primary);
}

.field-textarea {
  resize: vertical;
  min-height: 72px;
}

.field-hint {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

.char-count {
  display: block;
  text-align: right;
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-group--vertical {
  flex-direction: column;
  gap: 8px;
}

.radio-item,
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-md);
  color: var(--text-secondary);
  cursor: pointer;
}

.radio-item input,
.checkbox-item input {
  accent-color: var(--primary);
}

/* Cover upload */
.cover-upload {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition);
}

.cover-upload:hover {
  border-color: var(--primary);
}

.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  color: var(--text-muted);
  font-size: var(--font-md);
}

.cover-tip {
  font-size: var(--font-xs);
}

.cover-preview {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.cover-preview.hidden,
.cover-remove.hidden {
  display: none;
}

.cover-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: var(--font-xs);
  font-family: inherit;
  cursor: pointer;
}

.sidebar-panel--tips .tips-list {
  list-style: none;
}

.sidebar-panel--tips li {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  padding-left: 14px;
  position: relative;
  margin-bottom: 8px;
}

.sidebar-panel--tips li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: bold;
}

/* Preview modal */
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.preview-modal.open {
  opacity: 1;
  visibility: visible;
}

.preview-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.preview-box {
  position: relative;
  background: var(--bg-white);
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.preview-header h2 {
  font-size: var(--font-lg);
  font-weight: 600;
}

.preview-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.preview-body {
  padding: 24px 32px 32px;
  overflow-y: auto;
}

.preview-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
}

.preview-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.preview-content {
  font-size: var(--font-base);
  line-height: 1.8;
  color: var(--text-primary);
}

/* 预览区复用 Markdown 正文样式 */
.preview-content.markdown-body h2,
.markdown-body h2 {
  font-size: var(--font-xl);
  font-weight: 700;
  margin: 28px 0 14px;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
}

.preview-content.markdown-body h3,
.markdown-body h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  margin: 22px 0 12px;
}

.preview-content.markdown-body pre,
.markdown-body pre {
  margin: 16px 0;
  border-radius: 8px;
  overflow-x: auto;
}

.preview-content.markdown-body table,
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: var(--font-sm);
}

.preview-content.markdown-body th,
.preview-content.markdown-body td,
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.preview-content.markdown-body th,
.markdown-body th {
  background: var(--bg-page);
  font-weight: 600;
}

.preview-content.markdown-body blockquote,
.markdown-body blockquote {
  border-left: 4px solid var(--border);
  padding: 12px 16px;
  color: var(--text-secondary);
  margin: 16px 0;
  background: var(--bg-page);
}

.preview-content.markdown-body img,
.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 992px) {
  .editor-sidebar {
    flex: 0 0 280px;
  }
}

@media (max-width: 768px) {
  .editor-layout {
    flex-direction: column;
    overflow-y: auto;
  }

  .editor-main {
    min-height: 60vh;
  }

  .editor-sidebar {
    flex: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .editor-title {
    padding: 16px 16px 12px;
    font-size: 20px;
  }

  .editor-content-wrap .vditor-ir pre.vditor-reset,
  .editor-content-wrap .vditor-wysiwyg pre.vditor-reset {
    padding: 12px 16px;
  }

  .draft-status {
    display: none;
  }

  .btn-editor {
    padding: 6px 12px;
    font-size: var(--font-sm);
  }
}
