/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-light: #6b7c93;
  --text-muted: #95a5b8;
  --primary: #4a90d9;
  --primary-hover: #3a7bc8;
  --accent: #e8f0fe;
  --border: #e8ecf1;
  --border-light: #f0f3f6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Noto Sans SC', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --max-width: 960px;
  --transition: 0.2s ease;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
}

/* ===== Base ===== */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }
hr { border: none; border-top: 1px solid var(--border-light); margin: 1.5rem 0; }

/* ===== Layout ===== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
.main-content { flex: 1; padding: 2rem 0 3rem; }

/* ===== Navbar ===== */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}
.nav-container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.nav-brand {
  font-size: 1.2rem; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em;
}
.nav-brand:hover { color: var(--primary); }
.nav-menu { display: flex; align-items: center; gap: 0.25rem; }
.nav-link {
  padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; color: var(--text-light); font-weight: 500;
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active { color: var(--primary); background: var(--accent); }
.nav-search input {
  border: 1px solid var(--border); border-radius: 20px;
  padding: 0.35rem 0.9rem; font-size: 0.85rem;
  outline: none; width: 160px; transition: all var(--transition);
  background: var(--bg);
}
.nav-search input:focus { border-color: var(--primary); width: 200px; background: #fff; }
.nav-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; }

/* ===== Page Header ===== */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.page-header p { color: var(--text-light); margin-top: 0.3rem; font-size: 0.95rem; }

/* ===== Article List ===== */
.article-list { display: flex; flex-direction: column; gap: 1.25rem; }
.article-card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden; transition: all var(--transition);
}
.article-card:hover { box-shadow: var(--shadow); border-color: var(--border); transform: translateY(-1px); }
.article-cover img { width: 100%; height: 200px; object-fit: cover; }
.article-body { padding: 1.25rem 1.5rem; }
.article-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap; }
.article-title { font-size: 1.2rem; font-weight: 600; line-height: 1.5; margin-bottom: 0.5rem; }
.article-title a { color: var(--text); }
.article-title a:hover { color: var(--primary); }
.article-summary { color: var(--text-light); font-size: 0.92rem; line-height: 1.7; margin-bottom: 0.75rem; }
.article-footer { display: flex; justify-content: space-between; align-items: center; }
.article-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.meta-author { font-size: 0.85rem; color: var(--text-muted); }

/* ===== Badges & Tags ===== */
.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px;
  font-size: 0.75rem; font-weight: 500; line-height: 1.5;
}
.badge-primary { background: var(--accent); color: var(--primary); }
.badge-danger { background: #fde8e8; color: var(--danger); }
.badge-sm { font-size: 0.7rem; padding: 0.1rem 0.4rem; }
.tag {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 20px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 0.78rem; color: var(--text-light);
  transition: all var(--transition);
}
.tag:hover { border-color: var(--primary); color: var(--primary); background: var(--accent); }
.tag-lg { padding: 0.35rem 0.9rem; font-size: 0.88rem; }
.tag-count { font-size: 0.72rem; color: var(--text-muted); margin-left: 0.2rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* ===== Article Detail ===== */
.article-detail { max-width: 780px; margin: 0 auto; }
.article-header { margin-bottom: 2rem; text-align: center; }
.article-header h1 { font-size: 1.8rem; font-weight: 700; line-height: 1.4; margin: 0.75rem 0; }
.article-header .article-meta { justify-content: center; }
.article-header .article-tags { justify-content: center; margin-top: 0.6rem; }

/* ===== Markdown Body ===== */
.markdown-body { font-size: 1rem; line-height: 1.85; color: var(--text); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 1.8rem 0 0.8rem; font-weight: 600; line-height: 1.4; color: var(--text);
}
.markdown-body h2 { font-size: 1.4rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border-light); }
.markdown-body h3 { font-size: 1.2rem; }
.markdown-body p { margin-bottom: 1rem; }
.markdown-body ul, .markdown-body ol { margin: 0.8rem 0; padding-left: 1.5rem; }
.markdown-body li { margin: 0.35rem 0; }
.markdown-body blockquote {
  margin: 1.2rem 0; padding: 0.8rem 1.2rem;
  border-left: 3px solid var(--primary);
  background: var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-light);
}
.markdown-body code {
  font-family: var(--font-mono); font-size: 0.88em;
  background: #f0f3f6; padding: 0.15em 0.4em; border-radius: 4px; color: #c0392b;
}
.markdown-body pre {
  margin: 1.2rem 0; padding: 1rem 1.2rem; border-radius: var(--radius-sm);
  background: #1e2127; overflow-x: auto; line-height: 1.5;
}
.markdown-body pre code { background: none; color: #abb2bf; padding: 0; font-size: 0.85rem; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.markdown-body th, .markdown-body td { padding: 0.6rem 0.8rem; border: 1px solid var(--border); text-align: left; }
.markdown-body th { background: var(--bg); font-weight: 600; }
.markdown-body img { border-radius: var(--radius-sm); margin: 1rem auto; }
.markdown-body a { color: var(--primary); border-bottom: 1px solid transparent; }
.markdown-body a:hover { border-bottom-color: var(--primary); }

/* ===== TOC ===== */
.toc {
  background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 1rem 1.5rem; margin-bottom: 2rem;
}
.toc h3 { font-size: 0.95rem; margin-bottom: 0.5rem; color: var(--text); }
.toc ul { list-style: none; padding: 0; }
.toc li { margin: 0.3rem 0; }
.toc a { color: var(--text-light); font-size: 0.88rem; }
.toc a:hover { color: var(--primary); }
.toc .toc-level-2 { padding-left: 1rem; }
.toc .toc-level-3 { padding-left: 2rem; font-size: 0.84rem; }

/* ===== Article Nav ===== */
.article-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin: 2.5rem 0; padding: 1.2rem 0; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light);
}
.article-nav a { color: var(--primary); font-size: 0.9rem; max-width: 45%; }
.nav-prev::before { content: '← '; }
.nav-next::after { content: ' →'; }

