:root {
  --brand: #8a1f1f;
  --brand-strong: #741a1a;
  --brand-soft: #f9eeee;
  --brand-line: #ecd9d9;
  --gold: #b99a5b;
  --gold-soft: #f4ecdd;
  --ink: #26231f;
  --muted: #8b837a;
  --line: #ece5da;
  --line-strong: #ddd2c2;
  --bg: #f7f4ef;
  --panel: #ffffff;
  --ok: #2f7d4f;
  --ok-bg: #eef7f0;
  --warn: #a35b0a;
  --warn-bg: #fdf4e6;
  --err: #b3261e;
  --err-bg: #fdf0ef;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(38, 35, 31, .04), 0 6px 18px -12px rgba(38, 35, 31, .18);
  --shadow-md: 0 2px 6px rgba(38, 35, 31, .05), 0 16px 32px -18px rgba(38, 35, 31, .25);
  --ring: 0 0 0 3px rgba(185, 154, 91, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.75 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--brand-strong); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
::selection { background: var(--gold-soft); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 16px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, #9c2626, #6f1818);
  color: #f8e9c9; font-weight: 700; font-size: 17px; letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 10px -4px rgba(138, 31, 31, .6);
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--gold); letter-spacing: .12em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-chip {
  font-size: 12px; color: var(--muted); background: #fbf8f3;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  white-space: nowrap;
}
.user-chip {
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; background: var(--brand-soft);
  color: var(--brand-strong);
}
.user-chip em {
  font-style: normal; font-size: 11px; color: #fff; background: var(--gold);
  border-radius: 999px; padding: 1px 8px; letter-spacing: .04em;
}
.nav-toggle { display: none; font-size: 20px; background: none; border: 0; cursor: pointer; color: var(--ink); }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: linear-gradient(180deg, #fffdf9, #fbf8f3);
  border-right: 1px solid var(--line);
  padding: 16px 12px 28px;
  position: sticky; top: 60px;
  height: calc(100vh - 60px); overflow-y: auto;
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: #57534c; font-size: 14.5px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar a:hover { background: #f4efe6; color: var(--ink); }
.sidebar a.is-active {
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--brand);
}
.nav-ico { width: 17px; height: 17px; flex: 0 0 17px; stroke-width: 1.8; opacity: .75; }
.sidebar a.is-active .nav-ico { opacity: 1; }
.nav-group {
  margin: 18px 12px 6px; font-size: 11px; color: #b0a698;
  letter-spacing: .16em; font-weight: 600;
}
.badge {
  margin-left: auto; background: var(--brand); color: #fff;
  border-radius: 999px; font-size: 11.5px; line-height: 1; padding: 4px 8px;
  box-shadow: 0 2px 6px -2px rgba(138, 31, 31, .5);
}

/* ---------------- 内容区 ---------------- */
.content { flex: 1; padding: 26px 32px 70px; min-width: 0; }
.page-title { font-size: 23px; font-weight: 700; letter-spacing: .01em; }
.page-title .muted { font-size: 14px; font-weight: 400; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  border-radius: var(--radius-sm); padding: 8px 16px; font-size: 14px;
  font-family: inherit; line-height: 1.4; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { background: #faf7f3; border-color: #cfc2b0; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary {
  background: linear-gradient(180deg, #972525, var(--brand));
  border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 14px -8px rgba(138, 31, 31, .8);
}
.btn-primary:hover { background: linear-gradient(180deg, #8a2020, var(--brand-strong)); border-color: var(--brand-strong); color: #fff; }
.btn-danger { background: #fff; border-color: #ecc6c2; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); border-color: #dda9a3; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f4efe6; color: var(--ink); border-color: transparent; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.inline { display: inline; }
.link-btn {
  border: 0; background: none; color: var(--brand); cursor: pointer;
  font-size: 13.5px; font-family: inherit; padding: 2px 3px; border-radius: 5px;
}
.link-btn:hover { color: var(--brand-strong); background: var(--brand-soft); }
.link-btn.danger { color: var(--err); }
.link-btn.danger:hover { background: var(--err-bg); }

/* ---------------- 提示 ---------------- */
.flash {
  position: relative; padding: 11px 16px 11px 18px; border-radius: var(--radius-sm);
  margin-bottom: 16px; border: 1px solid; font-size: 14px;
  animation: flashIn .25s ease;
}
.flash::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.flash-success { background: var(--ok-bg); border-color: #cfe6d6; color: var(--ok); }
.flash-success::before { background: var(--ok); }
.flash-error { background: var(--err-bg); border-color: #f0cdc9; color: var(--err); }
.flash-error::before { background: var(--err); }
.flash-warn { background: var(--warn-bg); border-color: #eed9b8; color: var(--warn); }
.flash-warn::before { background: var(--warn); }
@keyframes flashIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.notice {
  background: #f2f7fd; border: 1px solid #d7e5f5; color: #2a5a8f;
  padding: 11px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px;
}

/* ---------------- 卡片 ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.panel h2 { font-size: 16px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.panel.narrow { max-width: 480px; }
.panel-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 18px; align-items: start; }
.quick-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

/* ---------------- 概览卡片 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 3px;
  color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.stat-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-number { font-size: 29px; font-weight: 700; color: var(--brand); letter-spacing: .01em; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ---------------- 表格 ---------------- */
.table-wrap {
  overflow-x: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; background: var(--panel); }
.table th, .table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid #f3ede4; vertical-align: middle; }
.table thead th {
  background: #fbf8f3; font-size: 12.5px; color: var(--muted); font-weight: 600;
  white-space: nowrap; letter-spacing: .03em; border-bottom: 1px solid var(--line);
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:nth-child(even) { background: #fdfbf8; }
.table tbody tr:hover { background: #faf5ec; }
.table tbody tr:last-child td { border-bottom: 0; }
.col-actions { width: 1%; white-space: nowrap; }
.actions { white-space: nowrap; display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }
.strong-link { font-weight: 600; color: var(--ink); }
.strong-link:hover { color: var(--brand); }

/* ---------------- 状态徽标 ---------------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; line-height: 1.5; white-space: nowrap;
}
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.tag-published { background: var(--ok-bg); color: var(--ok); }
.tag-draft { background: #f2efea; color: #7d766c; }
.tag-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------------- 筛选与分页 ---------------- */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { width: 300px; }
.filters input, .filters select { width: auto; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 14px; background: #fff; font-family: inherit; }
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination .current {
  padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: 13.5px; transition: all .15s ease;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------------- 表单 ---------------- */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; color: #4d4840; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="search"], textarea, select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { resize: vertical; line-height: 1.75; }
input:hover, textarea:hover, select:hover { border-color: #cfc2b0; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.req { color: var(--err); font-style: normal; }
.hint { font-size: 12.5px; color: var(--muted); margin: 5px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field-full { grid-column: 1 / -1; }
.field label { letter-spacing: .01em; }
.form-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  position: sticky; bottom: 0; z-index: 8;
  background: #fff;
  margin: 20px -24px -22px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 -12px 18px -14px rgba(38, 35, 31, .35);
}
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }

.image-field {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px; background: #fdfbf8;
}
.image-inputs { display: flex; gap: 8px; align-items: center; }
.image-preview img { max-width: 220px; max-height: 160px; margin-top: 10px; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }

.quill-editor { min-height: 280px; background: #fff; }
.quill-editor.quill-compact { min-height: 62px; }
.quill-compact .ql-editor { min-height: 30px; padding: 9px 14px; font-size: 15.5px; line-height: 1.7; }
.ql-toolbar.ql-snow {
  border-color: var(--line-strong); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: #fdfbf8;
}
.ql-container.ql-snow { border-color: var(--line-strong); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ql-editor { min-height: 250px; font-size: 15px; line-height: 1.8; }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--brand); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--brand); }

/* ---------------- 图片库 ---------------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 16px; }
.media-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 0; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease;
}
.media-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.media-card img { width: 100%; height: 152px; object-fit: cover; background: #f4efe7; }
.media-card figcaption { padding: 12px; display: flex; flex-direction: column; gap: 5px; }
.media-path { font-size: 11.5px; word-break: break-all; color: #6d665c; background: #f7f3ed; padding: 2px 6px; border-radius: 5px; }
.media-actions { display: flex; gap: 10px; }
.upload-inline { display: flex; gap: 8px; align-items: center; }
.upload-inline input[type="file"] { font-size: 13.5px; }

/* ---------------- 登录页 ---------------- */
.login-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
}
.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  padding: 52px 60px;
  background: linear-gradient(165deg, #9c2727 0%, #7c1c1c 55%, #641414 100%);
  color: #f7ead2;
}
.login-brand::before {
  content: "凯";
  position: absolute; right: -0.06em; bottom: -0.34em;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 26rem; line-height: 1; font-weight: 700;
  color: rgba(255, 255, 255, .045); pointer-events: none;
}
.login-brand::after {
  content: "";
  position: absolute; right: -160px; top: -160px; width: 460px; height: 460px;
  border-radius: 50%; border: 1px solid rgba(230, 200, 150, .22);
  box-shadow: 0 0 0 60px rgba(230, 200, 150, .05), 0 0 0 140px rgba(230, 200, 150, .03);
  pointer-events: none;
}
.lb-top { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.brand-mark--lg {
  width: 54px; height: 54px; font-size: 28px; border-radius: 14px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(230, 200, 150, .45);
  color: #f4dca9; box-shadow: none;
}
.lb-names strong { display: block; font-size: 20px; color: #fff; letter-spacing: .05em; }
.lb-names em { font-style: normal; font-size: 11px; letter-spacing: .26em; color: #d9b678; }
.lb-main { margin: auto 0; position: relative; z-index: 1; padding: 40px 0; }
.lb-main h1 {
  font-size: 46px; line-height: 1.3; color: #fff; font-weight: 700;
  letter-spacing: .06em; margin: 0 0 16px;
}
.lb-main h1::after {
  content: ""; display: block; width: 56px; height: 2px; margin-top: 22px;
  background: linear-gradient(90deg, var(--gold), rgba(185, 154, 91, 0));
}
.lb-sub { color: #e7cfa4; font-size: 15px; letter-spacing: .12em; margin: 0 0 30px; }
.lb-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lb-points li { color: rgba(247, 234, 210, .82); font-size: 14.5px; letter-spacing: .02em; }
.lb-points li::before { content: "—"; color: var(--gold); margin-right: 12px; }
.lb-foot { font-size: 12.5px; color: rgba(247, 234, 210, .5); letter-spacing: .08em; position: relative; z-index: 1; }

.login-panel {
  display: flex; align-items: center; justify-content: center;
  background: #fff; padding: 48px;
}
.login-form { width: 100%; max-width: 400px; }
.login-form h2 { font-size: 30px; margin: 0 0 6px; letter-spacing: .02em; }
.login-form .sub { color: var(--muted); margin: 0 0 30px; font-size: 14.5px; }
.login-form label { margin-bottom: 18px; font-size: 14px; }
.login-form input { padding: 13px 15px; font-size: 15px; }
.login-form .btn-lg { padding: 13px 18px; font-size: 16px; letter-spacing: .35em; margin-top: 10px; }
.login-tip { margin: 18px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------------- 错误页 ---------------- */
.error-page { max-width: 480px; margin: 90px auto; text-align: center; }
.error-page h1 { font-size: 64px; color: var(--brand); margin: 0; letter-spacing: .02em; }
.error-page p { color: var(--muted); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1000px) {
  .panel-grid { grid-template-columns: 1fr; }
  .content { padding: 22px 20px 70px; }
}
@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-brand { padding: 26px 24px 22px; }
  .login-brand::before { font-size: 14rem; bottom: -0.3em; }
  .lb-main { padding: 16px 0 4px; }
  .lb-main h1 { font-size: 29px; margin-bottom: 8px; }
  .lb-main h1::after { margin-top: 14px; }
  .lb-sub { margin-bottom: 0; font-size: 13.5px; }
  .lb-points { display: none; }
  .lb-foot { display: none; }
  .lb-names strong { font-size: 17px; }
  .login-panel { padding: 32px 22px 44px; }
  .login-form { max-width: 420px; }
}
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 60px; bottom: 0; z-index: 40;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 24px 0 48px -30px rgba(0, 0, 0, .45);
  }
  .sidebar.is-open { transform: translateX(0); }
  .content { padding: 16px 14px 80px; }
  .topbar { padding: 0 12px; height: 56px; }
  .topbar-right .sync-chip { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { margin: 18px -18px -22px; padding: 12px 18px; }
  .page-title { font-size: 20px; }
  .user-chip { padding: 3px 8px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
