/* "Documentation Precision" — the Stitch design system for the Dart course portal. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef4ff;
  --surface-3: #e5eeff;
  --text: #16202c;
  --muted: #5b6878;
  --faint: #8a96a6;
  --border: #dbe3ee;
  --accent: #0468b5;
  --accent-strong: #00508d;
  --accent-soft: #e2eefb;
  --accent-text: #ffffff;
  --success: #1a7f45;
  --success-soft: #eaf7ee;
  --red: #c4231b;
  --red-soft: #fde8e8;
  --purple: #7c3aed;
  --purple-soft: #f3ecff;
  --code-bg: #ffffff;
  --code-bar: #f1f5fb;
  --code-border: #d3dce8;
  --code-text: #0f1722;
  --code-muted: #5b6878;
  --hl-keyword: #c0136b;
  --hl-type: #0757a8;
  --hl-string: #0a7a32;
  --hl-number: #a84f00;
  --hl-comment: #6a7685;
  --hl-function: #6a32c9;
  --hl-attr: #8a3ab9;
  --output-label: #c4231b;
  --mark: #cfe8ff;
  --gradient: linear-gradient(135deg, #0175c2, #13b9fd);
  --shadow: 0 1px 2px rgb(16 32 52 / 4%), 0 4px 20px -2px rgb(15 23 42 / 6%);
  --radius: 12px;
  --radius-sm: 10px;
  --header-h: 64px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Default theme is always light, regardless of the OS/browser color-scheme preference —
   dark mode is opt-in only, via the toggle (stored in localStorage, see app.js). */

:root[data-theme="dark"] {
  --bg: #0b1119;
  --surface: #121a25;
  --surface-2: #17212e;
  --surface-3: #1c2836;
  --text: #e4eaf2;
  --muted: #93a1b3;
  --faint: #6c7d93;
  --border: #253244;
  --accent: #3fa9f5;
  --accent-strong: #79c3f8;
  --accent-soft: #10273b;
  --accent-text: #0b1119;
  --success: #4cc77d;
  --success-soft: #0e2818;
  --red: #ff8a80;
  --red-soft: #3a1414;
  --purple: #b794f6;
  --purple-soft: #231a36;
  --code-bg: #0b121c;
  --code-bar: #141d2a;
  --code-border: #2a384b;
  --code-text: #f1f5fa;
  --code-muted: #93a1b3;
  --hl-keyword: #ff7ab2;
  --hl-type: #6fdcff;
  --hl-string: #a5e07b;
  --hl-number: #e5d48a;
  --hl-comment: #7d8ea4;
  --hl-function: #7cc4ff;
  --hl-attr: #d6c5ff;
  --output-label: #ff8a80;
  --mark: #1d4a70;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 24px -2px rgb(0 0 0 / 35%);
  color-scheme: dark;
}

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

html { scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 32px 64px; min-width: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; }

code, kbd { font-family: var(--mono); font-size: 0.88em; }

.icon { flex: none; }
.muted { color: var(--muted); }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow-purple { color: var(--purple); }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Header, sidebar & footer ────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: var(--header-h);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover { color: var(--accent); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--gradient);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgb(1 117 194 / 25%);
}

