*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0c0f;
  --bg-card: #141419;
  --bg-code: #1a1a25;
  --border: #25252f;
  --text: #c9c7dd;
  --text-muted: #6b6b85;
  --heading: #f4f2ff;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-bg: rgba(167, 139, 250, 0.08);
  --green: #4ade80;
  --sky: #7dd3fc;
  --orange: #fb923c;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ── Header ── */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12, 12, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

header nav {
  display: flex; align-items: center;
  justify-content: space-between; height: 60px;
}

.logo a {
  font-size: 1.2rem; font-weight: 800;
  color: var(--heading); letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 32px; list-style: none; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.nav-links a:hover { color: var(--text); }

/* ── Hero ── */
.hero { padding: 80px 0 64px; text-align: center; }

.hero-badge {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800; line-height: 1.1;
  color: var(--heading); letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.hero-sub {
  max-width: 540px; margin: 0 auto 32px;
  font-size: 1.1rem; color: var(--text-muted); line-height: 1.6;
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #0c0c0f;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 700; font-size: 0.95rem;
  transition: background 0.2s, transform 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #0c0c0f;
  transform: translateY(-2px);
}

/* ── Section headers ── */
.section-header {
  display: flex; justify-content: space-between;
  align-items: baseline; margin-bottom: 28px;
}

.section-header h2 {
  font-size: 1.35rem; font-weight: 700;
  color: var(--heading); letter-spacing: -0.02em;
}

/* ── Article grid ── */
.articles { padding: 60px 0; }

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.article-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s, transform 0.2s;
  color: var(--text);
}

.article-card:hover {
  border-color: rgba(167, 139, 250, 0.5);
  transform: translateY(-2px);
  color: var(--text);
}

.article-card:hover .card-title { color: var(--accent-hover); }

.card-tag {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 3px 8px; border-radius: 4px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.05rem; font-weight: 700;
  color: var(--heading); line-height: 1.3;
  margin-bottom: 10px; transition: color 0.2s;
}

.card-excerpt {
  font-size: 0.875rem; color: var(--text-muted);
  line-height: 1.5; margin-bottom: 16px;
}

.card-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.78rem; color: var(--text-muted);
}

/* ── Topics ── */
.topics { padding: 0 0 64px; }

.topics-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.topic-pill {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 0.875rem; font-weight: 500; color: var(--text);
  transition: all 0.2s;
}

.topic-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── About ── */
.about { padding: 60px 0; border-top: 1px solid var(--border); }

.about-inner {
  max-width: 680px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px;
}

.about h2 {
  font-size: 1.35rem; font-weight: 700;
  color: var(--heading); margin-bottom: 14px;
}

.about p {
  color: var(--text-muted); line-height: 1.7;
  margin-bottom: 12px;
}

.about p:last-child { margin-bottom: 0; }

/* ── Footer ── */
footer { border-top: 1px solid var(--border); padding: 48px 0; }

.footer-inner {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 40px; flex-wrap: wrap;
}

.footer-brand .logo-text {
  font-size: 1.1rem; font-weight: 800;
  color: var(--heading); margin-bottom: 8px;
}

.footer-brand p {
  font-size: 0.825rem; color: var(--text-muted);
  max-width: 260px; line-height: 1.5;
}

.footer-links h4 {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 12px;
}

.footer-links ul { list-style: none; }
.footer-links ul li { margin-bottom: 8px; }
.footer-links ul li a { font-size: 0.875rem; color: var(--text-muted); }
.footer-links ul li a:hover { color: var(--accent); }

.footer-bottom {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center; font-size: 0.775rem; color: var(--text-muted);
}

/* ── Article page ── */
.article-page { padding: 60px 0 80px; }

.article-header { margin-bottom: 36px; }

.article-header .back-link {
  font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 20px; display: inline-block;
}

.article-header .back-link:hover { color: var(--accent); }

.article-header h1 {
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  font-weight: 800; color: var(--heading);
  line-height: 1.15; letter-spacing: -0.03em;
  margin: 12px 0 16px;
}

.article-meta {
  display: flex; gap: 20px;
  font-size: 0.82rem; color: var(--text-muted); flex-wrap: wrap;
}

.article-meta .tag { color: var(--accent); font-weight: 600; }

/* ── Table of contents ── */
.toc {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px 28px;
  margin-bottom: 40px;
}

.toc h3 {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-muted); margin-bottom: 14px;
}

.toc ol { margin-left: 20px; }
.toc ol li { margin-bottom: 7px; font-size: 0.875rem; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--accent); }

/* ── Article body ── */
.article-body { line-height: 1.78; }

.article-body h2 {
  font-size: 1.4rem; font-weight: 700; color: var(--heading);
  margin: 44px 0 16px; letter-spacing: -0.02em;
  padding-top: 20px; border-top: 1px solid var(--border);
}

.article-body h3 {
  font-size: 1.1rem; font-weight: 700;
  color: var(--heading); margin: 28px 0 10px;
}

.article-body p { margin-bottom: 18px; }

.article-body ul, .article-body ol { margin: 0 0 20px 24px; }
.article-body li { margin-bottom: 8px; }

.article-body strong { color: var(--heading); font-weight: 600; }

.article-body a { color: var(--accent); border-bottom: 1px solid rgba(167, 139, 250, 0.3); }
.article-body a:hover { color: var(--accent-hover); border-bottom-color: var(--accent-hover); }

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--sky);
  padding: 2px 6px; border-radius: 4px;
}

.article-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 24px;
}

.article-body pre code {
  background: none; padding: 0;
  font-size: 0.875rem; color: var(--text);
  line-height: 1.7;
}

/* Syntax highlight classes (manually applied in HTML) */
.comment { color: #4d4d6d; font-style: italic; }
.string { color: var(--green); }
.keyword { color: var(--accent); }
.number { color: var(--orange); }
.fn { color: var(--sky); }

/* ── Callout ── */
.callout {
  background: var(--accent-bg);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 24px;
}

.callout .callout-title {
  font-weight: 700; font-size: 0.85rem;
  color: var(--accent); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.callout p { margin-bottom: 0; }

/* ── Related articles ── */
.related {
  margin-top: 60px; padding-top: 40px;
  border-top: 1px solid var(--border);
}

.related h2 {
  font-size: 1.2rem; font-weight: 700;
  color: var(--heading); margin-bottom: 20px;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .nav-links { display: none; }
  .hero { padding: 56px 0 40px; }
  .footer-inner { flex-direction: column; gap: 32px; }
  .about-inner { padding: 28px; }
  .article-meta { gap: 12px; }
  .toc { padding: 20px; }
}
