/* ============================================================
   LearnHub — design tokens
   Two themes, both driven off the same CSS variable set.
   Terminal (default): pure black, white mono text, amber accent.
   VS Code: editor dark grey, blue accent.
   ============================================================ */

:root,
[data-theme="terminal"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #131313;
  --border: #2a2a2a;
  --fg: #e8e8e3;
  --fg-dim: #8a8a83;
  --accent: #ff7a1a;
  --accent-dim: #b85400;
  --accent-fg: #000000;
  --success: #3fbf6f;
  --danger: #ff5c5c;
  --font-mono: "JetBrains Mono", "Fira Code", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --font-ui: var(--font-mono);
  --radius: 2px;
  --prompt-char: ">";
  --caret: 2px;
}

[data-theme="vscode"] {
  --bg: #1e1e1e;
  --surface: #252526;
  --surface-2: #2d2d30;
  --border: #3c3c3c;
  --fg: #d4d4d4;
  --fg-dim: #858585;
  --accent: #007acc;
  --accent-dim: #005a9e;
  --accent-fg: #ffffff;
  --success: #4ec9b0;
  --danger: #f14c4c;
  --font-mono: "Consolas", "Menlo", "SFMono-Regular", monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", var(--font-mono);
  --radius: 4px;
  --prompt-char: "//";
  --caret: 0px;
}

/* White theme — default. Colors picked and checked against WCAG AA
   (4.5:1 for normal-sized body text) against every background they're
   actually paired with in this stylesheet (--bg, --surface, --surface-2):
     fg on bg/surface/surface-2   >= 16.6:1
     fg-dim on bg/surface/surface-2 >= 4.9:1
     accent on bg/surface/surface-2 >= 4.4:1  (used by links, active states)
     accent-fg on accent            >= 6:1    (white text on accent buttons)
     success on bg/surface-2        >= 4.5:1  (quiz "correct" state)
     danger on bg/surface-2         >= 5.4:1  (quiz "wrong" state)
   Re-check with a contrast checker if any of these colors change. */
[data-theme="white"] {
  --bg: #ffffff;
  --surface: #f6f6f4;
  --surface-2: #ececea;
  --border: #dcdcd8;
  --fg: #0b0b0b;
  --fg-dim: #65655f;
  --accent: #a84304;
  --accent-dim: #7a3000;
  --accent-fg: #ffffff;
  --success: #177a41;
  --danger: #b02e2e;
  --font-mono: "JetBrains Mono", "Fira Code", "IBM Plex Mono", monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

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

code, pre { font-family: var(--font-mono); }

::selection { background: var(--accent); color: var(--accent-fg); }

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

/* prefers-reduced-motion: kill decorative motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Boot sequence ---------- */
#boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  color: #d8d8d0;
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 10vh 6vw;
  z-index: 9999;
  white-space: pre-wrap;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#boot-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#boot-text .caret {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: #ff7a1a;
  margin-left: 2px;
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Nav ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: visible;
}
.nav-logo {
  position: absolute;
  left: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-right: 12px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.nav-logo .bracket { color: var(--accent); }
.nav-link {
  color: var(--fg-dim);
  padding: 6px 10px;
  border-radius: var(--radius);
  white-space: nowrap;
  font-size: 13px;
}
.nav-link:hover { color: var(--fg); text-decoration: none; background: var(--surface-2); }
.nav-link.active { color: var(--accent); }
.nav-center {
  position: absolute;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
}
.nav-spacer { flex: 1; }
.nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--fg); border-color: var(--accent); }

/* Hover navigation cards — the collapsed bar and paired preview cards follow
   the supplied reference while keeping all destinations usable by keyboard. */
