/* ============================================================
   CSS Variables — Dark & Light Themes
   ============================================================ */
:root,
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-hover: #1a1a1a;
  --bg-sidebar: #0d0d0d;
  --bg-elevated: #161616;
  --border: #222222;
  --border-hover: #333333;
  --text: #ededed;
  --text-muted: #888888;
  --text-faint: #555555;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim: rgba(59, 130, 246, 0.12);
  --code-bg: #161616;
  --code-text: #abb2bf;
  --header-bg: rgba(10, 10, 10, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-card: #fafafa;
  --bg-hover: #f5f5f5;
  --bg-sidebar: #f9f9f9;
  --bg-elevated: #f0f0f0;
  --border: #e5e5e5;
  --border-hover: #cccccc;
  --text: #111111;
  --text-muted: #666666;
  --text-faint: #aaaaaa;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-dim: rgba(37, 99, 235, 0.08);
  --code-bg: #f5f5f5;
  --code-text: #383a42;
  --header-bg: rgba(255, 255, 255, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.08);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  loading: lazy;
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

/* ============================================================
   Layout Utilities
   ============================================================ */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-wrapper {
  flex: 1;
}

/* ============================================================
   Header & Navigation
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-container {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.nav-logo {
  flex-shrink: 0;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg-hover);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.icon {
  width: 16px;
  height: 16px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
}

.mobile-menu-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s;
}

.hamburger {
  position: relative;
}

.hamburger::before {
  content: '';
  position: absolute;
  top: -5px;
}

.hamburger::after {
  content: '';
  position: absolute;
  top: 5px;
}

.mobile-nav {
  display: none;
  flex-direction: column;
  padding: 8px 24px 16px;
  border-top: 1px solid var(--border);
}

.mobile-nav.open {
  display: flex;
}

.mobile-nav-link {
  padding: 10px 0;
  font-size: 15px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}

.mobile-nav-link:last-child {
  border-bottom: none;
}

.mobile-nav-link:hover {
  color: var(--text);
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-brand {
  font-weight: 600;
  color: var(--text-muted);
}

.footer-sep {
  color: var(--text-faint);
}

.footer-link {
  color: var(--text-muted);
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--accent);
}

/* ============================================================
   Homepage — Hero
   ============================================================ */
.hero {
  padding: 80px 24px 64px;
  text-align: center;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(48px, 8vw, 72px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}

.hero-tagline {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-ghost {
  padding: 10px 24px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text);
  background: var(--bg-hover);
}

/* ============================================================
   Homepage — Sections
   ============================================================ */
.home-section {
  max-width: 1280px;
  margin: 0 auto 64px;
  padding: 0 24px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-more {
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.15s;
}

.section-more:hover {
  color: var(--accent);
}

/* ============================================================
   Series Cards
   ============================================================ */
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.series-grid-full {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.series-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.series-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.series-card-stripe {
  height: 3px;
  width: 100%;
  flex-shrink: 0;
}

.series-card-inner {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.series-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.series-icon {
  font-size: 28px;
  line-height: 1;
}

.series-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}

.series-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.series-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.series-card-meta {
  margin-top: 8px;
}

.series-updated {
  font-size: 12px;
  color: var(--text-faint);
}

/* ============================================================
   Page Header (list pages)
   ============================================================ */
.page-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.page-desc {
  font-size: 15px;
  color: var(--text-muted);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 15px;
}

.empty-hint a {
  color: var(--accent);
}

/* ============================================================
   Post List (homepage + blog list)
   ============================================================ */
.post-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.post-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  transition: background 0.15s;
}

.post-item:last-child {
  border-bottom: none;
}

.post-item:hover {
  background: var(--bg-hover);
}

.post-item .post-title {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-item .post-date {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Post Cards (blog list page)
   ============================================================ */
.post-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}

.post-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.post-card-inner {
  padding: 20px 24px;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.post-card-meta time {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.post-tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 4px;
  padding: 2px 7px;
  transition: background 0.15s;
}

.post-tag:hover {
  background: var(--accent-dim);
}

.post-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.post-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   Tag Filter
   ============================================================ */
.tag-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.tag-btn {
  padding: 5px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  background: var(--bg-card);
  transition: all 0.15s;
}

.tag-btn:hover,
.tag-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ============================================================
   Changelog Timeline
   ============================================================ */
.changelog-timeline {
  position: relative;
  padding-left: 28px;
}

.changelog-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.changelog-item {
  position: relative;
  padding-bottom: 36px;
}

.changelog-dot {
  position: absolute;
  left: -28px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.changelog-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.changelog-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
  transition: color 0.15s;
}

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

.changelog-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   Series Reader — Three-Column Layout
   ============================================================ */
.reader-layout {
  display: grid;
  grid-template-columns: 240px 1fr 200px;
  grid-template-rows: auto;
  min-height: calc(100vh - 56px);
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
}

/* ---- Left Sidebar ---- */
.series-sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  grid-column: 1;
  grid-row: 1;
}

.series-sidebar::-webkit-scrollbar {
  width: 4px;
}

.series-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.series-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  z-index: 1;
}

.sidebar-series-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-series-title:hover {
  color: var(--accent);
}

.sidebar-close {
  display: none;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.sidebar-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-close svg {
  width: 16px;
  height: 16px;
}

.sidebar-nav {
  padding: 8px 0 24px;
}

.sidebar-item {
  position: relative;
}

.sidebar-link {
  display: block;
  padding: 7px 16px;
  font-size: 13.5px;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-item.active .sidebar-link {
  color: var(--accent);
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.sidebar-link-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Center Article ---- */
.article-main {
  grid-column: 2;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: 780px;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.article-breadcrumb a {
  color: var(--text-muted);
  transition: color 0.15s;
}

.article-breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb-sep {
  color: var(--text-faint);
}

.article-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 12px;
}

.article-meta {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 36px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--border);
}

/* Article pagination */
.article-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}

.pagination-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}

.pagination-link:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.pagination-link.next {
  text-align: right;
}

.pagination-label {
  font-size: 12px;
  color: var(--text-muted);
}

.pagination-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* ---- Right TOC ---- */
.toc-sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 24px 16px 24px 20px;
  border-left: 1px solid var(--border);
  grid-column: 3;
  grid-row: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.toc-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.toc-content ul {
  list-style: none;
}

.toc-content li {
  line-height: 1.5;
}

.toc-content a {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  padding: 3px 0 3px 8px;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-content a:hover {
  color: var(--text);
}

.toc-content a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-content ul ul a {
  padding-left: 20px;
  font-size: 12px;
}

/* Mobile sidebar toggle button */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transition: background 0.15s, transform 0.15s;
}

.sidebar-toggle:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 88;
}

/* ============================================================
   Single Post Layout
   ============================================================ */
.post-container {
  padding-top: 0;
  padding-bottom: 80px;
}

.post-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 0;
  max-width: 980px;
  margin: 0 auto;
}

.post-article {
  padding: 40px 48px 80px 0;
  min-width: 0;
}

.post-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.post-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.post-breadcrumb a {
  color: var(--text-muted);
  transition: color 0.15s;
}

.post-breadcrumb a:hover {
  color: var(--accent);
}

.post-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.post-meta time {
  font-size: 13px;
  color: var(--text-faint);
}

/* ============================================================
   Prose (article content styles)
   ============================================================ */
.prose {
  color: var(--text);
  font-size: 15px;
  line-height: 1.85;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  scroll-margin-top: 80px;
}

.prose h1 { font-size: 28px; margin: 48px 0 20px; }
.prose h2 { font-size: 22px; margin: 40px 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 18px; margin: 32px 0 12px; }
.prose h4 { font-size: 16px; margin: 24px 0 10px; }

.prose p { margin-bottom: 20px; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

.prose a:hover {
  text-decoration-color: var(--accent);
}

.prose strong { font-weight: 600; }
.prose em { font-style: italic; }

.prose ul, .prose ol {
  margin: 0 0 20px 0;
  padding-left: 0;
  list-style: none;
}

.prose ul li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 6px;
}

.prose ul li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

.prose ol {
  counter-reset: list;
}

.prose ol li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 6px;
  counter-increment: list;
}

