:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e5e2da;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e5f1ed;
  --warn: #a15c07;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --ok-soft: #e7f5ec;
  --ok: #17663a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --surface: #1d2024; --text: #e6e6e3; --muted: #9aa0a6; --line: #2e3237;
    --accent: #4fb596; --accent-ink: #0d1512; --accent-soft: #1e332c;
    --warn: #f0b35a; --warn-soft: #33281a; --danger: #f97066; --ok-soft: #17301f; --ok: #6fd39a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; }
h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
body.admin .wrap { max-width: 1180px; }
.main { padding-top: 24px; padding-bottom: 40px; min-height: calc(100vh - 140px); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .right { text-align: right; }
.nowrap { white-space: nowrap; } .pre-wrap { white-space: pre-wrap; word-break: break-word; }
.mt { margin-top: 20px; } .big { font-size: 1.2rem; font-weight: 600; }
.warn-text { color: var(--warn); } .danger { color: var(--danger); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.row-between h2, .row-between h3 { margin: 0; }

/* 顶栏 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 12px; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { color: var(--muted); font-size: .95rem; }
.nav a.on, .nav a:hover { color: var(--text); text-decoration: none; }
.me-link { display: flex; align-items: center; gap: 6px; }
.footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; padding-top: 16px; padding-bottom: 28px; border-top: 1px solid var(--line); }

/* 按钮 / 表单 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-size: .95rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: .85rem; }
.btn.block { width: 100%; }
.nav .btn.sm { color: var(--accent-ink); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; }
button.link.danger { color: var(--danger); } button.link.muted { color: var(--muted); }
form.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form h3 { margin: 10px 0 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, textarea, select { font: inherit; font-size: .95rem; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.inline-form input { width: auto; flex: 1 1 160px; }
.w-sm { max-width: 100px; } .w-md { max-width: 180px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 32px auto; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 14px 0; font-size: .92rem; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; font-size: .72rem; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin-right: 6px; vertical-align: middle; font-weight: 500; }
.tag.danger { background: var(--warn-soft); color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 20px; }

/* 头像 */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--line); }
.avatar.sm { width: 28px; height: 28px; } .avatar.lg { width: 72px; height: 72px; }
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.avatar-form { flex-direction: row; align-items: flex-end; margin-bottom: 16px; }

/* 首页 */
.hero { text-align: center; padding: 48px 0 24px; }
.hero h1 { font-size: 2.2rem; margin-bottom: .2em; }
.tagline { color: var(--muted); font-size: 1.1rem; margin-top: 0; }
.intro { max-width: 520px; margin: 24px auto; color: var(--text); }
.intro p { margin: .3em 0; }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 28px 0 40px; }
.features { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; }
.features li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.features span { color: var(--muted); font-size: .88rem; }

/* 文章列表 */
.list-head { display: flex; justify-content: space-between; align-items: baseline; }
.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { border-bottom: 1px solid var(--line); }
.article-list a { display: block; padding: 18px 4px; color: var(--text); }
.article-list a:hover { text-decoration: none; }
.article-list a:hover h3 { color: var(--accent); }
.article-list h3 { margin: 0 0 6px; font-size: 1.15rem; }
.summary { margin: 0 0 6px; color: var(--muted); font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; gap: 14px; color: var(--muted); font-size: .82rem; flex-wrap: wrap; }
.pager { display: flex; justify-content: center; gap: 16px; align-items: center; margin-top: 24px; }

/* 正文 */
.post-head { margin-bottom: 24px; }
.post-head h1 { font-size: 1.8rem; }
.prose { font-family: var(--serif); font-size: 1.08rem; line-height: 1.9; word-break: break-word; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--sans); margin: 1.6em 0 .6em; }
.prose p { margin: 0 0 1.1em; }
.prose img { display: block; margin: 1.2em auto; border-radius: 6px; height: auto; }
.prose blockquote { margin: 1.2em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--muted); background: var(--surface); }
.prose pre { background: var(--surface); border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .88rem; }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .92rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* 评论 */
.comments { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.comment-form { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.replying { font-size: .88rem; color: var(--muted); }
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment.reply { border-bottom: 0; padding-bottom: 0; }
.comment.reply .avatar { width: 30px; height: 30px; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment-body { margin: 4px 0; word-break: break-word; }
.comment-actions { display: flex; gap: 14px; }

/* 付款 */
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.plan input { position: absolute; opacity: 0; }
.plan-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; height: 100%; }
.plan input:checked + .plan-card { border-color: var(--accent); background: var(--accent-soft); }
.plan input:focus-visible + .plan-card { outline: 2px solid var(--accent); }
.plan-name { font-weight: 600; }
.plan-price { font-size: 1.6rem; font-weight: 700; }
.plan-price small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.pay-submit { grid-column: 1 / -1; }
.order { max-width: 720px; margin: 0 auto 20px; }
.pay-box { display: flex; gap: 24px; align-items: flex-start; margin: 20px 0; }
.qr img { border-radius: 8px; background: #fff; padding: 6px; }
.pay-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.field .label { display: block; color: var(--muted); font-size: .82rem; }
.amount { font-size: 1.8rem; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.addr { word-break: break-all; background: var(--bg); padding: 4px 8px; border-radius: 6px; display: inline-block; margin-right: 6px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: .82rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.ua { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: .8rem; padding: 2px 8px; border-radius: 99px; background: var(--line); white-space: nowrap; }
.status.paid { background: var(--ok-soft); color: var(--ok); }
.status.pending { background: var(--warn-soft); color: var(--warn); }

/* 后台 */
.admin-nav, .tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.admin-nav a, .tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-nav a.on, .tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.admin-nav a:hover, .tabs a:hover { text-decoration: none; color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat b { font-size: 1.5rem; }
.plan-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.plan-row label:not(.check) { flex: 1 1 120px; }
.plan-row label.check { padding-bottom: 8px; }
.plan-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: 0; }
.checks { display: flex; gap: 20px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-panes textarea { font-family: var(--mono); font-size: .9rem; line-height: 1.6; min-height: 560px; resize: vertical; }
.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; overflow: auto; max-height: 80vh; font-size: 1rem; }

/* 内容保护 */
body.protect .main { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.protect .main textarea, body.protect .main input { -webkit-user-select: text; user-select: text; }
body.protect img { -webkit-user-drag: none; pointer-events: none; }
@media print {
  body.protect * { display: none !important; }
  body.protect::after { content: "本站内容禁止打印"; display: block !important; padding: 40px; font-size: 20px; }
}

@media (max-width: 720px) {
  .grid-2, .editor-panes, .features { grid-template-columns: 1fr; }
  .pay-box { flex-direction: column; align-items: center; }
  .hide-sm { display: none; }
  .hero h1 { font-size: 1.7rem; }
  .post-head h1 { font-size: 1.5rem; }
  .prose { font-size: 1.02rem; }
  .card { padding: 16px; }
}