.nav-menu { position: relative; display: inline-flex; align-items: center; }
.nav-menu-trigger {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px;
  color: var(--fg-dim); background: transparent; border: 0; border-radius: var(--radius);
  font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: color .18s ease, background .18s ease;
}
.nav-menu-trigger > span { font-size: 12px; transition: transform .22s ease; }
.nav-menu:hover .nav-menu-trigger, .nav-menu:focus-within .nav-menu-trigger, .nav-menu.is-open .nav-menu-trigger { color: var(--fg); background: var(--surface-2); }
.nav-menu:hover .nav-menu-trigger > span, .nav-menu:focus-within .nav-menu-trigger > span, .nav-menu.is-open .nav-menu-trigger > span { transform: rotate(180deg); }
.nav-menu-panel {
  position: absolute; top: calc(100% + 12px); left: 50%; width: min(470px, calc(100vw - 28px));
  padding: 12px; display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 20px 44px rgba(0,0,0,.32);
  opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, -8px) scale(.98);
  transition: opacity .18s ease, transform .22s cubic-bezier(.16,1,.3,1), visibility .22s;
  z-index: 250;
}
.nav-menu-panel::before { content: ""; position: absolute; top: -13px; left: 0; right: 0; height: 14px; }
.nav-menu:hover .nav-menu-panel, .nav-menu:focus-within .nav-menu-panel, .nav-menu.is-open .nav-menu-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0) scale(1); }
.nav-menu-lead { width: 110px; min-height: 104px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 9px; background: var(--surface-2); color: var(--fg-dim); }
.nav-menu-lead > span { color: var(--accent); font: 700 21px var(--font-mono); }
.nav-menu-lead p { margin: 0; font-size: 12px; line-height: 1.4; }
.nav-menu-cards { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.nav-menu-link { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 9px; border-radius: 8px; color: var(--fg-dim); text-decoration: none; transition: background .16s ease, color .16s ease, transform .16s ease; }
.nav-menu-link:hover, .nav-menu-link:focus-visible { color: var(--fg); background: var(--bg); text-decoration: none; transform: translateY(-1px); }
.nav-menu-link.active { color: var(--accent); }
.nav-menu-link-icon { display: grid; flex: 0 0 28px; width: 28px; height: 28px; place-items: center; border: 1px solid var(--border); border-radius: 7px; color: var(--accent); font: 700 10px var(--font-mono); }
.nav-menu-link strong, .nav-menu-link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-menu-link strong { font-size: 12px; color: currentColor; }
.nav-menu-link small { margin-top: 2px; font-size: 10px; opacity: .72; }
.nav-profile-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 0 4px; border: 1px solid var(--border); border-radius: 50%; color: var(--fg-dim); }
.nav-profile-btn:hover, .nav-profile-btn:focus-visible { color: var(--fg); border-color: var(--accent); }
.nav-profile-btn svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* "Skip to content" link — the first focusable element on every page.
   Off-screen until it receives keyboard focus, then it becomes a
   visible, high-contrast target above the sticky navbar so keyboard
   users can jump straight past the nav/boot-screen into the page. */
