/* ── Editor page overrides ── */
.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Full-width container ── */
.container-full {
  width: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Header ── */
.editor-page header {
  flex-shrink: 0;
  position: static;
  backdrop-filter: none;
  padding: 12px 0;
}

.editor-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.editor-status {
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.editor-status.saved {
  color: var(--green);
  border-color: rgba(63,185,80,0.3);
  background: rgba(63,185,80,0.06);
}

.editor-status.modified {
  color: var(--yellow);
  border-color: rgba(210,153,34,0.3);
  background: rgba(210,153,34,0.06);
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 12px;
  transition: all 0.15s;
}

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

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #0d1117;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }

/* ── Meta bar ── */
.meta-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  padding: 10px 0;
}

.meta-fields {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
}

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

.meta-field label {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.meta-field input,
.meta-field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  padding: 4px 8px;
  transition: border-color 0.15s;
}

.meta-field input:focus,
.meta-field select:focus {
  border-color: var(--accent);
}

.meta-title input  { width: 260px; }
.meta-slug input   { width: 180px; }
.meta-date input   { width: 140px; }

.meta-field select {
  cursor: pointer;
}

/* ── Toolbar ── */
.toolbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  padding: 6px 0;
}

.toolbar-groups {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  gap: 2px;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.tb-btn {
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  transition: all 0.12s;
  white-space: nowrap;
}

.tb-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tb-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
}

.tb-btn-img:hover {
  color: var(--purple);
}

/* ── Editor body ── */
.editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.pane-label {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 16px;
  flex-shrink: 0;
}

#pane-source .pane-label { border-right: 1px solid var(--border); }

/* ── Textarea ── */
#md-input {
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text);
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  outline: none;
  padding: 20px 24px;
  resize: none;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

#md-input::placeholder {
  color: var(--text-dim);
}

/* ── Preview ── */
.preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}

.preview-content.post-body {
  font-size: 14px;
}

.preview-empty {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 40px 0;
  text-align: center;
}

.preview-empty::before {
  content: '// ';
  color: var(--green);
}

/* ── Drag resize divider ── */
.editor-divider {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
}

.editor-divider:hover,
.editor-divider.dragging {
  background: var(--accent);
}

/* ── Only-source / only-preview modes ── */
.editor-body.preview-only #pane-source,
.editor-body.preview-only .editor-divider { display: none; }

.editor-body.source-only #pane-preview,
.editor-body.source-only .editor-divider  { display: none; }

/* ── Image dialog ── */
.dialog-overlay {
  align-items: center;
  background: rgba(0,0,0,0.6);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 999;
  backdrop-filter: blur(3px);
}

.dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  padding: 24px;
  width: 440px;
  max-width: 92vw;
}

.dialog-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
}

.dialog-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.dtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-bottom: -1px;
  padding: 6px 14px;
  transition: all 0.15s;
}

.dtab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.dialog-body {
  display: flex;
  flex-direction: column;
}

.d-label {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 6px;
}

.dialog-body input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  padding: 8px 10px;
  transition: border-color 0.15s;
}

.dialog-body input[type="text"]:focus {
  border-color: var(--accent);
}

/* ── Upload zone ── */
.upload-zone {
  align-items: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px;
  text-align: center;
  transition: all 0.15s;
  color: var(--text-muted);
  font-size: 13px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.upload-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.upload-hint {
  color: var(--text-dim);
  font-size: 11px;
}

.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.upload-preview img {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 160px;
  max-width: 100%;
  object-fit: contain;
}

.dialog-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  bottom: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  color: var(--text);
  font-size: 13px;
  left: 50%;
  opacity: 0;
  padding: 10px 20px;
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%) translateY(8px);
  transition: all 0.2s;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(63,185,80,0.5); color: var(--green); }
.toast.error   { border-color: rgba(248,81,73,0.5);  color: var(--red); }

/* ── Scrollbars in panes ── */
#md-input::-webkit-scrollbar,
.preview-content::-webkit-scrollbar { width: 4px; height: 4px; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .editor-body { flex-direction: column; }
  .editor-divider { width: 100%; height: 4px; cursor: row-resize; }
  #md-input { border-right: none; border-bottom: 1px solid var(--border); }
  .meta-fields { flex-wrap: wrap; }
  .meta-title input { width: 100%; }
}
