/* Computer Vision Course - builds on ../style.css (same tokens, header, footer, buttons). */
:root {
  --code-bg: #f6f6f4;
  --code-border: #e7e7e3;
  --tok-comment: #6b7280;
  --tok-keyword: #a626a4;
  --tok-string: #2f7d32;
  --tok-number: #b45309;
  --tok-func: #1d4ed8;
  --tok-builtin: #0e7490;
  --note: #2563eb;
  --tip: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --code-bg: #111116;
    --code-border: #26262e;
    --tok-comment: #8b8b99;
    --tok-keyword: #d19aef;
    --tok-string: #8fd694;
    --tok-number: #f5b971;
    --tok-func: #8ab4ff;
    --tok-builtin: #67d4e6;
    --note: #7aa2ff;
    --tip: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
  }
}
:root[data-theme="dark"] {
  --code-bg: #111116;
  --code-border: #26262e;
  --tok-comment: #8b8b99;
  --tok-keyword: #d19aef;
  --tok-string: #8fd694;
  --tok-number: #f5b971;
  --tok-func: #8ab4ff;
  --tok-builtin: #67d4e6;
  --note: #7aa2ff;
  --tip: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
}

.container.wide { max-width: 1320px; }
.nav a.current { color: var(--text); font-weight: 500; }
.menu-btn { display: none; }

/* ---------- Layout ---------- */
.course-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 210px;
  gap: 48px;
  align-items: start;
  padding-top: 32px;
  padding-bottom: 72px;
}
.course-side, .lesson-toc {
  position: sticky; top: 86px;
  max-height: calc(100vh - 100px); overflow-y: auto;
  font-size: 13.5px;
  scrollbar-width: thin;
}
.side-home { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.side-home:hover { color: var(--accent); }
.side-part { margin: 18px 0 6px; font-weight: 600; font-size: 13px; }
.side-part .mono { color: var(--accent); font-weight: 500; font-size: 11.5px; margin-right: 4px; }
.course-side ol { list-style: none; margin: 0; padding: 0; }
.course-side li a {
  display: flex; gap: 8px; padding: 5px 8px; border-radius: 8px;
  text-decoration: none; color: var(--muted); line-height: 1.35;
}
.course-side li a .mono { font-size: 11.5px; padding-top: 2px; opacity: .8; }
.course-side li a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.course-side li a.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }

.lesson-toc ul { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--border); }
.lesson-toc li a { display: block; padding: 3px 0; color: var(--muted); text-decoration: none; line-height: 1.35; }
.lesson-toc li.sub a { padding-left: 12px; font-size: 12.5px; }
.lesson-toc li a:hover, .lesson-toc li a.active { color: var(--accent); }

@media (max-width: 1180px) {
  .course-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .lesson-toc { display: none; }
}
@media (max-width: 860px) {
  .course-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 20px; }
  .menu-btn { display: grid; }
  .course-side {
    position: fixed; z-index: 20; top: 62px; left: 0; bottom: 0; width: min(320px, 86vw);
    max-height: none; padding: 16px 16px 40px; background: var(--bg);
    border-right: 1px solid var(--border); box-shadow: var(--shadow);
    transform: translateX(-105%); transition: transform .25s ease;
  }
  body.side-open .course-side { transform: none; }
  body.side-open::after {
    content: ""; position: fixed; inset: 62px 0 0 0; z-index: 15;
    background: rgba(0, 0, 0, .35);
  }
}

/* ---------- Lesson header ---------- */
.lesson { min-width: 0; max-width: 800px; }
.lesson-head h1 { font-size: clamp(1.9rem, 4.2vw, 2.7rem); line-height: 1.12; letter-spacing: -.03em; margin: 0 0 14px; }
.lesson-head .lead { max-width: none; }
.lesson-sources { font-size: 12.5px; color: var(--muted); margin: 0 0 18px; padding-left: 12px; border-left: 2px solid var(--accent); }
.run-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; margin: 6px 0 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.run-box > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.run-box .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); width: 100%; }
.run-box code { font: 13px var(--mono); padding: 4px 8px; border-radius: 6px; background: var(--code-bg); border: 1px solid var(--code-border); overflow-wrap: anywhere; }
.run-box .btn { padding: 8px 14px; font-size: 13.5px; word-break: normal; }

