/* ─── Variables ─────────────────────────────────────────── */
:root {
  --sidebar-bg:      #1a3d2b;
  --sidebar-text:    #a8c4b4;
  --sidebar-active:  #f5f0e8;
  --sidebar-hover:   #224d37;
  --sidebar-accent:  #c4612b;
  --sidebar-width:   240px;

  --color-bg:        #ffffff;
  --color-text:      #1a2e1f;
  --color-muted:     #5c7a65;
  --color-border:    #dde8e0;
  --color-accent:    #c4612b;
  --color-accent-bg: #fdf3ec;
  --color-code-bg:   #f5f0e8;

  --green-dark:      #1a3d2b;
  --green-mid:       #2d6a47;
  --rust:            #c4612b;
  --rust-light:      #fdf3ec;
  --cream:           #f8f4ee;

  --hero-bg:         #1a3d2b;
  --hero-text:       #f5f0e8;
  --hero-muted:      #a8c4b4;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  --content-max:  780px;
  --line-height:  1.75;
  --radius-sm:    0.375rem;
  --radius-md:    0.5rem;
  --radius-lg:    0.75rem;

  /* Touch-safe minimum tap target */
  --tap-min: 44px;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* ─── Base ──────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  overflow-x: hidden;
}

/* ─── App Layout ─────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  /* Green background fills the left column for the full page height,
     so the sidebar colour extends even when content is taller than the sidebar. */
  background: var(--sidebar-bg);
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;   /* grows with page content */
  min-width: 0;
}

/* Logo + nav stick to the top while the page scrolls */
.sidebar-top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--sidebar-bg);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--sidebar-active);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  min-height: var(--tap-min);
}
.sidebar-logo:hover { color: #fff; }

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--sidebar-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.sidebar-logo-icon svg { width: 16px; height: 16px; }

.sidebar-nav        { padding: 1rem 0.75rem; }
.sidebar-nav-label  {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ffffff;
  padding: 0 0.5rem;
  margin-bottom: 0.4rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--sidebar-text);
  transition: background 0.12s, color 0.12s;
  margin-bottom: 0.1rem;
  min-height: var(--tap-min);
}
.sidebar-item:hover                        { background: var(--sidebar-hover); color: var(--sidebar-active); }
.sidebar-item[aria-current="page"]         { background: rgba(196,97,43,0.2); color: #f0b992; }
.sidebar-item-icon                         { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-item:hover .sidebar-item-icon,
.sidebar-item[aria-current="page"] .sidebar-item-icon { opacity: 1; }
.sidebar-item-icon svg                     { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  text-align: center;
}
.sidebar-copyright a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── Sidebar About Section ──────────────────────────────── */
.sidebar-about {
  margin-top: auto;
  padding: 0.75rem 0.75rem 0;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-about .sidebar-nav-label {
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-author-avatar {
  width: 30px;
  height: 30px;
  background: var(--rust);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ─── Main Content ───────────────────────────────────────── */
.main-content          { overflow-y: auto; overflow-x: hidden; min-height: 100vh; min-width: 0; background: var(--color-bg); }
.main-content--page,
.main-content--lesson  { padding: 2.5rem 3rem 5rem; }

/* ─── Hero ───────────────────────────────────────────────── */
.hero {
  background: var(--hero-bg);
  color: var(--hero-text);
  padding: 1.5rem 3rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 3rem;
}
.hero-left  { flex: 1; min-width: 0; }
.hero-right {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
}
.hero-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-accent);
  margin-bottom: 1.25rem;
}
.hero-headline {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  max-width: 42ch;
}
.hero-headline-sub {
  color: var(--hero-muted);
  display: block;
  font-size: clamp(0.9rem, 1.8vw, 1.8rem);
  font-weight: 500;
  letter-spacing: 0;
}
.hero-desc {
  font-size: 0.95rem;
  color: var(--hero-muted);
  line-height: 1.65;
  margin-top: 0.3rem;
  margin-bottom: 0;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  background: var(--sidebar-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  min-height: var(--tap-min);
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: #a3501f; transform: translateY(-1px); }

/* ─── Stats Bar ──────────────────────────────────────────── */
.stats-bar {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
  overflow-x: auto;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 2rem;
  border-right: 1px solid var(--color-border);
  flex: 1;
  min-width: 90px;
}
.stat-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  gap: inherit;
}
.stat-link:hover .stat-value { color: var(--color-accent); }
.stat-link:hover .stat-label { color: var(--color-accent); }

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 0.2rem;
}

/* ─── Tracks Section ─────────────────────────────────────── */
.tracks-section    { padding: 3rem 3rem 4rem; }
.section-heading   { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.section-sub       { font-size: 0.9rem; color: var(--color-muted); margin-bottom: 2rem; }

/* ─── Track Cards ────────────────────────────────────────── */
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.track-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.track-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 16px rgba(196,97,43,0.1);
  transform: translateY(-1px);
}
.track-card-icon {
  width: 40px;
  height: 40px;
  background: var(--color-accent-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-accent);
}
.track-card-icon svg    { width: 20px; height: 20px; }
.track-card-body        { flex: 1; min-width: 0; }
.track-card-title       { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.track-card:hover .track-card-title { color: var(--color-accent); }
.track-card-desc        { font-size: 0.825rem; color: var(--color-muted); line-height: 1.5; margin-bottom: 0.5rem; }
.track-card-meta        { font-size: 0.75rem; color: var(--color-accent); font-weight: 600; }

/* ─── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-bottom: 2.5rem;
}
.breadcrumb a        { color: var(--color-accent); }
.breadcrumb a:hover  { text-decoration: underline; }

/* ─── Track Index ────────────────────────────────────────── */
.track-index { padding: 0 0 2rem; }

.track-index-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}
.track-index-icon {
  width: 52px;
  height: 52px;
  background: var(--color-accent-bg);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-accent);
}
.track-index-icon svg   { width: 26px; height: 26px; }
.track-index h1         { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.3rem; }
.track-index-desc       { color: var(--color-muted); font-size: 0.9rem; margin-bottom: 0.3rem; }
.lesson-count           { color: var(--color-muted); font-size: 0.8rem; }

ul.lesson-list          { list-style: none; padding: 0; }
.lesson-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--color-border);
  gap: 1rem;
  min-height: var(--tap-min);
}
.lesson-list a           { font-weight: 500; color: var(--color-text); }
.lesson-list a:hover     { color: var(--color-accent); text-decoration: underline; }
.lesson-list .duration   { font-size: 0.78rem; color: var(--color-muted); white-space: nowrap; }

