* { box-sizing: border-box; }

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #24292f;
  --muted: #6e7681;
  --line: #e3e6ec;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --code-bg: #f0f1f5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html.dark {
  --bg: #0f1115;
  --surface: #171a21;
  --text: #e6e6e6;
  --muted: #9aa0aa;
  --line: #262b34;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --code-bg: #1b1f27;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
}

.container { max-width: 780px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 16px; height: 56px; }
.logo { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.nav nav { display: flex; gap: 4px; margin-left: 8px; }
.nav nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}
.nav nav a:hover { color: var(--text); background: var(--accent-soft); }
.nav nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
#theme-toggle {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  font-size: 15px;
  line-height: 1;
}
#theme-toggle:hover { border-color: var(--accent); }

main { padding: 32px 0 56px; min-height: 60vh; }

/* ---------- 首页：工具栏 + 列表 ---------- */
.toolbar { margin-bottom: 24px; }
#search {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  margin-bottom: 12px;
}
#search:focus { border-color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
button.tag { border: none; cursor: pointer; }
button.tag:hover { filter: brightness(0.96); }
button.tag.active { background: var(--accent); color: #fff; }

.post-list { display: grid; gap: 16px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  border-color: var(--accent);
}
.post-card__link { text-decoration: none; color: inherit; display: block; }
.post-card h2 { margin: 0 0 8px; font-size: 18px; }
.post-card__link:hover h2 { color: var(--accent); }
.post-card__summary { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.post-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.post-card__foot time { color: var(--muted); font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- 分页 ---------- */
#pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}
#pager button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
#pager button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- about 页 ---------- */
.about-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.about-card h1 { margin: 0 0 16px; font-size: 26px; }
.about-card h2 { font-size: 18px; margin: 22px 0 8px; }
.about-card p { color: var(--muted); margin: 0 0 12px; }
.about-card ul { margin: 0 0 14px; padding-left: 20px; }
.about-card code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}
.deploy-recipe {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
  overflow-x: auto;
}
.deploy-recipe code { background: none; padding: 0; }

/* ---------- 文章页 ---------- */
.post-header { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.post-header h1 { margin: 0 0 12px; font-size: 28px; line-height: 1.35; }
.post-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; color: var(--muted); font-size: 13px; }

.post-content h2 {
  font-size: 22px;
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.post-content h3 { font-size: 18px; margin: 26px 0 10px; }
.post-content p { margin: 0 0 16px; }
.post-content a { color: var(--accent); }
.post-content ul, .post-content ol { margin: 0 0 16px; padding-left: 24px; }
.post-content li { margin: 4px 0; }
.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}
.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0 0 16px;
  line-height: 1.6;
}
.post-content pre code { background: none; padding: 0; font-size: 13px; }

/* 暗色主题下,h1/strong 及其 highlight.js 配色沿用浅色主题时可能与深色背景不协调,
   这里统一将代码块背景和文字拉回页面本身的码块样式 */
html.dark .post-content pre {
  background: var(--code-bg);
  border-color: var(--line);
}
html.dark .post-content pre code { color: var(--text); }
html.dark .post-content .hljs-comment,
html.dark .post-content .hljs-quote {
  color: #8b949e;
}
.post-content blockquote {
  margin: 0 0 16px;
  padding: 10px 16px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
}
.post-content img { max-width: 100%; border-radius: var(--radius); display: block; margin: 20px auto; }
.post-content hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

.post-nav { display: flex; gap: 16px; margin-top: 36px; border-top: 1px solid var(--line); padding-top: 20px; }
.post-nav a, .nav-empty {
  flex: 1;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.post-nav a:hover { border-color: var(--accent); }
.post-nav a span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- 底部 + 回到顶部 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
  background: var(--surface);
}
#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.2s;
}
#back-to-top.show { opacity: 1; visibility: visible; transform: none; }
#back-to-top:hover { border-color: var(--accent); }

@media (max-width: 480px) {
  .post-header h1 { font-size: 24px; }
  .nav nav a { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}