:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #191d24;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #3b6cf6;
  --accent-soft: #eef2ff;
  --danger: #e5484d;
  --ok: #12a150;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { padding-top: 22px; padding-bottom: 56px; }
.main.wide { max-width: 1080px; }

/* ---------------------------------------------------------- 顶栏 */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.head-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.2px; flex: none; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4f7cff, #7c5cff); color: #fff;
  font-size: 13px; font-weight: 800; letter-spacing: .5px;
}
.brand-text { font-size: 16px; }
.nav { display: flex; gap: 4px; flex: none; }
.navlink {
  padding: 7px 12px; border-radius: 9px; color: var(--muted); font-size: 14px;
  transition: background .15s, color .15s;
}
.navlink:hover { background: #f0f1f4; color: var(--text); }
.navlink.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.searchbar { margin-left: auto; flex: 1; max-width: 300px; }
.searchbar input {
  width: 100%; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fafbfc; font-size: 14px; outline: none;
  transition: border-color .15s, background .15s;
}
.searchbar input:focus { border-color: #b9c6f8; background: #fff; }

.userbox { display: flex; align-items: center; gap: 8px; flex: none; }
.me { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); }
.me:hover { color: var(--text); }
.me .avatar { border-radius: 50%; }

.avatar {
  display: inline-grid; place-items: center; border-radius: 50%;
  color: #fff; font-weight: 700; flex: none; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

/* ---------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  font-family: inherit; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.06); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #f2f3f6; color: var(--text); }
.btn.ghost:hover { background: #e9ebef; color: var(--text); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.inline { display: inline; }
.link-btn {
  background: none; border: 0; padding: 0; cursor: pointer; font: inherit;
  font-size: 12px; color: var(--muted);
}
.link-btn:hover { color: var(--text); text-decoration: underline; }
.link-btn.danger:hover { color: var(--danger); }
.link-btn.ok:hover { color: var(--ok); }

/* ---------------------------------------------------------- 通用 */
.flash {
  margin-bottom: 16px; padding: 11px 15px; border-radius: 11px; font-size: 14px;
  border: 1px solid #c7ecd6; background: #effaf3; color: #14663c;
}
.flash.err { border-color: #ffd6d8; background: #fff0f0; color: #a4232b; }

.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .3px; color: #303540; }
.more { font-size: 13px; color: var(--muted); }
.empty {
  padding: 30px; text-align: center; color: var(--muted); font-size: 14px;
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty.big { padding: 64px 30px; }
.empty.big h1 { margin: 0 0 8px; font-size: 40px; letter-spacing: -1px; }
.empty.big p { margin: 0 0 18px; }
.muted { color: #9aa1ac; }
.hint { color: var(--muted); font-size: 12px; }
.notice {
  padding: 16px; text-align: center; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--muted); font-size: 14px;
}
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; display: flex; gap: 6px; }
.crumb a:hover { color: var(--accent); }

/* ---------------------------------------------------------- 首页 hero */
.hero {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 34px; margin-bottom: 34px; border-radius: 20px;
  background: radial-gradient(1200px 400px at 85% -10%, #e6ecff 0%, transparent 60%), #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero-text { flex: 1 1 420px; }
.hero h1 { margin: 0 0 10px; font-size: 27px; line-height: 1.3; letter-spacing: -.5px; }
.hero p { margin: 0 0 20px; color: var(--muted); font-size: 14.5px; max-width: 620px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 26px; flex: none; }
.hero-stats div { text-align: center; }
.hero-stats b { display: block; font-size: 24px; letter-spacing: -.5px; }
.hero-stats span { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------- 版块卡片 */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cat-card {
  display: grid; gap: 3px; padding: 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d7dbe2; color: inherit; }
.cat-card .cat-name { font-weight: 700; font-size: 14.5px; }
.cat-card .cat-desc { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.cat-card .cat-count { color: #9aa1ac; font-size: 12px; margin-top: 4px; }
.cat-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999);
  display: inline-block; vertical-align: middle; margin-right: 6px;
}
.cat-dot.big { width: 12px; height: 12px; }
.cat-card.large { padding: 20px; }
.cat-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-head h1 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.cat-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.cat-head .btn { margin-left: auto; }

/* ---------------------------------------------------------- 话题列表 */
.topic-list { display: flex; flex-direction: column; gap: 8px; }
.topic-row {
  display: flex; gap: 18px; align-items: flex-start; padding: 15px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .14s, box-shadow .14s;
}
.topic-row:hover { border-color: #d7dbe2; box-shadow: var(--shadow); }
.tr-main { flex: 1; min-width: 0; }
.tr-tags { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; flex-wrap: wrap; }
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 11.5px;
  color: var(--pill); background: color-mix(in srgb, var(--pill) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--pill) 25%, #fff); font-weight: 600;
}
.tag { font-size: 11px; padding: 1px 7px; border-radius: 5px; font-weight: 600; }
.tag.pin { background: #fff1e5; color: #c05621; }
.tag.feat { background: #fff6d6; color: #a1701b; }
.tag.lock { background: #f1f2f4; color: #7b8290; }
.tag.role { background: #eef2ff; color: #3b5bdb; }
.tr-title { display: block; font-size: 15.5px; font-weight: 650; line-height: 1.45; letter-spacing: -.2px; }
.tr-title:hover { color: var(--accent); }
.tr-excerpt {
  margin-top: 4px; color: var(--muted); font-size: 12.8px; line-height: 1.55;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.tr-meta { flex: none; width: 132px; text-align: right; font-size: 12px; color: var(--muted); }
.tr-author { display: flex; align-items: center; justify-content: flex-end; gap: 6px; color: #4a515c; }
.tr-stats { display: flex; gap: 8px; justify-content: flex-end; margin-top: 5px; }
.tr-time { margin-top: 4px; color: #9aa1ac; }
.tr-meta .avatar { border-radius: 50%; }

.sortbar { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.sort {
  padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--muted);
  border: 1px solid transparent;
}
.sort:hover { background: #eff1f5; color: var(--text); }
.sort.current { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pg {
  min-width: 34px; height: 34px; display: grid; place-items: center; padding: 0 8px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--card); font-size: 13px;
}
.pg:hover { border-color: #c6cbd4; }
.pg.current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.pg-dots { padding: 0 4px; color: var(--muted); }

/* ---------------------------------------------------------- 话题页 */
.topic-head { margin-bottom: 16px; }
.topic-head h1 { margin: 6px 0 8px; font-size: 24px; line-height: 1.35; letter-spacing: -.5px; }
.topic-sub { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.floors { display: flex; flex-direction: column; gap: 10px; }
.floor { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.floor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.floor-user { display: flex; align-items: center; gap: 10px; }
.floor-user .avatar { border-radius: 50%; }
.uname { font-weight: 650; font-size: 14px; }
.ftime { display: block; font-size: 11.5px; color: #9aa1ac; }
.floor-no { font-size: 12px; color: #a8afba; font-family: var(--mono); }
.floor-body { font-size: 14.8px; line-height: 1.75; }
.floor-body p { margin: 0 0 10px; }
.floor-body p:last-child { margin-bottom: 0; }
.floor-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.like-btn {
  border: 1px solid var(--line); background: #fafbfc; border-radius: 20px; cursor: pointer;
  padding: 3px 11px; font-size: 12px; color: var(--muted); font-family: inherit;
}
.like-btn:hover { border-color: #f2c1c3; color: var(--danger); background: #fff7f7; }
.like-btn.on { border-color: #f6c9cb; color: var(--danger); background: #fff1f2; font-weight: 600; }
.quote {
  border-left: 3px solid var(--line); padding: 4px 0 4px 10px; margin: 0 0 10px;
  color: var(--muted); font-size: 12.5px;
}
.reply-form { margin-top: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.reply-form textarea, .stack-form textarea, .stack-form input, .stack-form select {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: #fafbfc; font: inherit; font-size: 14px; outline: none; resize: vertical;
  transition: border-color .15s, background .15s;
}
.reply-form textarea:focus, .stack-form textarea:focus, .stack-form input:focus {
  border-color: #b9c6f8; background: #fff;
}
.rf-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; }

/* ---------------------------------------------------------- 表单 */
.form-page h1, .auth-page h1 { font-size: 22px; margin: 0 0 18px; letter-spacing: -.4px; }
.stack-form {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.stack-form.narrow { max-width: 420px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #414852; }
.stack-form label input[type=color] { height: 40px; padding: 4px; }
.stack-form h2 { font-size: 15px; margin: 0 0 4px; }
.auth-page { max-width: 460px; margin: 20px auto; }
.auth-alt { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 14px; }
.auth-alt a { color: var(--accent); font-weight: 600; }
.search-page { display: flex; gap: 10px; margin-bottom: 16px; }
.search-page input {
  flex: 1; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  font: inherit; font-size: 14px; background: #fff; outline: none;
}
.search-info { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* ---------------------------------------------------------- 个人页 / 后台 */
.profile-card {
  display: flex; gap: 22px; align-items: center; padding: 26px; margin-bottom: 26px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
}
.profile-card .avatar { border-radius: 50%; }
.pc-main h1 { margin: 0 0 6px; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.bio { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.pc-stats { display: flex; gap: 20px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pc-stats b { color: var(--text); font-size: 15px; }

.admin-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-stats div {
  flex: 1 1 120px; padding: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; text-align: center;
}
.admin-stats b { display: block; font-size: 20px; }
.admin-stats span { font-size: 12px; color: var(--muted); }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.admin-table th, .admin-table td { padding: 10px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); }
.admin-table th { background: #fafbfc; font-size: 12px; color: var(--muted); font-weight: 600; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table a { display: inline-flex; align-items: center; gap: 6px; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-form { margin-top: 22px; max-width: 460px; }

/* ---------------------------------------------------------- Markdown 正文 */
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.35; letter-spacing: -.3px; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md blockquote {
  margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid #cbd5ff;
  background: #f7f8fc; color: #4a515c; border-radius: 0 8px 8px 0;
}
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md img { max-width: 100%; border-radius: 10px; display: block; margin: 8px 0; }
.md code {
  font-family: var(--mono); font-size: 12.8px; background: #f1f3f6; padding: 1px 6px;
  border-radius: 5px; color: #b1314a;
}
.md pre {
  margin: 0 0 12px; padding: 13px 15px; background: #1d2027; color: #e6e8ee;
  border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: 12.8px; line-height: 1.6;
}
.md pre code { background: none; padding: 0; color: inherit; font-size: 12.8px; }
.md a { color: var(--accent); }
.md a:hover { text-decoration: underline; }

/* ---------------------------------------------------------- 关于页 */
.about { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.about h1 { font-size: 22px; margin: 0 0 12px; }
.about p { color: #414852; font-size: 14px; }
.about ul { color: #414852; font-size: 14px; padding-left: 20px; }

/* ---------------------------------------------------------- 页脚 */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; }
.foot-inner { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 900px) {
  .searchbar { max-width: 180px; }
  .tr-meta { width: 104px; }
}
@media (max-width: 720px) {
  .head-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .searchbar { order: 4; max-width: none; width: 100%; }
  .topic-row { gap: 10px; padding: 13px 14px; }
  .tr-meta { width: auto; text-align: left; display: none; }
  .hero { padding: 24px; }
  .hero h1 { font-size: 21px; }
  .hero-stats { gap: 20px; }
  .profile-card { flex-direction: column; align-items: flex-start; }
  .admin-table { display: block; overflow-x: auto; }
  .floor { padding: 13px 14px; }
  .foot-inner { flex-direction: column; }
}