.skip-link {
  position: fixed;
  top: -60px;
  left: 8px;
  z-index: 1000;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 8px;
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* Visually hidden but still announced by screen readers (used for the
   theme-toggle's aria-live change announcements). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
}
.theme-toggle-btn svg { display: block; }

.nav-search { position: relative; margin-left: 4px; }
.gooey-search { width: 104px; height: 40px; transition: width .4s cubic-bezier(.16,1,.3,1); }
.gooey-search.is-expanded { width: 242px; }
.gooey-search-filter { position: absolute; width: 0; height: 0; overflow: hidden; }
.gooey-search-row { position: relative; display: flex; align-items: center; height: 40px; }
.gooey-search-trigger, .gooey-search-field, .gooey-search-bubble { background: var(--fg); color: var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.gooey-search-trigger { position: absolute; right: 0; z-index: 2; display: inline-flex; width: 104px; height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; border: 0; border-radius: 999px; font: 600 12px var(--font-mono); cursor: pointer; transition: width .4s cubic-bezier(.16,1,.3,1), opacity .16s ease; }
.gooey-search-trigger svg, .gooey-search-bubble svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.gooey-search-field { position: absolute; right: 0; display: flex; width: 0; height: 40px; align-items: center; overflow: visible; border-radius: 999px; opacity: 0; transition: width .4s cubic-bezier(.16,1,.3,1), opacity .18s ease; }
.gooey-search.is-expanded .gooey-search-field { width: 200px; padding: 0 16px; opacity: 1; }
.gooey-search.is-expanded .gooey-search-trigger { width: 200px; opacity: 0; pointer-events: none; }
.gooey-search-bubble { position: absolute; left: -2px; display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; opacity: 0; transform: scale(.2); transition: opacity .22s ease .08s, transform .4s cubic-bezier(.16,1,.3,1); }
.gooey-search.is-expanded .gooey-search-bubble { opacity: 1; transform: scale(1); }
.nav-search-input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--bg); font: 500 12px var(--font-mono); }
.nav-search-input::placeholder { color: color-mix(in srgb, var(--bg) 55%, transparent); }
.nav-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  max-width: 340px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 200;
}
.nav-search-results.open { display: block; }
.nav-search-group {
  padding: 8px 12px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}
.nav-search-result {
  display: block;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-search-result:hover { background: var(--surface-2); text-decoration: none; }
.nav-search-empty { padding: 10px 12px; font-size: 12px; color: var(--fg-dim); }

/* ---------- Landing ---------- */
.hero {
  padding: 14vh 6vw 8vh;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-size: clamp(28px, 5vw, 52px);
  margin: 0 0 14px;
  letter-spacing: -0.5px;
}
.hero .prompt { color: var(--accent); }
.hero p {
  color: var(--fg-dim);
  max-width: 560px;
  margin: 0 auto;
  font-size: 15px;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  padding: 6vh 6vw;
  max-width: 1100px;
  margin: 0 auto;
}
.lang-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lang-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.lang-card--expandable,
.teaser-card--expandable { cursor: pointer; color: inherit; text-decoration: none; }
.lang-card--expandable:hover,
.teaser-card--expandable:hover { text-decoration: none; }
.lang-card .icon { font-size: 22px; color: var(--accent); }
.lang-card h3 { margin: 0; font-size: 17px; }
.lang-card p { margin: 0; color: var(--fg-dim); font-size: 13px; flex: 1; }
.lang-card .start-btn {
  align-self: flex-start;
  color: var(--accent);
  font-size: 13px;
  border: 1px solid var(--accent-dim);
  padding: 5px 10px;
  border-radius: var(--radius);
  margin-top: 6px;
}
.lang-card .start-btn:hover { background: var(--accent); color: var(--accent-fg); text-decoration: none; }

/* ---------- Expandable home-path cards ---------- */
.expand-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(5px);
}
.expand-dialog-backdrop[hidden] { display: none; }
.expand-dialog {
  position: relative;
  width: min(100%, 560px);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: max(var(--radius), 10px);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .5);
  padding: 30px;
}
.expand-dialog-icon { color: var(--accent); font-size: 30px; line-height: 1; margin-bottom: 14px; }
.expand-dialog-kicker { color: var(--accent); font-size: 11px; letter-spacing: .12em; margin: 0 0 5px; text-transform: uppercase; }
.expand-dialog h2 { font-size: 26px; line-height: 1.2; margin: 0 36px 10px 0; }
.expand-dialog-summary { color: var(--fg-dim); margin: 0; }
.expand-dialog-content { margin: 20px 0; color: var(--fg-dim); font-size: 13px; }
.expand-dialog-content ul { margin: 10px 0 0; padding-left: 20px; }
.expand-dialog-content li + li { margin-top: 5px; }
.expand-dialog-cta { display: inline-block; }
.expand-dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font: 26px/1 var(--font-mono);
}
.expand-dialog-close:hover { border-color: var(--accent); color: var(--accent); }
body.dialog-open { overflow: hidden; }

