:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --ink: #22262b;
  --ink-soft: #5f666d;
  --ink-faint: #9299a0;
  --line: #e7e4de;
  --accent: #2d6a5f;
  --accent-soft: #e8f1ee;
  --danger: #b3453b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 35, 40, .04), 0 8px 24px rgba(30, 35, 40, .04);
  --serif: Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { width: min(1060px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(248, 247, 244, .9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 66px; gap: 20px; }
.brand { font-family: var(--serif); font-size: 21px; font-weight: 700; letter-spacing: .02em; }
.brand-dot { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 22px; font-size: 14px; flex-wrap: wrap; }
.nav a { color: var(--ink-soft); transition: color .15s; }
.nav a:hover, .nav a.active { color: var(--accent); }
.nav .nav-user { color: var(--ink-faint); font-size: 13px; }
.nav .link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-soft); font-size: 14px; }
.nav .link-btn:hover { color: var(--accent); }

/* ---------- generic ---------- */
main { min-height: calc(100vh - 190px); padding-top: 44px; padding-bottom: 72px; }
.loading { color: var(--ink-faint); padding: 60px 0; text-align: center; }
.hero { padding: 26px 0 40px; border-bottom: 1px solid var(--line); margin-bottom: 38px; }
.hero h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 44px); line-height: 1.25; margin: 0 0 12px; letter-spacing: -.01em; }
.hero p { color: var(--ink-soft); margin: 0; font-size: 16px; }
.section-title { font-family: var(--serif); font-size: 24px; margin: 0 0 24px; }
.muted { color: var(--ink-faint); }
.empty { padding: 48px 24px; text-align: center; color: var(--ink-faint); border: 1px dashed var(--line); border-radius: var(--radius); }

.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: #fff; cursor: pointer; font-size: 14px;
  transition: opacity .15s, transform .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.plain { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: #e7c9c5; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 7px; }
.input, .textarea, select.input {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }

/* ---------- layout ---------- */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 48px; align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}

/* ---------- post list ---------- */
.post-list { display: grid; gap: 14px; }
.post-item {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow);
  transition: transform .18s, border-color .18s;
}
.post-item:hover { transform: translateY(-2px); border-color: #cfd9d5; }
.post-item h2 { font-family: var(--serif); font-size: 21px; margin: 0 0 10px; line-height: 1.4; }
.post-item p { color: var(--ink-soft); margin: 0 0 14px; font-size: 14px; }
.post-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-faint); }
.cover { width: 100%; height: 180px; object-fit: cover; border-radius: 8px; margin-bottom: 18px; background: var(--accent-soft); }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.tag.plain { background: #f1f0ed; color: var(--ink-soft); }
.badge-draft { color: #a8781f; background: #fbf1dd; padding: 2px 9px; border-radius: 99px; font-size: 12px; }

.side h3 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 14px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a { background: var(--surface); border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; font-size: 13px; color: var(--ink-soft); }
.tag-cloud a:hover, .tag-cloud a.active { border-color: var(--accent); color: var(--accent); }
.search-box { display: flex; gap: 8px; margin-bottom: 20px; }
.search-box .input { flex: 1; }

/* ---------- article ---------- */
.article-head { padding-bottom: 26px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.article-head h1 { font-family: var(--serif); font-size: clamp(28px, 4.5vw, 38px); line-height: 1.3; margin: 0 0 14px; }
.article-body { font-size: 16px; line-height: 1.9; }
.article-body h1, .article-body h2, .article-body h3 { font-family: var(--serif); line-height: 1.4; margin: 1.8em 0 .7em; }
.article-body h2 { font-size: 24px; } .article-body h3 { font-size: 19px; }
.article-body p { margin: 0 0 1.1em; }
.article-body ul, .article-body ol { padding-left: 1.5em; margin: 0 0 1.1em; }
.article-body blockquote {
  margin: 1.4em 0; padding: 4px 20px; border-left: 3px solid var(--accent);
  color: var(--ink-soft); background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.article-body pre { background: #f4f3ef; border: 1px solid var(--line); padding: 16px 18px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.article-body code { background: #f1f0ec; padding: 2px 5px; border-radius: 4px; font-size: .9em; }
.article-body pre code { background: none; padding: 0; }
.article-body img { max-width: 100%; border-radius: 8px; }
.article-body table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 14px; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.article-body th { background: #f4f3ef; }
.article-body a { color: var(--accent); text-decoration: underline; }

/* ---------- comments ---------- */
.comments { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--line); }
.comments h3 { font-family: var(--serif); font-size: 21px; margin: 0 0 20px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.comment-head strong { color: var(--accent); }
.comment p { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- auth ---------- */
.auth-card { max-width: 420px; margin: 20px auto; }
.auth-card h1 { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; }
.tabs { display: flex; gap: 20px; margin: 22px 0; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0 0 10px; cursor: pointer; color: var(--ink-faint); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

/* ---------- admin ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.admin-row:last-child { border-bottom: 0; }
.admin-row .title { font-weight: 600; }
.admin-row .actions { display: flex; gap: 8px; flex-shrink: 0; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.editor-grid .full { grid-column: 1 / -1; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.preview-pane { min-height: 320px; max-height: 620px; overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.notice { background: var(--accent-soft); border: 1px solid #d3e5df; color: #255d52; padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 22px; }

/* ---------- footer / toast ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; padding: 24px 0; flex-wrap: wrap; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 16px);
  background: #22262b; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); }

@media (max-width: 820px) {
  .cols { grid-template-columns: 1fr; gap: 32px; }
  .editor-grid { grid-template-columns: 1fr; }
  .header-inner { min-height: 58px; }
  .nav { gap: 14px; font-size: 13px; }
  .post-item { padding: 20px; }
  main { padding-top: 28px; }
}
