:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #33312e;
  --muted: #8a857c;
  --accent: #a9785a;
  --accent-soft: #f3e9e1;
  --border: #ece8e0;
  --max: 920px;
  --radius: 14px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(250, 249, 246, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-name {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
}
.nav a {
  text-decoration: none;
  color: var(--muted);
  margin-left: 22px;
  font-size: 15px;
  transition: color .2s;
}
.nav a:hover,
.nav a.active { color: var(--accent); }

/* ---------- Hero (home) ---------- */
.hero {
  padding: 56px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.hero h1 {
  font-family: var(--serif);
  font-size: 30px;
  margin: 0 0 10px;
  letter-spacing: 1px;
}
.hero p {
  color: var(--muted);
  margin: 0;
  font-size: 15px;
}

/* ---------- Post list ---------- */
.section-title {
  font-family: var(--serif);
  font-size: 18px;
  margin: 36px 0 16px;
  color: var(--text);
}
.post-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(120, 90, 60, 0.08);
  border-color: var(--accent-soft);
}
.post-card h2 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 8px;
}
.post-card .excerpt {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 12px;
}

/* ---------- 首页双栏布局 + 时光轴 ---------- */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 40px;
  align-items: start;
}
.home-side {
  position: sticky;
  top: 104px;
}
.side-title {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.timeline {
  border-left: 2px solid var(--border);
  margin-left: 6px;
  padding-left: 16px;
}
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 3px var(--surface);
}
.timeline-date { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.timeline-title { font-size: 14px; line-height: 1.5; }
.timeline-title a { color: var(--text); text-decoration: none; }
.timeline-title a:hover { color: var(--accent); }
.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12.5px;
  text-decoration: none;
  transition: background .2s;
}
.tag:hover { background: #ecd9cb; }
.tag.lg { font-size: 14px; padding: 5px 14px; }

/* ---------- Tags overview ---------- */
.tag-cloud {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.tag-item { text-decoration: none; color: var(--accent); }
.tag-item .count {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

/* ---------- Post detail ---------- */
.article { padding: 28px 0 12px; max-width: 720px; margin: 0 auto; }
.article-header { margin-bottom: 28px; }
.article-header h1 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.35;
  margin: 0 0 14px;
  letter-spacing: .5px;
}
.back-link {
  display: inline-block;
  margin: 28px 0 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { text-decoration: underline; }

/* markdown body */
.markdown { font-size: 16.5px; }
.markdown h1, .markdown h2, .markdown h3 {
  font-family: var(--serif);
  line-height: 1.4;
  margin: 1.6em 0 .6em;
}
.markdown h2 { font-size: 23px; border-left: 4px solid var(--accent); padding-left: 12px; }
.markdown h3 { font-size: 19px; }
.markdown p { margin: .9em 0; }
.markdown a { color: var(--accent); }
.markdown ul, .markdown ol { padding-left: 1.4em; }
.markdown li { margin: .35em 0; }
.markdown blockquote {
  margin: 1.2em 0;
  padding: 10px 18px;
  border-left: 4px solid var(--accent-soft);
  background: #fcf8f4;
  color: #5a554d;
  border-radius: 0 8px 8px 0;
}
.markdown code {
  background: #f1ede6;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 14px;
  font-family: "SFMono-Regular", Consolas, monospace;
}
.markdown pre {
  background: #2b2b2b;
  color: #f4f0e8;
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.6;
}
.markdown pre code { background: none; color: inherit; padding: 0; }
.markdown table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 15px;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}
.markdown th { background: #f7f3ec; }
.markdown img { max-width: 100%; border-radius: 10px; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---------- About ---------- */
.about { padding: 28px 0; max-width: 720px; margin: 0 auto; }
.about h1 { font-family: var(--serif); font-size: 28px; margin-top: 0; }
.about .avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-family: var(--serif); margin-bottom: 18px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Loading / empty ---------- */
.placeholder { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 18px;
  transition: color .2s, border-color .2s, background .2s;
  font-family: var(--sans);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 搜索框 ---------- */
.search-bar { padding: 10px 0 0; }
.search-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14.5px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: var(--sans);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 备案信息(ICP / 公安) ---------- */
.beian {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12.5px;
}
.beian a {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color .2s;
}
.beian a:hover { color: var(--accent); }
.beian .police-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-size: 9px;
  line-height: 1;
}

/* ============================================================
 * 暗色主题
 * ============================================================ */
[data-theme="dark"] {
  --bg: #1a1816;
  --surface: #242120;
  --text: #ece6dd;
  --muted: #a59c8f;
  --accent: #d6a47c;
  --accent-soft: #3a2f28;
  --border: #352f2b;
}
[data-theme="dark"] .site-header {
  background: rgba(26, 24, 22, 0.85);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .post-card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .markdown blockquote {
  background: #211d1a;
  border-left-color: var(--accent);
  color: #c9c0b4;
}
[data-theme="dark"] .markdown th { background: #2c2724; }
[data-theme="dark"] .markdown pre { background: #0f0e0d; color: #f0ebe2; }
[data-theme="dark"] .markdown code { background: #322c28; }

@media (max-width: 760px) {
  .home-layout { grid-template-columns: 1fr; gap: 28px; }
  .home-side { position: static; top: auto; }
  .timeline { margin-left: 6px; }
}

@media (max-width: 600px) {
  .brand-sub { display: none; }
  .hero { padding: 36px 0 20px; }
  .hero h1 { font-size: 24px; }
  .article-header h1, .about h1 { font-size: 24px; }
  .theme-toggle { margin-left: 12px; padding: 4px 10px; }
  .beian { flex-direction: column; gap: 6px; }
}
