/* ============================ 后台样式 ============================ */

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.admin-body { background: var(--bg); }

/* ---------------- 登录 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 38px 34px 30px;
  border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -40px rgba(150, 90, 200, 0.6);
  backdrop-filter: blur(20px);
  text-align: center;
  animation: rise 0.5s var(--ease) both;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--grad);
  color: #fff;
  font-size: 26px;
  box-shadow: 0 14px 30px -14px rgba(255, 111, 174, 0.9);
}

.login-card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: 0.5px; }
.login-sub { margin: 0 0 24px; font-size: 12.5px; color: var(--muted); }
.login-card .field { text-align: left; margin-bottom: 14px; }
.login-tip { margin: 16px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; }

.btn-block { width: 100%; height: 44px; font-size: 14.5px; margin-top: 6px; }

/* ---------------- 表单元素 ---------------- */

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; }

.field span { font-weight: 500; letter-spacing: 0.2px; }

.field input,
.field select,
.field textarea {
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  min-width: 0;
}

[data-theme='dark'] .field input,
[data-theme='dark'] .field select,
[data-theme='dark'] .field textarea { background: rgba(255, 255, 255, 0.04); }

.field textarea { height: auto; padding: 10px 12px; line-height: 1.7; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(255, 111, 174, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 143, 196, 0.14);
}

.form-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.7; }.form-hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 11px; }

.apikey-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.apikey-row input {
  flex: 1 1 260px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--text-2);
  min-width: 0;
}
.form-actions { margin-top: 18px; display: flex; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-full { grid-column: 1 / -1; }

.btn-primary { height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--grad); color: #fff; font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 24px -14px rgba(255, 111, 174, 0.95); transition: transform 0.2s, filter 0.2s; }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.04); }
.btn-primary:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }

.ghost-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  transition: all 0.2s;
}
.ghost-btn:hover { border-color: rgba(255, 111, 174, 0.5); color: var(--brand); }

.danger-ghost { color: #ef4444 !important; }
.danger-ghost:hover { border-color: #ef4444 !important; }

/* ---------------- 框架 ---------------- */

.admin-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(16px);
}

.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.side-brand .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
.side-brand b { display: block; font-size: 14.5px; line-height: 1.3; }
.side-brand i { font-style: normal; font-size: 11px; color: var(--muted); }

.side-nav { display: flex; flex-direction: column; gap: 4px; }

.side-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: all 0.2s var(--ease);
}
.side-nav svg { width: 17px; height: 17px; flex: 0 0 auto; }
.side-nav em { font-style: normal; }
.side-nav button:hover { background: var(--grad-soft); color: var(--text); }
.side-nav button.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 22px -14px rgba(255, 111, 174, 0.95);
}

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.side-foot a, .side-foot button {
  font-size: 12.5px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 6px 0;
  text-align: left;
}
.side-foot a:hover, .side-foot button:hover { color: var(--brand); }

.main { padding: 26px 30px 60px; min-width: 0; }

.main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.main-head h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -0.3px; }
.main-head p { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------------- 面板 ---------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }

.pill-count {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--grad-soft);
  color: var(--brand);
  font-weight: 600;
}

.panel-tools { display: flex; gap: 10px; align-items: center; }

.search-mini input {
  height: 36px;
  width: 220px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  outline: none;
}
.search-mini input:focus { border-color: rgba(255, 111, 174, 0.5); }

.panel-tools select {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
}

/* ---------------- 概览 ---------------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat-card {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -34px; top: -34px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 143, 196, 0.22), rgba(167, 139, 250, 0.1) 55%, transparent 72%);
  pointer-events: none;
}
.stat-card b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -1px; line-height: 1.2; }
.stat-card span { font-size: 12px; color: var(--muted); }
.stat-card .ico { position: absolute; right: 14px; bottom: 12px; font-size: 18px; opacity: 0.65; }

.top-list { display: flex; flex-direction: column; }
.top-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.top-item:last-child { border-bottom: 0; }
.top-item i {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 7px;
  font-style: normal;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: var(--grad);
  flex: 0 0 auto;
}
.top-item a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-item a:hover { color: var(--brand); }
.top-item span { font-size: 11.5px; color: var(--muted); }

.quick { display: flex; flex-wrap: wrap; gap: 10px; }
.quick button, .quick a {
  height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
  transition: all 0.2s;
}
.quick button:hover, .quick a:hover { border-color: rgba(255, 111, 174, 0.5); color: var(--brand); transform: translateY(-1px); }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 780px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }

.thumb {
  width: 44px; height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--grad-soft);
  border: 1px solid var(--line);
}

.t-title { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.t-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.pub { background: rgba(52, 211, 153, 0.15); color: #059669; }
.badge.draft { background: rgba(148, 163, 184, 0.18); color: #64748b; }
.badge.pin { background: rgba(251, 191, 36, 0.18); color: #b45309; }
[data-theme='dark'] .badge.pub { color: #34d399; }
[data-theme='dark'] .badge.draft { color: #94a3b8; }
[data-theme='dark'] .badge.pin { color: #fbbf24; }

.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.row-actions button {
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: all 0.18s;
}
.row-actions button:hover { border-color: rgba(255, 111, 174, 0.5); color: var(--brand); }
.row-actions button.del:hover { border-color: #ef4444; color: #ef4444; }

/* ---------------- 分类 ---------------- */

