/* ===== CSS 变量 ===== */
:root {
  --bg: #fafafa;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --text-secondary: #5a5a5a;
  --text-muted: #999999;
  --accent: #2c4a6b;
  --accent-light: #eaf0f5;
  --accent-hover: #1f3a57;
  --border: #e8e8e8;
  --hover-bg: #f5f5f5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 8px;
  --max-width: 680px;
  --max-width-wide: 920px;
  --nav-height: 60px;
  --font-serif: Georgia, "Songti SC", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "Fira Code", "JetBrains Mono", "Courier New", monospace;
}

/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* ===== 布局容器 ===== */
.container { max-width: var(--max-width-wide); margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: var(--max-width); }

/* ===== 导航栏 ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
  background: rgba(247,249,251,0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
  z-index: 1000;
}
.navbar-scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }
.nav-container {
  max-width: var(--max-width-wide); margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand { display: flex; align-items: baseline; gap: 4px; }
.nav-logo {
  font-family: var(--font-serif); font-size: 1.6rem; font-weight: bold;
  color: var(--text); letter-spacing: 0.05em;
}
.nav-logo:hover { color: var(--accent); }
.nav-subtitle {
  font-size: 0.85rem; color: var(--text-muted);
}
.nav-links { display: flex; gap: 8px; }
.nav-link {
  color: var(--text-secondary); font-size: 0.95rem; padding: 6px 14px;
  border-radius: 6px; transition: all 0.2s;
}
.nav-link:hover { color: var(--accent); background: var(--accent-light); }
.nav-link.active { color: var(--accent); font-weight: 600; }
.nav-toggle {
  display: none; flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px;
}
.nav-toggle span {
  width: 22px; height: 2px; background: var(--text); border-radius: 2px;
  transition: all 0.3s;
}

/* ===== 主内容区 ===== */
.main-content {
  min-height: calc(100vh - var(--nav-height) - 120px);
  padding-top: var(--nav-height);
}

/* ===== 页面头部 ===== */
.page-header { padding: 48px 0 32px; }
.page-title {
  font-family: var(--font-serif); font-size: 2rem; font-weight: bold;
  color: var(--text); margin-bottom: 8px;
}
.page-subtitle { color: var(--text-muted); font-size: 0.95rem; }

