/* ==========================================================================
   ByteScale — ByteByteGo-Inspired Clean Visual Learning Platform
   Focus: Effortless readability, crisp diagrams, structured FAANG roadmap
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --accent: #0ea5e9;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;

  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --inline-code-bg: #f1f5f9;
  --inline-code-text: #0f172a;

  --diagram-bg: #fcfdff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);

  --topbar-h: 60px;
  --sidebar-w: 292px;
  --toc-w: 224px;
  --radius: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --bg-elevated: #162033;
  --bg-hover: #1e293b;
  --border: #1e293b;
  --border-strong: #334155;

  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-border: rgba(59, 130, 246, 0.35);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);

  --code-bg: #060a14;
  --code-text: #e2e8f0;
  --inline-code-bg: #1e293b;
  --inline-code-text: #93c5fd;

  --diagram-bg: #f8fafc; /* Keep diagrams crisp paper-white for max visual clarity */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.55);
}

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

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

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Top Navigation Bar
   ========================================================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 40;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  text-decoration: none !important;
}
.brand-bg {
  color: var(--primary);
}
.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  vertical-align: middle;
  margin-left: 4px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 14px;
}

.top-nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}
.top-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.top-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.search-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  color: var(--text);
}
.search-trigger kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
}
.progress-mini-bar {
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-mini-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

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

/* ==========================================================================
   App Shell (Sidebar + Main + TOC)
   ========================================================================== */
.app-shell {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px 32px;
  z-index: 30;
  transition: transform 0.22s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 10px;
}
.sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar-quick-links {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}
.quick-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.quick-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.track-group {
  margin-bottom: 10px;
}
.track-header-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.track-header-btn:hover {
  background: var(--bg-hover);
}
.track-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.track-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.track-lessons {
  list-style: none;
  margin: 4px 0 6px;
  padding: 0 0 0 8px;
  border-left: 1.5px solid var(--border);
  margin-left: 14px;
}
.track-group.collapsed .track-lessons {
  display: none;
}

.lesson-nav-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  margin: 2px 0;
  border-radius: 7px;
  font-size: 0.835rem;
  line-height: 1.38;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background 0.12s, color 0.12s;
}
.lesson-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.lesson-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.lesson-check-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  flex-shrink: 0;
  margin-top: 2px;
  color: transparent;
}
.lesson-nav-link.completed .lesson-check-dot {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 32px 40px 80px;
  display: flex;
  justify-content: center;
}

.content-container {
  width: 100%;
  max-width: 860px;
}
.content-container.wide {
  max-width: 1080px;
}

/* Right TOC */
.toc-aside {
  width: var(--toc-w);
  flex-shrink: 0;
  padding: 32px 18px 40px 0;
  display: none;
}
.toc-aside.visible {
  display: block;
}
.toc-sticky {
  position: sticky;
  top: calc(var(--topbar-h) + 28px);
}
.toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1.5px solid var(--border);
}
.toc-list a {
  display: block;
  padding: 5px 0 5px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none !important;
  border-left: 2px solid transparent;
  margin-left: -1.5px;
  transition: color 0.15s, border-color 0.15s;
}
.toc-list a:hover, .toc-list a.active {
  color: var(--primary);
  border-left-color: var(--primary);
}

/* ==========================================================================
   Hero & Home Page
   ========================================================================== */
.hero-card {
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--bg-subtle) 60%, var(--purple-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 38px 36px;
  margin-bottom: 32px;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg);
  border: 1px solid var(--primary-border);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero-card h1 {
  font-size: 2.15rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 14px;
}
.hero-subtitle {
  font-size: 1.03rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 0 24px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none !important;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-hover);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-subtle {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-subtle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 34px;
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary);
}
.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.section-heading {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.section-desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 20px;
}

.track-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 36px;
}
.track-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.track-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}
.track-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.track-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}
.track-card h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}
.track-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.track-card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.track-card-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--text);
  text-decoration: none !important;
  transition: background 0.12s;
}
.track-card-list a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ==========================================================================
   Lesson Typography & Reading Elements
   ========================================================================== */
.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.lesson-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.lesson-header h1 {
  font-size: 2rem;
  line-height: 1.22;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
}
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-secondary);
}
.meta-pill.level-senior {
  background: var(--purple-soft);
  border-color: transparent;
  color: var(--purple);
}

