@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a0e27;
  --bg-secondary: #111638;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --text-primary: #e8eaf6;
  --text-secondary: #9fa4c4;
  --text-muted: #9ea3c7;
  --accent-primary: #ec4899;
  --accent-light: #f472b6;
  --accent-amber: #f59e0b;
  --accent-teal: #06b6d4;
  --accent-green: #10b981;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --gradient-hero: linear-gradient(135deg, #be185d 0%, #ec4899 100%);
  --gradient-warm: linear-gradient(135deg, #b45309 0%, #be185d 100%);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(236, 72, 153, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.8;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
img { -webkit-user-drag: none; }
h1, h2, h3, h4, h5 { font-family: 'Outfit', sans-serif; line-height: 1.3; }

/* ===== PARTICLES ===== */
#particles-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: 0.4;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; width: 300px; height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 100; display: flex; flex-direction: column;
  transition: transform var(--transition); overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-300px); }

.sidebar-header {
  padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-header img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; }
.sidebar-header h2 {
  font-size: 1.05rem; font-weight: 700;
  background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-header span { font-size: 0.75rem; color: var(--text-muted); }

.nav-list { list-style: none; padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition);
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  margin-bottom: 2px; position: relative;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active { background: rgba(236,72,153,0.15); color: #f472b6; }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--accent-primary); border-radius: 4px;
}
.nav-num {
  width: 28px; height: 28px; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; font-size: 0.75rem;
  font-weight: 700; background: var(--bg-glass); flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}
.nav-item.active .nav-num { background: rgba(236,72,153,0.3); color: #f472b6; }

.nav-part-divider {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--accent-primary); opacity: 0.7; margin-top: 8px;
}
.nav-part-divider::after { content: ''; flex: 1; height: 1px; background: rgba(236,72,153,0.2); }

/* ===== LANG SWITCHER ===== */
.lang-switcher {
  display: flex; gap: 0.25rem; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
  padding: 0.25rem; margin: 0.75rem 1rem 0;
}
.lang-btn {
  flex: 1; background: transparent; border: none; color: var(--text-muted);
  font-family: 'Outfit','Inter',sans-serif; font-size: 0.78rem; font-weight: 600;
  padding: 0.4rem 0.6rem; border-radius: 7px; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1); white-space: nowrap; text-align: center;
}
.lang-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.07); }
.lang-btn.active { background: linear-gradient(135deg,#be185d,#ec4899); color: #fff; box-shadow: 0 2px 12px rgba(236,72,153,0.35); }

/* ===== MOBILE TOGGLE ===== */
.nav-toggle {
  position: fixed; top: 16px; left: 16px; z-index: 200;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-primary); cursor: pointer; display: none;
  align-items: center; justify-content: center; font-size: 1.2rem;
}
.nav-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 99; opacity: 0; transition: opacity var(--transition);
}
.nav-overlay.show { display: block; opacity: 1; }

/* ===== MAIN CONTENT ===== */
.main-content { margin-left: 300px; position: relative; z-index: 1; min-height: 100vh; transition: margin-left var(--transition); }
.main-content.expanded { margin-left: 0; }

