/* ============================================================
   blog.css — 极简技术风
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --text: #111827;
  --text-muted: #6b7280;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --border: #e5e7eb;
  --tag-bg: #eff6ff;
  --tag-color: #1d4ed8;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --max-w: 720px;
  --radius: 6px;
}

/* Dark mode */
html.dark {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --link: #60a5fa;
  --link-hover: #93bbfd;
  --border: #334155;
  --tag-bg: #1e3a5f;
  --tag-color: #93bbfd;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ── Header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
}
html.dark .site-header { background: rgba(15,23,42,0.95); }
.nav-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.site-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  margin-left: auto;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; margin-left: auto; }
.mobile-nav { display: none; padding: 0.5rem 1.5rem 1rem; gap: 1rem; }
.mobile-nav a { display: block; padding: 0.4rem 0; color: var(--text-muted); }

@media (max-width: 600px) {
  .nav-links { display: none; }
  .menu-toggle { display: block; }
  .mobile-nav.open { display: flex; flex-direction: column; }
}

/* ── Main ── */
.main-content { flex: 1; }
.page-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 2rem;
  letter-spacing: -0.5px;
}

/* ── Flash ── */
.flash-container { max-width: var(--max-w); margin: 1rem auto; padding: 0 1.5rem; }
.flash { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 0.5rem; font-size: 0.9rem; }
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Hero ── */
.home-hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 5rem 1.5rem 3rem;
}
.hero-title { font-size: 2.25rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 0.75rem; }
.hero-subtitle { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.btn-primary {
  background: var(--link);
  color: #fff;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--link-hover); color: #fff; text-decoration: none; }
.btn-secondary {
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--text-muted); text-decoration: none; }

/* ── Home section ── */
.home-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}
.section-title { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1.25rem; }

/* ── Post list ── */
.post-list { list-style: none; }
.post-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: none; }
.post-date { font-size: 0.85rem; color: var(--text-muted); margin-right: 1rem; font-variant-numeric: tabular-nums; }
.post-link { font-weight: 500; color: var(--text); }
.post-link:hover { color: var(--link); text-decoration: none; }
.post-tags { margin-left: 0.75rem; }
.post-excerpt { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.3rem; }
.post-empty { color: var(--text-muted); padding: 1rem 0; }
.more-link { display: inline-block; margin-top: 1.25rem; font-size: 0.9rem; color: var(--link); }

