/* ==========================================================================
   Deep Learning Lab — site styles
   Tokens first, then layout, then components. Light + dark themes.
   ========================================================================== */

/* Forest-and-cream design. Activation nodes show progress from started to mastered.
   Data classes in labs are blue and orange; green and rust mean right and wrong. */
:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --surface: #ffffff;
  --surface-2: #eef1e8;
  --surface-3: #e1e6dc;
  --ink: #202d28;
  --ink-2: #47584c;
  --ink-3: #536257;           /* 4.5:1 on every light surface, the darkest grey fill included */
  --line: #dce1d8;
  --line-2: #bac7b8;
  --accent: #234c3c;
  --accent-ink: #234c3c;
  --accent-soft: #eef1e8;
  --accent-soft-2: #e1e6dc;
  --mod: #234c3c;              /* the one module accent, replacing per-module colours */
  --on-mod: #ffffff;           /* text on a --mod fill */
  --a1: #356784;               /* started */
  --a2: #638f72;               /* practised */
  --a2-text: #426b50;          /* --a2 as text: deep enough for 4.5:1 on every light surface */
  --a3: #426b50;               /* strong */
  --a4: #ddeaab;               /* mastered */
  --orange: #c95c22;
  --orange-soft: #fbece3;
  --aqua: #1c7f7a;
  --aqua-soft: #e0f1f0;
  --violet: #5d4a9e;
  --violet-soft: #eeebf7;
  --yellow: #9a7300;
  --yellow-soft: #fbf3d4;
  --red: #b2451b;
  --red-soft: #f9e9e1;
  --green: #1d7a57;
  --green-soft: #e1f1ea;
  --c0: #3566c8;           /* class 0 / series 1 */
  --c1: #e0702f;           /* class 1 / series 2 */
  --c2: #638f72;
  --c3: #5d4a9e;
  --code-bg: #1f2e29;
  --code-bg-2: #263a31;
  --code-ink: #edf2e5;
  --code-line: #34493a;
  --shadow-sm: 0 1px 2px rgba(21, 19, 28, .05);
  --shadow: 0 1px 2px rgba(21, 19, 28, .05), 0 8px 24px rgba(21, 19, 28, .06);
  --shadow-lg: 0 16px 48px rgba(21, 19, 28, .16);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --topbar-h: 60px;
  --sidebar-w: 292px;
  --toc-w: 250px;
  --measure: 720px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14221c;
    --surface: #1b2c23;
    --surface-2: #25372c;
    --surface-3: #34493a;
    --ink: #edf2e5;
    --ink-2: #becdc0;
    --ink-3: #a1b5a4;
    --line: #34493a;
    --line-2: #4a6350;
    --accent: #ddeaab;
    --accent-ink: #ddeaab;
    --accent-soft: #25372c;
    --accent-soft-2: #34493a;
    --mod: #ddeaab;
    --on-mod: #14221c;
    --a2-text: #a4c5ac;
    --orange: #f08a4b;
    --orange-soft: #2e1a10;
    --aqua: #35b7a9;
    --aqua-soft: #0f2826;
    --violet: #a597e6;
    --violet-soft: #221d38;
    --yellow: #e8c347;
    --yellow-soft: #2b2410;
    --red: #ff9468;
    --red-soft: #2f1911;
    --green: #4fcf9a;
    --green-soft: #10281f;
    --c0: #5b8cf0;
    --c1: #f28a4b;
    --c2: #35b7a9;
    --c3: #a597e6;
    --code-bg: #0e1913;
    --code-bg-2: #16281d;
    --code-line: #34493a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14221c;
  --surface: #1b2c23;
  --surface-2: #25372c;
  --surface-3: #34493a;
  --ink: #edf2e5;
  --ink-2: #becdc0;
  --ink-3: #a1b5a4;
  --line: #34493a;
  --line-2: #4a6350;
  --accent: #ddeaab;
  --accent-ink: #ddeaab;
  --accent-soft: #25372c;
  --accent-soft-2: #34493a;
  --mod: #ddeaab;
  --on-mod: #14221c;
  --a2-text: #a4c5ac;
  --orange: #f08a4b;
  --orange-soft: #2e1a10;
  --aqua: #35b7a9;
  --aqua-soft: #0f2826;
  --violet: #a597e6;
  --violet-soft: #221d38;
  --yellow: #e8c347;
  --yellow-soft: #2b2410;
  --red: #ff9468;
  --red-soft: #2f1911;
  --green: #4fcf9a;
  --green-soft: #10281f;
  --c0: #5b8cf0;
  --c1: #f28a4b;
  --c2: #35b7a9;
  --c3: #a597e6;
  --code-bg: #0e1913;
  --code-bg-2: #16281d;
  --code-line: #34493a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 20px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
kbd { font-family: var(--mono); font-size: .75em; padding: .1em .45em; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--ink-2); }
.ic { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.18em; }
.muted { color: var(--ink-3); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-2); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: .5em; padding: .62em 1.1em; border-radius: 999px;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink); font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; line-height: 1.2;
}
.btn:hover { color: var(--bg); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { color: var(--ink); background: var(--surface); }
.btn-sm { padding: .42em .85em; font-size: .85rem; }
.btn-lg { padding: .8em 1.4em; font-size: 1rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: .4em; padding: .3em .75em; border-radius: 999px; font-size: .8rem; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: all .15s;
}
.chip-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.chip-btn.accent { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-ink); background: var(--accent-soft); }
.chip-btn.accent:hover { background: var(--accent-soft-2); }
.chip-btn.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 8px;
  padding: 0 16px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--c0), var(--violet)); flex: none; }