/* ===== CHAPTER ===== */
.chapter { display: none; animation: fadeIn 0.5s ease; }
.chapter.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.chapter-hero {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  background: linear-gradient(135deg, #090218 0%, #1c0638 50%, #060111 100%);
}
.chapter-hero img { max-width: 100%; max-height: 100vh; width: 100%; height: auto; display: block; margin: 0 auto; }
.chapter-hero-overlay {
  position: relative; z-index: 2; padding: 32px 48px 36px; width: 100%;
  background: linear-gradient(to bottom, rgba(10,14,39,0.85) 0%, var(--bg-primary) 100%);
  margin-top: -40px;
}
.chapter-hero-overlay .ch-num {
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--accent-amber);
  font-weight: 600; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 8px;
}
.chapter-hero-overlay h1 {
  font-size: 2.6rem; font-weight: 800; margin-bottom: 8px;
  background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.chapter-hero-overlay .ch-subtitle { font-size: 1.1rem; color: var(--text-secondary); max-width: 600px; }

.chapter-body { max-width: 860px; margin: 0 auto; padding: 48px 32px 80px; }
.chapter-body h2 {
  font-size: 1.7rem; font-weight: 700; margin: 48px 0 20px;
  color: var(--text-primary); position: relative; padding-left: 20px;
}
.chapter-body h2::before {
  content: ''; position: absolute; left: 0; top: 4px;
  width: 4px; height: 28px; background: var(--gradient-hero); border-radius: 4px;
}
.chapter-body h3 { font-size: 1.25rem; font-weight: 600; margin: 32px 0 14px; color: var(--accent-light); }
.chapter-body p { margin-bottom: 18px; color: var(--text-secondary); font-size: 1.02rem; }
.chapter-body ul, .chapter-body ol { padding-left: 24px; color: var(--text-secondary); margin-bottom: 16px; }
.chapter-body li { margin-bottom: 8px; font-size: 0.98rem; }
.chapter-body strong { color: var(--text-primary); }

/* ===== DIALOGUE ===== */
.dialogue {
  display: flex; gap: 16px; margin: 24px 0; padding: 20px;
  background: var(--bg-glass); border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.06);
}
.dialogue-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}
.dialogue-avatar.ava { background: linear-gradient(135deg,#7c3aed,#a78bfa); color: #fff; }
.dialogue-avatar.max { background: linear-gradient(135deg,#be185d,#ec4899); color: #fff; }
.dialogue-content { flex: 1; }
.dialogue-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.dialogue-name.ava { color: #a78bfa; }
.dialogue-name.max { color: var(--accent-primary); }
.dialogue-text { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7; }

/* ===== CODE BLOCKS ===== */
.code-block {
  margin: 24px 0; border-radius: var(--radius);
  background: #0d1117; border: 1px solid rgba(255,255,255,0.08); overflow: hidden;
}
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.code-lang { font-family: 'JetBrains Mono',monospace; font-size: 0.75rem; color: var(--accent-primary); font-weight: 600; text-transform: uppercase; }
.code-copy {
  background: none; border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted);
  padding: 4px 10px; border-radius: 6px; font-size: 0.72rem; cursor: pointer; transition: var(--transition);
}
.code-copy:hover { border-color: var(--accent-primary); color: var(--accent-light); }
.code-block pre { padding: 20px; overflow-x: auto; font-family: 'JetBrains Mono',monospace; font-size: 0.88rem; line-height: 1.7; color: #c9d1d9; }

/* Syntax */
.kw { color: #ff7b72; } .fn { color: #d2a8ff; } .str { color: #a5d6ff; }
.num { color: #79c0ff; } .cmt { color: #6b7b8d; font-style: italic; }
.op { color: #ff7b72; } .type { color: #ffa657; } .var { color: #ffa657; }
.tag { color: #7ee787; } .attr { color: #79c0ff; } .val { color: #a5d6ff; }

/* ===== CONCEPT CARDS ===== */
.concept-card {
  margin: 28px 0; padding: 24px 28px; border-radius: var(--radius);
  background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.06);
  border-left: 4px solid var(--accent-primary);
}
.concept-card.tip { border-left-color: var(--accent-green); }
.concept-card.warning { border-left-color: var(--accent-amber); }
.concept-card.info { border-left-color: var(--accent-purple); }
.concept-card.danger { border-left-color: var(--accent-rose); }
.concept-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.concept-card p { margin-bottom: 8px; font-size: 0.95rem; }
.concept-card ul { padding-left: 20px; }
.concept-card li { margin-bottom: 6px; font-size: 0.93rem; color: var(--text-secondary); }

/* ===== FLOWCHARTS ===== */
.flowchart-container {
  margin: 32px 0; padding: 28px; background: rgba(255,255,255,0.03);
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.06);
  text-align: center; overflow-x: auto;
}
.flowchart-container h4 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 2px; }
.mermaid { line-height: 1.4; }
.mermaid svg { height: auto; min-width: 100%; }
.mermaid .cluster rect { rx: 10; ry: 10; }
.mermaid .cluster-label foreignObject { overflow: visible !important; }
.mermaid .cluster-label .nodeLabel,
.mermaid .cluster-label span {
  background: rgba(10, 6, 30, 0.92);
  padding: 3px 12px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.mermaid .nodeLabel { line-height: 1.35; }

/* ===== QUIZ ===== */
.quiz-section {
  margin: 40px 0; padding: 32px; border-radius: var(--radius);
  background: linear-gradient(135deg,rgba(236,72,153,0.08),rgba(190,24,93,0.08));
  border: 1px solid rgba(236,72,153,0.2);
}
.quiz-section h3 { color: var(--accent-amber); margin-top: 0; font-size: 1.2rem; display: flex; align-items: center; gap: 10px; }
.quiz-question { margin: 20px 0; }
.quiz-question p { font-weight: 600; color: var(--text-primary); margin-bottom: 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: var(--transition); font-size: 0.92rem; color: var(--text-secondary);
}
.quiz-option:hover { border-color: var(--accent-primary); background: rgba(236,72,153,0.1); }
.quiz-option.correct { border-color: var(--accent-green); background: rgba(16,185,129,0.15); color: var(--accent-green); }
.quiz-option.wrong { border-color: var(--accent-rose); background: rgba(244,63,94,0.1); color: var(--accent-rose); }
.quiz-feedback { margin-top: 10px; padding: 12px; border-radius: var(--radius-sm); font-size: 0.9rem; display: none; }
.quiz-feedback.show { display: block; }
.quiz-feedback.correct { background: rgba(16,185,129,0.1); color: var(--accent-green); }
.quiz-feedback.wrong { background: rgba(244,63,94,0.1); color: var(--accent-rose); }

/* ===== EXERCISE BOX ===== */
.exercise-box {
  margin: 32px 0; padding: 28px; border-radius: var(--radius);
  background: rgba(236,72,153,0.06); border: 1px solid rgba(236,72,153,0.2);
}
.exercise-box h4 { color: var(--accent-amber); font-size: 1.05rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.exercise-box ol, .exercise-box ul { padding-left: 20px; color: var(--text-secondary); }
.exercise-box li { margin-bottom: 8px; font-size: 0.95rem; }

/* ===== COMPARISON TABLE ===== */
.compare-table { width: 100%; margin: 24px 0; border-collapse: collapse; border-radius: var(--radius); overflow: hidden; }
.compare-table th { padding: 14px 18px; background: rgba(236,72,153,0.15); color: var(--accent-light); font-weight: 600; font-size: 0.9rem; text-align: left; }
.compare-table td { padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; color: var(--text-secondary); }
.compare-table tr:hover td { background: var(--bg-glass); }
.compare-table code { font-family: 'JetBrains Mono',monospace; font-size: 0.82rem; background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 4px; color: #ffa657; }
.compare-table .green { color: var(--accent-green); }
.compare-table .amber { color: var(--accent-amber); }
.compare-table .rose { color: var(--accent-rose); }

/* ===== CHAPTER NAV ===== */
.chapter-nav { display: flex; justify-content: space-between; align-items: center; padding: 32px 0; margin-top: 48px; border-top: 1px solid rgba(255,255,255,0.06); }
.chapter-nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 14px 24px;
  border-radius: var(--radius-sm); background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.08); color: var(--text-secondary);
  cursor: pointer; transition: var(--transition); font-size: 0.9rem; font-weight: 500;
}
.chapter-nav-btn:hover { border-color: var(--accent-primary); background: rgba(236,72,153,0.1); }
.chapter-nav-btn.primary { background: var(--gradient-hero); color: #fff; border: none; font-weight: 600; }
.chapter-nav-btn.primary:hover { opacity: 0.9; transform: translateX(4px); }

/* ===== COVER PAGE ===== */
.cover-page {
  text-align: center; padding: 60px 30px; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.vol-marker { font-family: 'JetBrains Mono',monospace; font-size: 0.8rem; color: var(--accent-primary); text-transform: uppercase; letter-spacing: 4px; margin-bottom: 24px; font-weight: 600; }
.cover-page img { width: min(340px,80%); border-radius: 20px; box-shadow: var(--shadow-lg),var(--shadow-glow); margin-bottom: 32px; }
.cover-page h1 { font-size: 3.4rem; font-weight: 800; margin-bottom: 12px; background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.cover-page .subtitle { max-width: 560px; color: var(--text-secondary); font-size: 1.05rem; line-height: 1.7; margin-bottom: 32px; }
.author-badge { position: relative; margin: 24px auto 32px; max-width: 320px; }
.author-badge-glow { position: absolute; inset: -4px; border-radius: 20px; background: var(--gradient-hero); opacity: 0.25; filter: blur(16px); animation: badgePulse 3s ease-in-out infinite; }
@keyframes badgePulse { 0%,100% { opacity: 0.2; } 50% { opacity: 0.35; } }
.author-badge-inner { position: relative; z-index: 1; background: var(--bg-secondary); border: 1px solid rgba(236,72,153,0.3); border-radius: 16px; padding: 18px 24px; text-align: center; }
.author-badge-label { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 3px; color: var(--text-muted); margin-bottom: 4px; }
.author-badge-name { display: block; font-family: 'Outfit',sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--text-primary); }
.author-badge-links { margin-top: 8px; display: flex; gap: 12px; justify-content: center; }
.author-badge-links a { font-size: 0.78rem; color: var(--accent-primary); text-decoration: none; transition: var(--transition); }
.start-btn { background: var(--gradient-hero); color: #fff; border: none; padding: 16px 40px; border-radius: 14px; font-family: 'Outfit',sans-serif; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: var(--transition); box-shadow: 0 8px 32px rgba(236,72,153,0.4); margin-bottom: 40px; }
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(236,72,153,0.5); }
.series-checklist { background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.06); border-radius: var(--radius); padding: 24px; max-width: 460px; width: 100%; margin-bottom: 32px; }
.series-checklist h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 16px; }
.series-checklist h3 span { color: var(--accent-primary); }
.checklist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-muted); background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04); }
.checklist-item.completed { color: var(--accent-green); background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.15); }
.checklist-item.current { color: var(--accent-primary); background: rgba(236,72,153,0.08); border-color: rgba(236,72,153,0.2); box-shadow: 0 0 12px rgba(236,72,153,0.15); }
.check-box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; }
.checklist-item.completed .check-box { background: var(--accent-green); border-color: var(--accent-green); color: #fff; }
.checklist-item.current .check-box { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }
.cover-footer { margin-top: 40px; font-size: 0.8rem; color: var(--text-muted); }

/* ===== PROGRESS BAR ===== */
.progress-bar { position: fixed; top: 0; left: 300px; right: 0; height: 3px; background: rgba(255,255,255,0.05); z-index: 150; transition: left var(--transition); }
.progress-fill { height: 100%; background: var(--gradient-hero); width: 0%; transition: width 0.2s ease; }
#scrollProgress { position: fixed; top: 3px; left: 300px; right: 0; height: 2px; background: var(--accent-primary); z-index: 151; transition: width 0.1s linear; width: 0%; }

/* ===== SIDEBAR FOOTER ===== */
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06); text-align: center; font-size: 0.78rem; color: var(--text-muted); }
.sidebar-footer a { color: var(--accent-primary); text-decoration: none; display: block; margin-top: 4px; }

/* ===== SCROLL REVEAL ===== */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===== CODE TABS ===== */
.code-tabs { margin: 24px 0; border-radius: var(--radius); background: #0d1117; border: 1px solid rgba(255,255,255,0.08); overflow: hidden; }
.code-tabs-header { display: flex; background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.06); overflow-x: auto; }
.code-tab-btn { padding: 10px 16px; background: none; border: none; color: var(--text-muted); font-family: 'JetBrains Mono',monospace; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: var(--transition); white-space: nowrap; border-bottom: 2px solid transparent; text-transform: uppercase; }
.code-tab-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); }
.code-tab-btn.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); background: rgba(236,72,153,0.08); }
.code-tab-content { display: none; }
.code-tab-content.active { display: block; }
.code-tab-content pre { padding: 20px; overflow-x: auto; font-family: 'JetBrains Mono',monospace; font-size: 0.88rem; line-height: 1.7; color: #c9d1d9; }

/* ===== DEMO CONTAINER ===== */
.demo-container { margin: 32px 0; padding: 32px; border-radius: var(--radius); background: rgba(236,72,153,0.04); border: 1px solid rgba(236,72,153,0.15); overflow: hidden; }
.demo-container h4 { font-size: 0.85rem; color: var(--accent-primary); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }

/* ===== STATIC NAV ITEMS ===== */
.nav-static { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); color: var(--text-secondary); font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }
.nav-static:hover { background: var(--bg-glass); color: var(--text-primary); }

