:root {
  --bg: #f3efe6;
  --paper: #fffdf8;
  --ink: #1c1915;
  --muted: #6d645b;
  --line: #e3d9cc;
  --accent: #0f6e56;
  --accent-dark: #0b5342;
  --danger: #9d2c2c;
  --warn: #8a5a12;
  --shadow: 0 16px 40px rgba(58, 42, 24, 0.06);
  --sans: "Avenir Next", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", Palatino, "Songti SC", "Noto Serif SC", serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; }
a { color: var(--accent-dark); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
.topbar, .footer, .side { background: var(--paper); }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 20px; color: var(--ink); text-decoration: none; }
.brand-logo { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; }
.nav, .side nav { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.nav a, .side a { text-decoration: none; color: var(--ink); }
.nav a:hover, .side a:hover { color: var(--accent); }
.wrap { width: min(1080px, calc(100% - 32px)); margin: 28px auto 48px; }
.wrap.narrow { width: min(640px, calc(100% - 32px)); }
.hero { padding: 28px 0 8px; }
.eyebrow { margin: 0 0 8px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); font-size: 13px; }
.lead { color: var(--muted); font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.card, .grid article, .table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.grid article, .card { padding: 20px; }
.actions, .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.me-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-top: 16px; }
.me-groups h2 { margin: 0 0 10px; font-family: var(--sans); font-size: 13px; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.me-groups section { padding-top: 12px; border-top: 1px solid var(--line); }
.btn, button, .btn-link { appearance: none; border: 0; border-radius: 999px; background: var(--accent); color: white; padding: 10px 18px; min-height: 44px; font: inherit; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger, button.danger { background: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
label { display: block; margin: 14px 0 6px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="tel"], input[type="search"], input[type="number"], textarea, select { width: 100%; border: 1px solid var(--line); background: white; border-radius: 12px; padding: 12px 14px; font: inherit; }
textarea { min-height: 120px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; }
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.alert.ok { background: #e7f6f1; color: var(--accent-dark); }
.alert.bad { background: #fdecec; color: var(--danger); }
.alert.warn { background: #fff6e8; color: var(--warn); }
.hint { color: var(--muted); font-size: 14px; }
.footer { border-top: 1px solid var(--line); padding: 22px; color: var(--muted); font-size: 14px; }
.footer p { margin: 4px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 14px; }
.table-wrap { overflow: auto; }
.pager { margin-top: 16px; }
.pagination { display: flex; gap: 8px; list-style: none; padding: 0; }
.pagination li a, .pagination li span { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: white; }
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { padding: 18px 14px; border-right: 1px solid var(--line); }
.side .group { margin: 16px 0 6px; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.side a { display: block; padding: 8px 10px; border-radius: 10px; }
.side a:hover { background: #f6f1e8; }
.main { padding: 22px; }
.inline { display: inline; }
.depth-1 { padding-left: 18px; }
.depth-2 { padding-left: 36px; }
.feed { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 16px; }
.feed article { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
.cover { width: 100%; height: 180px; object-fit: cover; border-radius: 12px; background: #efe8dc; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chips a { text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 44px; display: inline-flex; align-items: center; }
.chips a.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.searchbar, .nav-search { display: flex; gap: 8px; align-items: center; }
.searchbar input, .nav-search input { min-height: 44px; }
.searchbar input { flex: 1; width: auto; min-width: 0; }
button.btn-rect { flex: 0 0 auto; width: auto; min-width: 88px; height: 44px; padding: 0 22px; border-radius: 12px; white-space: nowrap; }
.nav-search input { width: 180px; }
.article-body { white-space: pre-wrap; word-break: break-word; }
.paywall { margin-top: 16px; padding: 16px; border-radius: 16px; background: #fff6e8; border: 1px solid #f0d7b0; }
.comment { border-top: 1px solid var(--line); padding: 12px 0; }
.author-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
@media (max-width: 800px) {
  .grid, .shell, .feed, .me-groups { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav-search, .searchbar { width: 100%; }
  .nav-search input, .searchbar input { flex: 1; width: auto; }
}
.markdown-body { word-break: break-word; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 1em 0 0.4em; }
.markdown-body p { margin: 0.7em 0; }
.markdown-body ul, .markdown-body ol { margin: 0.4em 0; padding-left: 1.4em; }
.markdown-body blockquote { margin: 0.8em 0; padding: 0 0 0 14px; border-left: 3px solid var(--line); color: var(--muted); }
.markdown-body img { max-width: 100%; border-radius: 12px; }
.markdown-body a { text-underline-offset: 2px; }
.markdown-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.markdown-body p code, .markdown-body li code, .markdown-body td code { background: #f6f1e8; padding: 0 4px; border-radius: 6px; }
.markdown-body pre { overflow: auto; background: #f6f1e8; border-radius: 12px; padding: 12px 14px; white-space: pre; }
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.markdown-body table { margin: 0.8em 0; }
.md-editor { border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.md-editor:focus-within { border-color: var(--accent); }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); background: #fbf8f2; }
.md-toolbar button { min-height: 36px; padding: 6px 10px; border-radius: 8px; background: white; color: var(--ink); border: 1px solid var(--line); font-size: 14px; }
.md-toolbar button[aria-pressed="true"] { background: var(--accent); color: white; border-color: var(--accent); }
.md-stage textarea { border: 0; border-radius: 0; min-height: 320px; }
.md-preview { display: none; min-height: 320px; padding: 12px 14px; overflow: auto; }
.md-editor.is-preview .md-stage { display: grid; grid-template-columns: 1fr 1fr; }
.md-editor.is-preview .md-preview { display: block; border-left: 1px solid var(--line); }
@media (max-width: 800px) {
  .md-editor.is-preview .md-stage { grid-template-columns: 1fr; }
  .md-editor.is-preview .md-preview { border-left: 0; border-top: 1px solid var(--line); }
}