.brand-mark svg { width: 24px; height: 24px; fill: #fff; stroke: #fff; stroke-width: 1.6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .98rem; letter-spacing: -.01em; }
.brand-text span { font-size: .72rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.search-btn {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px 0 12px; min-width: 260px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-3); cursor: pointer; font-size: .88rem;
}
.search-btn span { flex: 1; text-align: left; }
.search-btn:hover { border-color: var(--ink-3); color: var(--ink-2); }
.show-dark { display: none; }
:root[data-theme="dark"] .show-dark { display: block; }
:root[data-theme="dark"] .show-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .show-dark { display: block; }
  :root:not([data-theme="light"]) .show-light { display: none; }
}
.read-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.read-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mod), var(--violet)); transition: width .1s linear; }

/* ------------------------------------------------------------------ shell & sidebar */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); width: var(--sidebar-w); flex: none;
  border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
}
.sidebar-inner { padding: 18px 12px 40px; }
.side-home { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .9rem; margin-bottom: 10px; }
.side-home:hover, .side-home.is-active { background: var(--surface-2); color: var(--ink); }
.side-module { margin-bottom: 2px; }
.side-module-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; border: 0; background: transparent;
  text-align: left; cursor: pointer; color: var(--ink); font-size: .88rem; font-weight: 600; line-height: 1.3;
}
button.side-module-head:hover { background: var(--surface-2); }
.side-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none; font-size: .78rem; font-weight: 700; background: color-mix(in srgb, var(--mod) 16%, transparent); color: var(--mod); }
.side-title { flex: 1; }
.side-module-head .chev { color: var(--ink-3); transition: transform .2s; }
.side-module.is-open .side-module-head .chev { transform: rotate(180deg); }
.side-module.is-locked .side-module-head { color: var(--ink-3); cursor: default; font-weight: 500; }
.side-module.is-locked .side-num { background: var(--surface-2); color: var(--ink-3); }
.side-module.is-locked .ic { color: var(--ink-3); width: .95em; }
.side-lessons { list-style: none; margin: 2px 0 8px; padding: 0 0 0 22px; display: none; border-left: 1px solid var(--line); margin-left: 23px; }
.side-module.is-open .side-lessons { display: block; }
.side-lessons a { display: flex; align-items: baseline; gap: 7px; padding: 6px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .84rem; line-height: 1.35; }
.side-lessons a:hover { background: var(--surface-2); color: var(--ink); }
.side-lessons a.is-active { background: color-mix(in srgb, var(--mod) 12%, transparent); color: var(--ink); font-weight: 600; }
.side-lnum { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: .78rem; font-weight: 600; }
.side-overview { font-style: italic; }
.side-dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; align-self: center; transition: all .2s; }
.side-dot.is-started { border-color: var(--mod); background: color-mix(in srgb, var(--mod) 30%, transparent); }
.side-dot.is-done { border-color: var(--green); background: var(--green); }
.side-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.side-foot a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .86rem; }
.side-foot a:hover { background: var(--surface-2); color: var(--ink); }
.scrim { display: none; }
/* Desktop: the menu button hides the sidebar (remembered per browser, applied in <head> so it never flashes);
   on narrow screens the sidebar is an off-canvas drawer instead, see the 980px breakpoint. */
@media (width > 980px) {
  .nav-collapsed .sidebar { display: none; }
}

.main { flex: 1; min-width: 0; }
.site-foot { padding: 40px 32px 60px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .88rem; margin-top: 60px; }
.site-foot p { margin: .2em 0; }

/* ------------------------------------------------------------------ lesson layout */
.lesson-layout { display: flex; gap: 40px; padding: 0 32px; justify-content: center; }
.lesson { flex: 1; min-width: 0; max-width: 880px; padding-bottom: 40px; }

/* ------------------------------------------------------------------ lesson hero */
.lesson-hero {
  position: relative; margin: 28px 0 8px; padding: 34px 36px 26px; border-radius: var(--radius-lg); overflow: hidden;
  background:
    radial-gradient(900px 300px at 100% 0%, color-mix(in srgb, var(--mod) 22%, transparent), transparent 60%),
    radial-gradient(600px 260px at 0% 100%, color-mix(in srgb, var(--violet) 14%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.lesson-title { font-size: clamp(1.9rem, 3.6vw, 2.75rem); line-height: 1.12; letter-spacing: -.025em; margin: 14px 0 12px; font-weight: 800; }
.lesson-summary { font-size: 1.08rem; color: var(--ink-2); max-width: 720px; }
.lesson-summary p { margin: .4em 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.lesson-progress, .module-progress { display: flex; align-items: center; gap: 12px; margin-top: 22px; font-size: .8rem; color: var(--ink-3); }
.lesson-progress .bar, .module-progress .bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.lesson-progress .bar span, .module-progress .bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--mod), var(--aqua)); transition: width .4s; }

/* ------------------------------------------------------------------ before you start */
.lesson-start { padding-top: 26px; }
.obj-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.obj-list li { display: flex; gap: 10px; font-size: .93rem; line-height: 1.5; }
.obj-check { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--green-soft); color: var(--green); flex: none; margin-top: 2px; }
.obj-check .ic { width: 13px; height: 13px; stroke-width: 3; }
.intro-part { margin-top: 26px; }
.setup-panel { margin-top: 22px; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface); }
.setup-panel > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 14px 18px; cursor: pointer; font-size: .92rem; }
.setup-panel > summary::-webkit-details-marker { display: none; }
.setup-panel > summary .chev { margin-left: auto; transition: transform .2s; }
.setup-panel[open] > summary .chev { transform: rotate(180deg); }
.setup-body { padding: 0 18px 16px; }

