/* ============================
   SEO Knowledge Base - Design System v2
   Professional Blog Design
   ============================ */

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

:root {
  --color-navy: #1a1a2e;
  --color-navy-light: #16213e;
  --color-navy-mid: #1f2b47;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-50: #eff6ff;
  --color-text: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-bg: #ffffff;
  --color-bg-page: #f1f5f9;
  --color-bg-light: #f8fafc;
  --color-bg-code: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-accent: #dc2626;
  --color-accent-orange: #ea580c;
  --color-success: #16a34a;
  --color-purple: #7c3aed;
  --color-teal: #0d9488;
  --font-sans: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --max-width: 1200px;
  --sidebar-width: 300px;
  --header-height: 64px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

html { font-size: 16px; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 24px); }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg-page);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--color-primary); text-decoration: none; transition: color 0.2s, opacity 0.2s; }
a:hover { color: var(--color-primary-dark); }
img { max-width: 100%; height: auto; }
ul, ol { padding-left: 1.5em; }

/* ── Container & Layout ── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 48px 24px; }
.two-column {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 48px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px;
}
.content-main { min-width: 0; }

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-light) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.1);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}
.site-logo {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.site-logo::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  border-radius: 6px;
  flex-shrink: 0;
}
.site-logo:hover { color: #fff; text-decoration: none; }
.main-nav { display: flex; gap: 2px; }
.main-nav a {
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
}
.main-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
}

/* Mobile menu */
.mobile-menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.mobile-menu-btn span { display: block; width: 22px; height: 2px; background: #fff; margin: 5px 0; transition: 0.3s; border-radius: 1px; }
.mobile-menu-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ── Breadcrumb ── */
.breadcrumb {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 24px;
  font-size: 0.8125rem;
}
.breadcrumb-inner { max-width: var(--max-width); margin: 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.breadcrumb a { color: var(--color-text-secondary); font-weight: 500; }
.breadcrumb a:hover { color: var(--color-primary); text-decoration: underline; }
.breadcrumb span { color: var(--color-text-muted); margin: 0 4px; font-size: 0.75rem; }
.breadcrumb .current { color: var(--color-text); font-weight: 500; }

/* ── Hero (Top page) ── */
.hero-section {
  background: linear-gradient(150deg, #0f172a 0%, var(--color-navy) 30%, var(--color-navy-light) 70%, #1e3a5f 100%);
  color: #fff;
  padding: 80px 24px 88px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(37,99,235,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.hero-section::after {
  content: '';
  position: absolute;
  bottom: -50%;
  right: -10%;
  width: 50%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(124,58,237,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.hero-inner { max-width: 720px; margin: 0 auto; position: relative; z-index: 1; }
.hero-title { font-size: 2.75rem; font-weight: 900; margin-bottom: 16px; letter-spacing: -0.02em; line-height: 1.3; }
.hero-subtitle { font-size: 1.0625rem; opacity: 0.85; line-height: 1.9; margin-bottom: 36px; }
.hero-search { max-width: 520px; margin: 0 auto; position: relative; }
.hero-search input {
  width: 100%;
  padding: 16px 24px 16px 48px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: rgba(255,255,255,0.08);
  color: #fff;
  backdrop-filter: blur(8px);
  transition: all 0.3s;
}
.hero-search input::placeholder { color: rgba(255,255,255,0.5); }
.hero-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.2);
}
.hero-search::before {
  content: '🔍';
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.5;
  z-index: 1;
  pointer-events: none;
}

/* ── Section Titles ── */
.section-title {
  font-size: 1.375rem;
  font-weight: 800;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 24px;
  background: var(--color-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.page-header { margin-bottom: 40px; }
.page-header h1 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 12px;
  color: var(--color-text);
  line-height: 1.4;
}
.page-description { font-size: 1.0625rem; color: var(--color-text-secondary); line-height: 1.8; }

/* ── Featured Card ── */
.featured-card {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 48px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.featured-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-purple));
}
.featured-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-xl);
  border-color: var(--color-primary);
  transform: translateY(-3px);
}
.featured-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--color-accent), #ef4444);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.featured-card h3 { font-size: 1.5rem; color: var(--color-text); margin-bottom: 12px; line-height: 1.5; font-weight: 800; }
.featured-card p { color: var(--color-text-secondary); margin-bottom: 16px; line-height: 1.8; }
.read-more {
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: gap 0.2s;
}
.featured-card:hover .read-more,
.article-card:hover .read-more { gap: 8px; }

/* ── Article Grid ── */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}
.article-grid.full-width { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.article-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px 24px 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.article-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  background: var(--color-primary);
  border-radius: 3px 3px 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}