.lesson-body h2 {
  font-size: 1.38rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 36px 0 12px;
  padding-top: 8px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
.lesson-body h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 24px 0 8px;
}
.lesson-body p {
  margin: 0 0 14px;
  color: var(--text-secondary);
}
.lesson-body ul, .lesson-body ol {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--text-secondary);
}
.lesson-body li {
  margin-bottom: 7px;
}
.lesson-body strong {
  color: var(--text);
}
.lesson-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 2px 6px;
  border-radius: 5px;
}
.lesson-body pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  margin: 16px 0 20px;
  border: 1px solid var(--border);
}
.lesson-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* Callout Boxes */
.callout {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 20px 0;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
}
.callout.tip {
  border-left-color: var(--success);
  background: var(--success-soft);
}
.callout.warn {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}
.callout.faang {
  border-left-color: var(--purple);
  background: var(--purple-soft);
}
.callout-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}
.callout p:last-child, .callout ul:last-child {
  margin-bottom: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 18px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
tr:last-child td {
  border-bottom: none;
}

/* Step Cards */
.step-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 18px 0 22px;
}
.step-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.step-num {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.step-box h4 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}
.step-box p {
  margin: 0;
  font-size: 0.86rem;
}

/* ==========================================================================
   ByteByteGo-Style Diagram Cards
   ========================================================================== */
.diagram-figure {
  margin: 24px 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
.diagram-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.diagram-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.diagram-zoom-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.diagram-zoom-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.diagram-stage {
  background: var(--diagram-bg);
  padding: 18px 16px;
  cursor: zoom-in;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}
.diagram-stage svg {
  width: 100%;
  max-width: 820px;
  height: auto;
  display: block;
}
.diagram-caption {
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* Diagram Gallery */
.diagram-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.gallery-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.gallery-card-preview {
  background: var(--diagram-bg);
  padding: 14px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.gallery-card-preview svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}
.gallery-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.gallery-card-body h3 {
  margin: 0;
  font-size: 0.98rem;
}
.gallery-card-body p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  flex: 1;
}
.gallery-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

/* ==========================================================================
   Interactive 16-Week Roadmap Timeline
   ========================================================================== */
.roadmap-phase {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  background: var(--bg-elevated);
}
.roadmap-phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.phase-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}
.week-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.week-item:last-child { margin-bottom: 0; }
.week-item.checked {
  border-color: var(--success);
  background: var(--success-soft);
}
.week-checkbox {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}
.week-content {
  flex: 1;
}
.week-title {
  font-weight: 700;
  font-size: 0.94rem;
  margin-bottom: 4px;
}
.week-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.week-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.week-chip {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--primary);
  text-decoration: none !important;
}
.week-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Interactive Estimator Tool */
.estimator-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 22px 0;
}
.estimator-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 14px 0 18px;
}
.estimator-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.estimator-field input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
}
.estimator-results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.est-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.est-metric-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}
.est-metric-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* Lesson Footer Navigation */
.lesson-footer {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.complete-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.prev-next-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.nav-card {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  text-decoration: none !important;
  transition: border-color 0.15s, background 0.15s;
}
.nav-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.nav-card.next { text-align: right; }
.nav-card-dir {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.nav-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 3px;
}

/* ==========================================================================
   Modals (Search & Diagram Lightbox)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 18px 24px;
}
.modal-overlay[hidden] {
  display: none;
}

.search-dialog {
  width: 100%;
  max-width: 620px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
}
.kbd-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}
.search-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}
.search-item {
  display: block;
  padding: 10px 12px;
  border-radius: 9px;
  text-decoration: none !important;
  color: var(--text);
}
.search-item:hover {
  background: var(--primary-soft);
}
.search-item-title {
  font-weight: 700;
  font-size: 0.92rem;
}
.search-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Lightbox */
.lightbox-dialog {
  width: 96vw;
  max-width: 1220px;
  height: 86vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: -24px;
}
.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.lightbox-header h3 {
  margin: 0;
  font-size: 1rem;
}
.lightbox-header p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#zoomLevel {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  min-width: 44px;
  text-align: center;
}
.lightbox-canvas {
  flex: 1;
  overflow: auto;
  background: var(--diagram-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox-svg-wrap {
  transform-origin: center center;
  transition: transform 0.15s ease;
  width: 100%;
  max-width: 1040px;
}
.lightbox-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
.mobile-only { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1220px) {
  .toc-aside.visible { display: none; }
}

@media (max-width: 960px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 25;
  }

  .main-content {
    margin-left: 0;
    padding: 24px 18px 64px;
  }

  .stats-grid, .track-cards-grid, .diagram-gallery-grid, .step-grid, .estimator-grid, .estimator-results {
    grid-template-columns: 1fr;
  }
  .prev-next-grid {
    grid-template-columns: 1fr;
  }
  .hero-card {
    padding: 24px 20px;
  }
  .hero-card h1 {
    font-size: 1.65rem;
  }
  .search-trigger span, .search-trigger kbd {
    display: none;
  }
}