/* ─── Lesson Header ──────────────────────────────────────── */
.lesson-header          { margin-bottom: 2.5rem; }
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--color-muted);
  margin-bottom: 0.875rem;
}
.track-label            { font-weight: 700; color: var(--color-accent); }
.duration               { margin-left: auto; }
.lesson-header h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 1.5rem;
}

/* ─── Objectives ─────────────────────────────────────────── */
section.objectives {
  background: var(--cream);
  border-left: 3px solid var(--rust);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.objectives-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--rust);
  margin-bottom: 0.5rem;
}
section.objectives ul { padding-left: 1.25rem; border: none; }
section.objectives li { margin-bottom: 0.25rem; font-size: 0.9rem; }

/* ─── Lesson Body ────────────────────────────────────────── */
.lesson-body { max-width: 100%; }

/* ─── Cards Grid (consecutive h4+table pairs) ───────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
  gap: 0 2rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.lesson-card {
  min-width: 0;
  margin-bottom: 1.5rem;
}
.lesson-card h4:first-child { margin-top: 0; }
.lesson-card .table-wrap    { margin-bottom: 0; }
.lesson-body h2 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-active);
  background: var(--green-dark);
  margin: 2.5rem 0 0;
  padding: 0.6rem 1rem 0.6rem 0.75rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.lesson-body h2::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(196, 97, 43, 0.7);
  background: radial-gradient(circle at 35% 35%, rgba(196,97,43,0.25), transparent 70%);
  box-shadow: 0 0 0 3px rgba(196,97,43,0.12);
}
/* make the next sibling element (usually h3/p/table-wrap) connect flush */
.lesson-body h2 + * { margin-top: 0; }

.lesson-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green-dark);
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--rust);
  display: inline-block;
}
.lesson-body h4 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rust);
  margin: 1.5rem 0 0.4rem;
}
.lesson-body p       { margin-bottom: 1rem; }
.lesson-body ul,
.lesson-body ol      { padding-left: 1.5rem; margin-bottom: 1rem; }
.lesson-body li      { margin-bottom: 0.3rem; }
.lesson-body a       { color: var(--color-accent); }
.lesson-body a:hover { text-decoration: underline; }

