:root {
  --bg: #F6F4EF;
  --panel: #FFFFFF;
  --panel-2: #FBFAF7;
  --line: #ECE7DE;
  --line-2: #E3DCD0;
  --text: #1E1B17;
  --ink-2: #4A453E;
  --muted: #9A9389;
  --primary: #6D5BFF;
  --primary-2: #B65BFF;
  --primary-d: #5848E0;
  --grad: linear-gradient(120deg, #6D5BFF 0%, #B65BFF 100%);
  --gold: #9A6A2F;
  --green: #12A37B;
  --amber: #E0892B;
  --red: #E2574C;
  --sidebar: #23202A;
  --sidebar-2: #2C2834;
  --shadow-sm: 0 2px 10px rgba(30,25,15,.05);
  --shadow: 0 14px 40px rgba(30,25,15,.09);
  --radius: 16px;
  --radius-sm: 10px;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

button { cursor: pointer; font-family: inherit; border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; background: #EFEDE7; color: var(--ink-2); font-size: 13px; transition: .16s; }
button:hover { background: #E6E2D9; }
button.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(109,91,255,.28); }
button.primary:hover { filter: brightness(1.05); box-shadow: 0 10px 26px rgba(109,91,255,.34); }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 10px 13px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); outline: none; background: #fff; color: var(--text);
  transition: .16s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,91,255,.14); }

