/* ============================================================
   八宝 · 设计系统 —— 「纸墨编辑部」
   米白纸感底 + 墨绿主色 + 朱砂点缀 + 衬线标题
   ============================================================ */
:root {
  /* 色板 */
  --paper: #faf7f0;          /* 页面纸底 */
  --paper-deep: #f3eee2;     /* 深一度纸色（分区底） */
  --card: #fffdf8;           /* 卡片 */
  --ink: #1a4d3e;            /* 墨绿主色 */
  --ink-deep: #12392e;       /* 深墨绿（侧栏底） */
  --ink-soft: #23624f;       /* 主色 hover */
  --ink-pale: #e4ede8;       /* 主色浅底 */
  --cinnabar: #a63d2f;       /* 朱砂红（印章/强调） */
  --cinnabar-pale: #f5e3df;
  --gold: #8a6d1d;           /* 赭金（提示） */
  --gold-pale: #f6edd6;
  --text: #2b2b28;           /* 正文 */
  --text-2: #6f6a5e;         /* 次级文字 */
  --text-3: #9a948a;         /* 弱化文字 */
  --line: #e2dccd;           /* 描边 */
  --line-deep: #cfc7b4;
  --danger: #b03a2e;
  --ok: #2e7d52;

  /* 字体 */
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --sans: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, "Courier New", monospace;

  /* 形状 */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(43, 43, 40, .05), 0 4px 14px rgba(43, 43, 40, .05);
  --shadow-lg: 0 8px 30px rgba(43, 43, 40, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 80% -100px, rgba(26, 77, 62, .05), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(43, 43, 40, .008) 2px 4px),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); color: var(--text); line-height: 1.35; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--ink-soft); }

::selection { background: rgba(26, 77, 62, .18); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d6cfbe; border-radius: 5px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: #c2b9a3; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14px; font-family: var(--sans); cursor: pointer;
  transition: all .15s ease; white-space: nowrap; user-select: none;
  background: transparent; color: var(--text);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #f6f3ea; border-color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: var(--ink-soft); }
.btn-outline { border-color: var(--line-deep); color: var(--text); background: var(--card); }
.btn-outline:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(43, 43, 40, .06); color: var(--text); }
.btn-danger { border-color: #dcb9b3; color: var(--danger); background: #fdf4f2; }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-lg { padding: 11px 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn .spin {
  width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block; margin-bottom: 6px; font-size: 13px;
  color: var(--text-2); font-weight: 500;
}
.field .hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-deep);
  border-radius: var(--r-sm); background: #fff; color: var(--text);
  font-size: 14px; font-family: var(--sans); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26, 77, 62, .12);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-mono { font-family: var(--mono); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.card-title h3 { font-size: 15px; }
.card-title .sub { font-size: 12px; color: var(--text-3); font-family: var(--sans); font-weight: normal; }

/* ---------- 徽章 / 标签 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line-deep); color: var(--text-2); background: var(--card);
}
.chip-ink { background: var(--ink-pale); border-color: #c3d6cc; color: var(--ink); }
.chip-red { background: var(--cinnabar-pale); border-color: #e0c3bc; color: var(--cinnabar); }
.chip-gold { background: var(--gold-pale); border-color: #e3d5ab; color: var(--gold); }
.chip-ok { background: #e3f0e7; border-color: #bcd8c5; color: var(--ok); }
.chip-gray { background: #eeece6; border-color: var(--line); color: var(--text-3); }
.tag {
  display: inline-block; padding: 1px 8px; margin: 0 4px 4px 0;
  background: var(--paper-deep); border-radius: 4px; font-size: 12px; color: var(--text-2);
}

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 9px 12px; color: var(--text-2); font-weight: 500;
  border-bottom: 1px solid var(--line-deep); background: var(--paper-deep);
  font-size: 12.5px; letter-spacing: .03em; white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(26, 77, 62, .03); }
.table .num { font-family: var(--mono); font-size: 13px; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 48px 20px; text-align: center; color: var(--text-3);
}
.empty .glyph { font-size: 34px; margin-bottom: 10px; opacity: .5; font-family: var(--serif); }
.empty p { font-size: 13.5px; }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: var(--r-sm); font-size: 14px;
  background: var(--ink-deep); color: #f0ede2; box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease; max-width: 70vw;
}
.toast.err { background: var(--cinnabar); color: #fdf3f0; }
.toast.ok { background: var(--ok); color: #f0f8f2; }
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- 模态 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 900; pointer-events: none; }
.modal-mask {
  position: absolute; inset: 0; background: rgba(24, 30, 27, .45);
  backdrop-filter: blur(2px); display: flex; align-items: flex-start;
  justify-content: center; padding: 8vh 16px 16px; pointer-events: auto;
  animation: fade-in .18s ease; overflow-y: auto;
}
.modal {
  width: 560px; max-width: 100%; background: var(--card);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.1);
  border: 1px solid var(--line);
}
.modal.wide { width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 17px; }
.modal-x { cursor: pointer; border: none; background: none; font-size: 18px; color: var(--text-3); padding: 4px 8px; border-radius: 4px; }
.modal-x:hover { background: var(--paper-deep); color: var(--text); }
.modal-body { padding: 18px 22px; max-height: 64vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--line);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ---------- 其他通用 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 6px;
  border: 1px solid var(--line-deep); border-bottom-width: 2px; border-radius: 4px; background: #fff;
}
.demo-banner {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--gold-pale); border: 1px solid #e3d5ab; color: #6d561a;
  padding: 9px 14px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 16px;
}
.boot-loading {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-family: var(--serif); font-size: 16px; letter-spacing: .2em;
}