.brand[class*="tone-"] .brand-mark { background: linear-gradient(135deg, var(--tone), var(--tone-2)); box-shadow: 0 2px 8px -2px var(--tone); }
.is-instructor .brand-mark { background: linear-gradient(135deg, #7c3aed, #c084fc); box-shadow: 0 2px 8px rgb(124 58 237 / 25%); }

.site-nav { display: flex; gap: 2px; padding: 4px; border-radius: 10px; background: var(--surface-2); }

.site-nav a {
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover { color: var(--text); background: var(--surface-3); }
.site-nav a.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgb(16 32 52 / 8%); font-weight: 600; }

.nav-logout { display: flex; margin: 0; }
.nav-logout .link-button { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-size: 0.88rem; }
.nav-logout .link-button:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }

.header-search { position: relative; display: flex; align-items: center; margin-left: auto; }
.header-search > .icon { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }

.header-search input {
  width: 280px;
  height: 38px;
  padding: 0 64px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.header-search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.hotkey {
  position: absolute;
  right: 8px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--faint);
  font-size: 0.68rem;
  pointer-events: none;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover { background: var(--surface-2); color: var(--text); }
.is-instructor .theme-toggle { margin-left: auto; }

.site-footer { border-top: 1px solid var(--border); background: var(--bg); }

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer-title { margin-right: auto; font-weight: 600; color: var(--text); }
.footer-youtube { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; text-decoration: none; }
.footer-youtube .icon { color: var(--red); }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; flex-basis: 100%; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.legal-page h1 { margin-bottom: 4px; }
.legal-page h2 { font-size: 1.2rem; }

/* ── Buttons, chips & badges ─────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }

.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-text); }

.button-red { background: #c4231b; border-color: #c4231b; color: #fff; }
.button-red:hover { background: #a51d16; border-color: #a51d16; color: #fff; }

.button-small { height: 32px; padding: 0 12px; font-size: 0.82rem; }
.button-wide { width: 100%; height: 48px; font-size: 0.95rem; }

.button-complete .when-todo, .button-complete .when-done { display: inline-flex; align-items: center; gap: 8px; }
.button-complete .when-done { display: none; }
.button-complete.is-done { background: var(--success); border-color: var(--success); color: #fff; }
.button-complete.is-done .when-todo { display: none; }
.button-complete.is-done .when-done { display: inline-flex; }

.link-button { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.chip-success { background: var(--success-soft); color: var(--success); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-video { background: var(--red-soft); color: var(--red); }
.badge-recording { background: #fff4d6; color: #8a5a00; }
.badge-soon { background: var(--surface-2); color: var(--faint); border-radius: 999px; }
.badge-next { display: none; background: var(--accent); color: var(--accent-text); letter-spacing: 0.05em; text-transform: uppercase; }

:root[data-theme="dark"] .badge-recording { background: #3a2c08; color: #f5c451; }

.count-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
}

/* ── Home ────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  align-items: start;
  margin-bottom: 48px;
}

.hero-inner h1 { margin: 0 0 12px; font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 700; letter-spacing: -0.025em; }
.hero-tagline { max-width: 640px; margin: 0 0 24px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }

.stat-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 170px)); gap: 12px; margin-bottom: 24px; }

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label { color: var(--faint); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.stat-card strong { font-size: 1.5rem; line-height: 1.3; letter-spacing: -0.02em; }
.stat-card small { color: var(--muted); font-size: 0.82rem; font-weight: 500; letter-spacing: 0; }
.stat-note { color: var(--success); font-size: 0.76rem; font-weight: 500; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-side { display: flex; flex-direction: column; gap: 16px; }

.progress-card { padding: 20px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; }
.progress-head .eyebrow { margin: 0; color: var(--faint); }
.progress-count { margin: 10px 0 14px; font-weight: 600; }
.progress-foot { display: flex; justify-content: space-between; margin-top: 12px; color: var(--faint); font-size: 0.78rem; }

.progress-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width 0.3s; }
.progress-bar-thin { height: 4px; }
.progress-bar-thin span { background: var(--accent); }
.progress-bar-purple span { background: var(--purple); }

.feature-card {
  display: flex;
  gap: 14px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
}

.feature-card:hover { border-color: var(--accent); color: var(--text); }
.feature-card > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.feature-card strong { font-size: 0.98rem; }
.feature-card > span > span { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.feature-card .feature-link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; }

.feature-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
}

.feature-icon-red { background: var(--red-soft); color: var(--red); }

.index-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.index-toolbar h2 { margin: 0 0 4px; font-size: 1.75rem; letter-spacing: -0.02em; }
.index-toolbar p { margin: 0; }

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.2s;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 20%);
  transition: transform 0.2s;
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.category-chips { display: flex; gap: 8px; margin: 20px 0 24px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: none; }

.category-chips a {
  flex: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
}

.category-chips a:hover { border-color: var(--accent); color: var(--accent); }
.category-chips a.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.category { margin-bottom: 20px; padding: 20px; }

.category-header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.category-header .eyebrow { color: var(--accent); }
.category-header h2 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.category-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; }

.lecture-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }

.lecture-row > a,
.lecture-row > div {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: inherit;
  text-decoration: none;
}

.lecture-row > a:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.lecture-row.is-published .lecture-title { font-weight: 600; }
.lecture-row.is-planned { color: var(--muted); }
.lecture-row.is-planned > div { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

.row-status {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--faint);
}

.is-published .row-status { background: var(--surface); color: var(--accent); box-shadow: 0 0 0 1px var(--border); }
.row-status .icon + .icon { display: none; }
.lecture-row.is-done .row-status { background: var(--success); color: #fff; box-shadow: none; }
.lecture-row.is-done .row-status .icon:first-child { display: none; }
.lecture-row.is-done .row-status .icon + .icon { display: block; }

.lecture-row.is-next > a { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.lecture-row.is-next .badge-next { display: inline-flex; }
.lecture-row.is-next .row-status { background: var(--accent); color: var(--accent-text); box-shadow: none; }

.lecture-number { color: var(--faint); font-family: var(--mono); font-size: 0.78rem; }
.lecture-title { min-width: 0; font-size: 0.92rem; }
.lecture-badges { display: flex; flex: 1; gap: 6px; }
.lecture-meta { display: flex; align-items: center; gap: 12px; }
.lecture-time { color: var(--faint); font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; }
.is-next .lecture-time { color: var(--accent); font-weight: 600; }
.row-chevron { display: grid; color: var(--faint); }

.only-published .lecture-row.is-planned,
.only-published .category:not(:has(.is-published)) { display: none; }

.video-section { margin-top: 40px; padding: 24px; }

.section-header { display: flex; align-items: center; gap: 14px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.section-header h2 { margin: 0; font-size: 1.2rem; }
.section-header p { margin: 2px 0 0; font-size: 0.88rem; }
.section-header .button { margin-left: auto; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.video-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }

.video-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #0f1722; overflow: hidden; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity 0.2s, transform 0.3s; }
.video-thumb:hover img { opacity: 1; transform: scale(1.02); }
.video-thumb iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.video-label, .video-duration {
  position: absolute;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgb(0 0 0 / 75%);
  color: #fff;
  font: 600 0.7rem var(--mono);
  text-transform: uppercase;
}

.video-label { top: 10px; left: 10px; }
.video-duration { right: 10px; bottom: 10px; }

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #c4231b;
  color: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 20px rgb(0 0 0 / 35%);
}

.video-play .icon { fill: currentColor; }
.video-body { display: flex; flex: 1; flex-direction: column; padding: 14px 16px 16px; }
.video-body h3 { margin: 0 0 4px; font-size: 1rem; }
.video-body h3 a { color: var(--text); text-decoration: none; }
.video-body h3 a:hover { color: var(--accent); }
.video-body p { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; }
.video-links { display: flex; justify-content: space-between; margin-top: auto; font-size: 0.82rem; font-weight: 600; }
.video-links a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.video-links a:first-child { color: var(--muted); }

/* ── Lecture page ────────────────────────────────────────────── */

/* Instructor recording timer, at the top of the right-hand rail. */
.rec-timer { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); }
.toc-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.toc-label .icon { color: var(--purple); }

.lecture { max-width: 820px; min-width: 0; }
.lecture-single .lecture { max-width: none; }

/* Student lecture pages: "On this page" as one collapsed bar above the article. */
.toc-inline { margin: 0 0 24px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.88rem; }
.toc-inline summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); font-weight: 600; cursor: pointer; list-style: none; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary .icon:first-child { color: var(--accent); }
.is-instructor .toc-inline summary .icon:first-child { color: var(--purple); }
.toc-inline summary small { color: var(--faint); font-weight: 500; }
.toc-inline summary .icon:last-child { margin-left: auto; transition: transform 0.15s; }
.toc-inline[open] summary .icon:last-child { transform: rotate(90deg); }
.toc-inline ol {
  columns: 2 220px;
  column-gap: 24px;
  max-height: 50vh;
  overflow-y: auto;
  margin: 0;
  padding: 8px 14px 12px 36px;
  border-top: 1px solid var(--border);
  list-style: none;
}
.toc-inline li { break-inside: avoid; padding: 3px 0; }
.toc-inline li a { color: var(--muted); text-decoration: none; }
.toc-inline li a:hover { color: var(--accent); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; color: var(--muted); font-size: 0.82rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current] { color: var(--text); font-weight: 600; }

