:root {
  --text-primary: #1a1a1a;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --border: #e5e7eb;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { font-family: "Sora", system-ui, sans-serif; font-weight: 700; line-height: 1.25; color: var(--text-primary); }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin: 1.5rem 0 0.75rem; }
h2 { font-size: 1.6rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }

/* ── Header ──────────────────────────────────────────────────────── */
.blog-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.blog-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
}
.blog-logo { font-family: "Sora", sans-serif; font-weight: 800; font-size: 1.1rem; color: var(--text-primary); text-decoration: none; }
.blog-logo span { color: var(--accent); }
.blog-nav { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
.blog-nav a { color: var(--text-secondary); font-weight: 500; }
.blog-nav a:hover { color: var(--accent); text-decoration: none; }

/* ── Container ───────────────────────────────────────────────────── */
.blog-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.blog-hero { text-align: center; margin: 2rem 0 3rem; }
.blog-hero h1 { margin-top: 0; }
.blog-hero p { color: var(--text-secondary); font-size: 1.05rem; max-width: 640px; margin: 0.5rem auto 1.5rem; }

.search-form { display: flex; gap: 0.5rem; max-width: 480px; margin: 0 auto; justify-content: center; }
.search-input {
  flex: 1; padding: 0.6rem 0.85rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.95rem; font-family: inherit; outline: none;
}
.search-input:focus { border-color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1rem; border-radius: 6px; border: none;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

/* ── Post grid ───────────────────────────────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.75rem;
  margin-bottom: 3rem;
}
.post-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex; flex-direction: column;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border-color: var(--accent);
}
.post-card-img { width: 100%; height: 200px; object-fit: cover; }
.post-card-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.post-card-body h2 { font-size: 1.15rem; margin: 0.25rem 0; line-height: 1.35; }
.post-card-body h2 a { color: var(--text-primary); }
.post-card-body h2 a:hover { color: var(--accent); text-decoration: none; }
.post-card-excerpt { color: var(--text-secondary); font-size: 0.9rem; margin: 0; flex: 1; }
.post-card-meta { color: var(--text-muted); font-size: 0.8rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }

.badge-category {
  display: inline-block; padding: 0.18rem 0.55rem; border-radius: 99px;
  background: rgba(124, 58, 237, 0.1); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 0.35rem; justify-content: center;
  margin: 2rem 0; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 0.7rem;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-secondary); font-size: 0.88rem; font-weight: 500;
  text-decoration: none;
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Breadcrumbs ─────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex; gap: 0.5rem; align-items: center;
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 1rem; flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs .separator { color: var(--text-muted); }

/* ── Post (individual) ───────────────────────────────────────────── */
.post-header { margin-bottom: 1.5rem; }
.post-header h1 { margin: 0.5rem 0 0.75rem; }
.post-meta { color: var(--text-muted); font-size: 0.9rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.post-meta .author { color: var(--text-primary); font-weight: 600; }

.post-cover {
  width: 100%; max-height: 480px; object-fit: cover;
  border-radius: 12px; margin-bottom: 2rem;
}

.post-layout {
  display: grid; grid-template-columns: 1fr 260px; gap: 2.5rem;
  margin: 2rem 0;
}
@media (max-width: 900px) {
  .post-layout { grid-template-columns: 1fr; }
}

.post-article { font-size: 1.05rem; line-height: 1.75; max-width: 720px; }
.post-article h2 { margin-top: 2rem; font-size: 1.5rem; }
.post-article h3 { margin-top: 1.5rem; font-size: 1.2rem; }
.post-article p { margin-bottom: 1.1rem; }
.post-article img { border-radius: 8px; margin: 1rem 0; }
.post-article a { color: var(--accent); }
.post-article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--text-secondary);
  margin: 1.25rem 0;
  font-style: italic;
}
.post-article code { background: var(--bg-tertiary); padding: 0.15rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.post-article pre { background: var(--bg-tertiary); padding: 1rem; border-radius: 8px; overflow-x: auto; }
.post-article pre code { background: transparent; padding: 0; }
.post-article table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.post-article th, .post-article td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.post-article th { background: var(--bg-secondary); font-weight: 600; }
.post-article ul, .post-article ol { padding-left: 1.5rem; }
.post-article li { margin-bottom: 0.4rem; }
.post-article hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.post-article figure { margin: 1.5rem 0; }
.post-article figcaption { color: var(--text-muted); font-size: 0.85rem; text-align: center; margin-top: 0.5rem; }

/* ── TOC ─────────────────────────────────────────────────────────── */
.toc {
  position: sticky; top: 100px;
  align-self: start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  font-size: 0.88rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.toc-title {
  font-weight: 700; font-size: 0.78rem; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin-bottom: 0.5rem; }
.toc li.level-3 { padding-left: 1rem; font-size: 0.85rem; }
.toc a { color: var(--text-secondary); display: block; line-height: 1.4; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc a.active { color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .toc { position: static; max-height: none; }
}

/* ── Tags ────────────────────────────────────────────────────────── */
.tag-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badge-tag {
  display: inline-block; padding: 0.3rem 0.7rem;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 99px; font-size: 0.82rem;
  color: var(--text-secondary); text-decoration: none;
}
.badge-tag:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

/* ── Author card ─────────────────────────────────────────────────── */
.author-card {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.25rem; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 10px;
  margin: 2rem 0;
}
.author-avatar { width: 64px; height: 64px; border-radius: 99px; object-fit: cover; flex-shrink: 0; }
.author-name a { color: var(--text-primary); font-weight: 700; font-size: 1rem; }
.author-name a:hover { color: var(--accent); text-decoration: none; }
.author-role { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ── 404 ─────────────────────────────────────────────────────────── */
.blog-404 { text-align: center; padding: 5rem 1rem; }
.blog-404 h1 { font-size: 4rem; margin: 0; }

/* ── Footer ──────────────────────────────────────────────────────── */
.blog-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  margin-top: 4rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}