/* ===== DEDICATION & PREFACE ===== */
.dedication-page { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 60px 30px; }
.dedication-card { max-width: 520px; text-align: center; padding: 48px 36px; background: var(--bg-glass); border: 1px solid rgba(255,255,255,0.06); border-radius: 24px; }
.dedication-card .ded-icon { font-size: 2.5rem; margin-bottom: 20px; }
.dedication-card .ded-text { font-size: 1.15rem; line-height: 1.9; color: var(--text-secondary); font-style: italic; }
.dedication-card .ded-text strong { color: var(--accent-primary); }
.preface-page { max-width: 800px; margin: 0 auto; padding: 60px 32px 80px; }
.preface-page h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 24px; background: var(--gradient-hero); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.preface-page p { color: var(--text-secondary); font-size: 1.02rem; margin-bottom: 16px; line-height: 1.8; }
.preface-page h3 { font-size: 1.2rem; color: var(--accent-light); margin: 32px 0 12px; }
.preface-page ul { padding-left: 24px; color: var(--text-secondary); }
.preface-page li { margin-bottom: 8px; font-size: 0.95rem; }

/* ===== PROJECT CARDS (Part VII) ===== */
.project-meta {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 28px;
}
.project-badge {
  padding: 5px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.project-badge.beginner { background: rgba(16,185,129,0.15); color: var(--accent-green); border: 1px solid rgba(16,185,129,0.3); }
.project-badge.intermediate { background: rgba(236,72,153,0.15); color: var(--accent-amber); border: 1px solid rgba(236,72,153,0.3); }
.project-badge.advanced { background: rgba(139,92,246,0.15); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.3); }
.project-badge.expert { background: rgba(244,63,94,0.15); color: var(--accent-rose); border: 1px solid rgba(244,63,94,0.3); }
.project-badge.lang { background: rgba(255,255,255,0.06); color: var(--text-primary); border: 1px solid rgba(255,255,255,0.1); }