.lecture-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.lecture-share { margin-left: auto; border-color: var(--border); background: var(--surface); }
.lecture-share.is-copied { border-color: var(--success); color: var(--success); }

.lecture .markdown h1 { margin: 0 0 20px; font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 700; letter-spacing: -0.025em; }

.lecture .markdown > h1:first-child { margin: 0 0 20px; }

/* A lecture's key-facts table (right under its title) reads as a card of facts. */
.lecture .markdown > h1 + table {
  display: block;
  width: 100%;
  margin: 0 0 28px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lecture .markdown > h1 + table thead { display: none; }
.lecture .markdown > h1 + table tbody { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 16px; }
.lecture .markdown > h1 + table tr { display: flex; flex-direction: column; gap: 4px; }
.lecture .markdown > h1 + table td { padding: 0; border: 0; background: none; font-size: 0.9rem; font-weight: 600; }
.lecture .markdown > h1 + table td:first-child { color: var(--faint); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.lecture .markdown > h1 + table td:first-child strong { font-weight: 600; }

.video-lecture { margin-top: 48px; }
.video-lecture-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.video-lecture-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.4rem; }
.video-lecture-head h2 .icon { color: var(--red); }

.player { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius) var(--radius) 0 0; background: #0f1722; overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff; text-decoration: none; }

.player-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}