/* ------------------------------------------------------------------ sections */
.lsec { padding-top: 34px; margin-top: 30px; border-top: 1px solid var(--line); }
.sec-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 10px; }
.sec-num {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none; margin-top: 2px;
  background: color-mix(in srgb, var(--mod) 13%, transparent); color: var(--mod); font-weight: 800; font-size: 1.05rem;
  font-variant-numeric: tabular-nums; transition: background .3s, color .3s;
}
.lsec.is-read .sec-num { background: var(--mod); color: #fff; }
.sec-icon .ic { width: 20px; height: 20px; }
.sec-head h2 { font-size: clamp(1.4rem, 2.4vw, 1.8rem); line-height: 1.22; letter-spacing: -.02em; margin: 4px 0 0; font-weight: 750; }
.kind-conclusion .sec-num { background: color-mix(in srgb, var(--aqua) 15%, transparent); color: var(--aqua); }
.lsec.kind-transition { border-top-style: dashed; }
.kind-transition .sec-num { background: var(--surface-2); color: var(--ink-2); }
.subhead { font-size: 1.2rem; letter-spacing: -.01em; margin: 1.9em 0 .4em; line-height: 1.3; font-weight: 700; }
h4.subhead { font-size: 1.05rem; }

/* ------------------------------------------------------------------ prose */
.prose { max-width: var(--measure); }
.prose p { margin: .85em 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .8em 0; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--ink-3); }
.prose strong { font-weight: 650; color: var(--ink); }
.prose h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.prose h4 { font-size: 1.02rem; margin: 1.4em 0 .3em; }
.prose code, .qtext code, .obj-list code, .lesson-title code, .sec-head code, .compare code, .quiz code, .term-pop code, .gl-def code {
  font-family: var(--mono); font-size: .86em; padding: .12em .38em; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); white-space: break-spaces; overflow-wrap: anywhere;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose blockquote.keyidea {
  margin: 1.3em 0; padding: 16px 20px 16px 52px; border-radius: var(--radius); position: relative;
  background: linear-gradient(135deg, color-mix(in srgb, var(--mod) 9%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--mod) 25%, var(--line)); font-size: 1.03rem; color: var(--ink);
}
.prose blockquote.keyidea::before {
  content: ""; position: absolute; left: 18px; top: 19px; width: 20px; height: 20px;
  background: var(--mod); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2V17h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2Z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2V17h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2Z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.prose blockquote.keyidea p { margin: .3em 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: .88rem; line-height: 1.45; }
.table-wrap th, .table-wrap td { padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-wrap th { background: var(--surface-2); font-weight: 650; font-size: .8rem; color: var(--ink-2); }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
pre.diagram {
  font-family: var(--mono); font-size: .84rem; line-height: 1.55; padding: 16px 20px; margin: 1.2em 0; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--mod); overflow-x: auto; color: var(--ink);
}
.prose pre.hl { background: var(--code-bg); color: var(--code-ink); padding: 14px 18px; border-radius: var(--radius); overflow-x: auto; font-size: .84rem; line-height: 1.6; }
.prose pre.hl code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; white-space: pre; }
.math-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: 1em 0; }
.katex { font-size: 1.08em; }

/* figures */
.figure { margin: 1.6em 0; text-align: center; }
.figure img, .out-img img {
  border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm); cursor: zoom-in;
}
.figure figcaption { margin-top: 10px; font-size: .88rem; color: var(--ink-2); line-height: 1.5; }
.fig-num { font-weight: 700; color: var(--ink); margin-right: .35em; }
.custom-figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.custom-figure { overflow-x: auto; }
.custom-figure svg { max-width: 100%; height: auto; }
@media (max-width: 720px) { .custom-figure svg { max-width: none; width: 580px; } }

