/* ============================================================
   社区功能样式
   配色跟主站 PaperMod 对齐，支持明暗两套。
   主题由 <html data-theme="light|dark"> 控制（和主站同一个 localStorage 键）。
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f8;
  --text: #1d1e20;
  --text-soft: #6b7280;
  --border: #e5e7eb;
  --accent: #3b6ef5;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --radius: 8px;
}

html[data-theme='dark'] {
  --bg: #1d1e20;
  --bg-soft: #26282c;
  --text: #dadadb;
  --text-soft: #9aa0a6;
  --border: #34363b;
  --accent: #5b8cff;
  --accent-text: #0b0c0e;
  --danger: #f87171;
}

* { box-sizing: border-box; }

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

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--text-soft); font-size: 14px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}
.brand { color: var(--text); text-decoration: none; font-weight: 600; }
.nav { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.nav a { color: var(--text-soft); text-decoration: none; }
.nav a:hover { color: var(--accent); }
.nav .who { color: var(--text-soft); }
.nav .who b { color: var(--text); font-weight: 600; }

/* ---------- 按钮 ---------- */
button, .btn {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary {
  background: var(--accent); color: var(--accent-text);
  border-color: var(--accent); font-weight: 600;
}
button.primary:hover { opacity: .9; color: var(--accent-text); }
button.link {
  border: 0; background: none; color: var(--text-soft);
  padding: 2px 4px; font-size: 13px;
}
button.link:hover { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
label { display: block; margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=password], input[type=tel], textarea {
  width: 100%; font: inherit; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 200px; line-height: 1.6; }
.hint { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* ---------- 提示条 ---------- */
.alert {
  padding: 10px 14px; border-radius: var(--radius); font-size: 14px;
  margin: 16px 0; border: 1px solid transparent;
}
.alert.error { background: rgba(220,38,38,.1); border-color: rgba(220,38,38,.35); color: var(--danger); }
.alert.ok    { background: rgba(22,163,74,.1); border-color: rgba(22,163,74,.35); color: #16a34a; }

/* ---------- 文章列表 ---------- */
.post-item { padding: 20px 0; border-bottom: 1px solid var(--border); }
.post-item h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.4; }
.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { color: var(--accent); }
.post-meta { font-size: 13px; color: var(--text-soft); }
.post-summary { margin: 8px 0 0; color: var(--text-soft); font-size: 15px; }

/* ---------- 文章正文 ---------- */
.article-title { margin: 28px 0 8px; font-size: 28px; line-height: 1.3; }
.prose { margin-top: 24px; }
.prose h1, .prose h2, .prose h3 { line-height: 1.35; margin: 28px 0 12px; }
.prose p { margin: 14px 0; }
.prose a { color: var(--accent); }
.prose code {
  background: var(--bg-soft); padding: 2px 6px; border-radius: 4px;
  font-size: 90%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.prose pre {
  background: var(--bg-soft); padding: 14px; border-radius: var(--radius);
  overflow-x: auto; border: 1px solid var(--border);
}
.prose pre code { background: none; padding: 0; }
.prose blockquote {
  margin: 16px 0; padding: 4px 16px; border-left: 3px solid var(--border);
  color: var(--text-soft);
}
.prose img { max-width: 100%; }
.prose table { border-collapse: collapse; width: 100%; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; }

/* ---------- 评论 ---------- */
.comments { margin-top: 12px; }
.comment {
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.comment-head { font-size: 13px; color: var(--text-soft); display: flex; gap: 10px; align-items: baseline; }
.comment-head b { color: var(--text); font-size: 14px; }
.comment-body { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.comment-children { margin-left: 20px; padding-left: 14px; border-left: 2px solid var(--border); }
.reply-box { margin-top: 10px; }
.reply-box textarea { min-height: 70px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 28px 0; }

/* ---------- 页脚 ---------- */
.footer { margin: 40px auto 32px; text-align: center; }

/* ---------- 通用：标题 / 链接 / 高亮 ---------- */
.page-title { margin: 28px 0 4px; font-size: 24px; line-height: 1.35; }
.ulink { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--border); }
.ulink:hover { color: var(--accent); border-bottom-color: var(--accent); }
mark { background: rgba(250, 204, 21, .35); color: inherit; padding: 0 2px; border-radius: 3px; }
html[data-theme='dark'] mark { background: rgba(250, 204, 21, .25); }
.bio { margin: 10px 0 0; color: var(--text); white-space: pre-wrap; }

/* ---------- 搜索框 ---------- */
.search { display: inline-flex; align-items: center; gap: 6px; }
.search-input {
  width: 200px !important; padding: 6px 10px !important; font-size: 14px !important;
}

/* ---------- 表单里的标签行 ---------- */
.label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 0 6px; gap: 12px; flex-wrap: wrap;
}
.row-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- 管理后台 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 16px; }
.tab {
  padding: 8px 14px; font-size: 14px; text-decoration: none; color: var(--text-soft);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--accent); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.stats-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.stat-extra { font-size: 12px; color: var(--text-soft); margin-top: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 12px; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.table th { color: var(--text-soft); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }

.admin-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.admin-row > div:first-child { min-width: 0; flex: 1; }
.admin-row .comment-body { margin: 0 0 4px; }

/* ---------- 门禁页 ---------- */
.gate {
  max-width: 380px; margin: 12vh auto 0; text-align: center;
  padding: 32px 24px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg-soft);
}
.gate-title { font-size: 22px; margin: 0 0 6px; }
.gate-input {
  text-align: center; font-size: 20px !important; letter-spacing: 4px;
  padding: 12px !important; margin-top: 14px;
}
.gate-btn { width: 100%; padding: 11px !important; font-size: 15px !important; }
.gate .row { justify-content: center; margin-top: 14px; }
.gate-admin {
  margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border);
  display: flex; flex-direction: column; gap: 4px; font-size: 13px;
}

/* ---------- 顶栏里的空间标识 ---------- */
.nav-site { display: inline-flex; align-items: center; gap: 6px; }
.site-badge {
  font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
}
.site-badge.admin { background: var(--border); color: var(--text); }
.back-blog { font-size: 13px; }

/* ---------- 空间选择 / 状态标签 / 小按钮 ---------- */
.site-select {
  width: 100%; font: inherit; padding: 9px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tag {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--text-soft);
}
.tag-pending  { background: rgba(250,204,21,.18); border-color: rgba(250,204,21,.5); color: #a16207; }
.tag-approved { background: rgba(22,163,74,.14);  border-color: rgba(22,163,74,.45); color: #15803d; }
.tag-rejected { background: rgba(220,38,38,.12);  border-color: rgba(220,38,38,.4);  color: var(--danger); }
html[data-theme='dark'] .tag-pending { color: #facc15; }
button.mini { padding: 3px 9px; font-size: 12px; margin-right: 4px; }
button.mini.primary { font-weight: 600; }
td.ops { white-space: nowrap; }
.site-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; background: var(--bg-soft);
}
@media (max-width: 600px) {
  .topbar-inner { height: auto; padding: 10px 20px; flex-wrap: wrap; gap: 8px; }
  .article-title { font-size: 22px; }
  .comment-children { margin-left: 8px; padding-left: 10px; }
  .search-input { width: 130px !important; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 6px; }
}