/* ===== Related Articles ===== */
.related-articles { margin: 2rem 0; }
.related-articles h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.related-articles ul { list-style: none; padding: 0; }
.related-articles li { padding: 0.4rem 0; border-bottom: 1px solid var(--border-light); }
.related-articles a { color: var(--text); font-size: 0.92rem; }
.related-articles a:hover { color: var(--primary); }

/* ===== Comments ===== */
.comments-section { margin-top: 3rem; }
.comments-section h3 { font-size: 1.15rem; margin-bottom: 1.2rem; }
.comment {
  padding: 1rem 0; border-bottom: 1px solid var(--border-light);
}
.comment-meta { display: flex; gap: 0.8rem; align-items: baseline; margin-bottom: 0.4rem; }
.comment-meta strong { font-size: 0.92rem; }
.comment-meta span { font-size: 0.78rem; color: var(--text-muted); }
.comment-body { font-size: 0.92rem; color: var(--text-light); line-height: 1.7; }
.comment.reply { margin-left: 2rem; padding-left: 1rem; border-left: 2px solid var(--border-light); }
.comment-form { margin-top: 1.5rem; }
.comment-form h4 { font-size: 1rem; margin-bottom: 0.8rem; }

/* ===== Grid Cards ===== */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 1.25rem; transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border); }
.card h3 { font-size: 1.05rem; margin-bottom: 0.4rem; color: var(--text); }
.card p { font-size: 0.88rem; color: var(--text-light); margin-bottom: 0.5rem; }

/* ===== Archive ===== */
.archive-list { max-width: 700px; }
.archive-group { margin-bottom: 1.5rem; }
.archive-month { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--primary); }
.archive-group ul { list-style: none; padding: 0; }
.archive-group li { display: flex; gap: 0.8rem; align-items: center; padding: 0.4rem 0; }
.archive-date { font-size: 0.82rem; color: var(--text-muted); min-width: 80px; font-family: var(--font-mono); }
.archive-group li a { color: var(--text); font-size: 0.92rem; }
.archive-group li a:hover { color: var(--primary); }

/* ===== Search ===== */
.search-form { display: flex; gap: 0.6rem; margin-top: 0.8rem; max-width: 500px; }
.search-input { flex: 1; }
.search-info { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.2rem; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--text); }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 0.55rem 0.8rem; font-size: 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; line-height: 1.6; }
.form-row { display: flex; gap: 0.8rem; margin-bottom: 0.8rem; }
.form-row .form-input { flex: 1; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1.1rem; font-size: 0.88rem; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition); font-family: var(--font);
  text-decoration: none; line-height: 1.5;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { background: transparent; color: var(--text-light); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* ===== Auth Pages ===== */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 50vh; }
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 2rem 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow);
}
.auth-card h2 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.88rem; color: var(--text-muted); }

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-danger { background: #fde8e8; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-warning { background: #fff8e1; color: #856404; border: 1px solid #ffeaa7; }
.alert-success { background: #d4edda; color: var(--success); border: 1px solid #c3e6cb; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; gap: 0.35rem; margin-top: 2rem; }
.page-link {
  padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; color: var(--text-light); transition: all var(--transition);
}
.page-link:hover, .page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Error Page ===== */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 3rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.error-page p { color: var(--text-light); margin-bottom: 1.5rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }

/* ===== About ===== */
.about-content { max-width: 700px; }
.about-content blockquote { font-style: italic; }

/* ===== Footer ===== */
.footer {
  background: var(--bg-card); border-top: 1px solid var(--border-light);
  padding: 1.5rem 0; text-align: center; font-size: 0.82rem; color: var(--text-muted);
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .nav-toggle { display: block; }
  .nav-menu {
    display: none; flex-direction: column; position: absolute;
    top: 60px; left: 0; right: 0; background: var(--bg-card);
    border-bottom: 1px solid var(--border); padding: 1rem;
    box-shadow: var(--shadow);
  }
  .nav-menu.active { display: flex; }
  .nav-search { width: 100%; }
  .nav-search input { width: 100%; }
  .container { padding: 0 1rem; }
  .form-row { flex-direction: column; }
  .article-header h1 { font-size: 1.4rem; }
  .grid-cards { grid-template-columns: 1fr; }
  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }
}

@media (max-width: 480px) {
  .article-body { padding: 1rem; }
  .auth-card { padding: 1.5rem; }
  .comment.reply { margin-left: 1rem; }
}