/* ── Tag ── */
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-color);
  font-size: 0.78rem;
  padding: 0.1rem 0.55rem;
  border-radius: 4px;
  margin: 0 0.2rem;
  text-decoration: none;
}
.tag:hover { text-decoration: none; filter: brightness(0.95); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tag-large { font-size: 1rem; padding: 0.25rem 0.75rem; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 2rem; }
.page-btn {
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
}
.page-btn:hover { text-decoration: none; border-color: var(--link); color: var(--link); }
.page-info { color: var(--text-muted); font-size: 0.9rem; }

/* ── Archive ── */
.archive-month { margin-bottom: 2rem; }
.archive-month-title { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ── Article ── */
.post-article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem;
}
.post-header { margin-bottom: 2.5rem; }
.post-title { font-size: 2rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1.3; margin-bottom: 0.75rem; }
.post-meta { font-size: 0.88rem; color: var(--text-muted); display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; }
.post-views { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Markdown body ── */
.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4 {
  font-weight: 700; line-height: 1.35; margin: 2rem 0 1rem; letter-spacing: -0.3px;
}
.markdown-body h1 { font-size: 1.75rem; }
.markdown-body h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body p { margin: 1rem 0; }
.markdown-body ul,.markdown-body ol { padding-left: 1.5rem; margin: 1rem 0; }
.markdown-body li { margin: 0.3rem 0; }
.markdown-body blockquote {
  border-left: 3px solid var(--border);
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  margin: 1.25rem 0;
}
.markdown-body code {
  background: var(--bg-alt);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.88em;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
}
.markdown-body pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
}
.markdown-body pre code { background: none; padding: 0; font-size: 0.9em; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1.25rem 0; }
.markdown-body th,.markdown-body td { border: 1px solid var(--border); padding: 0.6rem 1rem; text-align: left; }
.markdown-body th { background: var(--bg-alt); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }
.markdown-body a { color: var(--link); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Divider ── */
.divider {
  max-width: var(--max-w);
  margin: 0 auto;
  border: none;
  border-top: 1px solid var(--border);
}

/* ── Comments ── */
.comments-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}
.comments-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; }
.comment-item { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.comment-meta { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.comment-nick { font-weight: 600; }
.comment-nick a { color: var(--link); }
.comment-time { font-size: 0.82rem; color: var(--text-muted); }
.comment-body { font-size: 0.95rem; line-height: 1.7; }
.comment-reply {
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
  font-size: 0.9rem;
  border-left: 3px solid var(--border);
}
.no-comments { color: var(--text-muted); padding: 1rem 0; }
.comment-form-wrap { margin-top: 2rem; }
.comment-form-wrap h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Form ── */
.comment-form { display: flex; flex-direction: column; gap: 1rem; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .form-row-2 { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label { font-size: 0.88rem; font-weight: 500; color: var(--text-muted); }
.required { color: #ef4444; }
.form-group input, .form-group textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--link);
}
html.dark .form-group input,
html.dark .form-group textarea { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
.form-group textarea { resize: vertical; min-height: 100px; }
.btn-submit {
  background: var(--link);
  color: #fff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
  transition: background 0.15s;
}
.btn-submit:hover { background: var(--link-hover); }

/* ── Admin ── */
.admin-tabs { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-tabs a {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  color: var(--text-muted);
}
.admin-tabs a.tab-active { background: var(--link); color: #fff; border-color: var(--link); }
.tab-logout { margin-left: auto; color: #ef4444 !important; border-color: #fecaca !important; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 0.6rem 0.75rem; text-align: left; vertical-align: top; }
.admin-table th { background: var(--bg-alt); font-weight: 600; }
.admin-actions { display: flex; gap: 0.4rem; }
.btn-approve { background: #dcfce7; color: #166534; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.82rem; cursor: pointer; border: none; }
.btn-spam { background: #fef9c3; color: #854d0e; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.82rem; cursor: pointer; border: none; }
.btn-delete { background: #fee2e2; color: #991b1b; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.82rem; cursor: pointer; border: none; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer-inner { max-width: var(--max-w); margin: 0 auto; }
.footer-inner p { margin: 0.25rem 0; }
.disclaimer { font-size: 0.8rem; margin-top: 0.5rem; }

/* ── Theme toggle ── */
.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: border-color 0.15s;
}
.theme-btn:hover { border-color: var(--link); }

/* ── Code copy button ── */
.code-block-wrapper {
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,0.1);
  color: #a0a0b0;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.code-block-wrapper:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.copy-btn.copied { color: #a6e3a1; border-color: #a6e3a1; }

/* ── TOC sidebar ── */
.post-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  display: flex;
  gap: 3rem;
}
.post-layout .post-article {
  flex: 1;
  min-width: 0;
  max-width: var(--max-w);
  padding: 0;
}
.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: relative;
}
.toc-inner {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.toc-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.toc-nav ul { list-style: none; padding: 0; margin: 0; }
.toc-nav li { margin: 0; }
.toc-nav a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.toc-nav a:hover { color: var(--text); }
.toc-nav a.toc-active { color: var(--link); border-left-color: var(--link); }
.toc-nav ul ul a { padding-left: 1.5rem; font-size: 0.78rem; }
.toc-nav ul ul ul a { padding-left: 2.25rem; }

@media (max-width: 900px) {
  .toc-sidebar { display: none; }
  .post-layout { max-width: var(--max-w); }
}

/* ── Search ── */
.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.search-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: var(--link); }
.search-summary { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
