/* ==========================================================================
   个人网站 · 管理后台样式
   ========================================================================== */

:root {
  --bg: #0b0b0d;
  --bg-soft: #101014;
  --surface: #141418;
  --surface-2: #1b1b21;
  --line: #27272e;
  --line-soft: #1e1e24;
  --text: #f0efe9;
  --text-2: #a4a4ae;
  --text-3: #6a6a75;
  --accent: #f0783c;
  --accent-dim: rgba(240, 120, 60, 0.13);
  --ok: #6fbf8b;
  --err: #e07878;
  --radius: 13px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.admin {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

::selection {
  background: var(--accent);
  color: #0a0a0c;
}

/* -------------------------------- 侧边栏 -------------------------------- */

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line-soft);
  background: var(--bg-soft);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  min-width: 0;
}

.side-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: block;
  border-radius: 8px;
}

.side-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background 0.16s ease, color 0.16s ease;
  text-align: left;
  width: 100%;
}

.side-link:hover {
  background: var(--surface);
  color: var(--text);
}

.side-link.is-on {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
}

.side-link.is-on svg {
  color: var(--accent);
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.side-btn {
  font-size: 13.5px;
  color: var(--text-3);
}

/* -------------------------------- 主区域 -------------------------------- */

.main {
  padding: 30px 36px 90px;
  max-width: 1180px;
  width: 100%;
}

.main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.main-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* -------------------------------- 提示条 -------------------------------- */

.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.toast-ok {
  background: rgba(111, 191, 139, 0.1);
  border-color: rgba(111, 191, 139, 0.28);
  color: #8fd3a8;
}

.toast-err {
  background: rgba(224, 120, 120, 0.1);
  border-color: rgba(224, 120, 120, 0.28);
  color: #e89b9b;
}

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

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

.panel-tight {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel-note {
  font-size: 12.5px;
  color: var(--text-3);
}

.panel-more {
  font-size: 12.5px;
  color: var(--text-3);
}

.panel-more:hover {
  color: var(--accent);
}

.panel-empty {
  font-size: 13.5px;
  color: var(--text-3);
  padding: 8px 0;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* ------------------------------- 统计卡片 ------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card-label {
  font-size: 12.5px;
  color: var(--text-3);
}

.stat-card-num {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--text-3);
}

/* ------------------------------- 快捷入口 ------------------------------- */

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.quick-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--surface-2), var(--surface));
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.quick-card:hover {
  border-color: #3d3d47;
  transform: translateY(-1px);
}

.quick-icon {
  font-size: 17px;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.quick-title {
  font-size: 14.5px;
  font-weight: 600;
}

.quick-sub {
  font-size: 12.5px;
  color: var(--text-3);
}

/* ------------------------------- 迷你列表 ------------------------------- */

.mini-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.mini-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.mini-item:first-child {
  border-top: 0;
}

.mini-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.mini-title {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-main:hover .mini-title {
  color: var(--accent);
}

.mini-sub {
  font-size: 12px;
  color: var(--text-3);
}

.mini-ext {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  flex: none;
}

.status-dot {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
  flex: none;
}

.status-dot.is-live {
  color: var(--ok);
  background: rgba(111, 191, 139, 0.1);
}

.status-dot.is-draft {
  color: var(--text-3);
  background: var(--surface-2);
}

/* -------------------------------- 行列表 -------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar-hint {
  font-size: 13px;
  color: var(--text-3);
}

.rows {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  border-top: 1px solid var(--line-soft);
  transition: background 0.16s ease;
}

.row:first-child {
  border-top: 0;
}

.row:hover {
  background: var(--surface-2);
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 14.5px;
  font-weight: 500;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-title:hover {
  color: var(--accent);
}

.row-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 100px;
  white-space: nowrap;
  flex: none;
}

.pill-live {
  color: var(--ok);
  background: rgba(111, 191, 139, 0.1);
  border: 1px solid rgba(111, 191, 139, 0.22);
}

.pill-draft {
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.pill-private {
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(240, 120, 60, 0.24);
  margin-left: 6px;
}

/* -------------------------------- 表单 -------------------------------- */

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 400;
}

.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.input::placeholder {
  color: #55555f;
}

.input:focus {
  outline: none;
  border-color: rgba(240, 120, 60, 0.6);
  background: #0c0c10;
}

.input-lg {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  padding: 11px 13px;
}

.textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
}

select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%236a6a75' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

/* -------------------------------- 按钮 -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: #0a0a0c;
}

.btn-primary:hover {
  background: #fff;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  border-color: var(--line);
  color: var(--text-2);
  background: var(--surface);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: #3d3d47;
}

.btn-danger {
  border-color: rgba(224, 120, 120, 0.3);
  color: #e08a8a;
  background: rgba(224, 120, 120, 0.07);
}

.btn-danger:hover {
  background: rgba(224, 120, 120, 0.14);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
  margin-bottom: 8px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* ------------------------------- 文章编辑 ------------------------------- */

.edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.edit-main {
  min-width: 0;
}

.edit-side {
  position: sticky;
  top: 24px;
}

.md-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-3);
  padding-top: 4px;
}

.md-hint code {
  font-family: var(--mono);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 12.5px;
}

.kv dt {
  color: var(--text-3);
}

.kv dd {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding: 14px 18px;
  border: 1px dashed rgba(224, 120, 120, 0.28);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-2);
}

