:root {
  --adm-bg: #0f1419;
  --adm-card: #1a2332;
  --adm-border: #2d3a4f;
  --adm-text: #e8edf4;
  --adm-muted: #8b9cb3;
  --adm-primary: #3b82f6;
  --adm-danger: #ef4444;
  --adm-success: #22c55e;
}

* { box-sizing: border-box; }

body.adm-body {
  margin: 0;
  background: var(--adm-bg);
  color: var(--adm-text);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.adm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--adm-card);
  border-bottom: 1px solid var(--adm-border);
}

.adm-topbar h1 {
  margin: 0;
  font-size: 18px;
}

.adm-topbar nav a {
  color: var(--adm-muted);
  text-decoration: none;
  margin-left: 16px;
}

.adm-topbar nav a:hover { color: var(--adm-primary); }

.adm-topbar nav a.is-active {
  color: var(--adm-primary);
  font-weight: 700;
}

.adm-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.adm-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.adm-btn {
  display: inline-block;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--adm-primary);
}

.adm-btn:hover { opacity: 0.9; }

.adm-btn-secondary {
  background: transparent;
  border: 1px solid var(--adm-border);
  color: var(--adm-text);
}

.adm-btn-danger { background: var(--adm-danger); }

.adm-btn-success { background: var(--adm-success); }

.adm-table {
  width: 100%;
  border-collapse: collapse;
}

.adm-table th,
.adm-table td {
  padding: 12px;
  border-bottom: 1px solid var(--adm-border);
  text-align: left;
  font-size: 14px;
}

.adm-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.adm-badge-draft { background: #f59e0b33; color: #fbbf24; }
.adm-badge-published { background: #22c55e33; color: #86efac; }

.adm-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.adm-login-card {
  width: 360px;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  padding: 28px;
}

.adm-field { margin-bottom: 14px; }

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

.adm-field input,
.adm-field select,
.adm-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--adm-text);
  font-size: 14px;
}

.adm-alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.adm-alert-error {
  background: #ef444422;
  border: 1px solid #ef444466;
  color: #fca5a5;
}

.adm-editor-layout {
  display: grid;
  grid-template-columns: 240px minmax(420px, 1fr) 340px;
  gap: 12px;
  min-height: calc(100vh - 140px);
}

.adm-panel {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.adm-panel-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--adm-border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.adm-panel-body {
  padding: 12px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.adm-tree-item {
  padding: 7px 10px;
  border-radius: 8px;
  margin-bottom: 3px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.adm-tree-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-tree-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.adm-tree-item:hover { background: #0d1117; }
.adm-tree-item.active { border-color: var(--adm-primary); background: #132033; }
.adm-tree-item.hidden-by-search { display: none; }

.adm-tree-section {
  margin-bottom: 8px;
}

.adm-tree-section-title {
  font-size: 12px;
  color: var(--adm-muted);
  margin: 6px 0 4px;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.adm-tree-section-title.is-clickable {
  cursor: pointer;
}

.adm-tree-section-title.is-clickable:hover {
  background: #0d1117;
  color: var(--adm-text);
}

.adm-tree-section-body.collapsed {
  display: none;
}

.adm-tree-section-count {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.7;
}

.adm-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 560px;
  border: none;
  background: #fff;
  display: block;
}

.adm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
}

.adm-btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.adm-color-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.adm-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
}

.adm-color-swatch.active { border-color: #fff; }

.adm-content-editor {
  min-height: 280px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.adm-link-box {
  margin-top: 0;
  padding: 12px;
  background: #0d1117;
  border-radius: 8px;
  word-break: break-all;
  font-size: 12px;
}

.adm-qr {
  margin-top: 0;
  padding: 10px;
  background: #fff;
  display: inline-block;
  border-radius: 8px;
}

/* ===== 编辑器专用布局 ===== */

body.adm-editor-body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

body.adm-editor-body .adm-topbar {
  flex-shrink: 0;
  padding: 8px 16px;
}

body.adm-editor-body .adm-topbar h1 {
  font-size: 16px;
}

.adm-editor-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.adm-editor-header {
  flex-shrink: 0;
  padding: 10px 14px;
  background: var(--adm-card);
  border-bottom: 1px solid var(--adm-border);
}

.adm-editor-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.adm-editor-header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--adm-border);
}

.adm-editor-back {
  color: var(--adm-muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.adm-editor-back:hover {
  color: var(--adm-primary);
}

.adm-editor-meta {
  font-size: 12px;
  color: var(--adm-muted);
  white-space: nowrap;
}

.adm-editor-title {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--adm-border);
  background: #0d1117;
  color: var(--adm-text);
  font-size: 14px;
}

.adm-editor-status {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--adm-border);
  background: #0d1117;
  color: var(--adm-text);
  font-size: 13px;
}

.adm-editor-save-status {
  font-size: 12px;
  color: var(--adm-muted);
  min-width: 120px;
}

.adm-editor-delete-form {
  display: inline;
  margin: 0;
}

.adm-editor-layout {
  flex: 1;
  min-height: 0;
  padding: 10px 14px 0;
}

.adm-editor-layout.adm-editor-layout--no-preview {
  grid-template-columns: 240px minmax(420px, 1fr);
}

.adm-editor-layout.adm-editor-layout--no-preview .adm-panel-preview {
  display: none;
}

.adm-tree-toolbar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--adm-border);
  flex-shrink: 0;
}

.adm-tree-search {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--adm-border);
  background: #0d1117;
  color: var(--adm-text);
  font-size: 12px;
}