.teaser-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  padding: 4vh 6vw 10vh;
  max-width: 1100px;
  margin: 0 auto;
}
/* Solid (not dashed) and hoverable since 3.7 — these are real
   destinations now, not "coming soon" placeholders. */
.teaser-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--fg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.teaser-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.teaser-card h3 { margin-top: 0; color: var(--accent); }
.teaser-card p { color: var(--fg-dim); font-size: 13px; flex-grow: 1; }
.teaser-cta {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
}

/* ---------- Learn layout ---------- */
.learn-shell {
  display: grid;
  grid-template-columns: 20% 60% 20%;
  min-height: calc(100vh - 52px);
}

.sidebar {
  grid-column: 1;
  width: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  height: calc(100vh - 52px);
  position: sticky;
  top: 52px;
  padding: 14px 0;
}
.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-dim);
  padding: 0 16px 10px;
}
.unit { margin-bottom: 4px; }
.unit-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  /* Resets for the <button> this now is (was a clickable <div>) so it
     still looks like a plain row, not a browser-default button. */
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
}
.unit-head:hover { background: var(--surface-2); }
.unit-head .chev { color: var(--fg-dim); transition: transform 0.15s ease; font-size: 10px; }
.unit.open .unit-head .chev { transform: rotate(90deg); }
.unit-body { max-height: 0; overflow: hidden; padding-left: 8px; transition: max-height .35s cubic-bezier(.22,1,.36,1); }
.unit.open .unit-body { max-height: 1800px; }
.sub-unit-label {
  padding: 6px 16px 4px 24px;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lesson-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 30px;
  font-size: 13px;
  color: var(--fg-dim);
  cursor: pointer;
}
.lesson-link:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.lesson-link.active { color: var(--accent); background: var(--surface-2); }
.lesson-link .check {
  width: 12px;
  flex-shrink: 0;
  color: var(--success);
}

.content-panel {
  grid-column: 2;
  width: auto;
  padding: 6vh 4vw;
  max-width: none;
}
.lesson-eyebrow { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.lesson-heading { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; }
.lesson-heading h1 { margin: 0; font-size: 26px; }
.content-panel h2 { font-size: 17px; margin-top: 32px; color: var(--fg); }
.content-panel p { color: var(--fg); }

.bookmark-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 15px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.bookmark-btn:hover { border-color: var(--accent); color: var(--accent); }
.bookmark-btn.active { color: var(--accent); border-color: var(--accent-dim); }

.print-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.print-btn:hover { border-color: var(--accent); color: var(--accent); }

.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13px;
  margin: 14px 0;
  color: var(--fg);
}
.code-block .kw { color: var(--accent); }
.code-block .str { color: var(--success); }
.code-block .com { color: var(--fg-dim); }