.article-card:hover {
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  border-color: transparent;
  transform: translateY(-4px);
}
.article-card:hover::after { opacity: 1; }

.article-card .card-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; font-size: 0.8125rem; }
.article-card .card-meta time { color: var(--color-text-muted); font-weight: 500; }
.article-card h3 { font-size: 1.125rem; color: var(--color-text); margin-bottom: 10px; line-height: 1.6; font-weight: 700; }
.article-card p { color: var(--color-text-secondary); font-size: 0.9375rem; flex: 1; line-height: 1.7; }
.article-card .read-more { margin-top: 16px; font-size: 0.875rem; }

/* ── Category Badge ── */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-decoration: none;
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.category-badge:hover { text-decoration: none; opacity: 0.85; }
.category-badge.secondary { background: #f1f5f9; color: var(--color-text-secondary); }

/* ── Article Detail ── */
.article-body, .glossary-body {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 48px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.article-header { margin-bottom: 36px; padding-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.article-header h1 { font-size: 2rem; font-weight: 900; line-height: 1.5; margin-top: 14px; color: var(--color-text); }
.article-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 0.875rem; }
.article-subtitle { font-size: 1.125rem; color: var(--color-text-secondary); margin-top: 12px; line-height: 1.7; }
.updated-badge { color: var(--color-success); font-size: 0.8125rem; font-weight: 500; }

/* ── Article Content Typography ── */
.article-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 56px 0 20px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--color-primary-50) 0%, #f0f4ff 100%);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text);
  line-height: 1.5;
}
.article-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 40px 0 16px;
  padding-left: 14px;
  border-left: 3px solid var(--color-teal);
  color: var(--color-text);
  line-height: 1.5;
}
.article-content h4 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--color-text);
  position: relative;
  padding-left: 16px;
}
.article-content h4::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-size: 0.875rem;
}
.article-content p { margin-bottom: 20px; line-height: 1.9; color: var(--color-text); }
.article-content ul, .article-content ol { margin-bottom: 20px; }
.article-content li { margin-bottom: 8px; line-height: 1.8; color: var(--color-text); }
.article-content li::marker { color: var(--color-primary); }
.article-content blockquote {
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-50);
  padding: 20px 24px;
  margin: 28px 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: normal;
}
.article-content blockquote p { color: var(--color-text-secondary); }
.article-content blockquote p:last-child { margin-bottom: 0; }
.article-content code {
  background: var(--color-bg-code);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: #be185d;
  border: 1px solid var(--color-border);
}
.article-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 24px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 24px 0;
  font-size: 0.875rem;
  line-height: 1.7;
  border: 1px solid #1e293b;
}
.article-content pre code { background: none; padding: 0; color: inherit; border: none; font-size: inherit; }
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
.article-content th {
  background: var(--color-navy);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  font-size: 0.875rem;
  border: none;
}
.article-content td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  border-left: none;
  border-right: none;
}
.article-content tr:nth-child(even) td { background: var(--color-bg-light); }
.article-content tr:hover td { background: var(--color-primary-50); }
.article-content strong { font-weight: 700; color: var(--color-text); }
.article-content a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.article-content a:hover { text-decoration-thickness: 2px; color: var(--color-primary-dark); }

/* ── Glossary Term Styles ── */
.glossary-header { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--color-border); }
.glossary-header h1 { font-size: 2rem; font-weight: 900; margin-top: 14px; color: var(--color-text); line-height: 1.4; }
.glossary-summary {
  background: linear-gradient(135deg, var(--color-primary-50) 0%, #f0f4ff 100%);
  border-left: 4px solid var(--color-primary);
  padding: 20px 24px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-top: 20px;
}
.definition { font-size: 1.0625rem; font-weight: 500; color: var(--color-text); line-height: 1.8; }

/* ── Pillar Link Box ── */
.pillar-link-box {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-mid) 50%, #1e3a5f 100%);
  color: #fff;
  padding: 32px 36px;
  border-radius: var(--radius-lg);
  margin: 48px 0;
  position: relative;
  overflow: hidden;
}
.pillar-link-box::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -5%;
  width: 40%;
  height: 160%;
  background: radial-gradient(ellipse, rgba(37,99,235,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.pillar-link-box h3 { font-size: 1.25rem; margin-bottom: 8px; font-weight: 700; position: relative; }
.pillar-link-box p { opacity: 0.85; margin-bottom: 20px; font-size: 0.9375rem; line-height: 1.7; position: relative; }
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--color-navy);
  padding: 12px 28px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9375rem;
  transition: all 0.3s;
  position: relative;
}
.btn-primary:hover { background: var(--color-primary-light); color: var(--color-primary); text-decoration: none; transform: translateX(4px); }