.prose ol li::before {
  content: counter(list) '.';
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 24px 0;
  background: var(--bg-elevated);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  font-style: italic;
}

.prose blockquote p {
  margin-bottom: 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
  overflow-x: auto;
  display: block;
}

.prose th {
  background: var(--bg-elevated);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.prose td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose img {
  border-radius: 8px;
  margin: 24px 0;
  max-width: 100%;
  display: block;
}

/* Inline code */
.prose code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--code-text);
}

/* ============================================================
   Code Blocks (Chroma)
   ============================================================ */
.prose .highlight,
.highlight {
  position: relative;
  margin: 24px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--code-bg);
}

.highlight pre {
  overflow-x: auto;
  padding: 20px;
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13.5px;
  line-height: 1.7;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.highlight pre::-webkit-scrollbar {
  height: 4px;
}

.highlight pre::-webkit-scrollbar-track {
  background: transparent;
}

.highlight pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Code block header (injected by JS) */
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  text-transform: lowercase;
}

.code-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  cursor: pointer;
  font-family: inherit;
}

.code-copy:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.code-copy.copied {
  color: #22c55e;
  border-color: #22c55e;
}

/* Line numbers */
.chroma .lnt {
  user-select: none;
  color: var(--text-faint);
  margin-right: 16px;
  display: inline-block;
  min-width: 1.5em;
  text-align: right;
}

