/* ---------- 基础变量 ---------- */
:root {
  --bg: #faf9f7;
  --surface: #fffefc;
  --text: #22201d;
  --muted: #78736c;
  --faint: #a29c93;
  --line: #e6e2da;
  --line-soft: #f0ede7;
  --accent: #8a6f4e;
  --accent-hover: #6f5739;
  --accent-soft: #f2ece1;
  --shadow: 0 10px 30px rgba(40, 32, 22, .06);
  --serif: Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --wrap: 780px;
}

[data-theme="dark"] {
  --bg: #151412;
  --surface: #1d1c19;
  --text: #eae6df;
  --muted: #a39d93;
  --faint: #7f786e;
  --line: #33302a;
  --line-soft: #27241f;
  --accent: #d0ac72;
  --accent-hover: #e3c28c;
  --accent-soft: #2b261e;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.site-nav { display: flex; gap: 22px; margin-left: auto; }
.site-nav a {
  font-size: 14px;
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}
.site-nav a:hover, .site-nav a.active { color: var(--text); border-color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 14px; }
.admin-link { font-size: 13px; color: var(--faint); }
.admin-link:hover { color: var(--accent); }
.theme-toggle {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent); transform: rotate(20deg); }
.theme-icon { font-size: 17px; line-height: 1; }

.main-content { min-height: 62vh; padding-bottom: 64px; }

/* ---------- 首页 ---------- */
.hero { padding: 68px 0 44px; }
.hero-banner { margin: 0 0 34px; display: flex; justify-content: center; }
.hero-banner img {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
  border-radius: 10px;
}
.hero-label {
  font-size: 11px;
  letter-spacing: .24em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 18px;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(32px, 6vw, 46px);
  line-height: 1.25;
  margin: 0 0 16px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.hero-bio { color: var(--muted); font-size: 17px; margin: 0; max-width: 540px; }
.hero-line { width: 48px; height: 2px; background: var(--accent); margin-top: 28px; opacity: .8; }

.section { padding: 12px 0 40px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 14px; border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.section-head h2 { font-family: var(--serif); font-size: 20px; margin: 0; font-weight: 600; }
.section-head span { font-size: 13px; color: var(--faint); }

.post-list { display: block; }
.post-item {
  display: grid;
  grid-template-columns: 88px 1fr 20px;
  gap: 16px;
  align-items: start;
  padding: 26px 12px 26px 0;
  border-bottom: 1px solid var(--line-soft);
  transition: background .2s, transform .2s;
}
.post-item:hover { background: var(--accent-soft); padding-left: 12px; border-radius: 8px; transform: translateX(2px); }
.post-date { font-size: 13px; color: var(--faint); padding-top: 5px; font-variant-numeric: tabular-nums; }
.post-title { font-family: var(--serif); font-size: 21px; line-height: 1.45; margin: 0 0 6px; font-weight: 600; }
.post-desc { color: var(--muted); font-size: 14px; margin: 0 0 10px; line-height: 1.7; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12px; color: var(--accent); }
.tag:hover { text-decoration: underline; }
.post-arrow { color: var(--faint); font-size: 16px; padding-top: 4px; opacity: 0; transition: opacity .2s; }
.post-item:hover .post-arrow { opacity: 1; }

/* ---------- 文章页 ---------- */
.article { padding-top: 44px; }
.back-link { font-size: 13px; color: var(--faint); }
.back-link:hover { color: var(--accent); }
.article-head { padding-bottom: 28px; border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.article-head h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 5.5vw, 42px);
  line-height: 1.3;
  margin: 22px 0 14px;
  font-weight: 600;
}
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-size: 13px; color: var(--faint); }
.article-author { color: var(--muted); }
.article-author a { color: var(--accent); text-decoration: none; }
.article-author a:hover { text-decoration: underline; }
.meta-tags { display: flex; gap: 10px; }
.article-lead { margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.8; }