/* ── Related Box ── */
.related-box {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-top: 36px;
}
.related-box h3 { font-size: 1.0625rem; margin-bottom: 16px; font-weight: 700; color: var(--color-text); }
.related-box ul { list-style: none; padding: 0; }
.related-box li { margin-bottom: 8px; }
.related-box a {
  font-size: 0.9375rem;
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.related-box a::before { content: '→'; font-size: 0.75rem; color: var(--color-text-muted); }
.related-box a:hover { text-decoration: underline; }

/* ── Glossary Index ── */
.glossary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 40px;
  padding: 20px;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
.glossary-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 38px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  transition: all 0.2s;
}
.glossary-nav a:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); text-decoration: none; box-shadow: var(--shadow-sm); }
.glossary-section { margin-bottom: 48px; }
.glossary-section h2 {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--color-navy);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.glossary-card {
  display: block;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}
.glossary-card:hover {
  text-decoration: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.glossary-card h3 { font-size: 1rem; color: var(--color-primary); margin-bottom: 8px; font-weight: 700; }
.glossary-card p {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.7;
}

/* ── Algorithm Timeline ── */
.timeline { position: relative; padding-left: 36px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--color-primary), var(--color-purple));
  border-radius: 2px;
}
.timeline-entry { position: relative; margin-bottom: 48px; }
.timeline-entry::before {
  content: '';
  position: absolute;
  left: -32px;
  top: 8px;
  width: 14px;
  height: 14px;
  background: var(--color-primary);
  border: 3px solid var(--color-bg-page);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--color-primary);
}
.timeline-entry .timeline-year {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.timeline-entry h2 { font-size: 1.375rem; font-weight: 800; margin-bottom: 14px; color: var(--color-text); line-height: 1.4; }
.timeline-entry .timeline-content {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}
.timeline-entry:hover .timeline-content { box-shadow: var(--shadow-md); }
.timeline-entry .timeline-content p { margin-bottom: 12px; color: var(--color-text-secondary); line-height: 1.8; }
.timeline-entry .timeline-content p:last-child { margin-bottom: 0; }

/* ── Sidebar ── */
.sidebar { position: sticky; top: calc(var(--header-height) + 24px); align-self: start; }
.sidebar-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.sidebar-section h3 {
  font-size: 0.9375rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-border);
}
.sidebar-section ul { list-style: none; padding: 0; }
.sidebar-section li { margin-bottom: 4px; }
.sidebar-section li a {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.sidebar-section li a:hover { color: var(--color-primary); background: var(--color-primary-50); text-decoration: none; }
.sidebar-section p { font-size: 0.875rem; color: var(--color-text-secondary); line-height: 1.7; margin-bottom: 16px; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.btn-outline:hover { background: var(--color-primary); color: #fff; text-decoration: none; }
.btn-block { display: flex; justify-content: center; text-align: center; width: 100%; }

/* ── TOC ── */
.toc { max-height: 50vh; overflow-y: auto; }
.toc::-webkit-scrollbar { width: 3px; }
.toc::-webkit-scrollbar-track { background: transparent; }
.toc::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
.toc ul { list-style: none; padding: 0; }
.toc li { margin-bottom: 2px; }
.toc a {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  padding: 5px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.2s;
  line-height: 1.5;
}
.toc a:hover { color: var(--color-primary); background: var(--color-primary-50); border-left-color: var(--color-primary); text-decoration: none; }
.toc a.active { color: var(--color-primary); background: var(--color-primary-50); border-left-color: var(--color-primary); font-weight: 600; }
.toc .toc-h3 { padding-left: 26px; font-size: 0.8rem; }

/* ── Algo nav ── */
.algo-nav { max-height: 40vh; overflow-y: auto; }
.algo-nav a {
  display: block;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.algo-nav a:hover { color: var(--color-primary); background: var(--color-primary-50); text-decoration: none; }

/* ── Auto-linked glossary terms ── */
a.glossary-link {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-color: var(--color-teal);
  color: var(--color-teal);
}
a.glossary-link:hover { text-decoration-style: solid; color: var(--color-primary); }

/* ── Category list ── */
.category-list { list-style: none; padding: 0; }
.category-list li { margin-bottom: 2px; }
.category-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.category-list a:hover { color: var(--color-primary); background: var(--color-primary-50); text-decoration: none; }
.category-list .count {
  font-size: 0.6875rem;
  background: var(--color-bg-light);
  padding: 2px 10px;
  border-radius: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  border: 1px solid var(--color-border);
}

/* ── Glossary highlights ── */
.glossary-highlights { list-style: none; padding: 0; }
.glossary-highlights li { margin-bottom: 2px; }
.glossary-highlights a {
  font-size: 0.875rem;
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  transition: all 0.2s;
}
.glossary-highlights a:hover { color: var(--color-primary); background: var(--color-primary-50); text-decoration: none; }

/* ── Related terms ── */
.related-terms { list-style: none; padding: 0; }
.related-terms li { margin-bottom: 4px; }
.related-terms a {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.related-terms a:hover { color: var(--color-primary); background: var(--color-primary-50); text-decoration: none; }

/* ── Category Glossary Section ── */
.category-glossary { margin-top: 48px; }
.category-glossary h2 {
  font-size: 1.375rem;
  font-weight: 800;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
}
.category-glossary h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 24px;
  background: var(--color-teal);
  border-radius: 2px;
}

/* ── Footer ── */
.site-footer {
  background: var(--color-navy);
  color: rgba(255,255,255,0.8);
  margin-top: 0;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 56px 24px 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 48px; margin-bottom: 36px; }
.footer-col h3 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 20px;
  font-weight: 700;
  position: relative;
  padding-bottom: 10px;
}
.footer-col h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 32px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
}
.footer-col p { font-size: 0.875rem; line-height: 1.8; }
.footer-col ul { list-style: none; padding: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col a {
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.footer-col a::before { content: '›'; opacity: 0.5; }
.footer-col a:hover { color: #fff; text-decoration: none; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.4);
}

/* ── Search results overlay ── */
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 200;
}
.search-results.active { display: block; }
.search-results a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  font-size: 0.9375rem;
  transition: background 0.15s;
}
.search-results a:hover { background: var(--color-primary-50); text-decoration: none; }
.search-results .search-type {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── Algorithm Section on home page ── */
.algorithm-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}
.algorithm-section p { color: var(--color-text-secondary); margin: 12px 0 20px; line-height: 1.7; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .two-column { grid-template-columns: 1fr; gap: 32px; }
  .sidebar { position: static; }
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .article-grid { grid-template-columns: 1fr; }
  .glossary-grid { grid-template-columns: 1fr; }
  .article-body, .glossary-body { padding: 32px 24px; }
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: block; }
  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-navy);
    flex-direction: column;
    padding: 8px 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  }
  .main-nav.active { display: flex; }
  .main-nav a { padding: 12px 16px; font-size: 0.9375rem; }
  .hero-section { padding: 56px 16px 64px; }
  .hero-title { font-size: 2rem; }
  .hero-subtitle { font-size: 0.9375rem; }
  .container, .two-column { padding: 32px 16px; }
  .article-header h1, .glossary-header h1, .page-header h1 { font-size: 1.5rem; }
  .article-content h2 { font-size: 1.25rem; padding: 12px 16px; margin: 40px 0 16px; }
  .article-content h3 { font-size: 1.125rem; }
  .featured-card { padding: 24px; }
  .article-body, .glossary-body { padding: 24px 18px; border-radius: var(--radius-md); }
  .pillar-link-box { padding: 24px; }
  .site-logo::before { width: 24px; height: 24px; }
}

/* ── Print styles ── */
@media print {
  .site-header, .site-footer, .sidebar, .breadcrumb, .hero-search { display: none; }
  body { background: #fff; color: #000; }
  .article-body, .glossary-body { box-shadow: none; border: none; padding: 0; }
  .two-column { grid-template-columns: 1fr; }
}