.cat-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cat-form input {
  height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13.5px;
  outline: none;
  flex: 1 1 220px;
  min-width: 0;
}
.cat-form input:focus { border-color: rgba(255, 111, 174, 0.5); }

.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.cat-row input {
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 10px;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.cat-row .c-name { flex: 1 1 auto; }
.cat-row .c-icon { width: 76px; text-align: center; }
.cat-row .c-color { width: 46px; padding: 3px; }
.cat-row .count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------------- 编辑器 ---------------- */

.editor {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.editor-head {
  height: 60px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(14px);
}
.editor-head-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.editor-head-actions { margin-left: auto; display: flex; gap: 10px; }

.editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
}

.editor-main { display: flex; flex-direction: column; padding: 18px 20px 0; min-height: 0; min-width: 0; }

.title-input {
  height: 52px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  outline: none;
  padding: 0 2px;
  margin-bottom: 12px;
  color: var(--text);
}
.title-input::placeholder { color: var(--muted); font-weight: 500; }

.md-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding-bottom: 10px;
}
.md-toolbar button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  transition: all 0.18s;
}
.md-toolbar button:hover { border-color: rgba(255, 111, 174, 0.5); color: var(--brand); }
.md-toolbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.md-modes { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.md-modes button { border: 0; background: transparent; height: 26px; padding: 0 10px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.md-modes button.active { background: var(--grad); color: #fff; }

.uploading { font-size: 11.5px; color: var(--brand); margin-left: auto; }

.md-area {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 8px;
}
.md-area.mode-split { grid-template-columns: 1fr 1fr; }
.md-area.mode-edit .md-preview { display: none; }
.md-area.mode-preview textarea { display: none; }

.md-area textarea {
  border: 0;
  outline: none;
  resize: none;
  padding: 18px 20px;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.9;
  background: transparent;
  color: var(--text);
  min-height: 0;
  width: 100%;
}

.md-preview { overflow: auto; padding: 16px 22px; border-left: 1px solid var(--line); background: var(--surface-2); }
.md-preview:empty::before { content: '预览区'; color: var(--muted); font-size: 12px; }

.editor-hint { font-size: 11.5px; color: var(--muted); margin: 0 0 14px; }

.editor-side {
  border-left: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
  padding: 18px 18px 40px;
}
.side-block { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px dashed var(--line); }
.side-block:last-child { border-bottom: 0; }
.side-block h4 { margin: 0 0 12px; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.side-block .field { margin-bottom: 12px; }

.switch-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; margin-bottom: 12px; }
.switch-row input { width: 16px; height: 16px; accent-color: #ff6fae; }

.cover-picker { display: flex; gap: 12px; align-items: center; }
.cover-preview {
  width: 108px;
  height: 68px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: flex; flex-direction: column; gap: 6px; }

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 12, 30, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--line);
  animation: rise 0.25s var(--ease) both;
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 1fr; padding-bottom: 64px; }
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    height: 60px;
    flex-direction: row;
    align-items: center;
    padding: 0 8px;
    gap: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    z-index: 90;
  }
  .side-brand, .side-foot { display: none; }
  .side-nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .side-nav button { flex-direction: column; gap: 2px; height: 52px; padding: 0 12px; font-size: 10.5px; }
  .side-nav button.active { box-shadow: none; }
  .main { padding: 18px 14px 30px; }
  .main-head h2 { font-size: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .editor-body { grid-template-columns: 1fr; overflow-y: auto; }
  .editor-main { padding: 14px 14px 0; min-height: 60vh; }
  .editor-side { border-left: 0; border-top: 1px solid var(--line); }
  .md-area { min-height: 46vh; }
  .md-area.mode-split { grid-template-columns: 1fr; }
  .md-area.mode-split .md-preview { display: none; }
  .title-input { font-size: 18px; height: 46px; }
  .editor-head { padding: 0 12px; gap: 8px; height: 56px; }
  .editor-head-title { display: none; }
  .search-mini input { width: 140px; }
  .stat-card b { font-size: 22px; }
}

@media (max-width: 560px) {
  .login-card { padding: 30px 22px 24px; }
  .panel { padding: 16px 14px; border-radius: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .panel-head { gap: 10px; }
  .panel-tools { width: 100%; }
  .search-mini { flex: 1; }
  .search-mini input { width: 100%; }
  .editor-head-actions .ghost-btn { display: none; }
  .quick button, .quick a { flex: 1 1 100%; justify-content: center; }
}
