/* =========================================================
   拾光集 · 管理后台样式
   ========================================================= */
:root {
  --bg: #faf8f4;
  --surface: #fff;
  --ink: #292420;
  --ink-soft: #6b6257;
  --muted: #9a9185;
  --line: #ece5d8;
  --accent: #d97706;
  --accent-deep: #b45309;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(41,36,32,.05), 0 6px 20px rgba(41,36,32,.06);
  --serif: "Noto Serif SC","Source Han Serif SC","Songti SC","SimSun",Georgia,serif;
  --sans: -apple-system,BlinkMacSystemFont,"PingFang SC","HarmonyOS Sans SC","Microsoft YaHei","Segoe UI",Roboto,sans-serif;
  --mono: ui-monospace,"SF Mono","Cascadia Mono",Consolas,monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font-family: var(--sans); cursor: pointer; }
input, select, textarea { font-family: var(--sans); }

/* ---------- 通用控件 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 10px; padding: 9px 18px; font-size: .92rem;
  transition: all .2s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f3c9c9; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .84rem; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--danger); border-color: var(--line); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: .82rem; color: var(--ink-soft);
  margin-bottom: 6px; font-weight: 500;
}
.field input[type="text"], .field input[type="password"], .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: .95rem; color: var(--ink); background: var(--surface);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,6,.13);
}
.field textarea { resize: vertical; line-height: 1.75; font-family: var(--mono); font-size: .9rem; }
.field-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: #221f1a; color: #cfc8ba;
  display: flex; flex-direction: column; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  font-family: var(--serif); font-size: 1.25rem; color: #f5efe3; letter-spacing: .05em;
  padding: 0 10px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-brand span { display: block; font-size: .72rem; color: var(--accent); letter-spacing: .3em; margin-top: 4px; }
.side-nav { margin-top: 18px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-item {
  text-align: left; background: transparent; border: none; color: #b5ad9e;
  padding: 11px 14px; border-radius: 10px; font-size: .95rem;
  transition: all .18s ease;
}
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a, .side-foot button {
  background: none; border: none; color: #9a917f; font-size: .88rem;
  text-align: left; padding: 8px 14px; border-radius: 8px; text-decoration: none;
  transition: color .18s;
}
.side-foot a:hover, .side-foot button:hover { color: #fff; }

.main { flex: 1; padding: 30px 34px 60px; max-width: 1180px; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-title { font-family: var(--serif); font-size: 1.5rem; letter-spacing: .02em; margin-bottom: 22px; }
.view-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.view-bar .view-title { margin-bottom: 0; }
.bar-actions { display: flex; gap: 10px; }

/* ---------- 概览 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
}
.stat-num { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.panel-narrow { max-width: 560px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { font-family: var(--serif); font-size: 1.05rem; }
.panel-head a { color: var(--accent-deep); font-size: .85rem; }
.panel-sub { font-family: var(--serif); font-size: 1.02rem; margin-bottom: 16px; color: var(--ink-soft); }

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 8px; border-radius: 10px; text-decoration: none;
  transition: background .15s;
}
.recent-item:hover { background: #faf6ee; }
.recent-thumb {
  width: 58px; height: 40px; border-radius: 8px; object-fit: cover;
  background: #f1ece2; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.recent-item .ri-title { flex: 1; font-size: .94rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .ri-date { color: var(--muted); font-size: .8rem; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid #f4efe6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .t-cover { width: 76px; }
.table .t-cover img, .table .t-cover .t-ph {
  width: 64px; height: 44px; border-radius: 8px; object-fit: cover; display: block;
  background: #f1ece2; display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.table .t-title { font-weight: 500; max-width: 360px; }
.table .t-title .t-excerpt { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-ops { display: flex; gap: 8px; }
.badge-sm {
  display: inline-block; font-size: .74rem; padding: 2px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c, #d97706) 13%, #fff); color: var(--c, #b45309);
}
.empty-hint { text-align: center; color: var(--muted); padding: 46px 0; }

/* ---------- 编辑器 ---------- */
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cover-row { display: flex; gap: 14px; align-items: center; }
.cover-preview {
  width: 168px; height: 96px; border-radius: 10px; border: 1px dashed #d8cdb8;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem;
  overflow: hidden; background: #faf6ee;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: flex; flex-direction: column; gap: 8px; }

.md-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  border: 1px solid var(--line); border-bottom: none; border-radius: 10px 10px 0 0;
  padding: 7px 10px; background: #faf6ee;
}
.md-toolbar button {
  border: none; background: transparent; color: var(--ink-soft);
  font-size: .9rem; min-width: 30px; height: 30px; border-radius: 7px;
  font-family: var(--serif); font-weight: 700;
}
.md-toolbar button:hover { background: rgba(41,36,32,.07); color: var(--ink); }
.toolbar-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.preview-head {
  font-size: .82rem; color: var(--ink-soft); font-weight: 500;
  border: 1px solid var(--line); border-bottom: none; border-radius: 10px 10px 0 0;
  padding: 10px 14px; background: #faf6ee;
}
.preview-body {
  border: 1px solid var(--line); border-radius: 0 0 10px 10px;
  min-height: 420px; max-height: 640px; overflow-y: auto;
  padding: 18px 20px; background: var(--surface); line-height: 1.9; font-size: .96rem;
}
.preview-empty { color: var(--muted); }
.preview-body h1, .preview-body h2, .preview-body h3 { font-family: var(--serif); margin: 1em 0 .5em; }
.preview-body h2 { border-left: 3px solid var(--accent); padding-left: .6em; }
.preview-body p { margin: .8em 0; }
.preview-body img { max-width: 100%; border-radius: 8px; }
.preview-body pre { background: #26221c; color: #f3ecdd; padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: .85em; }
.preview-body code { background: #f1ece2; padding: .12em .4em; border-radius: 5px; font-family: var(--mono); font-size: .88em; }
.preview-body pre code { background: none; padding: 0; }
.preview-body blockquote { border-left: 3px solid #d8cdb8; color: var(--ink-soft); padding-left: 1em; margin: 1em 0; }
.preview-body a { color: var(--accent-deep); }
.preview-body table { border-collapse: collapse; }
.preview-body th, .preview-body td { border: 1px solid var(--line); padding: .4em .7em; }

/* ---------- 图片库 ---------- */
.img-tip { color: var(--muted); font-size: .84rem; margin-bottom: 16px; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.img-card {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #faf6ee; cursor: pointer; transition: all .2s ease; position: relative;
}
.img-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.img-card .ic-img { aspect-ratio: 4/3; overflow: hidden; }
.img-card .ic-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-card .ic-info { padding: 8px 10px; font-size: .74rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.img-card .ic-del {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff;
  border: none; border-radius: 999px; width: 26px; height: 26px; font-size: .8rem;
  opacity: 0; transition: opacity .2s;
}
.img-card:hover .ic-del { opacity: 1; }
.img-card .ic-del:hover { background: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: #26221c; color: #f5efe3; padding: 12px 26px; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 99;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(600px 320px at 15% 10%, rgba(217,119,6,.12), transparent 62%),
    radial-gradient(520px 300px at 85% 20%, rgba(79,70,229,.10), transparent 62%),
    var(--bg);
}
.login-card {
  width: 380px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 18px 50px rgba(41,36,32,.10);
  padding: 40px 36px 28px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-star { font-size: 2rem; color: var(--accent); }
.login-brand h1 { font-family: var(--serif); font-size: 1.7rem; letter-spacing: .12em; margin-top: 6px; }
.login-brand p { color: var(--muted); font-size: .86rem; margin-top: 4px; letter-spacing: .3em; }
.login-msg { color: var(--danger); font-size: .85rem; margin: -6px 0 14px; }
.login-back { display: block; text-align: center; margin-top: 20px; color: var(--muted); font-size: .84rem; text-decoration: none; }
.login-back:hover { color: var(--accent-deep); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .side-brand span, .side-item { font-size: 0; }
  .side-item { text-align: center; padding: 12px 0; }
  .side-foot a, .side-foot button { font-size: 0; padding: 8px 0; text-align: center; }
  .main { padding: 20px 16px 50px; }
  .editor-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