/* ─── Responsive Tables ──────────────────────────────────── */
.lesson-body table   { width: 100%; }
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1.5rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid var(--color-border);
  border-top: none;
}
/* Builder wraps tables; raw tables from mistune get basic styles */
.lesson-body table {
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 400px;
}
.lesson-body th,
.lesson-body td {
  border: 1px solid var(--color-border);
  padding: 0.55rem 0.875rem;
  text-align: left;
  vertical-align: top;
  white-space: normal;
}
.lesson-body th {
  background: var(--cream);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.82rem;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  border-color: var(--color-border);
}
.lesson-body td:first-child {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--rust);
  white-space: nowrap;
}
.lesson-body tr:nth-child(even) td { background: var(--cream); }
.lesson-body tr:hover td           { background: #f0ede8; }

/* ─── Code ───────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--cream);
  color: var(--rust);
  padding: 0.15em 0.4em;
  border-radius: 0.2rem;
  border: 1px solid var(--color-border);
  word-break: break-word;
}
pre {
  background: var(--green-dark);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
  line-height: 1.6;
}
pre code { background: none; border: none; padding: 0; font-size: 0.875rem; color: #d4e8dc; }

/* ─── Blockquote / HR ────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--rust);
  background: var(--cream);
  padding: 0.75rem 1.25rem;
  color: var(--color-muted);
  margin: 1.5rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}
hr { border: none; border-top: 2px solid var(--rust); opacity: 0.2; margin: 2.5rem 0; }

/* ─── Lesson Nav ─────────────────────────────────────────── */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  padding: 1.75rem 0 0;
  margin-top: 3rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  max-width: 100%;
}
.lesson-nav a        { color: var(--color-accent); }
.lesson-nav a:hover  { text-decoration: underline; }

/* ─── PDF Export Button ──────────────────────────────────── */
.pdf-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.pdf-export-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}
.pdf-export-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

@media print {
  .pdf-export-btn,
  .sidebar,
  .breadcrumb,
  .lesson-nav,
  .lesson-meta .track-label,
  .lesson-meta .module-label {
    display: none !important;
  }
  .app-layout { display: block; }
  .main-content { padding: 0; }
  .lesson-body { max-width: 100%; }
}

/* ─── Responsive: Tablet ─────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }
  .hero            { padding: 3rem 2.5rem 3rem; }
  .tracks-section  { padding: 2.5rem 2.5rem 3.5rem; }
  .main-content--page,
  .main-content--lesson { padding: 2rem 2.5rem 4rem; }
}

/* ─── Responsive: Mid (hero stacks before it gets cramped) ── */
@media (max-width: 900px) {
  .hero        { flex-direction: column; gap: 1.25rem; }
  .hero-right  { flex: none; width: 100%; }
  .btn-primary { width: 100%; justify-content: center; }
}

/* ─── Nav-toggle (burger) — hidden on desktop ────────────── */
.nav-toggle {
  display: none;
}

