/* =============================================================================
   Course page (/courses/{slug})

   Same vocabulary as the rest of the site: the indigo hero used by articles,
   jobs and tools, white cards on a soft panel, brand-indigo actions. The only
   per-course colour is the icon tile, so each course is recognisable without
   breaking the brand.
   ========================================================================== */

/* ---- Hero ---------------------------------------------------------------- */
.course-hero {
  background: var(--hero-gradient); color: var(--white);
  padding: 40px 0 48px; position: relative; overflow: hidden;
}
.course-hero::before {
  content: ''; position: absolute; top: -30%; left: -10%; width: 520px; height: 520px;
  background: radial-gradient(circle, rgba(108,107,216,0.28) 0%, transparent 70%); pointer-events: none;
}
.course-hero::after {
  content: ''; position: absolute; top: -50%; right: -10%; width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(156,155,232,0.18) 0%, transparent 70%); pointer-events: none;
}
.course-hero .wrap { position: relative; z-index: 1; }
.course-hero .breadcrumbs ol { margin-bottom: 26px; }
.course-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: center; }
.course-hero-head { display: flex; align-items: center; gap: 14px; }
.course-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 1.05rem; color: var(--white);
  box-shadow: 0 8px 22px rgba(7, 7, 15, 0.35), inset 0 0 0 1px rgba(255,255,255,0.18);
}
.course-hero h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 2.85rem); line-height: 1.12; margin-top: 16px; letter-spacing: -0.03em; }
.course-hero .lead { color: var(--slate-light); font-size: 1.05rem; max-width: 62ch; }
.course-facts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; }
.course-facts li {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);
  font-size: 0.84rem; font-weight: 600; color: var(--white);
}
.course-facts svg { width: 15px; height: 15px; color: var(--accent-2); flex: 0 0 auto; }
.course-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.course-cta .btn-primary { box-shadow: 0 10px 24px rgba(91, 90, 196, 0.45); }
.course-cta .btn-primary:hover { transform: translateY(-1px); }
.course-btn-ghost { background: rgba(255,255,255,0.06); color: var(--white); border-color: rgba(255,255,255,0.22); }
.course-btn-ghost:hover { background: rgba(255,255,255,0.12); color: var(--white); border-color: rgba(255,255,255,0.4); }

