@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&family=JetBrains+Mono:ital,wght@0,400;0,600;1,400&family=Manrope:wght@600;700;800;900&display=swap');

:root {
  --navy: #1a365d;
  --navy-light: #2a4a7f;
  --blue: #2563eb;
  --blue-soft: #3b82f6;
  --blue-light: #dbeafe;
  --blue-xlight: #eff6ff;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --green: #059669;
  --green-light: #d1fae5;
  --coral: #dc2626;
  --coral-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  --code-bg: #0d1117;
  --font-body: 'Noto Sans KR', sans-serif;
  --font-heading: 'Manrope', 'Noto Sans KR', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --sidebar-w: 270px;
  --header-h: 60px;
  --content-max: 820px;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--white);
  color: var(--gray-700);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ─── GLOBAL PROGRESS BAR ─── */
#global-progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  transition: width 0.6s ease;
  z-index: 999;
}

/* ─── HEADER ─── */
.site-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo .logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; font-weight: 700;
  font-family: var(--font-heading);
}
.header-logo .logo-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 17px;
  color: var(--navy);
  letter-spacing: -0.3px;
}
.header-logo .logo-sub {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
  display: block;
  line-height: 1;
}

.header-spacer { flex: 1; }

.header-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--gray-500);
}
.header-progress .progress-track {
  width: 100px;
  height: 6px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}
.header-progress .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  border-radius: 99px;
  transition: width 0.6s ease;
}

.header-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  font-family: var(--font-body);
  transition: all 0.15s;
  cursor: pointer;
}
.header-home-btn:hover {
  background: var(--blue-xlight);
  border-color: var(--blue-light);
  color: var(--blue);
}

/* ─── LAYOUT: SIDEBAR + MAIN ─── */
.page-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  padding: 24px 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  background: var(--gray-50);
}

.sidebar-section-label {
  padding: 4px 20px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gray-400);
}

.sidebar-nav { list-style: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13.5px;
  color: var(--gray-600);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.4;
}
.sidebar-nav a:hover {
  background: var(--white);
  color: var(--blue);
  border-left-color: var(--blue-light);
}
.sidebar-nav a.active {
  background: var(--blue-xlight);
  color: var(--blue);
  border-left-color: var(--blue);
  font-weight: 600;
}
.sidebar-nav a.done {
  color: var(--green);
}
.sidebar-nav a.done .ch-num { background: var(--green); color: white; }

.ch-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--gray-200);
  color: var(--gray-600);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.ch-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.sidebar-nav .check-icon {
  margin-left: auto;
  color: var(--green);
  font-size: 14px;
}

.sidebar-progress-wrap {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  margin-top: 12px;
}
.sidebar-progress-wrap .sp-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.sidebar-progress-wrap .sp-track {
  height: 8px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}
.sidebar-progress-wrap .sp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ─── MAIN CONTENT AREA ─── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: calc(var(--content-max) + 96px);
}

/* ─── CHAPTER HERO ─── */
.ch-hero {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--gray-200);
}
.ch-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-coral { background: var(--coral-light); color: var(--coral); }

.ch-hero h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.25;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}
.ch-hero .ch-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--gray-400);
  align-items: center;
  flex-wrap: wrap;
}
.ch-hero .ch-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ─── CONTENT TYPOGRAPHY ─── */
.content-body h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  margin: 36px 0 12px;
  padding-left: 14px;
  border-left: 4px solid var(--blue);
  letter-spacing: -0.3px;
}
.content-body h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 24px 0 8px;
}
.content-body p {
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--gray-600);
  margin-bottom: 16px;
}
.content-body ul, .content-body ol {
  margin: 12px 0 16px 24px;
}
.content-body li {
  font-size: 15px;
  color: var(--gray-600);
  margin-bottom: 6px;
  line-height: 1.7;
}
.content-body strong { color: var(--gray-800); font-weight: 600; }
.content-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--gray-100);
  color: var(--coral);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
}

/* ─── CODE BLOCK ─── */
.code-wrap {
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.1);
}
.code-header {
  background: #1e2430;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.code-header .code-lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #7c8db0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.code-header .code-title {
  font-size: 12px;
  color: #8892a4;
}
.code-copy-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #8892a4;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s;
}
.code-copy-btn:hover { background: rgba(255,255,255,0.15); color: white; }
.code-wrap pre {
  background: var(--code-bg);
  margin: 0;
  padding: 20px;
  overflow-x: auto;
}
.code-wrap pre code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  background: none;
  color: #e2e8f0;
  border: none;
  padding: 0;
}