/* ============================================================
   One Dark syntax highlight theme (Chroma classes)
   ============================================================ */
.chroma { color: #abb2bf; background: transparent; }
.chroma .err { color: #e06c75; }
.chroma .hl { background: rgba(255,255,255,0.05); display: block; }
.chroma .ln { color: #5c6370; }
.chroma .k  { color: #c678dd; }
.chroma .kc { color: #c678dd; }
.chroma .kd { color: #c678dd; }
.chroma .kn { color: #c678dd; }
.chroma .kp { color: #c678dd; }
.chroma .kr { color: #c678dd; }
.chroma .kt { color: #e5c07b; }
.chroma .na { color: #e06c75; }
.chroma .nb { color: #56b6c2; }
.chroma .nc { color: #e5c07b; }
.chroma .nd { color: #61afef; }
.chroma .ne { color: #e06c75; }
.chroma .nf { color: #61afef; }
.chroma .ni { color: #56b6c2; }
.chroma .nl { color: #abb2bf; }
.chroma .nn { color: #e5c07b; }
.chroma .nt { color: #e06c75; }
.chroma .nv { color: #e06c75; }
.chroma .nx { color: #61afef; }
.chroma .s  { color: #98c379; }
.chroma .s1 { color: #98c379; }
.chroma .s2 { color: #98c379; }
.chroma .sa { color: #98c379; }
.chroma .sb { color: #98c379; }
.chroma .sc { color: #98c379; }
.chroma .dl { color: #98c379; }
.chroma .sd { color: #98c379; }
.chroma .se { color: #56b6c2; }
.chroma .si { color: #56b6c2; }
.chroma .sx { color: #98c379; }
.chroma .sr { color: #56b6c2; }
.chroma .ss { color: #98c379; }
.chroma .m  { color: #d19a66; }
.chroma .mb { color: #d19a66; }
.chroma .mf { color: #d19a66; }
.chroma .mh { color: #d19a66; }
.chroma .mi { color: #d19a66; }
.chroma .il { color: #d19a66; }
.chroma .mo { color: #d19a66; }
.chroma .o  { color: #56b6c2; }
.chroma .ow { color: #56b6c2; }
.chroma .p  { color: #abb2bf; }
.chroma .c  { color: #5c6370; font-style: italic; }
.chroma .c1 { color: #5c6370; font-style: italic; }
.chroma .cm { color: #5c6370; font-style: italic; }
.chroma .cs { color: #5c6370; font-style: italic; }
.chroma .cp { color: #5c6370; }
.chroma .cpf{ color: #5c6370; }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: bold; }
.chroma .gu { color: #56b6c2; font-weight: bold; }
.chroma .gh { color: #e06c75; font-weight: bold; }
.chroma .gp { color: #5c6370; user-select: none; }
.chroma .gr { color: #e06c75; }
.chroma .gt { color: #e06c75; }
.chroma .w  { color: #abb2bf; }

/* Light theme syntax */
[data-theme="light"] .chroma { color: #383a42; }
[data-theme="light"] .chroma .k  { color: #a626a4; }
[data-theme="light"] .chroma .kc { color: #a626a4; }
[data-theme="light"] .chroma .kd { color: #a626a4; }
[data-theme="light"] .chroma .kn { color: #a626a4; }
[data-theme="light"] .chroma .kr { color: #a626a4; }
[data-theme="light"] .chroma .kt { color: #c18401; }
[data-theme="light"] .chroma .na { color: #e45649; }
[data-theme="light"] .chroma .nb { color: #0184bc; }
[data-theme="light"] .chroma .nc { color: #c18401; }
[data-theme="light"] .chroma .nf { color: #4078f2; }
[data-theme="light"] .chroma .ni { color: #0184bc; }
[data-theme="light"] .chroma .nt { color: #e45649; }
[data-theme="light"] .chroma .nv { color: #e45649; }
[data-theme="light"] .chroma .nx { color: #4078f2; }
[data-theme="light"] .chroma .s  { color: #50a14f; }
[data-theme="light"] .chroma .s1 { color: #50a14f; }
[data-theme="light"] .chroma .s2 { color: #50a14f; }
[data-theme="light"] .chroma .se { color: #0184bc; }
[data-theme="light"] .chroma .si { color: #0184bc; }
[data-theme="light"] .chroma .sr { color: #0184bc; }
[data-theme="light"] .chroma .m  { color: #986801; }
[data-theme="light"] .chroma .mb { color: #986801; }
[data-theme="light"] .chroma .mf { color: #986801; }
[data-theme="light"] .chroma .mi { color: #986801; }
[data-theme="light"] .chroma .o  { color: #0184bc; }
[data-theme="light"] .chroma .ow { color: #0184bc; }
[data-theme="light"] .chroma .c  { color: #a0a1a7; font-style: italic; }
[data-theme="light"] .chroma .c1 { color: #a0a1a7; font-style: italic; }
[data-theme="light"] .chroma .cm { color: #a0a1a7; font-style: italic; }

/* ============================================================
   Responsive — Tablet (≤1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .reader-layout {
    grid-template-columns: 240px 1fr;
  }

  .toc-sidebar {
    display: none;
  }

  .post-layout {
    grid-template-columns: 1fr;
  }

  .post-layout .toc-sidebar {
    display: none;
  }
}

/* ============================================================
   Responsive — Mobile (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .hero {
    padding: 56px 24px 48px;
  }

  .hero-title {
    font-size: 52px;
  }

  .reader-layout {
    grid-template-columns: 1fr;
    position: relative;
  }

  .series-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    width: 280px;
    z-index: 89;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }

  .series-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: flex;
  }

  .article-main {
    padding: 24px 20px 64px;
    grid-column: 1;
  }

  .article-title {
    font-size: 24px;
  }

  .article-pagination {
    grid-template-columns: 1fr;
  }

  .series-grid,
  .series-grid-full {
    grid-template-columns: 1fr;
  }

  .home-section {
    margin-bottom: 48px;
    padding: 0 16px;
  }

  .page-header {
    padding: 32px 0 24px;
  }

  .page-title {
    font-size: 26px;
  }

  .container {
    padding: 0 16px;
  }

  .post-article {
    padding: 32px 0 64px;
  }

  .prose { font-size: 15px; }
  .prose h1 { font-size: 24px; }
  .prose h2 { font-size: 20px; }
  .prose h3 { font-size: 17px; }

  .post-card-inner {
    padding: 16px;
  }
}

/* ============================================================
   Utility: scrollbar hidden for sidebar in mobile
   ============================================================ */
@media (max-width: 480px) {
  .hero-title {
    font-size: 42px;
  }

  .hero-tagline {
    font-size: 16px;
  }

  .hero-cta {
    flex-direction: column;
    align-items: center;
  }
}