/* Progress card */
.course-progress-card {
  display: flex; align-items: center; gap: 20px; padding: 22px;
  background: rgba(13, 13, 28, 0.38); border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.progress-ring { position: relative; width: 104px; height: 104px; flex: 0 0 auto; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 10; }
.ring-track { stroke: rgba(255,255,255,0.12); }
.ring-fill {
  stroke: #5EEAD4; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p));
  transition: stroke-dashoffset 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.ring-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-value strong { font-size: 1.45rem; line-height: 1; }
.ring-value small { font-size: 0.7rem; color: var(--slate-light); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.06em; }
.progress-copy { flex: 1 1 auto; min-width: 0; }
.progress-title { font-weight: 700; font-size: 0.95rem; }
.progress-sub { color: var(--slate-light); font-size: 0.82rem; margin-top: 2px; }
.step-track { display: flex; gap: clamp(2px, 1.2%, 5px); margin-top: 12px; max-width: 100%; }
.step-track .seg { flex: 1; min-width: 0; height: 6px; border-radius: 99px; background: rgba(255,255,255,0.14); transition: background 0.3s ease; }
.step-track .seg.done { background: #5EEAD4; }
.step-track .seg.part { background: linear-gradient(90deg, var(--accent-2) 50%, rgba(255,255,255,0.14) 50%); }
.progress-note { margin-top: 10px; font-size: 0.74rem; color: var(--slate-light); }
.progress-reset { color: var(--accent-2); font-weight: 700; font-size: 0.74rem; text-decoration: underline; padding: 0 2px; }
.progress-reset:hover { color: var(--white); }

/* ---- Reader -------------------------------------------------------------- */
.course-body { background: var(--panel); border-top: 1px solid var(--line); }
.reader-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 280px; gap: 32px; align-items: start; padding-top: 36px; padding-bottom: 72px; }
.col-heading { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--slate); margin-bottom: 12px; }

/* Contents (desktop: sticky card; below 1024px: the drawer) */
.toc-col {
  position: sticky; top: calc(var(--header-h) + 20px); max-height: calc(100vh - var(--header-h) - 40px); overflow-y: auto;
  background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm);
  padding: 0 0 10px; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.toc-col::-webkit-scrollbar { width: 6px; }
.toc-col::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

/* Header: title, done count and overall progress, pinned while the list scrolls */
.toc-summary {
  position: sticky; top: 0; z-index: 2; padding: 18px 18px 14px;
  background: linear-gradient(180deg, var(--white) 82%, rgba(255,255,255,0.92));
  border-bottom: 1px solid var(--line);
}
.toc-summary-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toc-summary-title { font-size: 0.95rem; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.toc-summary-count {
  font-size: 0.72rem; font-weight: 700; color: var(--primary-ink); background: var(--primary-light);
  border: 1px solid var(--primary-soft); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.toc-summary-bar { height: 6px; margin-top: 12px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.toc-summary-bar span {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent-2));
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.toc-summary-sub { margin-top: 8px; font-size: 0.74rem; color: var(--slate); }
.toc-foot { display: none; }

#tocList { padding: 8px 8px 0; }
.toc-static { margin: 0; padding: 4px 10px 0 26px; font-size: 0.9rem; }
.toc-static li { margin-bottom: 8px; }
.toc-static ul { margin: 4px 0 0; padding-left: 16px; color: var(--slate); font-size: 0.82rem; }

/* Module rows */
.toc-group { border-radius: 14px; transition: background-color 0.2s ease, box-shadow 0.2s ease; }
.toc-group + .toc-group { margin-top: 2px; }
.toc-group.expanded { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.toc-topic-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 58px; padding: 10px 10px 10px 10px; border-radius: 14px;
  transition: background-color 0.15s ease;
}
.toc-topic-row:hover { background: var(--panel); }
.toc-group.expanded .toc-topic-row:hover { background: var(--panel-2); }

/* Progress ring around the module number; fills as lessons are completed. */
.toc-ring {
  --size: 34px; position: relative; flex: 0 0 auto; width: var(--size); height: var(--size); border-radius: 50%;
  background: conic-gradient(var(--success) calc(var(--done, 0) * 1%), var(--line) 0);
  display: inline-flex; align-items: center; justify-content: center;
}
.toc-ring::before { content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--white); }
.toc-ring-num, .toc-ring-check { position: relative; font-family: var(--mono); font-size: 0.76rem; font-weight: 800; color: var(--slate-dark); }
.toc-ring-check { display: none; color: var(--white); }
.toc-ring-check svg { width: 15px; height: 15px; display: block; }
.toc-topic-row.active .toc-ring::before { background: var(--primary-light); }
.toc-topic-row.active .toc-ring-num { color: var(--primary-ink); }
.toc-topic-row.completed .toc-ring::before { background: var(--success); inset: 0; }
.toc-topic-row.completed .toc-ring-num { display: none; }
.toc-topic-row.completed .toc-ring-check { display: block; }

.toc-details { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 3px; }
.toc-label { font-size: 0.88rem; font-weight: 700; color: var(--ink); line-height: 1.32; }
.toc-topic-row.active .toc-label { color: var(--primary-ink); }
.toc-count { font-size: 0.72rem; color: var(--slate); }
.toc-count-done { font-weight: 700; color: var(--slate-dark); }
.toc-chevron {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--slate);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.15s ease, color 0.15s ease;
}
.toc-chevron svg { width: 16px; height: 16px; }
.toc-topic-row:hover .toc-chevron { background: var(--white); color: var(--primary); }
.toc-group.expanded .toc-chevron { transform: rotate(180deg); color: var(--primary); }

/* Smooth open/close: the 0fr -> 1fr grid row animates to the content height. */
.toc-collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
.toc-group.expanded .toc-collapse { grid-template-rows: 1fr; }
.toc-lessons {
  min-height: 0; overflow: hidden; list-style: none; margin: 0; padding: 0 8px 0 10px;
  opacity: 0; transition: opacity 0.2s ease, padding 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.toc-group.expanded .toc-lessons { opacity: 1; padding-bottom: 8px; }

/* Lesson rows: a timeline of status dots */
.toc-lessons li { position: relative; }
.toc-lessons li + li::before {
  content: ''; position: absolute; left: 16px; top: -10px; height: 20px; width: 2px; background: var(--line); border-radius: 2px;
}
.toc-lessons li.done-link::before { background: var(--success); }
.toc-lesson {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  min-height: 42px; padding: 8px 10px 8px 6px; border-radius: 10px;
  font-size: 0.84rem; color: var(--slate-dark); font-weight: 500; line-height: 1.35;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.toc-lesson:hover { background: var(--white); color: var(--ink); }
.toc-lesson-icon {
  position: relative; z-index: 1; flex: 0 0 auto; width: 22px; height: 22px; margin-left: 1px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; color: var(--white);
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.toc-lesson-icon svg { width: 12px; height: 12px; display: block; }
.toc-lesson:hover .toc-lesson-icon { border-color: var(--primary-border); }
.toc-lesson.done .toc-lesson-icon { background: var(--success); border-color: var(--success); }
.toc-lesson.active { background: var(--white); color: var(--primary-ink); font-weight: 700; box-shadow: 0 1px 2px rgba(13,13,28,0.06), inset 0 0 0 1px var(--primary-border); }
.toc-lesson.active .toc-lesson-icon { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.toc-lesson-title { flex: 1; min-width: 0; }
.toc-lesson-no { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; color: var(--slate); margin-right: 6px; }
.toc-lesson.active .toc-lesson-no { color: var(--primary); }
.toc-lesson-time { flex: 0 0 auto; font-size: 0.7rem; color: var(--slate); font-weight: 500; }
.toc-lesson.active .toc-lesson-time { color: var(--primary-ink); }

@media (prefers-reduced-motion: reduce) {
  .toc-collapse, .toc-lessons, .toc-chevron, .toc-summary-bar span { transition: none; }
}

/* Lesson */
.content-col { min-width: 0; }
.js .topic-panel { display: none; }
.js .topic-panel.active { display: block; animation: lesson-in 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes lesson-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.topic-panel + .topic-panel { margin-top: 48px; }
.js .topic-panel + .topic-panel { margin-top: 0; }
.topic-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.topic-num {
  font-family: var(--mono); font-weight: 800; font-size: 1.05rem; color: var(--primary);
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--white); border: 1px solid var(--primary-border); box-shadow: var(--shadow-sm);
}
.topic-kicker { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--primary-ink); }
.topic-head h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; margin-top: 2px; }

.lesson-card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.lesson-card-head { padding: 26px 32px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--primary-light), var(--white)); }
.lesson-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 0.78rem; font-weight: 700; color: var(--primary-ink); }
.lesson-kicker .sub-num-label { font-family: var(--mono); }
.lesson-time { font-weight: 600; color: var(--slate); padding-left: 10px; border-left: 1px solid var(--line-strong); }
.lesson-card h3 { font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem); line-height: 1.25; margin-top: 8px; color: var(--ink); }
.lesson-prose { padding: 26px 32px 6px; font-size: 1.04rem; line-height: 1.78; color: var(--ink-2); overflow-wrap: break-word; }
.lesson-prose > * + * { margin-top: 16px; }
.lesson-prose h2, .lesson-prose h3, .lesson-prose h4 { color: var(--ink); line-height: 1.3; margin-top: 28px; }
.lesson-prose h2 { font-size: 1.3rem; }
.lesson-prose h3 { font-size: 1.12rem; }
.lesson-prose ul, .lesson-prose ol { padding-left: 1.3em; }
.lesson-prose li + li { margin-top: 6px; }
.lesson-prose li::marker { color: var(--primary); }
.lesson-prose a { color: var(--primary-ink); text-decoration: underline; text-underline-offset: 3px; }
.lesson-prose blockquote { margin: 18px 0; padding: 12px 18px; border-left: 4px solid var(--primary); background: var(--primary-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-2); }
.lesson-prose img { border-radius: var(--radius-md); }
.lesson-prose :not(pre) > code {
  font-family: var(--mono); background: var(--primary-light); color: var(--primary-ink);
  padding: 2px 6px; border-radius: 6px; font-size: 0.86em; border: 1px solid var(--primary-soft);
}
.lesson-prose .code-block-wrapper { margin: 20px 0; border: 1px solid var(--navy-card); box-shadow: var(--shadow-md); }
.lesson-prose table { width: 100%; border-collapse: collapse; font-size: 0.92rem; display: block; overflow-x: auto; }
.lesson-prose th, .lesson-prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.lesson-prose th { background: var(--panel); }
.lesson-card-foot { padding: 14px 32px 22px; font-size: 0.84rem; }