/* Syntax colors */
.tok-keyword { color: #ff79c6; }
.tok-string  { color: #f1fa8c; }
.tok-comment { color: #6272a4; font-style: italic; }
.tok-func    { color: #50fa7b; }
.tok-class   { color: #8be9fd; }
.tok-num     { color: #bd93f9; }
.tok-decorator { color: #ffb86c; }
.tok-param   { color: #f8f8f2; }

/* ─── DIAGRAM CONTAINER ─── */
.diagram-wrap {
  margin: 24px 0;
  padding: 24px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.diagram-caption {
  font-size: 12.5px;
  color: var(--gray-400);
  text-align: center;
  font-style: italic;
}
.diagram-wrap svg { max-width: 100%; height: auto; }

/* ─── CALLOUT BOXES ─── */
.callout {
  margin: 20px 0;
  padding: 16px 20px;
  border-radius: var(--radius);
  border-left: 4px solid;
  font-size: 14.5px;
  line-height: 1.7;
}
.callout-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.3px;
}
.callout-blue { background: var(--blue-xlight); border-color: var(--blue); color: var(--gray-700); }
.callout-blue .callout-title { color: var(--blue); }
.callout-green { background: var(--green-light); border-color: var(--green); }
.callout-green .callout-title { color: var(--green); }
.callout-amber { background: var(--amber-light); border-color: var(--amber); }
.callout-amber .callout-title { color: var(--amber); }
.callout-purple { background: var(--purple-light); border-color: var(--purple); }
.callout-purple .callout-title { color: var(--purple); }

/* ─── SUMMARY BOX ─── */
.summary-box {
  margin: 32px 0;
  border: 1px solid var(--blue-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.summary-header {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  padding: 14px 20px;
  color: white;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary-body {
  padding: 20px;
  background: var(--blue-xlight);
}
.summary-body ul { list-style: none; margin: 0; padding: 0; }
.summary-body ul li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.summary-body ul li:last-child { border-bottom: none; }
.summary-body ul li::before {
  content: '✓';
  color: var(--blue);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ─── DEFINITION GRID ─── */
.def-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.def-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s;
}
.def-card:hover { box-shadow: var(--shadow-sm); }
.def-card .dc-icon { font-size: 24px; margin-bottom: 8px; }
.def-card .dc-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}
.def-card .dc-desc {
  font-size: 12.5px;
  color: var(--gray-500);
  line-height: 1.5;
}

/* ─── CHAPTER COMPLETION BUTTON ─── */
.completion-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.complete-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  color: white;
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.complete-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.complete-btn.done {
  background: linear-gradient(135deg, var(--green), #0d9488);
}

.ch-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.ch-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--gray-600);
  text-decoration: none;
  transition: all 0.15s;
}
.ch-nav a:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-xlight); }
.ch-nav a.prev::before { content: '←'; }
.ch-nav a.next::after { content: '→'; }

/* ─── INDEX PAGE ─── */
.index-hero {
  background: linear-gradient(150deg, var(--navy) 0%, #1e3a8a 50%, #1d4ed8 100%);
  color: white;
  padding: 80px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.index-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.index-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 16px;
  position: relative;
}
.index-hero p {
  font-size: 17px;
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto 32px;
  line-height: 1.7;
  position: relative;
}
.hero-badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}
.hero-badge {
  padding: 6px 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
}

.index-body { padding: 48px; max-width: 1100px; margin: 0 auto; }

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.section-sub {
  font-size: 14px;
  color: var(--gray-400);
  margin-bottom: 28px;
}

/* ─── CHAPTER GRID ─── */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 60px;
}
.chapter-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.chapter-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.chapter-card.c1::before { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.chapter-card.c2::before { background: linear-gradient(90deg, #d97706, #f59e0b); }
.chapter-card.c3::before { background: linear-gradient(90deg, #0d9488, #14b8a6); }
.chapter-card.c4::before { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.chapter-card.c5::before { background: linear-gradient(90deg, #059669, #10b981); }
.chapter-card.c6::before { background: linear-gradient(90deg, #dc2626, #ef4444); }
.chapter-card.c7::before { background: linear-gradient(90deg, #db2777, #ec4899); }
.chapter-card.c8::before { background: linear-gradient(90deg, #0284c7, #0ea5e9); }
.chapter-card.c9::before { background: linear-gradient(90deg, #1a365d, #2563eb); }

.chapter-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--gray-300);
}
.chapter-card .card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 600;
  letter-spacing: 1px;
}
.chapter-card .card-icon { font-size: 28px; }
.chapter-card .card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.chapter-card .card-desc {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.5;
  flex: 1;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}
.card-time {
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-done-badge {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-light);
  padding: 3px 9px;
  border-radius: 99px;
}
.chapter-card.done .card-done-badge { display: flex; }
.chapter-card.done { border-color: #a7f3d0; }

/* ─── FEATURES ROW ─── */
.features-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
  padding: 28px;
  background: var(--gray-50);
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
}
.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.feature-icon {
  font-size: 22px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.fi-blue { background: var(--blue-xlight); }
.fi-teal { background: var(--teal-light); }
.fi-amber { background: var(--amber-light); }
.fi-purple { background: var(--purple-light); }

.feature-item h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 3px;
}
.feature-item p {
  font-size: 12.5px;
  color: var(--gray-500);
  line-height: 1.4;
  margin: 0;
}

/* ─── HAMBURGER BUTTON ─── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--gray-600);
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
}
.hamburger-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--navy);
}

/* ─── SIDEBAR CLOSE ROW ─── */
.sidebar-close-row {
  display: none;
  justify-content: flex-end;
  padding: 12px 12px 4px;
}
.sidebar-close-row button {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px 10px;
  line-height: 1;
  transition: all 0.15s;
}
.sidebar-close-row button:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

/* ─── MOBILE SIDEBAR OVERLAY ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .hamburger-btn { display: flex; }
  .sidebar-close-row { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: min(var(--sidebar-w), 85vw);
    box-shadow: var(--shadow-lg);
    padding-top: 0;
    display: block;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { padding: 24px; }
  .index-body { padding: 24px; }
  .index-hero { padding: 48px 24px; }
}

@media (max-width: 600px) {
  .chapter-grid { grid-template-columns: 1fr; }
  .ch-hero h1 { font-size: 1.5rem; }
  .features-row { grid-template-columns: 1fr 1fr; }

  .header-logo .logo-sub { display: none; }
  .header-progress .progress-track { width: 64px; }

  .main-content { padding: 20px 16px; }
  .index-body { padding: 20px 16px; }
  .index-hero { padding: 40px 16px; }

  .code-wrap pre { padding: 14px; }
  .code-wrap pre code { font-size: 12.5px; }

  .callout { padding: 14px 16px; }
  .summary-body { padding: 16px; }
  .ch-nav { gap: 8px; }
  .ch-nav a { padding: 8px 14px; font-size: 13px; }
}

@media (max-width: 400px) {
  .features-row { grid-template-columns: 1fr; }
  .def-grid { grid-template-columns: 1fr; }
  .index-hero { padding: 28px 14px; }
  .index-hero h1 { font-size: 1.65rem; }
  .ch-hero h1 { font-size: 1.3rem; }
  .hero-badges { gap: 6px; }
  .hero-badge { font-size: 12px; padding: 4px 10px; }
  .site-header { padding: 0 14px; gap: 10px; }
  .header-logo .logo-text { font-size: 15px; }
  .complete-btn { padding: 12px 24px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════
   GROUP GRID — main dashboard
   ═══════════════════════════════════════════════════════ */
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
  margin-bottom: 60px;
}

.group-card {
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: inherit;
  transition: all 0.25s;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gray-200);
}
.group-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.gc-header {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gc-icon { font-size: 36px; line-height: 1; }
.gc-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.25);
}

.gc-body {
  padding: 22px 24px;
  flex: 1;
  background: var(--white);
}
.gc-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--navy);
  letter-spacing: -0.5px;
  line-height: 1.15;
}
.gc-subtitle {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
  margin-bottom: 12px;
  font-weight: 500;
}
.gc-desc {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.7;
  margin-bottom: 16px;
}
.gc-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gc-topics span {
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--gray-200);
}

.gc-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gray-50);
}
.gc-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  flex-shrink: 0;
}
.gc-progress-wrap {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
}
.gc-prog-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}
.gc-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

/* Color variants */
.gc-teal .gc-header  { background: linear-gradient(135deg, #0d9488, #0f766e); }
.gc-teal .gc-progress-wrap { background: #ccfbf1; }
.gc-teal .gc-prog-bar { background: var(--teal); }

.gc-purple .gc-header { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.gc-purple .gc-progress-wrap { background: var(--purple-light); }
.gc-purple .gc-prog-bar { background: var(--purple); }

.gc-blue .gc-header  { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.gc-blue .gc-progress-wrap { background: var(--blue-light); }
.gc-blue .gc-prog-bar { background: var(--blue); }

.gc-coral .gc-header { background: linear-gradient(135deg, #e11d48, #be123c); }
.gc-coral .gc-progress-wrap { background: var(--coral-light); }
.gc-coral .gc-prog-bar { background: var(--coral); }

/* ═══════════════════════════════════════════════════════
   GROUP HERO — group landing page
   ═══════════════════════════════════════════════════════ */
.group-hero {
  color: white;
  padding: 64px 48px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.group-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.group-hero-inner { position: relative; }
.gh-teal  { background: linear-gradient(150deg, #0f766e 0%, #0d9488 50%, #14b8a6 100%); }
.gh-purple { background: linear-gradient(150deg, #5b21b6 0%, #7c3aed 50%, #8b5cf6 100%); }
.gh-blue  { background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%); }
.gh-coral { background: linear-gradient(150deg, #9f1239 0%, #e11d48 50%, #f43f5e 100%); }

.gh-breadcrumb {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 20px;
}
.gh-breadcrumb a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
}
.gh-breadcrumb a:hover { color: white; }
.gh-breadcrumb span { margin: 0 6px; }

.gh-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 12px;
}
.gh-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.group-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 14px;
}
.group-hero p {
  font-size: 16px;
  opacity: 0.85;
  max-width: 600px;
  margin: 0 auto 28px;
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════
   TOPIC GRID — group landing page
   ═══════════════════════════════════════════════════════ */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 60px;
}

.topic-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.topic-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gray-200);
  transition: background 0.2s;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--gray-300);
}
.topic-card.done {
  border-color: #a7f3d0;
}
.topic-card.done::before { background: linear-gradient(90deg, var(--green), var(--teal)); }

.tc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 700;
  letter-spacing: 1px;
}
.tc-icon { font-size: 26px; }
.tc-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.tc-desc {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.55;
  flex: 1;
}
.tc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
}
.tc-tags span {
  font-size: 11px;
  color: var(--gray-400);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ═══════════════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════════════ */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.breadcrumb-nav a {
  color: var(--gray-500);
  text-decoration: none;
}
.breadcrumb-nav a:hover { color: var(--blue); }
.breadcrumb-nav span { color: var(--gray-300); }
.breadcrumb-nav span:last-child { color: var(--gray-600); font-weight: 500; }

/* ═══════════════════════════════════════════════════════
   SPEC TABLE — API reference
   ═══════════════════════════════════════════════════════ */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.spec-table thead tr {
  background: var(--navy);
  color: white;
}
.spec-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.4px;
}
.spec-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
}
.spec-table tbody tr:last-child { border-bottom: none; }
.spec-table tbody tr:hover { background: var(--blue-xlight); }
.spec-table td {
  padding: 10px 16px;
  color: var(--gray-700);
  vertical-align: top;
  line-height: 1.5;
}
.spec-table td:first-child {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--coral);
  white-space: nowrap;
}
.spec-table td code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--gray-100);
  color: var(--coral);
  padding: 1px 5px;
  border-radius: 3px;
}
.spec-table .td-req {
  font-size: 11px;
  font-weight: 700;
  color: var(--coral);
  white-space: nowrap;
}
.spec-table .td-opt {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  white-space: nowrap;
}
.spec-table .td-type {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--purple);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   PATTERN CARDS
   ═══════════════════════════════════════════════════════ */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.pattern-card {
  border-radius: var(--radius);
  padding: 18px;
  border-left: 4px solid;
}
.pattern-card.good {
  background: var(--green-light);
  border-color: var(--green);
}
.pattern-card.bad {
  background: var(--coral-light);
  border-color: var(--coral);
}
.pattern-card .pc-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.pattern-card.good .pc-label { color: var(--green); }
.pattern-card.bad .pc-label { color: var(--coral); }

.pattern-card .pc-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
.pattern-card .pc-desc {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.55;
}

/* ═══════════════════════════════════════════════════════
   COMPARISON TABLE
   ═══════════════════════════════════════════════════════ */
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.cmp-table thead tr { background: var(--gray-800); color: white; }
.cmp-table thead th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.3px; }
.cmp-table tbody tr { border-bottom: 1px solid var(--gray-100); }
.cmp-table tbody tr:last-child { border-bottom: none; }
.cmp-table td { padding: 9px 16px; color: var(--gray-700); }
.cmp-table td:first-child { font-weight: 600; color: var(--navy); }
.cmp-table .yes { color: var(--green); font-weight: 700; }
.cmp-table .no  { color: var(--coral); font-weight: 600; }
.cmp-table .partial { color: var(--amber); font-weight: 600; }

/* ═══════════════════════════════════════════════════════
   CHECKLIST
   ═══════════════════════════════════════════════════════ */
.checklist {
  list-style: none;
  margin: 16px 0;
  padding: 0;
}
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  line-height: 1.5;
}
.checklist li:last-child { border-bottom: none; }
.checklist li::before {
  content: '□';
  color: var(--gray-300);
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
.checklist li.done-item::before { content: '✓'; color: var(--green); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE — new components
   ═══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .group-grid { grid-template-columns: 1fr; }
  .group-hero { padding: 48px 24px; }
  .topic-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .group-grid { gap: 16px; }
  .gc-title { font-size: 1.3rem; }
  .group-hero { padding: 36px 16px; }
  .spec-table { font-size: 12px; }
  .spec-table td { padding: 8px 12px; }
  .pattern-grid { grid-template-columns: 1fr; }
}