.step-list { counter-reset: step; list-style: none; padding: 0; margin: 20px 0; }
.step-list li { counter-increment: step; display: flex; gap: 16px; margin-bottom: 20px; }
.step-list li::before {
  content: counter(step); min-width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient-hero); color: #fff; font-weight: 700; font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}

/* ===== CASE STUDY CARDS ===== */
.case-header {
  background: linear-gradient(135deg, rgba(236,72,153,0.12), rgba(139,92,246,0.08));
  border: 1px solid rgba(236,72,153,0.2); border-radius: var(--radius);
  padding: 28px; margin-bottom: 32px;
}
.case-header h3 { color: var(--accent-light); margin: 0 0 8px; font-size: 1.3rem; }
.case-header p { color: var(--text-secondary); margin: 0; font-size: 0.95rem; }
.decision-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3);
  color: var(--accent-green); padding: 4px 12px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 600; margin: 4px;
}

/* ===== PROJECT OVERVIEW ===== */
.project-overview {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 28px;
}
.project-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
.project-meta-item { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.meta-value { font-size: 0.9rem; color: var(--text-primary); font-weight: 600; }
.meta-badge { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.meta-badge.beginner { background: rgba(16,185,129,0.2); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.meta-badge.intermediate { background: rgba(236,72,153,0.2); color: #ec4899; border: 1px solid rgba(236,72,153,0.3); }
.meta-badge.advanced { background: rgba(139,92,246,0.2); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.meta-badge.expert { background: rgba(244,63,94,0.2); color: #fb7185; border: 1px solid rgba(244,63,94,0.3); }

/* ===== DEPLOY CHECKLIST ===== */
.checklist-deploy { display: flex; flex-direction: column; gap: 8px; margin: 20px 0; }
.deploy-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 0.9rem;
  border: 1px solid rgba(255,255,255,0.06); background: var(--bg-glass);
}
.deploy-item.done { color: var(--accent-green); border-color: rgba(16,185,129,0.2); background: rgba(16,185,129,0.06); }
.deploy-item.todo { color: var(--text-muted); }

/* ===== COLOURS IN TABLES ===== */
.compare-table .green { color: var(--accent-green) !important; }
.compare-table .amber { color: var(--accent-amber) !important; }
.compare-table .rose { color: var(--accent-rose) !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-300px); }
  .sidebar.open { transform: translateX(0); }
  .nav-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .progress-bar, #scrollProgress { left: 0; }
  .chapter-hero-overlay { padding: 24px 20px 28px; }
  .chapter-hero-overlay h1 { font-size: 1.8rem; }
  .chapter-body { padding: 32px 16px 60px; }
  .cover-page h1 { font-size: 2.4rem; }
  .chapter-nav { flex-direction: column; gap: 12px; }
  .chapter-nav-btn { width: 100%; justify-content: center; }
  .checklist-grid { grid-template-columns: 1fr; }
  .compare-table { font-size: 0.85rem; }
  .compare-table th, .compare-table td { padding: 10px 12px; }
  .dialogue { flex-direction: column; gap: 12px; }
}
@media (max-width: 500px) {
  .cover-page h1 { font-size: 2rem; }
  .chapter-hero-overlay h1 { font-size: 1.5rem; }
  .chapter-body h2 { font-size: 1.4rem; }
  .chapter-body { padding: 24px 14px 50px; }
  .chapter-body h3 { font-size: 1.1rem; }
  .chapter-body p, .chapter-body li { font-size: 0.95rem; line-height: 1.65; }
  .chapter-hero { min-height: 280px; }
  .chapter-hero-overlay { padding: 18px 14px 22px; }
  .dialogue { padding: 14px 12px; gap: 10px; }
  .dialogue-avatar { width: 38px; height: 38px; font-size: 0.95rem; }
  .compare-table { font-size: 0.78rem; }
  .compare-table th, .compare-table td { padding: 8px 9px; }
  .checklist-grid { gap: 10px; }
}

/* ===== Narrow-phone safety net ===== */
@media (max-width: 720px) {
  /* Make overflowing wide content scroll instead of breaking the layout */
  .chapter-body table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap; max-width: 100%;
  }
  .chapter-body pre,
  .chapter-body code,
  .chapter-body .mermaid {
    max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .chapter-body pre { font-size: 0.78rem; }
  .chapter-body img { max-width: 100%; height: auto; }
  .chapter-body iframe { max-width: 100%; }
}