/* ─── Responsive: Mobile ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Layout: sidebar on top, content below */
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  /* On mobile the whole sidebar is the sticky header bar */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    overflow: visible;
  }
  /* sidebar-top is transparent on mobile — its children flow directly into .sidebar */
  .sidebar-top {
    position: static;
    display: contents;
  }

  /* Logo: grow to fill the row (not full-width), hide icon */
  .sidebar-logo {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 0.875rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.78rem;
    min-height: 44px;
  }
  .sidebar-logo-icon { display: none; }

  /* Burger button: sits at the right end of the logo row */
  .nav-toggle {
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    height: 44px;
    background: none;
    border: none;
    border-left: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    cursor: pointer;
    color: var(--sidebar-text);
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle:hover { color: var(--sidebar-active); }

  /* Three hamburger bars */
  .nav-toggle-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 18px;
  }
  .nav-toggle-icon span {
    display: block;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  /* Animate burger → ✕ when open */
  .sidebar.nav-open .nav-toggle-icon span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .sidebar.nav-open .nav-toggle-icon span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .sidebar.nav-open .nav-toggle-icon span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* Nav: hidden by default; drops down as full-width column when open */
  .sidebar-nav {
    display: none;
    flex: 0 0 100%;
    flex-direction: column;
    padding: 0.5rem 0.75rem 0.625rem;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    mask-image: none;
    -webkit-mask-image: none;
  }
  .sidebar-nav-label { display: none; }
  .sidebar.nav-open .sidebar-nav { display: flex; }

  /* About: hidden by default; shown below nav when open */
  .sidebar-about {
    display: none;
    flex: 0 0 100%;
    border-top: 1px solid rgba(255,255,255,0.06);
    border-left: none;
    padding: 0.5rem 0.75rem 0.625rem;
  }
  .sidebar-about .sidebar-nav-label { display: none; }
  .sidebar.nav-open .sidebar-about { display: flex; }
  .sidebar-author-avatar { width: 26px; height: 26px; font-size: 0.6rem; flex-shrink: 0; }

  /* Nav items: full-width vertical links in the drawer */
  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    white-space: normal;
    padding: 0.45rem 0.625rem;
    font-size: 0.83rem;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    min-height: 0;
    margin-bottom: 0;
    line-height: 1.4;
    color: var(--sidebar-text);
  }
  .sidebar-item:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }
  .sidebar-item[aria-current="page"] { background: rgba(196,97,43,0.2); color: #f0b992; }
  .sidebar-item-icon {
    display: flex;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
  }
  .sidebar-item-icon svg { width: 16px; height: 16px; }
  .sidebar-footer { display: none; }

  /* Content: page scroll (not element scroll) on mobile */
  .main-content {
    min-height: 0;
    overflow: visible;
    overflow-x: hidden;
  }
  .main-content--page,
  .main-content--lesson { padding: 1.5rem 1.25rem 3rem; }

  /* Hero */
  .hero          { padding: 1.5rem 1.25rem; flex-direction: column; gap: 1.25rem; }
  .hero-right    { flex: none; width: 100%; }
  .hero-headline { max-width: none; }
  .btn-primary   { width: 100%; justify-content: center; }

  /* Stats: 2-column grid */
  .stats-bar { display: grid; grid-template-columns: 1fr 1fr; overflow-x: visible; }
  .stat      { border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); padding: 1rem; min-width: 0; }

  /* Tracks */
  .tracks-section { padding: 1.75rem 1.25rem 2.5rem; }
  .track-grid     { grid-template-columns: 1fr; }

  /* Track index */
  .track-index-header { flex-direction: column; gap: 0.875rem; }
  .track-index h1     { font-size: 1.4rem; }

  /* Lesson header */
  .lesson-header h1 {
    font-size: clamp(1.3rem, 5vw, 1.75rem);
  }
  .lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
  }
  .pdf-export-btn { margin-left: 0; }

  /* Lesson body */
  .lesson-body             { max-width: 100%; }
  .lesson-body h2          { font-size: 1.15rem; margin: 2rem 0 0.6rem; }
  .lesson-body h3          { font-size: 0.975rem; }
  .lesson-body blockquote  { padding: 0.6rem 1rem; }
  .lesson-body pre         { padding: 1rem; border-radius: var(--radius-sm); }
  .lesson-body .table-wrap { border-radius: 0; margin-left: -1.25rem; margin-right: -1.25rem; width: calc(100% + 2.5rem); }

  /* Lesson list & nav */
  .lesson-list li        { flex-wrap: wrap; gap: 0.25rem; }
  .lesson-list .duration { margin-left: auto; }
  .lesson-nav            { flex-direction: column; gap: 0.75rem; }
  .breadcrumb            { margin-bottom: 1.5rem; }
}

/* ─── Author Profile (ap-*) ──────────────────────────────── */

/* Hero */
.ap-hero {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: 2rem 2.5rem;
  background: var(--green-dark);
  color: var(--hero-text);
  border-radius: var(--radius-lg);
  margin-bottom: 2.5rem;
}
.ap-avatar {
  width: 80px;
  height: 80px;
  background: var(--rust);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  border: 3px solid rgba(255,255,255,0.15);
}
.ap-name     { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.2rem; }
.ap-title    { font-size: 1rem; color: var(--hero-muted); margin-bottom: 0.5rem; }
.ap-location {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--hero-muted);
  margin-bottom: 0.875rem;
}
.ap-location svg { width: 13px; height: 13px; }
.ap-bio { font-size: 0.9rem; color: var(--hero-muted); line-height: 1.65; margin-bottom: 1.25rem; max-width: 64ch; }