/* ===== 文章列表 ===== */
.article-list { padding-bottom: 48px; }
.article-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 16px;
  border: 1px solid var(--border); transition: all 0.25s;
  cursor: pointer;
}
.article-card:hover {
  border-color: var(--accent); box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.article-card-link { display: block; color: inherit; }
.article-card-title a { color: inherit; text-decoration: none; }
.article-card-title {
  font-family: var(--font-serif); font-size: 1.35rem; font-weight: bold;
  color: var(--text); margin-bottom: 8px; line-height: 1.4;
  transition: color 0.2s;
}
.article-card:hover .article-card-title { color: var(--accent); }
.article-card-meta {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px;
}
.article-card-meta .dot { color: var(--border); }
.article-card-summary {
  color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7;
  margin-bottom: 14px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.read-more {
  font-size: 0.9rem; color: var(--accent); font-weight: 500;
  white-space: nowrap; transition: color 0.2s;
}
.article-card:hover .read-more { color: var(--accent-hover); }

/* ===== 标签 ===== */
.tag {
  display: inline-block; padding: 3px 12px; font-size: 0.8rem;
  background: var(--accent-light); color: var(--accent);
  border-radius: 20px; transition: all 0.2s; cursor: pointer;
}
.tag:hover { background: var(--accent); color: #fff; }
.tag-large { font-size: 0.95rem; padding: 6px 18px; }
.tag-count { margin-left: 4px; font-size: 0.75rem; opacity: 0.7; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; padding-bottom: 48px; }

/* ===== 文章详情 ===== */
.back-link {
  display: inline-block; color: var(--text-muted); font-size: 0.9rem;
  margin-bottom: 24px; transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }
.article-detail { padding-bottom: 48px; }
.article-title {
  font-family: var(--font-serif); font-size: 2.2rem; font-weight: bold;
  color: var(--text); line-height: 1.35; margin-bottom: 16px;
}
.article-meta {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px;
}
.article-meta .dot { color: var(--border); }
.article-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 32px; }

/* ===== Markdown 正文样式 ===== */
.markdown-body { font-size: 1.05rem; line-height: 1.85; color: var(--text); }
.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, .markdown-body h5, .markdown-body h6 {
  font-family: var(--font-serif); font-weight: bold; color: var(--text);
  margin-top: 1.8em; margin-bottom: 0.6em; line-height: 1.35;
}
.markdown-body h1 { font-size: 1.7em; }
.markdown-body h2 { font-size: 1.4em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body p { margin-bottom: 1.2em; }
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body a:hover { color: var(--accent-hover); }
.markdown-body strong { font-weight: 700; color: var(--text); }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.2em; padding-left: 1.8em; }
.markdown-body li { margin-bottom: 0.4em; }
.markdown-body li > ul, .markdown-body li > ol { margin-top: 0.4em; }
.markdown-body blockquote {
  margin: 1.5em 0; padding: 0.5em 1.2em;
  border-left: 3px solid var(--accent); background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-secondary);
}
.markdown-body blockquote p:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: var(--hover-bg); padding: 2px 6px; border-radius: 4px;
  color: #c0392b;
}
.markdown-body pre {
  margin: 1.5em 0; padding: 16px 20px; background: #2d2d2d;
  border-radius: var(--radius); overflow-x: auto;
}
.markdown-body pre code { background: none; padding: 0; color: #f8f8f2; font-size: 0.9em; line-height: 1.6; }
.markdown-body img { border-radius: var(--radius); margin: 1.5em 0; max-width: 100%; height: auto; display: block; }
.markdown-body img[src*="uploads/"] { box-shadow: var(--shadow-md); }
.markdown-body hr { border: none; height: 1px; background: var(--border); margin: 2em 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.95rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown-body th { background: var(--hover-bg); font-weight: 600; }

/* ===== 相关文章 ===== */
.related-articles { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.related-title {
  font-family: var(--font-serif); font-size: 1.1rem; font-weight: bold;
  color: var(--text); margin-bottom: 16px;
}
.related-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  transition: padding-left 0.2s;
}
.related-item:last-child { border-bottom: none; }
.related-item:hover { padding-left: 8px; }
.related-item-title { color: var(--text-secondary); font-size: 0.95rem; }
.related-item:hover .related-item-title { color: var(--accent); }
.related-item-date { color: var(--text-muted); font-size: 0.85rem; flex-shrink: 0; margin-left: 16px; }

/* ===== 空状态 ===== */
.empty-state { text-align: center; color: var(--text-muted); padding: 60px 0; font-size: 1rem; }

/* ===== 关于页面 ===== */
.about-content { padding-bottom: 48px; }
.about-intro { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.about-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-family: var(--font-serif); font-weight: bold; flex-shrink: 0;
}
.about-name { font-family: var(--font-serif); font-size: 1.5rem; font-weight: bold; }
.about-bio { color: var(--text-muted); font-size: 0.95rem; }

/* ===== 分页 ===== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 24px 0 48px;
}
.page-link {
  display: inline-block; padding: 8px 20px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-secondary);
  font-size: 0.9rem; transition: all 0.2s;
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-info { color: var(--text-muted); font-size: 0.9rem; }

/* ===== 页脚 ===== */
.footer {
  text-align: center; padding: 40px 24px;
  border-top: 1px solid var(--border); background: var(--card-bg);
}
.footer p { color: var(--text-muted); font-size: 0.85rem; }
.footer-sub { margin-top: 4px; font-size: 0.8rem; opacity: 0.7; }

/* ===== 返回顶部 ===== */
.back-to-top {
  position: fixed; bottom: 32px; right: 32px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card-bg); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); cursor: pointer;
  font-size: 1.2rem; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: all 0.3s; z-index: 999;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== 动画 ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.main-content > * { animation: fadeInUp 0.4s ease; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: var(--nav-height); left: 0; right: 0;
    flex-direction: column; background: var(--card-bg);
    border-bottom: 1px solid var(--border); padding: 8px 24px 16px;
    gap: 4px; transform: translateY(-100%); opacity: 0; visibility: hidden;
    transition: all 0.3s;
  }
  .nav-links-open { transform: translateY(0); opacity: 1; visibility: visible; }
  .nav-search { width: 100%; margin-top: 8px; }
  .search-input { flex: 1; }
  .page-title { font-size: 1.6rem; }
  .article-title { font-size: 1.7rem; }
  .article-card { padding: 20px; }
  .markdown-body { font-size: 1rem; }
  .back-to-top { bottom: 20px; right: 20px; }
  .prev-next { flex-direction: column; gap: 12px; }
  .pn-empty { display: none; }
  .nav-subtitle { display: none; }
}
@media (max-width: 480px) {
  .container, .nav-container { padding: 0 16px; }
  .article-card { padding: 16px; }
  .article-card-title { font-size: 1.15rem; }
  .related-item { flex-direction: column; align-items: flex-start; gap: 4px; }
  .related-item-date { margin-left: 0; }
}