.tryit-box {
  /* Editors stay terminal-like regardless of the surrounding site theme. */
  --surface: #171717;
  --surface-2: #232323;
  --border: #353535;
  --fg: #e5e5e5;
  --fg-dim: #a3a3a3;
  border: 1px solid color-mix(in srgb, var(--border) 80%, #000);
  border-radius: 10px;
  margin: 16px 0 26px;
  overflow: hidden;
  background: #171717;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .2);
}
.tryit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #232323;
  border-bottom: 1px solid #303030;
  padding: 9px 12px;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tryit-header .btns { display: flex; gap: 6px; }
.tryit-header .nav-btn { border-color: #4a4a4a; color: #e5e5e5; }
.tryit-header .nav-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.tryit-hint {
  text-transform: none;
  letter-spacing: normal;
  opacity: 0.6;
  font-size: 10px;
  margin-left: 4px;
}
/* .tryit-editor is now the mount point for a CodeMirror 6 instance
   (vendor/codemirror/) rather than a <textarea>. Sizing/scrolling lives
   here; colors, padding, and font come from the CM6 theme in
   vendor/codemirror/ so they can react to .cm-focused etc. */
.tryit-editor {
  width: 100%;
  max-height: 420px;
  overflow: auto;
}
.tryit-editor .cm-editor { min-height: 110px; }
.tryit-editor .cm-scroller { max-height: 420px; }
.tryit-output {
  border-top: 1px solid #303030;
  background: #101010;
  color: #d4d4d4;
  padding: 10px 14px;
  font-size: 12px;
  min-height: 32px;
  white-space: pre-wrap;
}
[data-theme="vscode"] .tryit-box { border-color: #3c3c3c; }
[data-theme="vscode"] .tryit-header { background: #252526; }
[data-theme="vscode"] .tryit-output { background: #181818; }

.tryit-frame {
  display: block;
  width: 100%;
  min-height: 160px;
  border: none;
  border-top: 1px solid var(--border);
  background: #fff;
}

.quiz-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 30px 0;
  background: var(--surface);
}
.quiz-box h2 { margin-top: 0; }
.quiz-q { margin-bottom: 16px; }
.quiz-q p { font-size: 14px; margin: 0 0 8px; }
.quiz-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
}
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.correct { border-color: var(--success); color: var(--success); }
.quiz-opt.wrong { border-color: var(--danger); color: var(--danger); }
.quiz-opt[disabled] { cursor: default; }

/* ---------- Certificate box (shown on a language's last lesson once complete) ---------- */
.certificate-box {
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 22px;
  margin: 30px 0;
  background: var(--surface);
  text-align: center;
}
.certificate-box h2 { margin-top: 0; color: var(--accent); }
.certificate-box p { color: var(--fg-dim); font-size: 13px; margin-bottom: 16px; }
.certificate-box .start-btn {
  display: inline-block;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
}
.certificate-box .start-btn:hover { background: var(--accent); color: var(--accent-fg); }

/* ---------- Bookmark / related-lesson cards (same visual language as the landing page's lang-card) ---------- */
.bookmark-grid,
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.bookmark-card,
.related-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.15s ease, transform 0.15s ease;
  color: var(--fg);
}
.bookmark-card:hover,
.related-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.bookmark-card .bookmark-eyebrow,
.related-card .related-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--fg-dim); }
.bookmark-card .bookmark-title,
.related-card .related-title { font-size: 14px; color: var(--fg); }
.bookmark-card:hover .bookmark-title,
.related-card:hover .related-title { color: var(--accent); }

/* ---------- Related lessons (bottom of each lesson, below the quiz) ---------- */
.related-lessons { margin: 30px 0; }
.related-lessons h2 { font-size: 17px; margin: 0 0 14px; color: var(--fg); }

.lesson-nav { display: flex; justify-content: space-between; margin-top: 40px; border-top: 1px solid var(--border); padding-top: 18px; }
.points-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 200;
}
.points-toast.show { transform: translateY(0); opacity: 1; }

/* ---------- Auth widget (navbar) + login/signup modal ---------- */
.auth-widget { display: flex; align-items: center; gap: 10px; margin-right: 10px; }
.auth-username { font-size: 13px; color: var(--fg); opacity: 0.8; white-space: nowrap; }
.auth-btn { padding: 6px 12px; font-size: 13px; }

/* Streak counter — dim/grey by default (streak at 0, or lapsed and not
   yet renewed today), lights up in --accent once today's lesson/quiz is
   done. Deliberately small so it doesn't compete with the username. */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.streak-badge svg { flex-shrink: 0; }
.streak-badge--active { color: var(--accent); border-color: var(--accent); }
.streak-count { min-width: 1ch; text-align: center; }

/* ---------- Badges (profile page, 3.6) ----------
   Grid of tiles, one per known badge code. Locked tiles stay visible
   (greyed out) rather than being hidden, so the profile page also works
   as a checklist of what's left to earn. */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.badge-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.badge-tile-icon { font-size: 28px; line-height: 1; }