.player-bar a { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; }

.lecture-end { margin-top: 48px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }

.pager-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.pager-card > span { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem; }
.pager-card small { color: var(--muted); font-size: 0.8rem; }
.pager-card:hover { border-color: var(--accent); color: var(--text); }
.pager-next { align-items: flex-end; text-align: right; }

/* ── Rendered Markdown ───────────────────────────────────────── */

.markdown { overflow-wrap: break-word; font-size: 1rem; line-height: 1.7; }
.markdown > :first-child { margin-top: 0; }
.markdown h1 { margin: 24px 0 16px; font-size: 2.1rem; }
.markdown h2 { margin: 48px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 1.45rem; font-weight: 600; }
.markdown h3 { margin: 32px 0 12px; font-size: 1.15rem; font-weight: 600; }
.markdown h4 { margin: 24px 0 8px; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 16px; }
.markdown li + li { margin-top: 4px; }
.markdown hr { margin: 32px 0; border: 0; border-top: 1px solid var(--border); }

.markdown h1, .markdown h2, .markdown h3, .markdown h4 { position: relative; }
.markdown .anchor { position: absolute; left: -0.9em; padding-right: 0.2em; color: var(--faint); text-decoration: none; opacity: 0; }
.markdown :is(h1, h2, h3, h4):hover .anchor { opacity: 1; }

.markdown :not(pre) > code { padding: 0.12em 0.4em; border-radius: 5px; background: var(--accent-soft); color: var(--accent-strong); font-size: 0.85em; }

.markdown table { display: block; width: max-content; max-width: 100%; margin: 0 0 16px; overflow-x: auto; border-collapse: collapse; font-size: 0.92rem; }
.markdown th, .markdown td { padding: 8px 14px; border: 1px solid var(--border); }
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown td { background: var(--surface); }
.markdown tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }

.markdown blockquote {
  margin: 0 0 20px;
  padding: 16px 20px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  color: var(--text);
  font-style: italic;
}

.markdown blockquote > :last-child { margin-bottom: 0; }

.markdown details {
  margin: 0 0 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.markdown summary { font-weight: 600; cursor: pointer; }
.markdown details[open] summary { margin-bottom: 12px; }

.markdown kbd {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.8em;
}

.markdown div[align="center"] { text-align: center; }

/* Article images. Screenshots are mostly phones, so they stay at a phone-like width and
   centred; app.js marks landscape images .is-wide to let them use the column's width. */
.markdown img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  vertical-align: middle;
}