.content-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }
.content-nav[hidden] { display: none; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px;
  border: 1px solid var(--line-strong); background: var(--white); color: var(--ink);
  padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 0.92rem; box-shadow: var(--shadow-xs);
}
.nav-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.nav-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-ink); }
.nav-btn.primary { background: var(--primary); color: var(--white); border-color: var(--primary); box-shadow: 0 8px 20px rgba(91, 90, 196, 0.32); padding: 12px 24px; }
.nav-btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--white); transform: translateY(-1px); }
.nav-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.course-done {
  display: flex; gap: 16px; align-items: flex-start; margin-top: 20px; padding: 18px 20px;
  background: #ECFDF5; border: 1px solid #A7F3D0; border-radius: var(--radius-lg); color: #065F46;
}
.course-done[hidden] { display: none; }
.course-done-icon { font-size: 1.6rem; line-height: 1; }
.course-done p { margin-top: 4px; font-size: 0.9rem; }

/* Right column */
.ads-col { display: flex; flex-direction: column; gap: 20px; position: sticky; top: calc(var(--header-h) + 20px); }
.side-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; }
.glance-list { margin: 0; display: grid; gap: 0; }
.glance-list div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 0.88rem; }
.glance-list div:first-child { border-top: none; padding-top: 0; }
.glance-list dt { color: var(--slate); }
.glance-list dd { margin: 0; font-weight: 700; color: var(--ink); text-align: right; }
.more-courses { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.more-courses a { display: flex; align-items: center; gap: 12px; padding: 8px; margin: 0 -8px; border-radius: var(--radius-md); transition: background 0.15s ease; }
.more-courses a:hover { background: var(--panel); }
.more-courses a:hover strong { color: var(--primary-ink); }
.mini-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.78rem; color: var(--white);
}
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-text strong { font-size: 0.88rem; color: var(--ink); line-height: 1.3; }
.mini-text small { font-size: 0.74rem; color: var(--slate); margin-top: 2px; }
.ads-col .ad-placement { margin: 0; }