.ap-social      { display: flex; flex-wrap: wrap; gap: 0.625rem; }
.ap-social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  transition: background 0.12s, border-color 0.12s;
}
.ap-social-link:hover          { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.4); }
.ap-social-link svg            { width: 14px; height: 14px; flex-shrink: 0; }
.ap-social-linkedin:hover      { background: rgba(10,102,194,0.3); border-color: #0a66c2; }
.ap-social-github:hover        { background: rgba(255,255,255,0.15); }
.ap-social-email:hover         { background: rgba(196,97,43,0.3); border-color: var(--rust); }
.ap-social-phone:hover         { background: rgba(196,97,43,0.3); border-color: var(--rust); }

/* Two-column grid */
.ap-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: start;
}

/* Section heading */
.ap-section       { margin-bottom: 2rem; }
.ap-section-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-active);
  background: var(--green-dark);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-bottom: 0;
}
.ap-section-title svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Card wrapper under a section title */
.ap-card {
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 1.25rem;
  background: #fff;
}
.ap-card p            { margin-bottom: 0.75rem; font-size: 0.9rem; line-height: 1.7; }
.ap-card p:last-child { margin-bottom: 0; }

/* Timeline */
.ap-timeline { border: 1px solid var(--color-border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: #fff; }
.ap-job {
  padding: 1.25rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
}
.ap-job:last-child   { border-bottom: none; }
.ap-job-header       { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.625rem; }
.ap-job-title        { font-size: 0.95rem; font-weight: 700; color: var(--color-text); margin-bottom: 0.1rem; }
.ap-job-company      { font-size: 0.82rem; color: var(--rust); font-weight: 600; }
.ap-job-dates        { font-size: 0.75rem; color: var(--color-muted); white-space: nowrap; padding-top: 0.1rem; }
.ap-job-bullets      { padding-left: 1.25rem; margin: 0; }
.ap-job-bullets li   { font-size: 0.875rem; color: var(--color-text); margin-bottom: 0.2rem; line-height: 1.55; }
.ap-job--minor .ap-job-title   { font-size: 0.875rem; font-weight: 600; }
.ap-job--minor .ap-job-company { font-size: 0.78rem; }
.ap-job--minor       { padding: 0.75rem 1.25rem; }

/* Education */
.ap-edu-degree { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.15rem !important; }
.ap-edu-school { color: var(--color-muted); font-size: 0.875rem; margin-bottom: 0.1rem !important; }
.ap-edu-year   { font-size: 0.78rem; color: var(--color-muted); margin-bottom: 0 !important; }

/* Tags */
.ap-tags       { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ap-tag {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  background: var(--cream);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  color: var(--color-text);
}
.ap-skill-group       { margin-bottom: 0.875rem; }
.ap-skill-group:last-child { margin-bottom: 0; }
.ap-skill-label       { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-muted); display: block; margin-bottom: 0.3rem; }

@media (max-width: 900px) {
  .ap-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .ap-hero   { flex-direction: column; gap: 1.25rem; padding: 1.5rem 1.25rem; }
  .ap-avatar { width: 60px; height: 60px; font-size: 1.1rem; }
  .ap-name   { font-size: 1.4rem; }
}

/* ─── Roles Page ─────────────────────────────────────────── */
.roles-header          { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--color-border); }
.roles-header h1       { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.6rem; }
.roles-intro           { color: var(--color-muted); font-size: 0.95rem; line-height: 1.7; max-width: 680px; }
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}
.role-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}
.role-card-icon {
  width: 40px;
  height: 40px;
  background: var(--color-accent-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-accent);
}
.role-card-icon svg    { width: 20px; height: 20px; }
.role-card-body        { flex: 1; min-width: 0; }
.role-card-title       { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.35rem; }
.role-card-desc        { font-size: 0.825rem; color: var(--color-muted); line-height: 1.6; margin-bottom: 0.5rem; }
.role-card-tracks      { font-size: 0.75rem; color: var(--color-accent); font-weight: 600; }

@media (max-width: 768px) {
  .roles-grid { grid-template-columns: 1fr; }
}

/* ─── Print ──────────────────────────────────────────────── */
@media print {
  .sidebar, .breadcrumb, .lesson-nav { display: none; }
  .app-layout   { display: block; }
  .main-content--lesson { padding: 0; max-width: none; }
  body          { font-size: 11pt; color: #000; }
  a             { color: #000; }
  pre           { white-space: pre-wrap; background: #f5f5f5; color: #000; }
  .lesson-body table { font-size: 9pt; min-width: 0; }
  .track-card   { border: 1px solid #ccc; break-inside: avoid; }
}