/* ===== 搜索框 ===== */
.nav-search {
  display: flex; align-items: center; gap: 0;
  border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; background: var(--hover-bg); margin-left: 8px;
}
.nav-search:focus-within { border-color: var(--accent); background: var(--card-bg); }
.search-input {
  border: none; background: transparent; outline: none;
  padding: 6px 14px; font-size: 0.85rem; width: 140px; color: var(--text);
}
.search-input::placeholder { color: var(--text-muted); }
.search-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 10px; color: var(--text-muted); display: flex; align-items: center;
}
.search-btn:hover { color: var(--accent); }

.card-pinned { border-color: var(--accent); box-shadow: 0 2px 8px rgba(44,74,107,0.12); }

/* ===== 置顶标识 ===== */
.pin-badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
  vertical-align: middle; margin-right: 6px; font-weight: 600;
}

/* ===== 上一篇/下一篇 ===== */
.prev-next {
  display: flex; gap: 16px; margin-top: 40px; padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pn-link {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  padding: 16px; border-radius: var(--radius); text-decoration: none;
  background: var(--hover-bg); transition: background 0.2s;
  min-width: 0;
}
.pn-link:hover { background: var(--accent-light); }
.pn-next { text-align: right; }
.pn-empty { flex: 1; }
.pn-label { font-size: 0.8rem; color: var(--text-muted); }
.pn-title {
  font-size: 0.95rem; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== 微信二维码弹窗 ===== */
.wechat-link { color: var(--accent); cursor: pointer; border-bottom: 1px dashed var(--accent); }
.wechat-link:hover { color: var(--accent-hover); }
.wechat-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 9999; align-items: center; justify-content: center;
}
.wechat-modal-mask {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
}
.wechat-modal-box {
  position: relative; background: #fff; border-radius: 12px;
  padding: 24px; text-align: center; max-width: 300px; z-index: 1;
}
.wechat-modal-box img { width: 240px; height: 240px; object-fit: cover; border-radius: 8px; }
.wechat-modal-box p { margin-top: 12px; font-size: 0.95rem; color: var(--text-secondary); }
.wechat-modal-close {
  position: absolute; top: -12px; right: -12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border);
  font-size: 20px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.wechat-modal-close:hover { background: var(--hover-bg); }

/* ===== 归档时间线 ===== */
.archive-list { margin-top: 24px; }
.archive-group { margin-bottom: 36px; }
.archive-month {
  font-size: 1.2rem; font-weight: 600; color: var(--text);
  padding-bottom: 10px; border-bottom: 2px solid var(--accent-light);
  margin-bottom: 12px;
}
.archive-count { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }
.archive-items { list-style: none; padding: 0; }
.archive-item { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.archive-item:last-child { border-bottom: none; }
.archive-item a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.archive-item a:hover { color: var(--accent); }
.archive-date {
  font-size: 0.85rem; color: var(--text-muted); min-width: 40px;
  font-variant-numeric: tabular-nums;
}
.archive-title { font-size: 0.95rem; }