/* ---------- Prose ---------- */
.prose { font-size: 16.5px; line-height: 1.72; }
.prose > * + * { margin-top: 0; }
.prose h2 { font-size: 1.5rem; letter-spacing: -.02em; margin: 52px 0 12px; padding-top: 6px; line-height: 1.25; }
.prose h3 { font-size: 1.15rem; letter-spacing: -.01em; margin: 32px 0 8px; }
.prose h2 .headerlink, .prose h3 .headerlink { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose h2:hover .headerlink, .prose h3:hover .headerlink { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; }
.prose li { margin: 4px 0; }
.prose ul, .prose ol { padding-left: 24px; }
.prose a { color: var(--accent); text-underline-offset: 2px; }
.prose strong { font-weight: 600; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.prose blockquote { margin: 0 0 16px; padding: 4px 16px; border-left: 3px solid var(--border); color: var(--muted); }

.prose code, .run-box code { font-variant-ligatures: none; }
.prose :not(pre) > code {
  font: .86em var(--mono); padding: .12em .38em; border-radius: 5px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  overflow-wrap: anywhere;
}
.prose .highlight { position: relative; margin: 0 0 20px; }
.prose pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 10px;
  font: 13.4px/1.6 var(--mono); tab-size: 4; font-variant-ligatures: none;
}
.prose pre code { font: inherit; background: none; padding: 0; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; opacity: 0;
  font: 500 11.5px var(--mono); padding: 4px 9px; border-radius: 6px; cursor: pointer;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); transition: opacity .15s;
}
.highlight:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* Pygments tokens */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .ch, .highlight .cs, .highlight .sd { color: var(--tok-comment); font-style: italic; }
.highlight .k, .highlight .kn, .highlight .kc, .highlight .kd, .highlight .kr, .highlight .ow, .highlight .kp { color: var(--tok-keyword); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sa, .highlight .se, .highlight .si, .highlight .sb, .highlight .sh { color: var(--tok-string); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: var(--tok-number); }
.highlight .nf, .highlight .fm, .highlight .nc { color: var(--tok-func); }
.highlight .nb, .highlight .bp { color: var(--tok-builtin); }
.highlight .gp { color: var(--muted); user-select: none; }

/* Tables */
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 14.5px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { font-weight: 600; font-size: 13px; color: var(--muted); }

/* Figures */
.fig { margin: 8px 0 28px; }
.fig img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.fig figcaption { font-size: 13.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* Math */
.arithmatex { overflow-x: auto; overflow-y: hidden; }
div.arithmatex { margin: 0 0 18px; padding: 4px 0; }

/* Admonitions */
.admonition {
  margin: 0 0 20px; padding: 12px 16px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--adm, var(--note)) 35%, var(--border));
  background: color-mix(in srgb, var(--adm, var(--note)) 7%, var(--surface));
  font-size: 15px;
}
.admonition > p:last-child, .admonition > ul:last-child { margin-bottom: 0; }
.admonition-title { font-weight: 600; margin: 0 0 6px !important; color: var(--adm, var(--note)); }
.admonition.tip { --adm: var(--tip); }
.admonition.warning, .admonition.bug { --adm: var(--warn); }
.admonition.danger { --adm: var(--danger); }
.admonition .highlight:last-child { margin-bottom: 0; }

details { margin: 0 0 20px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 10px; }

.footnote { font-size: 14px; color: var(--muted); }

/* Pager reuses .pager from style.css */
.lesson .pager { margin-top: 56px; }

/* ---------- Course index ---------- */
.course-index { padding-bottom: 80px; }
.course-hero { padding: 64px 0 24px; }
.course-hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 18px; max-width: 18ch; }
.course-hero .lead { max-width: 64ch; margin-bottom: 26px; }
.hero-strip { margin: 40px 0 0; }
.hero-strip img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; box-shadow: var(--shadow); }
.course-index .intro { max-width: 800px; margin: 40px 0 8px; }
.part { padding-top: 40px; }
.part h2 { font-size: 1.4rem; letter-spacing: -.02em; margin: 0 0 18px; }
.part h2 .mono { color: var(--accent); font-size: 13px; font-weight: 500; margin-right: 6px; vertical-align: 2px; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.lesson-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--text) 18%, var(--border)); }
.lesson-card .num { color: var(--accent); font-size: 12.5px; }
.lesson-card strong { font-size: 1.05rem; letter-spacing: -.01em; line-height: 1.3; }
.lesson-card .desc { color: var(--muted); font-size: 14px; line-height: 1.5; }
.lesson-card .tags-line { margin-top: auto; padding-top: 6px; font-size: 11.5px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .lesson-card, .course-side { transition: none; }
}