/* ---------- 登录 ---------- */
.login-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--grad); }
.login-card { background: #fff; padding: 44px 38px; border-radius: 22px; width: 350px;
  box-shadow: 0 30px 80px rgba(20,15,40,.35); text-align: center; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; background: var(--grad);
  color: #fff; font-size: 32px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(109,91,255,.4); }
.login-card h1 { font-family: var(--serif); font-size: 23px; letter-spacing: 1px; }
.login-sub { color: var(--muted); margin: 6px 0 26px; font-size: 13px; letter-spacing: 2px; }
.login-card input { width: 100%; margin-bottom: 14px; }
.login-card button { width: 100%; background: var(--grad); color: #fff; padding: 12px; font-size: 15px;
  box-shadow: 0 10px 26px rgba(109,91,255,.32); }
.login-tip { color: var(--red); margin-top: 12px; font-size: 12px; min-height: 16px; }

/* ---------- 框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--sidebar); color: #C9C5D6; display: flex; flex-direction: column;
  padding: 26px 16px; position: fixed; top: 0; bottom: 0; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 700; color: #fff;
  margin-bottom: 30px; padding-left: 10px; letter-spacing: .5px; }
.brand::before { content: ''; width: 30px; height: 30px; border-radius: 9px; background: var(--grad);
  box-shadow: 0 6px 16px rgba(109,91,255,.4); }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 11px;
  color: #B9B4C8; text-decoration: none; margin-bottom: 6px; cursor: pointer; transition: .16s; font-size: 14px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(109,91,255,.32); }
.side-foot { margin-top: auto; font-size: 12px; color: #807C90; padding: 12px 10px; }
.side-foot a { display: block; margin-top: 8px; color: #B9B4C8; cursor: pointer; }
.side-foot a:hover { color: #fff; }

.main { margin-left: 232px; flex: 1; padding: 30px 36px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.topbar h2 { font-family: var(--serif); font-size: 24px; letter-spacing: 1px; color: var(--text); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters input { min-width: 180px; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: var(--panel-2); color: var(--muted); font-weight: 600; letter-spacing: .5px; font-size: 12px; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: #FAF8F3; }
tbody tr:last-child td { border-bottom: none; }
.thumb { width: 58px; height: 42px; object-fit: cover; border-radius: 8px; background: #eee; display: inline-block; }
.tag { display: inline-block; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag.article { background: #EDEAFF; color: var(--primary); }
.tag.audio { background: #E4F7F0; color: var(--green); }
.tag.video { background: #FCEFDD; color: var(--amber); }
.board-badge { display: inline-block; padding: 3px 11px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent; }
.board-badge.b-jing { background: rgba(154,106,47,.1); color: var(--gold); border-color: rgba(154,106,47,.22); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.dot.published { background: var(--green); }
.dot.draft { background: var(--muted); }
.dot.unread { background: var(--amber); }

/* ---------- 留言管理 ---------- */
.unread-badge { background: var(--amber); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 10px; border-radius: 20px; margin-left: 12px; letter-spacing: .5px; vertical-align: middle; }
#m-filter { min-width: 130px; }
.m-content { white-space: pre-wrap; word-break: break-word; max-width: 420px; line-height: 1.6; color: var(--ink-2); }
.row-actions button { padding: 6px 12px; margin-right: 6px; font-size: 12px; }
.row-actions button:hover { background: #E6E2D9; }
.empty { padding: 56px; text-align: center; color: var(--muted); }

/* ---------- 媒体库 ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); gap: 18px; }
.media-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--line); transition: transform .16s, box-shadow .16s; }
.media-card:hover { transform: translateY(-3px); box-shadow: 0 20px 48px rgba(30,25,15,.12); }
.media-card .prev { height: 124px; background: #F0EEE8; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.media-card .prev img { width: 100%; height: 100%; object-fit: cover; }
.media-card .info { padding: 12px 14px; }
.media-card .info .nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-card .info .mt { color: var(--muted); font-size: 11px; margin: 5px 0 10px; }
.media-card .info .acts button { padding: 5px 10px; font-size: 11px; margin-right: 5px; }
.upload-btn { background: var(--grad); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; box-shadow: 0 8px 20px rgba(109,91,255,.28); transition: .16s; }
.upload-btn:hover { filter: brightness(1.05); }

/* ---------- 编辑器 ---------- */
.editor { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; max-width: 900px;
  border: 1px solid var(--line); }
.editor-row { margin-bottom: 20px; }
.editor-row > label { display: block; font-weight: 600; margin-bottom: 9px; font-size: 13px; color: var(--ink-2); }
.editor-row input, .editor-row textarea, .editor-row select { width: 100%; }
.cover-pick { display: flex; gap: 10px; }
.cover-pick input { flex: 1; }
.mini-upload { background: #EFEDE7; padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; transition: .16s; }
.mini-upload:hover { background: #E6E2D9; }
.cover-preview { max-width: 220px; margin-top: 12px; border-radius: 12px; border: 1px solid var(--line); }
.duration-input { max-width: 220px; margin-top: 12px; }
.editor-row.check { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.editor-row.check .check-label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.editor-row.check .check-label input { width: auto; }
.editor-row.check .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }

.rich-toolbar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.rich-toolbar button { background: #F1EFEA; padding: 7px 12px; }
.rich-toolbar button:hover { background: #E7E3DB; }
.rich-editor { min-height: 300px; border: 1px solid var(--line-2); border-radius: 12px; padding: 18px; line-height: 1.8;
  outline: none; overflow-y: auto; max-height: 62vh; font-size: 14px; color: var(--ink-2); }
.rich-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,91,255,.14); }
.rich-editor img { max-width: 100%; border-radius: 10px; }
.rich-editor h2 { font-family: var(--serif); font-size: 20px; margin: 14px 0 10px; color: var(--text); }
.rich-editor blockquote { border-left: 4px solid var(--primary); padding: 8px 16px; color: var(--muted);
  margin: 12px 0; background: #FAF8F3; border-radius: 0 8px 8px 0; }

/* ---------- 分卷编辑（古籍） ---------- */
.mode-switch { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.mode-switch .ms { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.mode-switch .ms input { width: auto; }
#chapterPanel { margin-top: 4px; }
.ch-bar { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; flex-wrap: wrap; }
.ch-bar .hint { color: var(--muted); font-size: 12px; }
.ch-edit { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; background: var(--panel-2); }
.ch-edit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ch-title-input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.ch-del { background: #FCEAE8; color: #C0392B; border: none; border-radius: 8px; padding: 10px 14px; cursor: pointer; font-size: 13px; }
.ch-del:hover { filter: brightness(.97); }
.ch-content { min-height: 180px; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fff;
  line-height: 1.8; font-size: 14px; color: var(--ink-2); }
.ch-content:focus { outline: none; border-color: var(--primary); }
.ch-content img { max-width: 100%; border-radius: 8px; }
.ch-content h2 { font-family: var(--serif); font-size: 20px; margin: 14px 0 10px; color: var(--text); }
.ch-content blockquote { border-left: 4px solid var(--primary); padding: 8px 16px; color: var(--muted); margin: 12px 0; background: #FAF8F3; }

/* ---------- 提示条 ---------- */
.toast { position: fixed; top: 26px; left: 50%; transform: translateX(-50%); background: var(--sidebar); color: #fff;
  padding: 13px 24px; border-radius: 12px; box-shadow: var(--shadow); z-index: 999; font-size: 13px; letter-spacing: .5px; }
