/* ==========================================================================
   校园墙 · 公共样式
   --------------------------------------------------------------------------
   只放两类东西：1) 设计变量与基础重置  2) 前台和后台都要用的通用组件
   前台专属样式在文件后半段，后台专属样式在 css/admin.css
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --ink: #17171c;
  --ink-soft: #4a4a52;
  --muted: #7b7b84;
  --line: #e7e7e4;
  --line-strong: #dcdcd8;
  --accent: #17171c;
  --accent-ink: #ffffff;
  --rose: #b4455f;
  --ok: #3f7a5e;
  --danger: #b4455f;
  --warn: #a06a2c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 22, 30, .04), 0 12px 28px -16px rgba(22, 22, 30, .18);
  --shadow-lift: 0 1px 2px rgba(22, 22, 30, .05), 0 18px 34px -18px rgba(22, 22, 30, .26);
}

/* 深色主题：给 <html> 加 data-theme="dark" 即可切换 */
html[data-theme="dark"] {
  --bg: #0c0c0f;
  --surface: #15151a;
  --surface-2: #1a1a20;
  --ink: #f1f1f4;
  --ink-soft: #c6c6cd;
  --muted: #93939e;
  --line: #26262e;
  --line-strong: #34343e;
  --accent: #f1f1f4;
  --accent-ink: #0c0c0f;
  --rose: #e0798f;
  --ok: #6fbf94;
  --danger: #e0798f;
  --warn: #d9a86a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 14px 30px -18px rgba(0, 0, 0, .9);
  --shadow-lift: 0 1px 2px rgba(0, 0, 0, .5), 0 20px 38px -20px rgba(0, 0, 0, 1);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
.wrap { max-width: 660px; margin: 0 auto; padding: 0 18px; }
.wrap-wide { max-width: 780px; margin: 0 auto; padding: 0 18px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .22s ease, border-color .22s ease, transform .22s ease;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
}
.btn:hover { border-color: var(--line-strong); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover { opacity: .86; }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.btn.ok:hover { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
  transition: border-color .18s, transform .18s, color .18s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn:active { transform: scale(.93); }

/* ---------- 输入 ---------- */
input, textarea, select { font-family: inherit; color: var(--ink); }
input:focus, textarea:focus { outline: none; }
input[type=password], input[type=text], .text-input {
  width: 100%; font-size: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 13px;
  transition: border-color .18s;
}
input[type=password]:focus, input[type=text]:focus, .text-input:focus { border-color: var(--line-strong); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .bar { height: 60px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 600;
}
.brand b { font-size: 15.5px; font-weight: 600; letter-spacing: .02em; display: block; line-height: 1.2; }
.brand span { font-size: 9.5px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; display: block; }
.spacer { flex: 1; }

/* ---------- 分类标签 ---------- */
.tag {
  font-size: 11.5px; letter-spacing: .04em;
  padding: 3px 10px; border-radius: 999px; flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--tc) 34%, transparent);
  background: color-mix(in srgb, var(--tc) 10%, transparent);
  color: var(--tc);
}
.t-shudong { --tc: #7d78a8; }
.t-biaobai  { --tc: #b4455f; }
.t-tucao    { --tc: #a06a2c; }
.t-qiuzhu   { --tc: #3e6f9e; }
.t-xianzhi  { --tc: #3f7a5e; }

/* ---------- 审核状态 ---------- */
.badge {
  font-size: 11px; letter-spacing: .04em; padding: 2px 9px;
  border-radius: 999px; flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--warn);
}
.badge.pin {
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--ink-soft);
}
.badge.official {
  border-color: color-mix(in srgb, #3e6f9e 34%, transparent);
  background: color-mix(in srgb, #3e6f9e 10%, transparent);
  color: #3e6f9e;
}
html[data-theme="dark"] .badge.official { color: #8ab4e0; }
.post.is-pinned { border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.sec-title {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin: 24px 0 10px;
}

/* ---------- 空状态 / 提示 ---------- */
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty .ico { font-size: 26px; opacity: .45; margin-bottom: 10px; }
.empty p { font-size: 13.5px; }

.banner {
  display: none;
  font-size: 13px; line-height: 1.7;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 13px;
  margin-bottom: 14px;
}
.banner.show { display: block; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px;
  transform: translate(-50%, 12px);
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; padding: 9px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity .24s, transform .24s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 「有新帖」浮标 ---------- */
.newpill {
  position: fixed; left: 50%; bottom: 74px; z-index: 45;
  transform: translate(-50%, 14px) scale(.96);
  background: var(--accent); color: var(--accent-ink);
  border: none; font: inherit; font-size: 13px;
  padding: 9px 20px; border-radius: 999px;
  box-shadow: var(--shadow-lift);
  cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity .24s, transform .24s;
}
.newpill.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.newpill:active { transform: translate(-50%, 0) scale(.96); }

/* ---------- 页脚 ---------- */
footer {
  text-align: center; color: var(--muted);
  font-size: 11.5px; letter-spacing: .1em;
  padding: 34px 0 44px;
}
footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
footer a:hover { color: var(--ink); }

/* ==========================================================================
   以下是前台专属
   ========================================================================== */

.masthead { padding: 34px 0 22px; }
.masthead h1 { font-size: 27px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.masthead p { color: var(--muted); font-size: 13.5px; margin-top: 7px; }
.rule { height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); margin-top: 20px; }

/* 发布框 */
.composer { padding: 16px 16px 12px; margin-bottom: 16px; }
.composer:focus-within { border-color: var(--line-strong); box-shadow: var(--shadow-lift); }
.composer textarea {
  width: 100%; border: none; background: transparent; resize: none;
  font-size: 15.5px; line-height: 1.75; min-height: 84px;
}
.composer .bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.picker { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pick {
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); font: inherit; font-size: 12.5px;
  padding: 4px 11px; border-radius: 999px; cursor: pointer;
  transition: all .18s ease;
}
.pick:hover { color: var(--ink-soft); border-color: var(--line-strong); }
.pick.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.composer input.nick {
  border: none; background: transparent;
  font-size: 13px; width: 118px; padding: 5px 2px;
  border-bottom: 1px dashed var(--line-strong);
}
.composer input.nick:focus { border-bottom-style: solid; border-bottom-color: var(--ink-soft); }
#count, .counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-primary {
  border: none; background: var(--accent); color: var(--accent-ink);
  font: inherit; font-size: 14px; font-weight: 500; letter-spacing: .04em;
  padding: 9px 22px; border-radius: 10px; cursor: pointer;
  transition: opacity .18s, transform .18s;
}
.btn-primary:hover { opacity: .86; }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

/* 搜索 + 排序 */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.searchbox { position: relative; flex: 1; }
.searchbox input {
  width: 100%; font-size: 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px 9px 34px;
  transition: border-color .18s;
}
.searchbox input:focus { border-color: var(--line-strong); }
.searchbox::before {
  content: "⌕"; position: absolute; left: 13px; top: 50%;
  transform: translateY(-52%); color: var(--muted); font-size: 15px;
}
.segmented {
  display: flex; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--surface);
}
.segmented button {
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; padding: 9px 14px; cursor: pointer;
  transition: all .18s;
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--surface-2); color: var(--ink); font-weight: 500; }

/* 分类筛选 */
.filters { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip {
  flex-shrink: 0; font: inherit; font-size: 13px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  transition: all .18s;
}
.filters .chip:hover { color: var(--ink-soft); border-color: var(--line-strong); }
.filters .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* 帖子 */
.feed { display: flex; flex-direction: column; gap: 12px; padding-bottom: 10px; }
.post { padding: 16px 16px 10px; animation: rise .34s cubic-bezier(.22,.8,.3,1) both; }
.post:hover { box-shadow: var(--shadow-lift); }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.post .head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-soft);
}
.meta { display: flex; flex-direction: column; min-width: 0; }
.meta .who { font-size: 13.5px; font-weight: 500; letter-spacing: .01em; }
.meta .time { font-size: 11.5px; color: var(--muted); }
.post .head .tag { margin-left: auto; }
.post .content { font-size: 15.5px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }

.post .actions {
  display: flex; align-items: center; gap: 4px;
  margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--line);
}
.act {
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  transition: background .18s, color .18s, transform .18s;
}
.act:hover { background: var(--surface-2); color: var(--ink); }
.act:active { transform: scale(.95); }
.act.liked { color: var(--rose); }
.act .num { font-variant-numeric: tabular-nums; }
.act.pop { animation: pop .42s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 45% { transform: scale(1.22); } }

/* 评论 */
.comments { margin-top: 4px; padding-top: 4px; }
.comments[hidden] { display: none; }
.clist { display: flex; flex-direction: column; }
.citem { padding: 9px 2px; border-bottom: 1px solid var(--line); animation: rise .28s ease both; }
.citem:last-child { border-bottom: none; }
.citem .cline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.citem .cname { font-size: 13px; font-weight: 500; color: var(--ink-soft); flex-shrink: 0; }
.citem .ctime { font-size: 11px; color: var(--muted); margin-left: auto; flex-shrink: 0; }
.citem .ctext { font-size: 14px; line-height: 1.72; margin-top: 2px; word-break: break-word; }
.cform { display: flex; gap: 8px; margin-top: 10px; }
.cform input {
  flex: 1; font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px;
  transition: border-color .18s;
}
.cform input:focus { border-color: var(--line-strong); }
.cform button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  font: inherit; font-size: 13px; padding: 8px 16px; border-radius: 9px; cursor: pointer;
  transition: all .18s;
}
.cform button:hover { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.cform button:disabled { opacity: .45; cursor: not-allowed; }
.nocomment { font-size: 13px; color: var(--muted); padding: 8px 2px 2px; }

/* 我的待审内容 */
.post.pending { border-style: dashed; }
.pending-note { margin-top: 10px; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.pending-note b { color: var(--warn); font-weight: 500; }

@media (max-width: 480px) {
  .masthead h1 { font-size: 23px; }
  .composer input.nick { width: 96px; }
  .toolbar { flex-wrap: wrap; }
}
