:root {
  color-scheme: light;
  --ink: #18241f;
  --muted: #68736e;
  --paper: #fbfaf6;
  --card: #fff;
  --line: #e4e4dc;
  --brand: #176b4d;
  --brand-soft: #e8f3ee;
  --accent: #e99b45;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 20px max(24px, calc((100vw - 980px) / 2));
  color: white;
  background: var(--brand);
}
.brand { color: white; font-size: 1.5rem; font-weight: 800; text-decoration: none; }
.site-header p { margin: 0; opacity: .82; }
.account { display: flex; align-items: center; gap: 12px; }

main { width: min(980px, calc(100% - 32px)); margin: 28px auto 64px; }
.categories { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.category {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
  background: var(--card);
  color: var(--ink);
}
.category.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 24px 0 18px; }
.toolbar h1 { margin: 0 0 5px; font-size: 1.55rem; }
.toolbar p { margin: 0; color: var(--muted); }

.primary, .secondary {
  border-radius: 9px;
  padding: 10px 16px;
  border: 1px solid var(--brand);
}
.primary { color: white; background: var(--brand); }
.secondary { color: var(--brand); background: transparent; }

.post-list { display: grid; gap: 10px; }
.post-card, .post-detail, .reply {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.post-card { padding: 18px 20px; cursor: pointer; transition: transform .15s, border-color .15s; }
.post-card:hover { transform: translateY(-1px); border-color: #aabeb5; }
.post-card h2 { margin: 8px 0; font-size: 1.12rem; }
.post-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: .88rem; }
.badge { color: var(--brand); font-weight: 700; }
.post-detail { padding: 24px; }
.post-detail h1 { margin: 12px 0; }
.post-body { white-space: pre-wrap; line-height: 1.75; margin: 24px 0; }
.image-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.image-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 9px; background: var(--line); }
.image-gallery.compact { grid-template-columns: repeat(3, minmax(0, 160px)); margin-bottom: 0; }
.image-gallery.compact img { aspect-ratio: 16 / 10; }
.back { border: 0; background: none; color: var(--brand); padding: 0; }
.replies { display: grid; gap: 10px; margin-top: 20px; }
.reply { padding: 16px 18px; }
.reply p { white-space: pre-wrap; line-height: 1.6; }
.reply-form { display: grid; gap: 10px; margin-top: 20px; }
.reply-form textarea { width: 100%; }

.notice { margin-bottom: 14px; border-radius: 9px; padding: 11px 14px; background: #fff1d9; color: #79501d; }
.empty, .loading { padding: 64px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.admin-panel { padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.admin-panel h2 { margin-top: 0; }
.feature-rows { display: grid; gap: 10px; margin: 24px 0; }
.feature-row { display: grid; grid-template-columns: 1.2fr 1fr auto auto auto; align-items: center; gap: 10px; }
.inline-check { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; }
.admin-actions { display: flex; justify-content: space-between; gap: 12px; }
.danger { border: 0; background: transparent; color: #a52b2b; padding: 8px; }

dialog { width: min(600px, calc(100% - 24px)); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 70px #13251d44; }
dialog::backdrop { background: #12221b88; }
dialog form { display: grid; gap: 17px; padding: 24px; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; }
.dialog-title h2 { margin: 0; }
.icon-button { border: 0; background: none; font-size: 1.8rem; }
label { display: grid; gap: 7px; font-weight: 650; }
input, textarea, select { border: 1px solid #cbd1cd; border-radius: 8px; padding: 10px 12px; background: white; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #76aa94; border-color: transparent; }

@media (max-width: 680px) {
  .site-header { grid-template-columns: 1fr auto; padding: 16px; }
  .site-header > p { display: none; }
  main { margin-top: 18px; }
  .toolbar { align-items: center; }
  .toolbar p { display: none; }
  .post-detail { padding: 18px; }
  .feature-row { grid-template-columns: 1fr 1fr; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .image-gallery, .image-gallery.compact { grid-template-columns: repeat(2, 1fr); }
}