.badge-tile-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.badge-tile-desc { font-size: 11px; color: var(--fg-dim); }
.badge-tile--locked { opacity: 0.4; filter: grayscale(1); }
.badge-tile--earned { border-color: var(--accent); }

.auth-modal-backdrop { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 18px; background: rgba(3,5,8,.74); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s; }
.auth-modal-backdrop.open { opacity: 1; visibility: visible; }
.auth-modal { width: 420px; max-width: 100%; padding: 22px; color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 28px 80px rgba(0,0,0,.48); transform: translateY(10px) scale(.98); transition: transform .24s cubic-bezier(.16,1,.3,1); }
.auth-modal-backdrop.open .auth-modal { transform: translateY(0) scale(1); }
.auth-modal-header { display: flex; align-items: center; justify-content: space-between; }
.auth-modal-mark { display: grid; width: 34px; height: 34px; place-items: center; color: var(--accent-fg); background: var(--accent); border-radius: 10px; font: 700 12px var(--font-mono); }
.auth-modal-close { width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--fg-dim); font-size: 22px; cursor: pointer; }
.auth-modal-close:hover, .auth-modal-close:focus-visible { color: var(--fg); border-color: var(--accent); }
.auth-modal-copy { margin: 22px 0 18px; }
.auth-eyebrow { margin: 0 0 7px; color: var(--accent); font: 700 10px var(--font-mono); letter-spacing: .11em; }
.auth-modal-copy h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.auth-modal-description { margin: 8px 0 0; color: var(--fg-dim); font-size: 13px; line-height: 1.55; }
.auth-modal-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 17px; background: var(--surface-2); border-radius: 10px; }
.auth-tab { padding: 9px; border: 0; border-radius: 7px; background: transparent; color: var(--fg-dim); font: 600 12px var(--font-ui); cursor: pointer; }
.auth-tab.active { color: var(--fg); background: var(--surface); box-shadow: 0 1px 5px rgba(0,0,0,.18); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form[hidden] { display: none; }
.auth-form label { display: grid; gap: 6px; color: var(--fg-dim); font: 600 11px var(--font-mono); }
.auth-form input { width: 100%; box-sizing: border-box; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--fg); font: 13px var(--font-ui); }
.auth-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.auth-password-hint, .auth-switch-copy { margin: -2px 0 0; color: var(--fg-dim); font-size: 11px; line-height: 1.45; }
.auth-submit { display: flex; justify-content: space-between; align-items: center; padding: 11px 13px; border: 0; border-radius: 9px; background: var(--accent); color: var(--accent-fg); font: 700 13px var(--font-ui); cursor: pointer; transition: transform .16s ease, filter .16s ease; }
.auth-submit:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-error { margin: 0; color: #e5484d; font-size: 12px; }
.auth-switch-copy { margin: 17px 0 0; text-align: center; }

@media (max-width: 720px) {
  .auth-username { display: none; }
}

/* ---------- Bookmarks page ---------- */
.bookmarks-empty { max-width: 480px; margin: 10vh auto; padding: 0 6vw; text-align: center; color: var(--fg-dim); }
.bookmarks-empty h1 { color: var(--fg); font-size: 22px; }

/* ---------- Coming soon / simple pages ---------- */
.simple-page { max-width: 640px; margin: 12vh auto; padding: 0 6vw; text-align: center; }
.simple-page h1 { font-size: 24px; }
.simple-page p { color: var(--fg-dim); }

/* ---------- Leaderboard page ---------- */
.leaderboard-page { max-width: 640px; margin: 0 auto; padding: 40px 6vw 60px; }
.leaderboard-page h1 { font-size: 24px; margin-bottom: 4px; }
.leaderboard-page > p.leaderboard-sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 20px; }