.prose { font-size: 16.5px; line-height: 1.9; color: var(--text); }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.4;
  margin: 2em 0 .7em;
  scroll-margin-top: 90px;
}
.prose h1 { font-size: 28px; }
.prose h2 { font-size: 23px; }
.prose h3 { font-size: 19px; }
.prose p { margin: 0 0 1.3em; }
.prose a { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.prose a:hover { border-color: var(--accent); }
.prose strong { font-weight: 650; }
.prose blockquote {
  margin: 1.8em 0;
  padding: 4px 20px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
  border-radius: 0 6px 6px 0;
}
.prose blockquote p { margin: .6em 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.3em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--accent); }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
}
.prose pre.code-block {
  background: #1e1d1a;
  color: #e8e4dc;
  padding: 18px 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1.6em 0;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
.prose pre.code-block code { background: transparent; padding: 0; color: inherit; font-size: 13.5px; }
.prose img { border-radius: 8px; margin: 1.4em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.article-end { text-align: center; color: var(--faint); font-size: 13px; letter-spacing: .2em; margin: 48px 0 36px; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.post-nav-item { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; transition: background .2s; }
.post-nav-item:hover { background: var(--accent-soft); }
.post-nav-item span { font-size: 12px; color: var(--faint); }
.post-nav-item strong { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.post-nav-item.next { text-align: right; }

/* ---------- 归档 / 标签 / 关于 ---------- */
.page-head { padding: 48px 0 30px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.page-head h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 40px); margin: 0 0 8px; font-weight: 600; }
.page-head p { color: var(--muted); margin: 0; }
.archive-group { margin-bottom: 34px; }
.archive-year { font-family: var(--serif); font-size: 20px; margin: 0 0 12px; font-weight: 600; }
.archive-year span { font-family: var(--sans); font-size: 12px; color: var(--faint); font-weight: 400; margin-left: 8px; }
.archive-list { list-style: none; padding: 0; margin: 0; }
.archive-list a { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.archive-list a:hover { color: var(--accent); }
.archive-list time { color: var(--faint); font-size: 13px; white-space: nowrap; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 12px; }
.tag-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--muted); }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tag-chip span { font-size: 11px; color: var(--faint); }
.contact { margin-top: 32px; }
.contact a { color: var(--accent); }
.back-row { margin-top: 28px; font-size: 14px; color: var(--muted); }
.empty { padding: 36px 0; color: var(--muted); }
.empty a { color: var(--accent); text-decoration: underline; }
.empty-page { text-align: center; padding: 80px 0; }
.error-code { font-family: var(--serif); font-size: 72px; color: var(--accent); opacity: .5; line-height: 1; }
.empty-page h1 { font-family: var(--serif); margin: 20px 0 8px; }
.empty-page p { color: var(--muted); }
.button { display: inline-block; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; cursor: pointer; background: var(--surface); }
.button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0 34px; color: var(--faint); font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-left p { margin: 0; }
.footer-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.footer-right a:hover { color: var(--accent); }
.sep { opacity: .5; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .wrap { padding: 0 18px; }
  .header-inner { min-height: auto; flex-wrap: wrap; gap: 10px 14px; padding-top: 12px; padding-bottom: 10px; }
  .brand { font-size: 17px; }
  .header-actions { margin-left: auto; gap: 10px; }
  .site-nav { order: 3; width: 100%; margin-left: 0; gap: 20px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .site-nav a { font-size: 13px; flex: 0 0 auto; }
  .hero { padding: 46px 0 32px; }
  .hero-title { font-size: 32px; }
  .hero-bio { font-size: 16px; }
  .post-item { grid-template-columns: 1fr; gap: 6px; padding: 20px 4px 20px 0; }
  .post-date { padding-top: 0; font-size: 12px; }
  .post-title { font-size: 19px; }
  .post-arrow { display: none; }
  .article { padding-top: 28px; }
  .article-head h1 { font-size: 29px; margin-top: 16px; }
  .prose { font-size: 16px; line-height: 1.85; }
  .prose h2 { font-size: 21px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-item.next { text-align: left; }
  .page-head { padding: 34px 0 24px; }
  .footer-inner { flex-direction: column; gap: 6px; }
}

/* ---------- 站点 logo ---------- */
.site-logo { width: 30px; height: 30px; vertical-align: middle; margin-right: 9px; border-radius: 7px; }
.brand { display: inline-flex; align-items: center; }
@media (max-width: 640px) { .site-logo { width: 24px; height: 24px; margin-right: 6px; } }

/* ---------- 评论 ---------- */
.comments { margin-top: 52px; padding-top: 30px; border-top: 1px solid var(--line); }
.comments-head h2 { font-size: 20px; margin: 0 0 18px; font-weight: 600; }
.comments-head h2 span { font-size: 13px; color: var(--muted); margin-left: 6px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 24px; }
.comment-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.comment-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.comment-head strong { font-size: 14px; color: var(--text); }
.comment-head time { font-size: 12px; color: var(--faint); }
.comment-item p { margin: 0; font-size: 14px; line-height: 1.8; color: var(--muted); }
.comment-empty { color: var(--muted); font-size: 14px; padding: 10px 0 18px; }
.comment-form { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.comment-row { display: flex; gap: 12px; margin-bottom: 12px; }
.comment-row input { flex: 1; min-width: 0; }
.comment-form input, .comment-form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; outline: none;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--accent); }
.comment-form textarea { resize: vertical; line-height: 1.7; }
.comment-honey { display: none; }
.comment-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.comment-submit { border: 0; border-radius: 8px; padding: 9px 18px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; }
.comment-submit:disabled { opacity: .6; cursor: default; }
.comment-status { font-size: 13px; color: var(--muted); }
.comment-hint { font-size: 12px; color: var(--faint); margin: 10px 0 0; }
@media (max-width: 640px) {
  .comment-row { flex-direction: column; gap: 10px; }
  .comment-form { padding: 14px; }
}

/* 文章卡片：标题链接继承样式（article 外层不再用 a，避免 a 嵌套 a） */
.post-title a { color: inherit; text-decoration: none; }
.post-title a:hover { color: var(--accent); }

/* PWA 安装入口 */
.pwa-install-link { display: none; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.pwa-install-link:hover { border-color: var(--accent); color: var(--accent); }
.pwa-install-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 999; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; color: var(--text); }
.pwa-install-text { flex: 1; line-height: 1.5; }
.pwa-install-ok { border: 0; border-radius: 8px; padding: 7px 14px; background: var(--accent); color: #fff; font-size: 13px; cursor: pointer; white-space: nowrap; }
.pwa-install-close { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--faint); cursor: pointer; padding: 0 2px; }
@media (max-width: 820px) {
  .pwa-install-link { display: inline-block; }
}

/* 日历归档 */
.calendar { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 15px; }
.calendar-head strong { font-size: 17px; }
.cal-nav { color: var(--accent); text-decoration: none; font-size: 13px; }
.cal-nav:hover { text-decoration: underline; }
.calendar-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--faint); padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal-cell { min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.cal-cell.empty { visibility: hidden; }
.cal-cell.has-posts { background: var(--accent-soft); }
.cal-cell.selected { outline: 2px solid var(--accent); }
.cal-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 100%; height: 100%; text-decoration: none; color: var(--text); font-size: 13px; }
.cal-day:hover .cal-num { color: var(--accent); }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.calendar-result { margin-top: 24px; }
.calendar-result h2 { font-size: 16px; margin-bottom: 12px; }
@media (max-width: 640px) {
  .calendar { padding: 12px; }
  .cal-cell { min-height: 38px; }
  .calendar-head strong { font-size: 15px; }
}