.copy-toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy-card); color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.15); padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(10px);
  transition: all 0.25s ease; pointer-events: none; z-index: 100;
}
.copy-toast.show { opacity: 1; transform: translateY(0); }

/* ---- Contents bar + drawer (below the desktop breakpoint) --------------- */
.toc-bar, .toc-backdrop, .toc-head, .toc-close { display: none; }
.toc-bar {
  position: sticky; top: var(--header-h); z-index: 40; width: 100%;
  align-items: center; gap: 14px; padding: 10px 16px; text-align: left;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); box-shadow: 0 6px 16px -10px rgba(13,13,28,0.25);
}
.toc-bar-btn {
  display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 11px; background: var(--primary); color: var(--white); box-shadow: 0 4px 12px rgba(91,90,196,0.35);
}
.toc-bar-btn svg { width: 20px; height: 20px; }
.toc-bar-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.toc-bar-title { font-size: 0.92rem; font-weight: 700; color: var(--ink); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-bar-sub { font-size: 0.76rem; color: var(--slate); }
.toc-bar-progress { flex: 0 0 auto; margin-left: auto; padding-left: 12px; }
.toc-bar-track { display: block; width: 64px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.toc-bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--primary); transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.toc-backdrop {
  position: fixed; inset: 0; z-index: 110; background: rgba(13, 13, 28, 0.5);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.28s ease;
}
.toc-backdrop[hidden] { display: none; }
.toc-backdrop.in { opacity: 1; }

@media (max-width: 1180px) {
  .reader-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .ads-col { grid-column: 1 / -1; position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1024px) {
  .course-hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .course-progress-card { max-width: 460px; }
  .reader-layout { grid-template-columns: minmax(0, 1fr); padding-top: 24px; }

  .toc-bar { display: flex; }
  .toc-backdrop { display: block; }
  .toc-summary { position: static; padding: 14px 20px 14px; background: var(--white); }
  .toc-summary-title { display: none; }
  .toc-summary-top { justify-content: flex-start; }
  .toc-col {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(360px, 88vw); max-width: 100%;
    height: 100dvh; max-height: none; z-index: 120; display: flex; flex-direction: column;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0; border: none; padding: 0;
    transform: translateX(-100%); transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden; box-shadow: 0 24px 60px rgba(13, 13, 28, 0.25); padding-top: env(safe-area-inset-top);
  }
  .toc-col.open { transform: translateX(0); visibility: visible; }
  .toc-col.closing { transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.28s; }
  .toc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; padding: 16px 14px 14px 20px; border-bottom: 1px solid var(--line); }
  .toc-head .col-heading { margin: 0; }
  .toc-close {
    display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 auto;
    border-radius: 12px; color: var(--slate); background: var(--panel); border: 1px solid var(--line);
  }
  .toc-close:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
  .toc-close svg { width: 18px; height: 18px; }
  .toc-col #tocList { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 10px 16px; }

  body.toc-open { overflow: hidden; }
}
@media (max-width: 640px) {
  .course-hero { padding: 28px 0 32px; }
  .course-hero .breadcrumbs ol { margin-bottom: 18px; }
  .course-icon { width: 44px; height: 44px; border-radius: 12px; font-size: 0.92rem; }
  .course-facts li { font-size: 0.78rem; padding: 6px 11px; }
  .course-cta .btn { flex: 1 1 100%; }
  .course-progress-card { padding: 16px; gap: 16px; }
  .progress-ring { width: 84px; height: 84px; }
  .ring-value strong { font-size: 1.2rem; }
  .topic-num { width: 44px; height: 44px; font-size: 0.95rem; }
  .lesson-card-head { padding: 20px 18px 16px; }
  .lesson-prose { padding: 20px 18px 4px; font-size: 1rem; }
  .lesson-card-foot { padding: 12px 18px 18px; }
  .content-nav { position: sticky; bottom: 0; z-index: 30; margin: 16px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(247,247,252,0.96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
  .nav-btn { padding: 12px 16px; }
  .nav-btn.primary { flex: 1; justify-content: center; }
  .ads-col { grid-template-columns: 1fr; }
}

/* Scrolling to a lesson stops below the sticky header (and the phone contents bar). */
#contentCol, #reader, #tocCol { scroll-margin-top: calc(var(--header-h) + 16px); }
@media (max-width: 1024px) { #contentCol, #reader { scroll-margin-top: calc(var(--header-h) + 76px); } }