.leaderboard-me {
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}
.leaderboard-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.leaderboard-rank { font-family: var(--font-mono); color: var(--fg-dim); width: 60px; }
.leaderboard-points { text-align: right; font-family: var(--font-mono); font-weight: 600; }
.leaderboard-row--me { background: var(--surface-2); }
.leaderboard-row--me .leaderboard-user::after { content: " (you)"; color: var(--fg-dim); font-weight: 400; }
.leaderboard-row--top1 .leaderboard-rank { color: var(--accent); }
.leaderboard-empty { text-align: center; color: var(--fg-dim); padding: 24px 10px; }

.leaderboard-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.leaderboard-pager button:disabled { opacity: 0.4; cursor: default; }
#leaderboard-status { font-size: 12px; color: var(--fg-dim); }

/* ---------- Profile page ---------- */
.profile-page { max-width: 640px; margin: 0 auto; padding: 40px 6vw 60px; }
#profile-status { color: var(--fg-dim); font-size: 13px; }

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
#profile-username { margin: 0; font-size: 26px; }
.profile-header-stats { display: flex; align-items: center; gap: 16px; }
.profile-points { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--accent); }
#profile-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-dim);
}
#profile-streak svg { flex-shrink: 0; }

.profile-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--fg-dim); margin: 24px 0 12px; }
#profile-challenges { font-size: 13px; color: var(--fg); margin-bottom: 24px; }

.profile-progress-item { margin-bottom: 14px; }
.profile-progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--fg); margin-bottom: 5px; }
.profile-progress-bar { height: 8px; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; }
.profile-progress-fill { height: 100%; background: var(--accent); }
.profile-empty { color: var(--fg-dim); font-size: 13px; }

/* cursor trail canvas */
#cursor-trail { position: fixed; inset: 0; pointer-events: none; z-index: 9998; }

footer {
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  padding: 30px 0;
  border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
  .sidebar { position: static; height: auto; width: 100%; }
  .learn-shell { display: flex; flex-direction: column; }
  .content-panel { padding: 6vh 6vw; max-width: 100%; }
}

@media (max-width: 900px) {
  .nav-logo { position: static; }
  .nav-center { position: static; transform: none; margin-right: auto; }
}

/* ---------- Print (lesson pages) ----------
   Leaves a clean printable version of the explanation + code example:
   navbar, sidebar, mouse trail, quiz interactivity, and try-it editor
   chrome are all stripped out. */
/* ============================================================
   Part 3.7 — Attack + Project
   Both pages reuse the learn-shell / sidebar / tryit-box chrome above.
   What follows is only the genuinely new bits: challenge cards, the
   grading verdict pane, and the checkpoint meter.
   ============================================================ */

/* ---------- Shared sidebar extras ---------- */
.unit-count,
.challenge-pts {
  margin-left: auto;
  font-size: 10px;
  color: var(--fg-dim);
  opacity: 0.75;
  flex-shrink: 0;
}
.unit-head .unit-count { margin-left: auto; }
.challenge-name { min-width: 0; }

.sidebar-foot {
  margin: 14px 16px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--fg-dim);
}
.sidebar-foot strong { color: var(--accent); }

/* ---------- Prompt / brief prose ---------- */
.attack-prompt p {
  margin: 0 0 12px;
  line-height: 1.7;
}
.attack-prompt code,
.attack-intro code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.solved-tag {
  font-size: 11px;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Submit button + verdict ---------- */
.attack-submit-btn {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.attack-submit-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-fg);
}

