/* ============================================================
 * base.css — 设计 tokens（§8.0）、重置、公共组件。
 * 视觉参数来源：../novel_rank_proto/ 原型实测（§8.9）。
 * ============================================================ */

:root {
  --bg: #FAF7F1;
  --card: #FFFDF8;
  --ink: #2B2118;
  --ink-2: #3D3125;
  --red: #B23A2E;
  --gold: #C9962E;
  --muted: #9A8B74;
  --muted-2: #8A7B63;
  --border: #EFE7D8;
  --input-border: #E3D9C4;
  --input-bg: #FAF7F1;
  --placeholder: #B4A88F;
  --dark-grad: linear-gradient(120deg, #33302B, #4A4238);
  --gold-num: #E8C97A;
  --gold-chip-text: #5C4522;
  --admin-side: #2E2A24;
  --admin-side-text: #C9BBA0;
  --admin-bg: #F6F3EC;
  --ok: #3E7A3E;
  --ok-bg: #E4F0E4;
  --wait: #A67B24;
  --wait-bg: #FBF0DC;
  --no: #B23A2E;
  --no-bg: #F9E4E0;
  --adm-chip: #6B4FA1;
  --adm-chip-bg: #EFE9FB;
  --vis-chip: #3A6B9C;
  --vis-chip-bg: #E4EEF7;
  --serif: "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --sans: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--sans); }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { border: none; background: none; font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; }
.hidden { display: none !important; }

/* ---------- 页面容器（访客端手机优先，480px 居中） ---------- */
.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* ---------- 按钮 ---------- */
.btn {
  display: block;
  width: 100%;
  background: var(--red);
  color: #fff;
  padding: 15px 0;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 22px rgba(178, 58, 46, .35);
  transition: filter .15s;
}
.btn:active { filter: brightness(.92); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-plain {
  background: var(--input-bg);
  color: #6B5B45;
  border: 1.5px solid var(--input-border);
  box-shadow: none;
}
.btn-danger { background: var(--red); color: #fff; }
.btn-sm {
  display: inline-block;
  width: auto;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 10px;
  box-shadow: none;
}

/* ---------- 表单 ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6B5B45;
  margin: 16px 0 8px;
}
label:first-child { margin-top: 0; }
.req { color: var(--red); }
.input {
  display: block;
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--red); }
.input::placeholder { color: var(--placeholder); }
textarea.input { height: 128px; line-height: 1.6; resize: none; }
.count { text-align: right; font-size: 11px; color: var(--placeholder); margin-top: 5px; }

/* 分段二选一（原型 .seg） */
.seg { display: flex; gap: 10px; }
.seg .seg-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  border-radius: 12px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  font-size: 15px;
  color: #6B5B45;
  cursor: pointer;
  user-select: none;
}
.seg .seg-item.on { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
  margin: 12px 16px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
}
.card h3 {
  font-size: 13px;
  color: var(--muted-2);
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.card p { font-size: 14.5px; line-height: 1.75; color: var(--ink-2); }
.admin-note { border-left: 3.5px solid var(--gold); background: #FBF6EA; }
.admin-note h3 { color: var(--wait); }

/* ---------- 徽标 / chip ---------- */
.badge { font-size: 10px; padding: 1.5px 7px; border-radius: 8px; font-weight: 500; }
.b-on { background: var(--ok-bg); color: var(--ok); }
.b-end { background: #ECE7DC; color: var(--muted-2); }

.chip { font-size: 11px; padding: 2.5px 9px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.c-ok { background: var(--ok-bg); color: var(--ok); }
.c-wait { background: var(--wait-bg); color: var(--wait); }
.c-no { background: var(--no-bg); color: var(--no); }
.c-on { background: var(--ok-bg); color: var(--ok); }
.c-end { background: #ECE7DC; color: var(--muted-2); }
.c-adm { background: var(--adm-chip-bg); color: var(--adm-chip); }
.c-vis { background: var(--vis-chip-bg); color: var(--vis-chip); }
.c-off { background: #ECE7DC; color: var(--muted-2); }

/* ---------- 样式封面（不用图片） ---------- */
.cover {
  width: 44px;
  height: 64px;
  border-radius: 5px;
  color: #FFF7E8;
  font-family: var(--serif);
  font-size: 11px;
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .5px;
  box-shadow: 0 3px 8px rgba(60, 40, 10, .25);
  flex: none;
  overflow: hidden;
  white-space: nowrap;
}

/* 名次（前三金银铜） */
.rank {
  font-family: var(--serif);
  font-size: 21px;
  width: 30px;
  text-align: center;
  color: var(--muted-2);
  flex: none;
}
.rank.g1 { color: var(--gold); font-size: 25px; }
.rank.g2 { color: #8E979E; font-size: 24px; }
.rank.g3 { color: #B07A45; font-size: 24px; }

/* ---------- tabbar（64px 底栏，中间凸起＋） ---------- */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  height: 64px;
  border-top: 1px solid var(--border);
  background: var(--card);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
}
.tab.on { color: var(--red); font-weight: 600; }
.tab .ic { font-size: 19px; position: relative; line-height: 1; }
.tab .bdg {
  position: absolute;
  right: -9px;
  top: -4px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-weight: 600;
}
.tab .plus {
  background: var(--red);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-top: -16px;
  box-shadow: 0 6px 14px rgba(178, 58, 46, .4);
}
.tab.on .plus { box-shadow: 0 6px 18px rgba(178, 58, 46, .55); }

/* ---------- 演示模式徽标 ---------- */
.demo-badge {
  display: inline-block;
  font-size: 10px;
  color: var(--gold-chip-text);
  background: rgba(232, 201, 122, .28);
  border: 1px solid rgba(201, 150, 46, .45);
  border-radius: 8px;
  padding: 1.5px 8px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- toast ---------- */
.nr-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(43, 33, 24, .92);
  color: #F7F0E3;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: 12px;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 300;
  box-shadow: 0 10px 26px rgba(40, 28, 12, .3);
}
.nr-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.nr-toast-ok { background: rgba(62, 122, 62, .95); }
.nr-toast-err { background: rgba(178, 58, 46, .95); color: #fff; }

/* ---------- 弹层 ---------- */
.nr-mask {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  animation: nrFade .16s;
}
.nr-mask.closing { animation: nrFadeOut .16s forwards; }
@keyframes nrFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nrFadeOut { from { opacity: 1; } to { opacity: 0; } }
.nr-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(60, 45, 20, .3);
  animation: nrPop .18s;
}
@keyframes nrPop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.nr-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}
.nr-modal-t { font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--ink); }
.nr-modal-x { font-size: 22px; color: var(--muted); line-height: 1; padding: 2px 6px; }
.nr-modal-bd { padding: 14px 18px 6px; overflow-y: auto; }
.nr-modal-ft { display: flex; gap: 10px; padding: 12px 18px 18px; }
.nr-modal-ft .btn { flex: 1; box-shadow: none; padding: 12px 0; font-size: 15px; }
.nr-confirm-msg { font-size: 14.5px; color: var(--ink-2); line-height: 1.7; }

/* ---------- 确认页/空状态 ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 34px 16px;
  line-height: 1.8;
}
.empty .big { font-size: 30px; margin-bottom: 6px; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 0 4px;
}
.pg-btn {
  font-size: 13px;
  color: #6B5B45;
  background: var(--card);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 8px 14px;
}
.pg-btn[disabled] { opacity: .4; cursor: not-allowed; }
.pg-info { font-size: 12px; color: var(--muted); }

/* ---------- 会话气泡（详情页留言 / 我的消息 / 后台会话共用） ---------- */
.thread-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.bubble-row { display: flex; }
.bubble-row.r { justify-content: flex-end; }
.bubble-row.c { justify-content: center; }
.bubble {
  max-width: 76%;
  font-size: 13.5px;
  line-height: 1.65;
  padding: 9px 13px;
  border-radius: 13px;
  word-break: break-word;
}
.bubble .b-time { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
.b-me { background: var(--card); border: 1px solid var(--input-border); color: var(--ink-2); border-top-left-radius: 4px; }
.b-adm { background: #FBF3E7; border: 1px solid #EBD9BC; color: var(--ink-2); border-top-right-radius: 4px; }
.b-sys { background: #F1EDE3; color: #7C6F58; font-size: 12.5px; border-radius: 10px; max-width: 92%; }
.bubble .b-unread { display: inline-block; margin-right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }

/* ---------- 通用小字 ---------- */
.tiny-tip { font-size: 12px; color: var(--muted); line-height: 1.7; }