/* -------------------------------- 上传区 -------------------------------- */

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 38px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
  text-align: center;
}

.dropzone:hover,
.dropzone.is-drag {
  border-color: rgba(240, 120, 60, 0.55);
  background: rgba(240, 120, 60, 0.05);
}

.dropzone-icon {
  color: var(--text-3);
  margin-bottom: 2px;
}

.dropzone.is-drag .dropzone-icon,
.dropzone:hover .dropzone-icon {
  color: var(--accent);
}

.dropzone-title {
  font-size: 14px;
  font-weight: 500;
}

.dropzone-sub {
  font-size: 12.5px;
  color: var(--text-3);
}

.dropzone.has-files .dropzone-title {
  color: var(--accent);
}

.upload-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.upload-fields .field {
  margin-bottom: 0;
  min-width: 130px;
}

.upload-fields .field-grow {
  flex: 1;
  min-width: 180px;
}

.upload-tips {
  margin: 14px 0 0;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-3);
}

.upload-tips b {
  color: var(--text-2);
  font-weight: 600;
}

.progress {
  position: relative;
  height: 8px;
  border-radius: 100px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 100px;
  background: linear-gradient(90deg, #b8862f, var(--accent));
  transition: width 0.18s ease;
}

.progress-text {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.upload-msg {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.upload-msg.is-ok {
  background: rgba(111, 191, 139, 0.1);
  color: #8fd3a8;
}

.upload-msg.is-err {
  background: rgba(224, 120, 120, 0.1);
  color: #e89b9b;
}

/* ------------------------------ 后台文件行 ------------------------------ */

.file-rows {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
  transition: background 0.16s ease;
}

.file-row:first-child {
  border-top: 0;
}

.file-row:hover {
  background: var(--surface-2);
}

.file-row:target {
  background: var(--accent-dim);
}

.file-ext {
  width: 52px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  letter-spacing: 0.03em;
}

.file-main {
  flex: 1;
  min-width: 180px;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.file-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.file-origin {
  font-family: var(--mono);
  font-size: 11px;
  color: #55555f;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  flex-wrap: wrap;
}

.inline-details {
  display: inline-block;
}

.inline-details summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.inline-details[open] summary {
  background: var(--surface-2);
  color: var(--text);
}

.edit-pop {
  position: absolute;
  right: 18px;
  z-index: 20;
  width: 300px;
  margin-top: 8px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid #33333d;
  background: #17171c;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.edit-pop .field {
  margin-bottom: 10px;
}

/* -------------------------------- 设置页 -------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 22px;
  align-items: start;
}

.settings-side {
  display: flex;
  flex-direction: column;
}

.settings-panel .btn {
  margin-top: 4px;
}

.settings-note {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.75;
}

.settings-note code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
}

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

/* 登录页不套后台的两栏网格 */
body.admin.login-body {
  display: block;
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 20px;
  background:
    radial-gradient(ellipse 700px 420px at 50% -10%, rgba(240, 120, 60, 0.12), transparent 65%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 34px 30px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.login-brand .side-mark {
  width: 46px;
  height: 46px;
  border-radius: 11px;
}

.login-title {
  font-size: 19px;
  font-weight: 600;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 5px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  margin-bottom: 24px;
}

.login-form .field {
  margin-bottom: 16px;
}

.login-error {
  padding: 10px 13px;
  margin-bottom: 16px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  background: rgba(224, 120, 120, 0.1);
  border: 1px solid rgba(224, 120, 120, 0.26);
  color: #e89b9b;
}

.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
}

.login-foot a:hover {
  color: var(--text-2);
}

/* ------------------------------- 标签条 -------------------------------- */

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 100px;
  font-size: 13px;
  color: var(--text-2);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 0.16s ease;
}

.chip:hover {
  color: var(--text);
  border-color: #3d3d47;
}

.chip.is-on {
  background: var(--text);
  color: #0a0a0c;
  border-color: var(--text);
}

.chip-n {
  font-size: 11px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

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

@media (max-width: 1100px) {
  .edit-grid {
    grid-template-columns: minmax(0, 1fr) 270px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body.admin {
    grid-template-columns: 1fr;
  }
  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    overflow-x: auto;
  }
  .side-brand {
    padding: 0;
    flex: none;
  }
  .side-name {
    display: none;
  }
  .side-nav {
    flex-direction: row;
    gap: 2px;
  }
  .side-link {
    white-space: nowrap;
    padding: 7px 10px;
  }
  .side-foot {
    margin: 0 0 0 auto;
    flex-direction: row;
    border: 0;
    padding: 0;
    gap: 4px;
  }
  .side-foot form {
    display: inline;
  }
  .main {
    padding: 22px 18px 80px;
  }
  .edit-grid {
    grid-template-columns: 1fr;
  }
  .edit-side {
    position: static;
  }
  .stat-grid,
  .quick-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }
  .edit-pop {
    position: fixed;
    right: 12px;
    left: 12px;
    width: auto;
    top: auto;
  }
  .file-origin {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .row {
    flex-wrap: wrap;
    gap: 10px;
  }
  .row-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .main-title {
    font-size: 20px;
  }
  .upload-fields .field {
    width: 100%;
    flex: 1 1 100%;
  }
  .upload-fields #uploadBtn {
    width: 100%;
    justify-content: center;
  }
}