.adm-tree-body {
  padding: 8px;
}

.adm-edit-head {
  gap: 12px;
}

.adm-edit-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.adm-edit-nav-index {
  font-size: 12px;
  color: var(--adm-muted);
  min-width: 56px;
  text-align: center;
}

.adm-edit-body {
  padding: 14px 16px;
}

.adm-edit-placeholder {
  color: var(--adm-muted);
  font-size: 13px;
  margin: 0;
}

.adm-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--adm-border);
  position: sticky;
  bottom: 0;
  background: var(--adm-card);
}

.adm-panel-edit .adm-content-editor {
  min-height: calc(100vh - 360px);
}

.adm-preview-body {
  padding: 0;
  background: #eef1f5;
}

.adm-preview-device {
  height: 100%;
  min-height: 560px;
  padding: 12px;
}

.adm-editor-shortcuts {
  flex-shrink: 0;
  padding: 6px 14px 10px;
  font-size: 11px;
  color: var(--adm-muted);
}

.adm-editor-shortcuts kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--adm-border);
  background: #0d1117;
  font-size: 10px;
  font-family: inherit;
}

.adm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.adm-modal-backdrop[hidden] {
  display: none;
}

.adm-modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.adm-modal-wide {
  width: min(640px, 100%);
}

.adm-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--adm-border);
}

.adm-modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.adm-modal-close {
  border: none;
  background: transparent;
  color: var(--adm-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.adm-modal-close:hover {
  color: var(--adm-text);
}

.adm-modal-body {
  padding: 16px;
}

.adm-modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--adm-border);
}

.adm-modal-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--adm-muted);
}

.adm-batch-textarea {
  font-family: Consolas, "Courier New", monospace;
  min-height: 220px;
}

@media (max-width: 1200px) {
  .adm-editor-layout {
    grid-template-columns: 220px minmax(320px, 1fr);
    grid-template-rows: minmax(360px, 1fr) 320px;
  }

  .adm-editor-layout .adm-panel-tree {
    grid-row: 1 / 3;
  }

  .adm-editor-layout .adm-panel-edit {
    grid-column: 2;
  }

  .adm-editor-layout .adm-panel-preview {
    grid-column: 2;
  }

  .adm-editor-layout.adm-editor-layout--no-preview {
    grid-template-columns: 220px minmax(320px, 1fr);
    grid-template-rows: 1fr;
  }

  .adm-editor-layout.adm-editor-layout--no-preview .adm-panel-edit {
    grid-row: 1;
  }
}

@media (max-width: 860px) {
  body.adm-editor-body {
    overflow: auto;
  }

  body.adm-editor-body .adm-container {
    height: auto;
    min-height: calc(100vh - 49px);
  }

  .adm-editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .adm-editor-layout .adm-panel-tree,
  .adm-editor-layout .adm-panel-edit,
  .adm-editor-layout .adm-panel-preview {
    grid-column: 1;
    grid-row: auto;
    min-height: 320px;
  }

  .adm-panel-edit .adm-content-editor {
    min-height: 240px;
  }
}
