:root {
  --navy: #0f172a;
  --navy-2: #162238;
  --slate-800: #1e293b;
  --slate-600: #475569;
  --slate-500: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --gold: #c89b3c;
  --gold-light: #f3d278;
  --gold-dark: #9c721b;
  --jade: #10b981;
  --danger: #dc2626;
  --radius: 14px;
  --shadow-sm: 0 3px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 14px 36px rgba(15, 23, 42, 0.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--navy);
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.container { width: min(1180px, calc(100% - 28px)); margin-inline: auto; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  transition: transform 0.14s ease, background-color 0.14s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.sm { padding: 6px 13px; font-size: 0.85rem; }
.btn.xs { padding: 4px 10px; font-size: 0.78rem; border-radius: 7px; }
.btn.full { width: 100%; }
.btn-gold { background: linear-gradient(135deg, #f3d278, #c89b3c); color: #140e04; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--slate-800); }
.btn-outline-light { background: rgba(255, 255, 255, 0.08); color: #f8fafc; border-color: rgba(255, 255, 255, 0.25); }
.btn-outline-dark { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-outline-dark:hover { background: #f8fafc; border-color: var(--navy); }
.btn-danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #dc2626; color: #fff; }

/* Header */
.bbs-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.bbs-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
}
.brand-logo { display: inline-flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.02rem; color: #fff; }
.brand-text small { font-size: 0.72rem; color: var(--gold-light); }

.bbs-top-links { display: flex; align-items: center; gap: 18px; }
.bbs-top-links a { font-size: 0.9rem; font-weight: 600; color: #cbd5e1; }
.bbs-top-links a:hover { color: var(--gold-light); }
.bbs-nav-actions { display: flex; align-items: center; gap: 8px; }
.btn-admin-unlocked {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: rgba(16, 185, 129, 0.55) !important;
  color: #6ee7b7 !important;
}

/* Main Layout */
.bbs-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 22px;
  padding: 26px 0 60px;
  align-items: start;
}

.side-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.side-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.side-card-head h2 { font-size: 1rem; color: var(--navy); }
.side-total {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--gold-dark);
  background: #fef6df;
  padding: 2px 8px;
  border-radius: 999px;
}

.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--slate-800);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.cat-btn em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--slate-500);
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 999px;
}
.cat-btn:hover { background: #f8fafc; }
.cat-btn.active {
  background: var(--navy);
  color: var(--gold-light);
}
.cat-btn.active em {
  background: rgba(243, 210, 120, 0.2);
  color: var(--gold-light);
}

.side-notice h3 { font-size: 0.96rem; margin-bottom: 8px; }
.side-notice ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--slate-600);
  margin-bottom: 14px;
}
.side-notice a:not(.btn) { color: var(--gold-dark); font-weight: 700; text-decoration: underline; }
.side-quick-links { display: flex; flex-direction: column; gap: 8px; }

/* Toolbar */
.toolbar-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.search-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.search-wrap input {
  flex: 1;
  padding: 9px 13px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  font-size: 0.92rem;
  font-family: inherit;
}
.search-wrap input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.sort-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sort-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sort-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--slate-600);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.sort-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.feed-meta { font-size: 0.82rem; color: var(--slate-500); font-weight: 600; }

/* Post Cards */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.post-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.post-card.pinned { border-color: rgba(200, 155, 60, 0.55); background: #fffdf7; }

.post-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 7px; }
.badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
}
.badge-pin { background: #fef3c7; color: #92400e; }
.badge-cat { background: #e2e8f0; color: var(--navy); }
.badge-official { background: var(--navy); color: var(--gold-light); }
.badge-solved { background: #d1fae5; color: #065f46; }

.post-title { font-size: 1.08rem; font-weight: 800; color: var(--navy); margin-bottom: 6px; }
.post-excerpt { font-size: 0.9rem; color: var(--slate-600); margin-bottom: 10px; line-height: 1.55; }
.post-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--slate-500);
}
.post-stats { display: flex; gap: 14px; font-weight: 700; color: var(--slate-600); }

.list-empty {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--slate-500);
  font-weight: 600;
}
.load-more-wrap { text-align: center; margin-top: 16px; }

/* Post Detail View */
.detail-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.admin-post-tools { display: flex; flex-wrap: wrap; gap: 6px; }

.detail-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.detail-title { font-size: 1.38rem; font-weight: 900; margin-bottom: 10px; color: var(--navy); }
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  font-size: 0.85rem;
  color: var(--slate-500);
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.detail-body {
  font-size: 0.98rem;
  color: var(--slate-800);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  margin-bottom: 18px;
}
.detail-actions { display: flex; align-items: center; gap: 10px; }

/* Replies */
.replies-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
.replies-card h3 { font-size: 1.05rem; margin-bottom: 14px; }
.replies-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.reply-item {
  padding: 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--slate-500);
  margin-bottom: 6px;
}
.reply-author-wrap { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--navy); }
.reply-body { font-size: 0.93rem; color: var(--slate-800); white-space: pre-wrap; word-break: break-word; }

.reply-form {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.reply-form h4 { font-size: 0.96rem; margin-bottom: 10px; }
.form-grid-reply { display: grid; grid-template-columns: 220px 1fr; gap: 12px; margin-bottom: 10px; }
.reply-form label, .form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--slate-600);
  margin-bottom: 4px;
}
.reply-form input, .reply-form textarea,
.dialog-form input, .dialog-form select, .dialog-form textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-size: 0.92rem;
  font-family: inherit;
}
.reply-form input:focus, .reply-form textarea:focus,
.dialog-form input:focus, .dialog-form select:focus, .dialog-form textarea:focus {
  outline: 2px solid var(--gold);
  border-color: var(--gold);
}
.reply-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Dialogs */
dialog.modal-dialog {
  margin: auto;
  width: min(640px, calc(100vw - 24px));
  max-height: 92dvh;
  border-radius: 16px;
  border: 1px solid rgba(200, 155, 60, 0.45);
  padding: 0;
  box-shadow: var(--shadow-md);
  background: #fff;
  color: var(--navy);
}
dialog.modal-sm { width: min(460px, calc(100vw - 24px)); }
dialog.modal-dialog::backdrop { background: rgba(15, 23, 42, 0.72); backdrop-filter: blur(4px); }
dialog.modal-dialog[open] { display: flex; flex-direction: column; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { font-size: 1.12rem; }
.dialog-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}
.dialog-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; }
.dialog-btns { display: flex; gap: 8px; margin-left: auto; }
.adm-note { font-size: 0.88rem; color: var(--slate-600); }
.form-msg { font-size: 0.85rem; font-weight: 700; }
.form-msg.ok { color: #059669; }
.form-msg.err { color: var(--danger); }

@media (max-width: 900px) {
  .bbs-shell { grid-template-columns: 1fr; }
  .bbs-top-links { display: none; }
}
@media (max-width: 640px) {
  .form-row-2, .form-grid-reply { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
}