/* ------------------------------------------------------------------ code cells */
.code-cell { margin: 1.3em 0; border-radius: var(--radius); background: var(--code-bg); border: 1px solid var(--code-line); overflow: hidden; box-shadow: var(--shadow-sm); }
.code-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; background: var(--code-bg-2); border-bottom: 1px solid var(--code-line); color: #9aa0b4; font-size: .76rem; }
.code-lang { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: #c7cbdb; }
.code-meta { color: #858aa0; white-space: nowrap; }
.code-head { flex-wrap: wrap; row-gap: 6px; }
.code-actions { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; align-items: center; min-width: 0; }
.code-head .icon-btn { color: #9aa0b4; }
.code-head .icon-btn:hover { background: #262a35; color: #fff; }
.code-head .chip-btn.accent { background: #1c2b44; border-color: #2f4a74; color: #a9c8f5; }
pre.code { margin: 0; padding: 14px 0; overflow-x: auto; font-family: var(--mono); font-size: .835rem; line-height: 1.62; color: var(--code-ink); counter-reset: ln; tab-size: 4; }
pre.code code { display: block; min-width: max-content; }
pre.code .ln { display: block; padding: 0 18px 0 52px; position: relative; min-height: 1.62em; }
pre.code .ln::before { counter-increment: ln; content: counter(ln); position: absolute; left: 0; width: 36px; text-align: right; color: #4a5064; font-size: .78em; user-select: none; }
pre.code .ln[data-note] { background: rgba(75, 147, 234, .09); box-shadow: inset 3px 0 0 #4b93ea; }
pre.code .ln[data-note]::before { color: transparent; }
pre.code .ln[data-note]::after {
  content: attr(data-note); position: absolute; left: 26px; top: .28em; width: 16px; height: 16px; border-radius: 50%;
  background: #4b93ea; color: #fff; font: 700 10px/16px var(--font); text-align: center; transform: translateX(-50%);
}
pre.code .ln.is-hl { background: rgba(75, 147, 234, .22); }
.code-cell.has-explain.explain-off pre.code .ln[data-note] { background: none; box-shadow: none; }
.code-cell.has-explain.explain-off pre.code .ln[data-note]::after { display: none; }
.code-cell.is-long:not(.is-expanded) pre.code { max-height: 30.5em; overflow-y: hidden; mask-image: linear-gradient(#000 75%, transparent); -webkit-mask-image: linear-gradient(#000 75%, transparent); }
.code-expand { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 8px; border: 0; border-top: 1px solid var(--code-line); background: var(--code-bg-2); color: #a9c8f5; font-size: .8rem; font-weight: 600; cursor: pointer; }
.code-expand:hover { background: #1c2030; }
.code-cell.is-expanded .code-expand .ic { transform: rotate(180deg); }
.code-cell.role-inspect pre.code { padding: 8px 0; }
.code-cell.role-shell pre.code .ln::before { content: "$"; color: #6f7589; }

/* Pygments (dark, used in both themes) */
.code .k, .code .kn, .code .kd, .code .kr, .code .ow, .hl .k, .hl .kn, .hl .ow { color: #c792ea; }
.code .kc, .hl .kc { color: #ff9cac; }
.code .nf, .code .fm, .hl .nf { color: #82aaff; }
.code .nc, .hl .nc { color: #ffcb6b; }
.code .nb, .code .bp, .hl .nb { color: #ffcb6b; }
.code .nd, .hl .nd { color: #82aaff; }
.code .s, .code .s1, .code .s2, .code .sa, .code .sb, .code .sc, .code .sh, .hl .s, .hl .s1, .hl .s2 { color: #c3e88d; }
.code .sd, .hl .sd { color: #8fb47d; }
.code .si, .code .se, .hl .si { color: #89ddff; }
.code .c, .code .c1, .code .cm, .code .ch, .code .cs, .hl .c, .hl .c1 { color: #7a829e; font-style: italic; }
.code .mi, .code .mf, .code .mh, .code .mo, .code .il, .hl .mi, .hl .mf { color: #f78c6c; }
.code .o, .hl .o { color: #89ddff; }
.code .p, .hl .p { color: #a6accd; }
.code .nn, .hl .nn { color: #e4e6ee; }
.code .err { color: #ff5370; }
.code .nv, .hl .nv { color: #f07178; }

/* explanation panel */
.code-explain { background: color-mix(in srgb, var(--code-bg-2) 70%, #1a2740); border-top: 1px solid #2a3a58; padding: 14px 18px 16px; color: #d7dbe8; }
.code-explain-head { display: flex; align-items: center; gap: 8px; font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #a9c8f5; margin-bottom: 4px; }
.code-explain .prose { color: #d7dbe8; font-size: .92rem; max-width: none; }
.code-explain .prose strong { color: #fff; }
.code-explain .prose code { background: #232838; border-color: #333a4e; color: #eef1e8; }
.line-notes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.line-notes li { display: flex; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: default; transition: background .15s; }
.line-notes li:hover, .line-notes li.is-hl { background: rgba(75, 147, 234, .14); }
.line-notes .prose p { margin: 0; }
.note-num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #4b93ea; color: #fff; font-size: 11px; font-weight: 700; flex: none; margin-top: 3px; }
.code-cell.explain-off .code-explain { display: none; }

/* outputs */
.out { border-top: 1px solid var(--code-line); background: var(--surface); color: var(--ink); }
.out-label { display: flex; align-items: center; gap: 6px; padding: 7px 14px 0; font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.out-toggle { margin-left: auto; border: 0; background: none; color: var(--accent-ink); font-size: .78rem; font-weight: 600; cursor: pointer; text-transform: none; letter-spacing: 0; }
.out-text { margin: 0; padding: 8px 14px 14px; font-family: var(--mono); font-size: .8rem; line-height: 1.55; white-space: pre; overflow-x: auto; color: var(--ink); }
.out.is-collapsed .out-text { max-height: 7.8em; overflow: hidden; mask-image: linear-gradient(#000 40%, transparent); -webkit-mask-image: linear-gradient(#000 40%, transparent); }
.out-stderr { background: color-mix(in srgb, var(--yellow-soft) 60%, var(--surface)); }
.out-error { background: var(--red-soft); }
.out-error .out-label { color: var(--red); }
.out-error-head { padding: 6px 14px 0; font-family: var(--mono); font-size: .84rem; color: var(--red); }
.out-img { padding: 12px 14px 16px; text-align: center; }
.out-img img { max-height: 560px; width: auto; }
.out-html { padding: 4px 14px 14px; }
.out-html .table-wrap { margin: 6px 0 0; }
.df-shape { font-size: .75rem; color: var(--ink-3); padding: 4px 2px 0; }
table.df { font-family: var(--mono); font-size: .76rem !important; }
table.df th, table.df td { padding: 5px 10px !important; white-space: nowrap; }

/* ------------------------------------------------------------------ question cards */
.qcard { margin: 1.6em 0; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); position: relative; }
.qcard::before { content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 3px; border-radius: 3px; background: var(--qc, var(--accent)); }
.q-check { --qc: var(--accent); --qc-soft: var(--accent-soft); }
.q-think { --qc: var(--violet); --qc-soft: var(--violet-soft); }
.q-try { --qc: var(--orange); --qc-soft: var(--orange-soft); }
.qcard-head, .predict-head { display: flex; align-items: center; gap: 12px; }
.qcard-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--qc-soft, var(--accent-soft)); color: var(--qc, var(--accent)); flex: none; }
.qcard-tag { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--qc, var(--accent)); }
.qcard-label { display: block; font-weight: 650; font-size: .98rem; line-height: 1.3; }
.qcard-intro { margin: 12px 0 0; color: var(--ink-2); }
.qlist { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: q; display: grid; gap: 10px; }
.qitem { counter-increment: q; padding: 12px 14px 12px 46px; border-radius: 12px; background: var(--surface-2); position: relative; }
.qitem::before { content: counter(q); position: absolute; left: 14px; top: 12px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface); color: var(--qc); border: 1px solid var(--line-2); }
.qlist.single .qitem { padding-left: 14px; }
.qlist.single .qitem::before { display: none; }
.qtext { line-height: 1.6; }
.qtext p { margin: 0; }
.qactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.qnote { display: block; width: 100%; min-height: 84px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-size: .92rem; line-height: 1.55; resize: vertical; }
.qnote:focus { outline: 2px solid var(--qc); border-color: transparent; }
.qanswer { margin-top: 10px; padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line)); position: relative; animation: pop .25s ease-out; }
.qanswer::before { content: "Explanation"; display: block; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--green); margin-bottom: 4px; }
.qanswer .prose { font-size: .95rem; max-width: none; }
.qanswer .prose > :first-child { margin-top: 0; }
.qanswer .prose > :last-child { margin-bottom: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ explainers */
.explainer { margin: 1.5em 0; padding: 16px 20px; border-radius: var(--radius); background: var(--ex-soft); border: 1px solid color-mix(in srgb, var(--ex) 22%, transparent); }
.explainer > .prose { max-width: none; font-size: .96rem; }
.explainer > .prose > :first-child { margin-top: .4em; }
.explainer > .prose > :last-child { margin-bottom: 0; }
.ex-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ex-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--ex); color: #fff; flex: none; }
.ex-icon .ic { width: 16px; height: 16px; }
.ex-tag { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ex); }
.ex-title { font-weight: 650; font-size: .98rem; flex-basis: 100%; margin-left: 38px; margin-top: -4px; line-height: 1.35; }
details.explainer > summary { list-style: none; cursor: pointer; }
details.explainer > summary::-webkit-details-marker { display: none; }
details.explainer > summary .chev { margin-left: auto; color: var(--ex); transition: transform .2s; order: 2; }
details.explainer[open] > summary .chev { transform: rotate(180deg); }
details.explainer > summary .ex-title { order: 3; }
details.explainer:not([open]) { padding-bottom: 14px; }
.ex-plain, .ex-code, .ex-result { --ex: var(--accent); --ex-soft: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
.ex-analogy { --ex: var(--violet); --ex-soft: color-mix(in srgb, var(--violet-soft) 70%, var(--surface)); }
.ex-why, .ex-remember { --ex: var(--aqua); --ex-soft: color-mix(in srgb, var(--aqua-soft) 70%, var(--surface)); }
.ex-deep, .ex-math, .ex-recap { --ex: #6b6a64; --ex-soft: var(--surface); }
.ex-deep { border-style: dashed; }
.ex-warning { --ex: var(--red); --ex-soft: color-mix(in srgb, var(--red-soft) 70%, var(--surface)); }
.ex-tip { --ex: var(--yellow); --ex-soft: color-mix(in srgb, var(--yellow-soft) 75%, var(--surface)); }

/* ------------------------------------------------------------------ compare */
.compare { margin: 1.6em 0; }
.compare-title { margin: 0 0 10px; font-size: 1.02rem; }
.compare-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.compare-card { padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--tone, var(--line-2)); }
.compare-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.compare-card-head .ic { color: var(--tone, var(--ink-2)); }
.compare-card .prose { font-size: .92rem; }
.compare-card .prose > :first-child { margin-top: .3em; }
.compare-card .prose > :last-child { margin-bottom: 0; }
.tone-blue { --tone: var(--c0); } .tone-orange { --tone: var(--c1); } .tone-green { --tone: var(--green); } .tone-red { --tone: var(--red); } .tone-violet { --tone: var(--violet); } .tone-aqua { --tone: var(--aqua); } .tone-yellow { --tone: var(--yellow); }

/* ------------------------------------------------------------------ predict */
.predict { margin: 1.5em 0; padding: 18px 20px; border-radius: var(--radius); background: linear-gradient(135deg, var(--violet-soft), var(--surface) 70%); border: 1px solid color-mix(in srgb, var(--violet) 25%, var(--line)); --qc: var(--violet); --qc-soft: color-mix(in srgb, var(--violet) 18%, transparent); }
.predict-prompt > :first-child { margin-top: 2px; }
.predict-prompt > :last-child { margin-bottom: 0; }
.predict-options, .quiz-options { display: grid; gap: 8px; margin-top: 12px; }
.predict-options { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.opt { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: .93rem; line-height: 1.4; transition: all .15s; }
.opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.opt:disabled { cursor: default; }
.opt.is-correct { border-color: var(--green); background: var(--green-soft); }
.opt.is-wrong { border-color: var(--red); background: var(--red-soft); }
.opt.is-picked { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.opt-letter { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--surface-2); font-size: .75rem; font-weight: 700; flex: none; }
.predict-slider { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.predict-slider input[type=range] { flex: 1; min-width: 180px; }
.predict-slider output { font-family: var(--mono); font-weight: 700; font-size: 1.1rem; min-width: 3.5em; }
.predict-reveal { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); animation: pop .25s; max-width: none; }
.predict-reveal > :first-child { margin-top: 0; }
.predict-reveal > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ stepper */
.stepper, .quiz { margin: 1.8em 0; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.stepper-head, .quiz-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px 0; }
.stepper-intro { padding: 0 20px; }
.stepper-dots { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 12px 0 0; padding: 0 20px; }
.stepper-dots button { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); font-size: .8rem; font-weight: 700; cursor: pointer; color: var(--ink-3); transition: all .2s; }
.stepper-dots button.is-done { border-color: var(--mod); color: var(--mod); }
.stepper-dots button.is-active { background: var(--mod); border-color: var(--mod); color: #fff; transform: scale(1.08); }
.stepper-frames { padding: 16px 20px 6px; min-height: 120px; }
.step-frame { display: none; animation: slidein .3s ease-out; }
.step-frame.is-active { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.step-frame:has(.step-visual).is-active { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; }
.step-visual { background: var(--surface-2); border-radius: var(--radius); padding: 12px; display: grid; place-items: center; }
.step-visual svg { width: 100%; height: auto; max-height: 340px; }
.step-text h5 { font-size: 1.05rem; margin: 0 0 .3em; }
.step-text > :last-child { margin-bottom: 0; }
@keyframes slidein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.stepper-nav { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.stepper-count { font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ quiz */
.quiz-head { padding-bottom: 6px; }
.quiz-score { margin-left: auto; font-size: .85rem; font-weight: 700; color: var(--ink-2); }
.quiz-q { padding: 14px 20px 16px; border-top: 1px solid var(--line); }
.quiz-q:first-of-type { border-top: 0; }
.quiz-qtext { display: flex; gap: 10px; font-weight: 600; max-width: none; }
.quiz-qtext p { margin: 0; }
.quiz-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: .75rem; flex: none; margin-top: 1px; }
.quiz-why { margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: .93rem; max-width: none; animation: pop .25s; }
.quiz-why > :first-child { margin-top: 0; } .quiz-why > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ badges */
.badge-lab { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--mod); color: #fff; }
.badge-lab.inline { vertical-align: .1em; }
.widget-title { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }

/* ------------------------------------------------------------------ wrap-up */
.takeaways { padding: 20px 24px; border-radius: var(--radius-lg); background: linear-gradient(135deg, color-mix(in srgb, var(--mod) 10%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--mod) 25%, var(--line)); }
.takeaways-head { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.05rem; margin-bottom: 6px; color: var(--ink); }
.takeaways-head .ic { color: var(--mod); }
.takeaways ol { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; }
.takeaways li { line-height: 1.55; }
.takeaways li::marker { font-weight: 700; color: var(--mod); }
.next-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 16px; margin-top: 18px; padding: 18px 22px; border-radius: var(--radius-lg); text-decoration: none; color: #fff; background: linear-gradient(120deg, var(--mod), color-mix(in srgb, var(--mod) 50%, var(--violet))); box-shadow: var(--shadow); transition: transform .15s; }
.next-card:hover { color: #fff; transform: translateY(-2px); }
.next-kicker { font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .85; }
.next-title { grid-column: 1; font-size: 1.2rem; font-weight: 750; letter-spacing: -.01em; }
.next-card .ic { grid-column: 2; grid-row: 1 / span 2; width: 26px; height: 26px; }

/* ------------------------------------------------------------------ glossary terms */
.term { border-bottom: 1.5px dotted color-mix(in srgb, var(--accent) 70%, transparent); cursor: help; transition: background .15s; border-radius: 2px; }
.term:hover, .term:focus { background: var(--accent-soft); }
.term:focus-visible { outline: 2px solid var(--a2); outline-offset: 2px; }
.term-pop { position: fixed; z-index: 90; max-width: 340px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: .86rem; line-height: 1.5; box-shadow: var(--shadow-lg); pointer-events: auto; animation: pop .15s; }
.term-pop strong { display: block; font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; opacity: .7; margin-bottom: 2px; color: inherit; }
.term-pop code { background: rgba(127,127,127,.25); border: 0; color: inherit; }
.term-pop a { color: inherit; opacity: .75; font-size: .78rem; }

/* ------------------------------------------------------------------ search */
.search-modal { position: fixed; inset: 0; z-index: 80; background: rgba(10, 10, 12, .45); backdrop-filter: blur(4px); display: grid; justify-items: center; align-items: start; padding: 10vh 16px 16px; }
.search-box { width: min(680px, 100%); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; animation: pop .15s; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); }
.search-input-row input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 1.05rem; padding: 10px 0; color: var(--ink); outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 56vh; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.search-results li a.is-active, .search-results li a:hover { background: var(--accent-soft); }
.sr-meta { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.sr-title { font-weight: 650; }
.sr-snip { font-size: .84rem; color: var(--ink-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-snip mark { background: color-mix(in srgb, var(--yellow) 35%, transparent); color: inherit; border-radius: 3px; }
.search-empty { padding: 26px; text-align: center; color: var(--ink-3); }
.search-hint { padding: 10px 18px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; background: var(--surface-2); }

/* ------------------------------------------------------------------ lightbox */
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(8, 8, 10, .88); display: grid; place-items: center; padding: 24px; cursor: zoom-out; animation: pop .15s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; background: #fff; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255,255,255,.1); }

/* ------------------------------------------------------------------ reveal on scroll */
.js .reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease-out, transform .5s ease-out; }
.js .reveal.is-in { opacity: 1; transform: none; }
.js .reveal.no-anim { transition: none; }

/* ------------------------------------------------------------------ home */
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 650; color: var(--mod); padding: 5px 12px; border-radius: 999px; background: color-mix(in srgb, var(--mod) 12%, var(--surface)); }
.lead { font-size: 1.18rem; color: var(--ink-2); max-width: 660px; margin: 0; line-height: 1.55; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.chips li { font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ module page */

/* ------------------------------------------------------------------ plain pages */
.plain-page { max-width: 880px; margin: 0 auto; padding: 0 32px; }
.plain-page.center { text-align: center; }
.plain-hero { padding: 48px 0 24px; }
.plain-hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); letter-spacing: -.03em; margin: 14px 0 10px; }
.term.demo { cursor: default; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1320px) {
  .lesson-layout { padding: 0 28px; }
}
@media (max-width: 980px) {
  :root { --sidebar-w: 300px; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 60; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow-lg); background: var(--surface); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 55; background: rgba(0,0,0,.35); }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd { display: none; }
  .search-btn { width: 38px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .topbar { padding: 0 10px; gap: 4px; }
  .brand-text span { display: none; }
  .hide-sm { display: none; }
  .lesson-layout, .plain-page { padding: 0 16px; }
  .lesson-hero { padding: 24px 20px 20px; border-radius: 18px; margin-top: 16px; }
  .obj-list { grid-template-columns: 1fr; }
  .sec-num { width: 36px; height: 36px; font-size: .95rem; }
  .qcard, .explainer, .predict { padding: 16px; }
  .qitem { padding: 12px 12px 12px 42px; }
  pre.code .ln { padding: 0 14px 0 40px; }
  pre.code .ln::before { width: 26px; }
  pre.code .ln[data-note]::after { left: 18px; }
  .step-frame:has(.step-visual).is-active { grid-template-columns: 1fr; }
  .site-foot { padding: 30px 16px 50px; }
}
@media print {
  .topbar, .sidebar, .lesson-end, .hero-actions, .widget, .qactions { display: none !important; }
  .qanswer { display: block !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ AI tutor */
.tutor-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 70; display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700; font-size: .92rem; color: #fff;
  background: linear-gradient(120deg, var(--c0), var(--violet)); box-shadow: 0 8px 28px rgba(60, 60, 140, .35);
  transition: transform .15s, box-shadow .15s;
}
.tutor-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(60, 60, 140, .45); }
.tutor-launch {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .86rem; white-space: nowrap;
}
.tutor-launch .ic { color: var(--violet); }
.tutor-launch:hover, .tutor-launch.is-on { border-color: var(--violet); background: var(--violet-soft); }
.tutor-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 75; width: min(var(--tutor-width, 430px), calc(100vw - 40px)); height: min(680px, calc(100vh - 100px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s ease-out;
}
.tutor-resize { position: absolute; inset: 12px auto 12px 0; width: 12px; z-index: 1; cursor: col-resize; touch-action: none; }
.tutor-resize::after { content: ''; position: absolute; top: 50%; left: 3px; width: 4px; height: 40px; margin-top: -20px; border-radius: 4px; background: var(--ink-3); opacity: .45; }
.tutor-resize:hover::after, .tutor-resize:focus-visible::after { background: var(--accent); opacity: 1; }
.tutor-resize:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tutor-resize-help { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.tutor-resizing, body.tutor-resizing * { cursor: col-resize !important; user-select: none !important; }
.tutor-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(120deg, color-mix(in srgb, var(--c0) 10%, var(--surface)), color-mix(in srgb, var(--violet) 10%, var(--surface))); }
.tutor-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #fff; background: linear-gradient(120deg, var(--c0), var(--violet)); flex: none; }
.tutor-title { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tutor-title strong { font-size: .95rem; }
.tutor-sub { font-size: .72rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tutor-context { display: flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: .74rem; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.tutor-context span { overflow: hidden; text-overflow: ellipsis; }
.tutor-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.tutor-hello { font-size: .9rem; color: var(--ink-2); line-height: 1.55; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.tutor-hello p { margin: .35em 0; }
.tmsg { display: flex; }
.tmsg-user { justify-content: flex-end; }
.tmsg-text { min-width: 0; max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: .9rem; line-height: 1.55; overflow-wrap: anywhere; }
.tmsg-user .tmsg-text { background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.tmsg-assistant .tmsg-text { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; max-width: 100%; }
.tmsg-assistant .prose p { margin: .45em 0; }
.tmsg-assistant .prose > :first-child { margin-top: 0; }
.tmsg-assistant .prose > :last-child { margin-bottom: 0; }
.tmsg-assistant .prose pre { background: var(--code-bg); color: var(--code-ink); padding: 10px 12px; border-radius: 10px; overflow-x: auto; font-size: .78rem; }
.tmsg-assistant .prose pre code { background: none; border: 0; padding: 0; color: inherit; }
.tmsg-assistant .prose ul, .tmsg-assistant .prose ol { padding-left: 1.2em; }
.tutor-panel .tutor-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); scrollbar-width: thin; }
.tutor-panel .tutor-table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tutor-panel .tutor-table-wrap table { width: 100%; border-collapse: collapse; margin: 0; font: .83rem/1.5 var(--font); font-variant-numeric: tabular-nums; }
.tutor-panel .tutor-table-wrap th, .tutor-panel .tutor-table-wrap td { min-width: 8rem; padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.tutor-panel .tutor-table-wrap th { background: var(--surface-2); color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--line-2); }
.tutor-panel .tutor-table-wrap tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.tutor-panel .tutor-table-wrap tr > :last-child { border-right: 0; }
.tutor-panel .tutor-table-wrap tbody tr:last-child td { border-bottom: 0; }
.tutor-panel .tutor-table-wrap [align="center"] { text-align: center; }
.tutor-panel .tutor-table-wrap [align="right"] { text-align: right; }
.tutor-panel .tutor-table-wrap code { white-space: normal; overflow-wrap: anywhere; }
.tutor-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.tutor-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.tutor-typing i:nth-child(2) { animation-delay: .2s; } .tutor-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.tutor-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.tutor-quick:empty { display: none; }
.tutor-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.tutor-form textarea { flex: 1; resize: none; border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 12px; font: inherit; font-size: .9rem; line-height: 1.4; background: var(--surface); color: var(--ink); max-height: 160px; }
.tutor-form textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.tutor-send { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; background: linear-gradient(120deg, var(--c0), var(--violet)); flex: none; }
.tutor-foot { padding: 0 14px 10px; font-size: .68rem; color: var(--ink-3); text-align: center; }
.tutor-keyform { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.tutor-keyform input { flex: 1; min-width: 160px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-family: var(--mono); font-size: .82rem; }
.tutor-select { position: fixed; z-index: 72; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 0; cursor: pointer; font-size: .8rem; font-weight: 700; color: #fff; background: linear-gradient(120deg, var(--c0), var(--violet)); box-shadow: var(--shadow-lg); }
.tutor-chip .ic { color: var(--violet); }
.code-head .tutor-chip { background: #221d3d; border-color: #3b3270; color: #c9c1ff; }
.code-head .tutor-chip .ic { color: #c9c1ff; }
@media (max-width: 720px) {
  .tutor-fab span { display: none; }
  .tutor-launch { width: 38px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .tutor-launch span { display: none; }
  .tutor-fab { padding: 14px; right: 14px; bottom: 14px; }
  .tutor-panel { right: 0; bottom: 0; width: 100vw; height: calc(100vh - var(--topbar-h)); border-radius: 20px 20px 0 0; }
  .tutor-resize, .tutor-expand { display: none; }
}
@media print { .tutor-fab, .tutor-panel, .tutor-select { display: none !important; } }

/* collapsible notes written inside notebooks (<details>) */
.prose details { margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 18px; }
.prose details > summary { cursor: pointer; padding: 12px 0; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
.prose details > summary::-webkit-details-marker { display: none; }
.prose details > summary::before { content: "▸"; color: var(--mod); transition: transform .2s; }
.prose details[open] > summary::before { transform: rotate(90deg); }
.prose details[open] { padding-bottom: 12px; }