.attack-verdict {
  border-top: 1px solid var(--border);
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.attack-verdict strong { font-weight: 600; }
.attack-verdict--pending { color: var(--fg-dim); }
.attack-verdict--right {
  color: var(--success);
  border-top-color: var(--success);
  background: color-mix(in srgb, var(--success) 8%, transparent);
}
.attack-verdict--wrong {
  color: var(--danger);
  border-top-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.attack-hint {
  margin: 20px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}
.attack-hint summary {
  cursor: pointer;
  padding: 9px 14px;
  color: var(--fg-dim);
  font-size: 12px;
  user-select: none;
}
.attack-hint summary:hover { color: var(--accent); }
.attack-hint[open] summary { border-bottom: 1px solid var(--border); }
.attack-hint p { margin: 0; padding: 11px 14px; line-height: 1.7; }

/* ---------- Challenge / project card grids ---------- */
.attack-grid,
.project-grid {
  display: grid;
  gap: 12px;
  margin: 24px 0 8px;
}
.attack-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.project-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.attack-card,
.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  color: var(--fg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.attack-card:hover,
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}
.attack-card--solved,
.project-card--done { border-color: var(--success); }

.attack-card-top,
.project-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.attack-card-title,
.project-card-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.attack-card-lang,
.project-card-lang { color: var(--fg-dim); }
.attack-card-pts { color: var(--accent); }
.project-card-blurb {
  font-size: 12px;
  color: var(--fg-dim);
  line-height: 1.6;
  flex-grow: 1;
}
.project-card-diff {
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}

.attack-card-diff { font-weight: 600; }
.attack-card-diff--warmup { color: var(--success); }
.attack-card-diff--medium { color: var(--accent); }
.attack-card-diff--hard { color: var(--danger); }

.attack-intro-note {
  font-size: 12px;
  color: var(--fg-dim);
  border-left: 2px solid var(--accent-dim);
  padding-left: 12px;
  line-height: 1.7;
}

/* ---------- Checkpoint meter ----------
   Used twice: as a strip under a checkpoint heading (rendered by
   learn-render.js) and inside the project picker cards. */
.checkpoint-meter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 18px;
}
.project-card .checkpoint-meter { margin: 2px 0 0; }
.checkpoint-meter-label {
  /* Two spans in the lesson strip ("Checkpoint 3 of 5" + "2/5 complete"),
     one in the picker cards. Flex handles both. */
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--fg-dim);
}
.checkpoint-meter-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.checkpoint-meter-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* .content-panel is `flex: 1` inside the row layout, and a flex item's
   default min-width is auto — so a wide <pre> forces the whole column
   wider than the viewport and the page scrolls sideways, instead of the
   code block using its own overflow-x. min-width: 0 lets it shrink and
   hands the scrolling back to .code-block / .cm-editor. */
.content-panel { min-width: 0; }
/* Prism ships `pre[class*="language-"] { overflow: auto }` — but its
   vendored theme also sets `overflow: visible` on some selectors that
   outrank the plain `.code-block` rule, which let a wide snippet push the
   page sideways on mobile. Match Prism's own specificity to win. */
.code-block,
.content-panel pre,
pre[class*="language-"].code-block,
pre.code-block[class*="language-"] {
  max-width: 100%;
  overflow-x: auto;
}
.lesson-heading h1 { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 700px) {
  .attack-grid,
  .project-grid { grid-template-columns: 1fr; }
  /* Narrow columns leave a long checkpoint title fighting the icon
     buttons for room — stack them so the heading gets the full width. */
  .lesson-heading { flex-wrap: wrap; }
  .lesson-heading h1 { flex: 1 1 100%; font-size: 22px; }
}

@media print {
  #boot-screen,
  .navbar,
  .skip-link,
  .sidebar,
  #cursor-trail,
  .quiz-box,
  .tryit-box,
  .related-lessons,
  .lesson-nav,
  .bookmark-btn,
  .print-btn,
  .certificate-box,
  .points-toast,
  .attack-verdict,
  .attack-hint,
  .attack-grid,
  .project-grid,
  .sidebar-foot,
  footer {
    display: none !important;
  }

  html, body { background: #fff; color: #000; }
  .learn-shell { display: block; min-height: 0; }
  .content-panel { max-width: 100%; padding: 0; }
  .lesson-eyebrow { color: #444; }
  .lesson-heading h1 { color: #000; }
  .content-panel p { color: #000; }
  .code-block {
    background: #f5f5f5;
    border: 1px solid #ccc;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
