:root {
  color-scheme: light;
  --bg: #e8e2d8;
  --paper: #fffdf8;
  --ink: #1d1a16;
  --muted: #6f675e;
  --line: #e3dacd;
  --brand: #1a3330;
  --brand-2: #24574c;
  --accent: #b85c38;
  --danger: #8d2f2f;
  --ok: #1f6a52;
  --shadow: 0 10px 30px rgba(48, 36, 22, 0.06);
  --serif: Palatino, "Palatino Linotype", "Songti SC", "Noto Serif SC", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(184, 92, 56, 0.08), transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--brand);
  color: #f6f1e8;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: max-content; }
.mark {
  width: 34px;
  height: 34px;
  display: block;
  flex: none;
  border-radius: 9px;
}
.brand-name { font-family: var(--serif); font-size: 22px; letter-spacing: 0.04em; }
.nav-toggle { display: none; background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 6px 10px; }
.search { flex: 1; display: flex; }
.search input, .field input, .field textarea, .field select, .composer textarea, .composer input, .reply-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
}
.search input { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.search input::placeholder { color: rgba(255,255,255,.7); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top a, .ghost {
  color: #f6f1e8;
  background: transparent;
  border: 0;
  padding: 6px 8px;
}
.badge-count {
  display: inline-block;
  min-width: 16px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.page {
  width: min(1120px, calc(100% - 28px));
  margin: 22px auto 48px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
}
.side, .card, .topic-row, .post, .comment, .auth, .admin-panel {
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--shadow);
}
.side { border-radius: 16px; padding: 14px; align-self: start; position: sticky; top: 76px; }
.side h2 { margin: 4px 8px 10px; font-size: 13px; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.side a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
}
.side a.active, .side a:hover { background: #f3ece3; }
.count { color: var(--muted); font-size: 12px; }
.desc { color: var(--muted); font-size: 13px; line-height: 1.5; padding: 8px; }

.main { min-width: 0; display: grid; gap: 14px; align-self: start; align-content: start; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: 0.01em; }
h1 { font-size: 32px; margin: 0; }
.announce {
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  background: #fff7ef;
  border-radius: 10px;
}

.topic-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; padding: 14px; border-radius: 16px; }
.topic-row:hover { outline: 1px solid #eadfD2; }
.topic-row h3 { margin: 0 0 6px; font-size: 18px; }
.meta, .muted { color: var(--muted); font-size: 13px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stats { text-align: right; color: var(--muted); font-size: 13px; white-space: nowrap; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 1px 8px;
  background: #f3ece3;
  color: var(--brand);
  font-size: 12px;
}
.pill.warn { background: #f8e7df; color: var(--accent); }
.title-badge { font-size: 12px; font-weight: 650; }

.avatar, .avatar.ph {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: #efe4d6;
  color: var(--brand);
  font-family: var(--serif);
  overflow: hidden;
}
.avatar.sm, .avatar.sm.ph { width: 32px; height: 32px; font-size: 14px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }

.card, .post, .comment, .auth, .admin-panel { border-radius: 16px; padding: 16px; }
.post-head, .comment-head, .profile-head { display: flex; gap: 12px; align-items: center; }
.who { display: grid; gap: 2px; }
.who strong { font-size: 15px; }
.rich p { margin: 0 0 8px; line-height: 1.7; white-space: pre-wrap; }
.rich .gap { height: 8px; }
.inline-img { border-radius: 12px; margin: 6px 0; max-height: 420px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn, .btn-primary, .btn-danger, .btn-ghost {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
}
.btn-primary { background: var(--brand); color: #f6f1e8; border-color: var(--brand); }
.btn-danger { color: var(--danger); border-color: #efd0d0; background: #fff7f7; }
.btn-ghost { background: transparent; }
.btn.on { background: #e7f3ee; border-color: #b7d8cc; color: var(--ok); }
.btn:disabled { opacity: 0.6; cursor: default; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
.auth { width: min(460px, 100%); margin: 10px auto; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; margin: 8px 0 14px; }
.composer, .modal-back {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 20, 0.45);
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 18px;
}
.composer form, .modal-back .sheet {
  width: min(720px, 100%);
  background: var(--paper);
  border-radius: 18px;
  padding: 18px;
  max-height: min(88vh, 820px);
  overflow: auto;
}
.reply-box textarea { min-height: 90px; }
.comment + .comment { margin-top: 10px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.empty, .loading, .error { padding: 28px 8px; color: var(--muted); text-align: center; }
.profile-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; }
.stack { display: grid; gap: 10px; align-content: start; }
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; align-self: start; }
.admin-nav a { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; background: #f3ece3; font-size: 14px; line-height: 20px; }
.admin-nav a.active { background: var(--brand); color: #f6f1e8; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.thread { display: grid; gap: 8px; }
.bubble { max-width: min(70%, 520px); padding: 10px 12px; border-radius: 14px; background: #f3ece3; }
.bubble.mine { margin-left: auto; background: #e5f0ea; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--brand); color: white; padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); }
.toast.bad { background: var(--danger); }
.help { color: var(--muted); font-size: 13px; line-height: 1.6; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .page { grid-template-columns: 1fr; }
  .side { display: none; position: static; }
  .side.open { display: block; }
  .search { display: none; }
  .profile-grid { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .topic-row { grid-template-columns: 36px minmax(0, 1fr); }
  .stats { display: none; }
}
