:root[data-theme="light"] {
  --bg: #f5f4ff;
  --bg2: #ffffff;
  --surface: rgba(255,255,255,0.9);
  --surface-border: rgba(124,58,237,0.1);
  --text-primary: #1a1040;
  --text-secondary: #4a3f72;
  --text-muted: #8a80a8;
  --accent: #7c3aed;
  --accent-hover: #5a23c8;
  --accent-light: rgba(124,58,237,0.08);
  --h-border: rgba(124,58,237,0.14);
  --code-bg: rgba(124,58,237,0.06);
  --blockquote-bg: rgba(124,58,237,0.05);
  --shadow: 0 4px 24px rgba(124,58,237,0.08);
  --shadow-lg: 0 12px 40px rgba(124,58,237,0.12);
}
:root[data-theme="dark"] {
  --bg: #0d0a1a;
  --bg2: #13102a;
  --surface: rgba(25,20,50,0.92);
  --surface-border: rgba(167,139,250,0.12);
  --text-primary: #f0edff;
  --text-secondary: #c4b8f0;
  --text-muted: #7a7098;
  --accent: #a78bfa;
  --accent-hover: #c4b8f0;
  --accent-light: rgba(167,139,250,0.1);
  --h-border: rgba(167,139,250,0.15);
  --code-bg: rgba(167,139,250,0.08);
  --blockquote-bg: rgba(167,139,250,0.07);
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.75;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  z-index: 999;
  transition: width 0.1s;
}

.hero-bar {
  background: linear-gradient(135deg, #7c3aed 0%, #4f23c8 50%, #2d1b8a 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
[data-theme="dark"] .hero-bar {
  background: linear-gradient(135deg, #4a23a8 0%, #2d1466 50%, #160a3a 100%);
}

.top-nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  gap: 1rem;
}
.nav-left { display: flex; align-items: center; gap: 0.75rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-radius: 100px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  transition: all 0.2s;
  white-space: nowrap;
}
.back-link:hover { background: rgba(255,255,255,0.22); transform: translateX(-2px); }
.site-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
}
.theme-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 100px;
  padding: 0.3rem 0.75rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.78rem;
  font-weight: 500;
  pointer-events: none;
}

.page-wrapper {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }

.toc {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.toc-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}
.toc-list {
  list-style: none;
  font-size: 0.9rem;
}
.toc-list li { margin: 0.25rem 0; }
.toc-list .toc-l3 { padding-left: 1.25rem; font-size: 0.86rem; }
.toc-list a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
.toc-list a:hover { color: var(--accent); }

.content-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow);
}

.article-header { margin-bottom: 2rem; border-bottom: 1px solid var(--h-border); padding-bottom: 1.25rem; }
.article-header h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.md-body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--h-border);
}
.md-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
.md-body p { margin: 0.9rem 0; color: var(--text-secondary); }
.md-body strong { color: var(--text-primary); font-weight: 700; }
.md-body ul, .md-body ol { margin: 0.9rem 0 0.9rem 1.5rem; color: var(--text-secondary); }
.md-body li { margin: 0.35rem 0; }
.md-body blockquote {
  background: var(--blockquote-bg);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  border-radius: 0 10px 10px 0;
  font-style: italic;
}
.md-body hr { border: none; border-top: 1px solid var(--h-border); margin: 1.75rem 0; }
.md-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.md-body a:hover { color: var(--accent-hover); }
.md-body code {
  background: var(--code-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.article-footer {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: var(--accent-light);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  text-align: center;
}
.article-footer p { color: var(--text-secondary); margin-bottom: 1rem; }
.cta-link {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  background: linear-gradient(135deg, #7c3aed, #5a23c8);
  color: #fff;
  text-decoration: none;
  border-radius: 100px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.back-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.back-top.visible { opacity: 1; pointer-events: auto; }
.back-top:hover { transform: translateY(-3px); }

/* ── Blog index ── */
.blog-index-header {
  text-align: center;
  padding: 2rem 0 1rem;
}
.blog-index-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}
.blog-subtitle { color: var(--text-secondary); font-size: 1rem; }

.post-list {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}
.post-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.post-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.post-card h2 a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.15s;
}
.post-card h2 a:hover { color: var(--accent); }
.post-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.post-card p { color: var(--text-secondary); margin-bottom: 0.75rem; font-size: 0.95rem; }
.read-more {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
}
.read-more:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .content-card { padding: 1.5rem 1.25rem; }
  .top-nav { padding: 0.7rem 1rem; }
  .site-badge, .nav-title { display: none; }
  .back-top { bottom: 1rem; right: 1rem; }
}