.markdown .figure { margin: 24px auto; text-align: center; }
.markdown .figure img { display: block; width: auto; max-width: min(100%, 360px); max-height: min(640px, 80vh); margin: 0 auto; box-shadow: var(--shadow); }
.markdown .figure img.is-wide { max-width: 100%; max-height: none; }
.markdown figcaption { margin-top: 10px; color: var(--muted); font-size: 0.86rem; }

/* GitHub-style alerts — the instructor scripts use them as their four parts. */
.alert {
  --tone: #0468b5;
  margin: 0 0 16px;
  padding: 14px 18px;
  border-left: 4px solid var(--tone);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--tone) 7%, var(--surface));
}

.alert > :last-child { margin-bottom: 0; }
.alert-title { margin: 0 0 4px; color: var(--tone); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.alert-note { --tone: #1f6feb; }
.alert-tip { --tone: #1a7f37; }
.alert-important { --tone: #8250df; }
.alert-warning { --tone: #bf8700; }
.alert-caution { --tone: #cf222e; }

:root[data-theme="dark"] .alert-title { filter: brightness(1.6); }

/* Code blocks follow the theme: white in light mode, dark in dark mode. */
.code { margin: 0 0 18px; border: 1px solid var(--code-border); border-radius: var(--radius-sm); background: var(--code-bg); overflow: hidden; box-shadow: var(--shadow); }

.code-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--code-border);
  background: var(--code-bar);
  color: var(--code-muted);
  font: 700 0.72rem var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.code-bar > span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 46px;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: 16px 0 #febc2e, 32px 0 #28c840;
  vertical-align: -1px;
}

.code-text .code-bar { color: var(--output-label); }
.code-text .code-bar > span::before { width: 8px; height: 8px; margin-right: 8px; background: #ff5f57; box-shadow: none; }

.copy {
  padding: 3px 9px;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-muted);
  font: 600 0.72rem var(--font);
  cursor: pointer;
}

.copy:hover { border-color: var(--accent); color: var(--accent); }

.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code code { color: var(--code-text); font-size: 0.92rem; font-weight: 500; line-height: 1.7; }

.hljs-keyword, .hljs-meta .hljs-keyword, .hljs-built_in { color: var(--hl-keyword); font-weight: 600; }
.hljs-type, .hljs-title.class_ { color: var(--hl-type); font-weight: 600; }
.hljs-string, .hljs-subst .hljs-string { color: var(--hl-string); }
.hljs-number, .hljs-literal { color: var(--hl-number); }
.hljs-comment { color: var(--hl-comment); font-style: italic; font-weight: 400; }
.hljs-title.function_, .hljs-title { color: var(--hl-function); }
.hljs-meta { color: var(--hl-number); }
.hljs-subst { color: var(--code-text); }
.hljs-attr, .hljs-variable, .hljs-params { color: var(--hl-attr); }

/* ── Courses (front page) ────────────────────────────────────── */

.courses-hero { max-width: 680px; margin: 16px auto 36px; text-align: center; }
.courses-hero h1 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 2.6rem); font-weight: 700; letter-spacing: -0.025em; }
.courses-hero p.muted { margin: 0; font-size: 1.05rem; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

.tone-blue { --tone: #0175c2; --tone-2: #13b9fd; }
.tone-teal { --tone: #0f8a7e; --tone-2: #2dd4bf; }
.tone-amber { --tone: #c26a00; --tone-2: #f5b031; }
.tone-purple { --tone: #7c3aed; --tone-2: #c084fc; }
.tone-orange { --tone: #e8590c; --tone-2: #ffb02e; }
.tone-pink { --tone: #c2255c; --tone-2: #f783ac; }
.tone-indigo { --tone: #4c51bf; --tone-2: #7f9cf5; }
.tone-green { --tone: #2b8a3e; --tone-2: #69db7c; }

.course-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.course-card:hover { border-color: var(--tone); color: var(--text); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .course-card:hover { transform: none; } }

.course-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tone), var(--tone-2));
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  box-shadow: 0 4px 14px -4px var(--tone);
}

.course-body { display: flex; flex: 1; flex-direction: column; gap: 8px; }
.course-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.course-title { font-size: 1.3rem; letter-spacing: -0.015em; }
.course-tagline { color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.course-stats { margin-top: auto; padding-top: 6px; color: var(--faint); font-size: 0.8rem; font-weight: 500; }
.course-card .progress-bar span { background: var(--tone); }
.course-cta { display: inline-flex; align-items: center; gap: 6px; color: var(--tone); font-size: 0.9rem; font-weight: 600; }

.message-page .course-mark { margin: 0 auto 16px; }

/* ── Search ──────────────────────────────────────────────────── */

.search-hero { max-width: 680px; margin: 8px auto 32px; text-align: center; }
.search-hero h1 { margin: 0 0 10px; font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 700; letter-spacing: -0.025em; }
.search-hero > p.muted { margin: 0 0 24px; }

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-form:focus-within { border-color: var(--accent); }
.search-form > .icon { margin-left: 10px; color: var(--faint); }

.search-form input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.search-form input:focus { outline: none; }

.search-summary { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 0; font-size: 0.88rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.dot-muted { background: var(--faint); }

.search-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }

.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 0.82rem; }
.results-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.1rem; }
.results-head h2 .icon { color: var(--accent); }

.results { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }

.result a { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; color: var(--text); text-decoration: none; }
.result:hover { border-color: var(--accent); }
.result-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.result-top .chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.result-heading { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.result-snippet { color: var(--muted); font-size: 0.92rem; line-height: 1.65; }
.result-open { display: inline-flex; align-items: center; gap: 4px; align-self: flex-end; color: var(--accent); font-size: 0.8rem; font-weight: 600; }

mark { padding: 1px 4px; border-radius: 4px; background: var(--mark); color: inherit; }

.search-aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--header-h) + 24px); }
.aside-card { padding: 18px; }
.aside-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 600; font-size: 0.9rem; }
.aside-title .icon { color: var(--accent); }

.suggestions { text-align: left; }
.suggestions > p { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 0.82rem; font-weight: 600; }
.suggestions > p .icon { color: var(--accent); }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.suggestion-chips a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font: 0.76rem var(--mono);
  text-decoration: none;
}

.suggestion-chips a:hover { border-color: var(--accent); color: var(--accent); }

.hotkeys { display: grid; gap: 8px; margin: 0; }
.hotkeys div { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.82rem; }
.hotkeys dd { margin: 0; }
.hotkeys kbd { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); font-size: 0.7rem; font-weight: 600; }

.empty-state { padding: 36px 28px; text-align: center; }
.empty-state h2 { margin: 12px 0 6px; font-size: 1.3rem; }
.empty-state .suggestions { margin: 20px 0; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.empty-state .hero-actions { justify-content: center; }

.message-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
}

/* ── About & message pages ───────────────────────────────────── */

.prose-page { max-width: 860px; margin: 0 auto; padding: 32px 40px; }
.message-page { max-width: 640px; margin: 24px auto; padding: 48px 32px; text-align: center; }
.message-page h1 { margin: 6px 0 12px; }
.message-page .message-icon { margin-bottom: 16px; }
.message-page .hero-actions { justify-content: center; margin-top: 24px; }
.message-page pre { text-align: left; white-space: pre-wrap; }

/* ── Instructor studio ───────────────────────────────────────── */

.studio-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: linear-gradient(110deg, #2a0f55, #4c1d95 60%, #2a0f55);
  color: #fff;
  box-shadow: 0 8px 24px -8px rgb(76 29 149 / 45%);
}

.studio-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: var(--radius-sm); background: #a855f7; }
.studio-banner h1 { margin: 0; font-size: 1.3rem; }
.studio-label { display: flex; align-items: center; gap: 10px; margin: 0 0 2px; color: #c9b6f2; font: 500 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }

.rec { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; background: rgb(255 255 255 / 10%); color: #ff8a80; font-weight: 700; }
.rec::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #ff5f57; animation: rec 1.4s infinite; }

@keyframes rec { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .rec::before { animation: none; } }

.studio-button { margin-left: auto; border-color: transparent; background: #a855f7; color: #fff; }
.studio-button:hover { background: #9333ea; border-color: transparent; color: #fff; }

.script-title { margin-bottom: 24px; padding: 24px; }
.script-title .markdown h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.2rem); }

.script .alert { padding: 18px 22px; font-size: 1.05rem; }

/* Code and the words said while typing it, in one frame. */
/* Code on the left, what to say on the right (4 : 2); stacked on narrow screens. */
.code-frame {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 2fr);
  margin: 0 0 18px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-frame .code { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.code-say {
  padding: 14px 22px 16px;
  border-left: 3px solid #1f6feb;
  background: color-mix(in srgb, #1f6feb 7%, var(--surface));
  font-size: 1.05rem;
}
.code-say p { margin: 0 0 8px; }
.code-say p:last-child { margin-bottom: 0; }
.code-say .code-do { color: var(--purple); font-size: 0.92rem; }
/* Script part titles: "🗣️ EXPLAIN  Say to the camera" — the hint says whether it is spoken. */
.alert-hint { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, currentColor 12%, transparent); font-size: 0.72rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.code-say .alert-hint { margin-left: 0; }
/* 🎬 DO: a slim strip — small pill, then the action on the same line. */
.script .alert.alert-do { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; padding: 7px 14px; border-left-width: 3px; font-size: 0.92rem; }
.alert-do .alert-title { flex: none; margin: 0; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--tone) 14%, transparent); font-size: 0.68rem; letter-spacing: 0.04em; }
.alert-do p { margin: 0; }
.alert-do p + p { margin-left: 0; }
.code-say .code-say-title { margin-bottom: 8px; color: #1f6feb; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.script .alert-title { font-size: 0.85rem; }

.rec-time { margin: 0 0 8px; font-size: 0.82rem; color: var(--muted); }
.rec-time strong { color: var(--text); font: 600 1.4rem var(--mono); }
.rec-time.is-over strong { color: var(--red); }
.rec-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }

.scripts-card { padding: 20px 24px; }
.scripts-card > p { margin-top: 0; }
.table-wrap { overflow-x: auto; }
.scripts-table { width: 100%; border-collapse: collapse; }
.scripts-table th, .scripts-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.scripts-table th { color: var(--faint); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.scripts-table tbody tr:hover td { background: var(--purple-soft); }
.scripts-table a { font-weight: 600; }

/* ── Smaller screens ─────────────────────────────────────────── */

@media (max-width: 1100px) {
  .search-grid { grid-template-columns: 1fr; }
  .search-aside { position: static; }
}

@media (max-width: 900px) {
  main { padding: 24px 16px 48px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .markdown .anchor { display: none; }
  .header-search input { width: 200px; }
  .hotkey { display: none; }
  .header-search input { padding-right: 12px; }
}

@media (max-width: 640px) {
  .header-inner { gap: 10px; padding: 0 16px; }
  .brand > span:last-child, .site-nav .nav-about { display: none; }
  .site-nav { padding: 3px; }
  .header-search { flex: 1; min-width: 0; }
  .header-search input { width: 100%; }
  .stat-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card strong { font-size: 1.2rem; }
  .stat-note { display: none; }
  .category { padding: 14px; }
  .lecture-row > a, .lecture-row > div { gap: 10px; padding: 8px 10px; }
  .lecture-number, .lecture-time, .badge-soon, .badge-video, .badge-recording { display: none; }
  .pager { grid-template-columns: 1fr; }
  .lecture-share { margin-left: 0; }
  .section-header { flex-wrap: wrap; }
  .studio-banner { flex-wrap: wrap; }
  .studio-button { margin-left: 0; }
  .prose-page { padding: 20px; }
  .footer-inner { padding: 20px 16px; }
  .search-form .button { padding: 0 12px; }
}

:root[data-theme="dark"] .course-cta { color: var(--tone-2); }

/* ── Ads ─────────────────────────────────────────────────────── */

.ad-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 28px auto; max-width: 970px; }
.ad-label { color: var(--faint); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.ad-slot .adsbygoogle { width: 100%; min-height: 90px; }
.ad-test {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  max-width: 728px;
  height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--bg) 10px 20px);
  color: var(--muted);
  font-size: 0.8rem;
}
.ad-test strong { color: var(--text); font-size: 0.9rem; }
.ad-rectangle { margin: 0 0 16px; }
.ad-rectangle .ad-test { max-width: 300px; height: 250px; }

/* Ad rail: a column on the right of every page that stays in view while the page scrolls;
   below 1100px it moves under the content and the ad becomes a bottom anchor instead. */
.with-rail {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 8px;
  width: 100%;
  padding-right: 24px;
}
.with-rail main { max-width: none; margin: 0; }
.side-rail {
  position: sticky;
  top: calc(var(--header-h) + 32px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 32px;
}
/* Each slot reserves its ad's exact size, so nothing moves when the ad loads. */
.ad-rail { width: 300px; height: 600px; }
.ad-in-article { display: flex; flex-direction: column; gap: 6px; margin: 32px 0; min-height: 300px; }
.ad-in-article .adsbygoogle { min-height: 280px; }
.ad-anchor { display: none; }

/* Placeholder native ads (no publisher id yet), one layout per slot size. */
.native-ad {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.native-ad-tall { width: 300px; height: 600px; }
.native-ad-tall .native-ad-body { flex: none; }
.native-ad-wide { display: grid; grid-template-columns: 1fr 1.2fr; grid-template-rows: auto 1fr auto; gap: 14px 24px; height: 280px; }
.native-ad-wide .native-ad-media { grid-column: 2; grid-row: 1 / 4; }
.native-ad-wide .native-ad-head, .native-ad-wide .native-ad-body, .native-ad-wide .native-ad-cta { grid-column: 1; }
.native-ad-small { flex-direction: row; align-items: center; gap: 12px; width: 320px; height: 100px; padding: 12px 14px; }
.native-ad-small .native-ad-head { flex: 1; }
.native-ad-small .native-ad-media, .native-ad-small .native-ad-body { display: none; }
.native-ad-small .native-ad-icon { width: 44px; height: 44px; }
.native-ad-small .native-ad-cta { flex: none; width: 72px; height: 32px; }
.native-ad-head { display: flex; align-items: center; gap: 12px; }
.native-ad-icon { flex: none; width: 52px; height: 52px; border-radius: 10px; background: var(--surface-3); }
.native-ad-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
/* Wavy placeholder lines, drawn with a repeating SVG wave as a mask so they follow the theme. */
.native-ad .wave {
  display: block;
  height: 10px;
  background: var(--faint);
  opacity: 0.45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 5 Q5 0 10 5 T20 5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") repeat-x left center / 20px 10px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='10'%3E%3Cpath d='M0 5 Q5 0 10 5 T20 5' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") repeat-x left center / 20px 10px;
}
.native-ad .wave.short { width: 60%; }
.native-ad-badge {
  align-self: flex-start;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f5b031;
  color: #1f2328;
  font-size: 0.7rem;
  font-weight: 700;
}
.native-ad-media {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--surface-2);
}
.native-ad-cta { flex: none; height: 38px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 22%, var(--surface-3)); }

@media (max-width: 1100px) {
  .with-rail { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .side-rail { position: static; width: min(100% - 32px, 360px); margin: 0 auto 32px; }
  .side-rail:empty, .ad-rail { display: none; }
  .ad-anchor {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    display: flex;
    justify-content: center;
    padding: 6px 0;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(8px);
  }
  .ad-anchor .native-ad { box-shadow: none; }
  body.has-anchor-ad { padding-bottom: 113px; }
}

@media (max-width: 700px) {
  .native-ad-wide { display: flex; height: 280px; }
  .native-ad-wide .native-ad-body { display: none; }
}

/* ── Accounts: register/login/dashboard/admin ──────────────────────── */

.auth-page {
  max-width: 420px;
  margin: 48px auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.auth-form input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.auth-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.password-field { position: relative; display: flex; }
.password-field input { flex: 1; padding-right: 72px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
}
.password-toggle:hover { color: var(--text); background: var(--border); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.auth-switch { margin-top: 10px; color: var(--muted); font-size: 0.9rem; }

.form-error {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--output-label) 12%, transparent);
  color: var(--output-label);
  font-size: 0.88rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dashboard-course-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }

.role-form select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
