:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --line: #e3ded2;
  --line-strong: #cfc7b6;
  --text: #23201a;
  --text-2: #6b6459;
  --text-3: #96907f;
  --brand: #8c2f2f;
  --brand-soft: #f6ece9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(35, 32, 26, .06), 0 6px 20px rgba(35, 32, 26, .05);
  --h-hongxin: #c0392b;
  --h-chuxin: #a25f2b;
  --h-aixin: #d2536f;
  --h-rexin: #e07a1f;
  --h-xixin: #1d7a8c;
  --h-naixin: #3b7a57;
  --h-xinxin: #4c4a9c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */
.site-head {
  background: linear-gradient(180deg, #ffffff, #fdfcfa);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.head-inner { display: flex; align-items: center; gap: 20px; padding: 14px 0; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 500; letter-spacing: 1px;
}
.brand-title { font-size: 16px; font-weight: 500; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.head-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.head-nav a {
  padding: 7px 13px; border-radius: 8px; font-size: 13px; color: var(--text-2);
}
.head-nav a:hover { background: var(--surface-2); color: var(--text); }
.head-nav a.on { background: var(--brand-soft); color: var(--brand); }
.user-chip {
  font-size: 12px; color: var(--text-2); padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}

/* ---------- generic ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #7a2828; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 18px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #e6d9d4; border-color: var(--brand); }
textarea { min-height: 88px; resize: vertical; line-height: 1.7; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .row2, .row3 { grid-template-columns: 1fr; } }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbox {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 13px;
  font-size: 13px; cursor: pointer; background: var(--surface); user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.chipbox input { display: none; }
.chipbox.checked { color: #fff; border-color: transparent; }

.empty { padding: 48px 0; text-align: center; color: var(--text-3); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #23201a; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* ---------- heart bar ---------- */
.heart-bar {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 22px 0 6px;
}
@media (max-width: 860px) { .heart-bar { grid-template-columns: repeat(4, 1fr); } }
.heart-cell {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 12px;
  background: var(--surface); cursor: pointer; transition: transform .12s, box-shadow .12s;
  box-shadow: var(--shadow);
}
.heart-cell:hover { transform: translateY(-2px); }
.heart-cell.on { border-width: 2px; }
.heart-cell .hname { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.heart-cell .hdesc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.heart-cell .hcount { font-size: 12px; color: var(--text-2); margin-top: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 0 4px; }
.filter-bar select { width: auto; min-width: 128px; }
.filter-bar input[type=text] { width: 200px; }
.spacer { flex: 1; }

.stat-strip { display: flex; gap: 24px; padding: 14px 0 4px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.stat-strip b { font-weight: 500; color: var(--text); font-size: 15px; }

/* ---------- activity grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 16px 0 40px; }
@media (max-width: 980px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.act {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column;
}
.act:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(35,32,26,.10); }
.act .cover { height: 132px; position: relative; }
.act .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.act .no-cover { width: 100%; height: 100%; }
.act .body { padding: 13px 14px 15px; flex: 1; display: flex; flex-direction: column; }
.act .ttl { font-size: 14px; font-weight: 500; line-height: 1.5; margin-bottom: 8px; }
.act .meta { font-size: 12px; color: var(--text-3); }
.act .abs { font-size: 12.5px; color: var(--text-2); margin-top: 8px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act .foot { margin-top: 11px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hb {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; color: #fff; white-space: nowrap;
}
.pub-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text-3); }

/* ---------- modal ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(35,32,26,.42); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow: auto;
}
.mask.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; max-width: 760px; width: 100%;
  box-shadow: 0 20px 60px rgba(35,32,26,.25); overflow: hidden;
}
.modal .mhead { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.modal .mhead h3 { margin: 0; font-size: 17px; font-weight: 500; line-height: 1.5; }
.modal .mbody { padding: 18px 22px 24px; }
.modal .close { margin-left: auto; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-3); line-height: 1; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 9px 14px; font-size: 13px; margin-top: 14px; }
.kv .k { color: var(--text-3); }
.sect { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.sect h4 { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.cover-big { width: 100%; border-radius: 10px; display: block; }
.para { font-size: 13.5px; line-height: 1.85; white-space: pre-wrap; }

.flow { list-style: none; margin: 0; padding: 0; }
.flow li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.flow li:last-child { border-bottom: none; }
.flow .st { flex: none; width: 84px; color: var(--text-3); }
.flow .ac { flex: none; width: 52px; }

/* ---------- tables (admin) ---------- */
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th, table.tb td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tb th { color: var(--text-3); font-weight: 400; font-size: 12px; background: var(--surface-2); }
table.tb tr:hover td { background: #fdfcfa; }

.state {
  font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.st-submitted { color: #8a6d1f; border-color: #e0cf9a; background: #fbf6e6; }
.st-unit_approved { color: #1d6a8c; border-color: #a9d4e6; background: #eaf6fb; }
.st-leader_approved { color: #4c4a9c; border-color: #c3c1e6; background: #f0effb; }
.st-published { color: #2c6b45; border-color: #a9d7bd; background: #eaf6ef; }
.st-rejected { color: #a33a2d; border-color: #eab7b0; background: #fcedeb; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 12px; }
.tab { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; }
.tab.on { background: var(--brand-soft); border-color: #e2cdc7; color: var(--brand); }

/* ---------- login ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-wrap h2 { font-size: 20px; font-weight: 500; margin: 0 0 4px; }
.auth-wrap .sub { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.seg button { flex: 1; padding: 9px; border: none; background: var(--surface); cursor: pointer; font-size: 13px; font-family: inherit; color: var(--text-2); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }

/* ---------- flipbook ---------- */
.book-stage { display: flex; flex-direction: column; align-items: center; padding: 26px 0 60px; }
.book {
  position: relative; width: 900px; max-width: 100%; height: 640px;
  perspective: 2400px; margin: 0 auto;
}
.page {
  position: absolute; inset: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 4px; box-shadow: 0 6px 24px rgba(35,32,26,.14);
  padding: 46px 54px; overflow: hidden; transform-origin: left center;
  transition: transform .5s ease, box-shadow .5s ease;
  backface-visibility: hidden;
}
.page.flipped { transform: rotateY(-180deg); }
.page-num { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--text-3); }
.book-ctl { display: flex; gap: 12px; align-items: center; margin-top: 18px; }
.book-ctl .pos { font-size: 13px; color: var(--text-2); min-width: 90px; text-align: center; }
.pg-title { font-size: 15px; font-weight: 500; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--brand); }
.pg-item { padding: 12px 0; border-bottom: 1px dashed var(--line); break-inside: avoid; }
.pg-item:last-child { border-bottom: none; }
.pg-item .t { font-size: 13.5px; font-weight: 500; }
.pg-item .m { font-size: 12px; color: var(--text-3); margin: 3px 0 5px; }
.pg-item .d { font-size: 12.5px; color: var(--text-2); line-height: 1.8; }
.cover-page { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: #8c2f2f; color: #fff; }
.cover-page h1 { font-size: 34px; font-weight: 500; letter-spacing: 3px; margin: 0 0 14px; }
.cover-page .cb-sub { font-size: 15px; opacity: .9; letter-spacing: 1px; }
.cover-page .cb-meta { margin-top: 46px; font-size: 13px; opacity: .85; line-height: 2; }
.toc-row { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; font-size: 13px; }
.toc-row .dots { flex: 1; border-bottom: 1px dotted var(--line-strong); }
.measure { position: absolute; left: -99999px; top: 0; width: 792px; padding: 46px 54px; font-size: 13.5px; }

@media print {
  .site-head, .book-ctl, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .book { width: auto; height: auto; display: block; perspective: none; }
  .page { position: relative; inset: auto; width: 100%; height: 860px; margin-bottom: 12px;
    transform: none !important; box-shadow: none; border: none; page-break-after: always; }
}
