/* Team 1257 learning library: readable lessons, clear experiments, local assets. */
/* Light theme: team green. Dark theme: near-black with muted purple accents. */
:root {
  color-scheme: light;
  --paper: #f8faf8;
  --surface: #fff;
  --surface-2: #f1f5f2;
  --ink: #182b26;
  --muted: #52665e;
  --line: #d7e1dc;
  --line-strong: #b4c5bd;
  --accent: #09684e;
  --accent-soft: #e8f4ed;
  --accent-ink: #fff;
  --focus: #92500b;
  --code: #f1f5f2;
  --code-line: #dde6e0;
  --mark: #fde68a;
  --header: rgba(248, 250, 248, 0.94);
  --shadow: 0 1px 2px #1a2b2410, 0 10px 30px #1a2b2414;
  --c-note: #2360a5;
  --c-tip: #09684e;
  --c-important: #6a46b6;
  --c-warning: #915400;
  --c-caution: #b42318;
  --c-history: #6a6158;
  --tok-comment: #5d7369;
  --tok-keyword: #7f3c84;
  --tok-string: #236d33;
  --tok-number: #9b4a16;
  --tok-function: #1d5f99;
  --header-h: 3.5rem;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0a0e;
  --surface: #131118;
  --surface-2: #1a1720;
  --ink: #e9e6f0;
  --muted: #a39fb1;
  --line: #27232f;
  --line-strong: #3d3748;
  --accent: #b6a4ea;
  --accent-soft: #1f1a2c;
  --accent-ink: #0b0a0e;
  --focus: #c9b6ff;
  --code: #110f15;
  --code-line: #24202c;
  --mark: #5b4a8a;
  --header: rgba(11, 10, 14, 0.9);
  --shadow: 0 1px 2px #0008, 0 14px 40px #000a;
  --c-note: #93b2e6;
  --c-tip: #9cc9d4;
  --c-important: #c3aef3;
  --c-warning: #e2b56a;
  --c-caution: #ee8f86;
  --c-history: #aaa196;
  --tok-comment: #807b90;
  --tok-keyword: #c8adf6;
  --tok-string: #dcc08f;
  --tok-number: #f0a98a;
  --tok-function: #93c0e8;
}
* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
a {
  color: var(--accent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}
button,
input,
select {
  font: inherit;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.85rem;
  border-radius: 0.45rem;
  line-height: 1.4;
  text-decoration: none;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s;
}
button[hidden] {
  display: none;
}
button:hover,
.button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.button-primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  filter: brightness(1.08);
}
button svg,
.button svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
img {
  max-width: 100%;
  height: auto;
}
svg {
  max-width: 100%;
}
mark {
  background: var(--mark);
  color: inherit;
  border-radius: 0.15rem;
  padding: 0 0.08em;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--muted);
  font: 600 0.7rem / 1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-align: center;
}

/* Lesson typography */
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  text-wrap: balance;
}
h1 {
  font-size: clamp(1.9rem, 2.6vw, 2.4rem);
  letter-spacing: -0.015em;
  margin: 0 0 1.1rem;
}
h2 {
  font-size: 1.45rem;
  letter-spacing: -0.005em;
  margin: 2.4rem 0 0.8rem;
}
h3 {
  font-size: 1.15rem;
  margin: 1.9rem 0 0.6rem;
}
h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}
article :is(h2, h3, h4)[id] {
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
article :is(h2, h3):target {
  animation: target-flash 1.6s var(--ease);
}
.heading-anchor {
  margin-left: 0.4rem;
  color: var(--line-strong);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.12s;
}
:is(h2, h3):hover > .heading-anchor {
  opacity: 1;
}
.heading-anchor:hover {
  color: var(--accent);
}
p,
ul,
ol {
  margin: 0 0 1.1rem;
}
li {
  margin-bottom: 0.35rem;
}
li > ul,
li > ol {
  margin-top: 0.35rem;
}
article {
  overflow-wrap: break-word;
}
code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.88em;
}
:not(pre) > code {
  background: var(--code);
  border: 1px solid var(--code-line);
  padding: 0.08rem 0.3rem;
  border-radius: 0.28rem;
  overflow-wrap: anywhere;
}
:is(h1, h2, h3, h4) > code {
  font-size: 0.9em;
}
pre {
  position: relative;
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.15rem;
  overflow: auto;
  background: var(--code);
  border: 1px solid var(--code-line);
  border-radius: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.6;
  tab-size: 4;
  max-width: 100%;
  white-space: pre;
  scrollbar-width: thin;
}
pre code {
  font-size: inherit;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}
blockquote {
  border-left: 3px solid var(--line-strong);
  margin: 1.25rem 0;
  padding: 0.2rem 0 0.2rem 1.1rem;
  color: var(--muted);
}
blockquote p:last-child {
  margin-bottom: 0;
}

/* Callouts: GitHub-style [!NOTE] markers and the historical-lesson banner. */
.callout {
  --c: var(--c-note);
  margin: 1.5rem 0;
  padding: 0.8rem 1rem 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  border-radius: 0.5rem;
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--c) 26%, var(--line));
  border-left-color: var(--c);
}
.callout-tip {
  --c: var(--c-tip);
}
.callout-important {
  --c: var(--c-important);
}
.callout-warning {
  --c: var(--c-warning);
}
.callout-caution {
  --c: var(--c-caution);
}
.callout-history {
  --c: var(--c-history);
  font-size: 0.92rem;
}
.callout > :last-child {
  margin-bottom: 0;
}
.callout-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  color: var(--c);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.callout-title svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}
.callout pre {
  margin: 0.75rem 0;
}

/* Wide tables scroll; the edge shadows appear only while more content is hidden. */
table {
  display: block;
  max-width: 100%;
  overflow: auto;
  border-collapse: collapse;
  margin: 1.25rem 0 1.75rem;
  font-size: 0.92rem;
  scrollbar-width: thin;
  background:
    linear-gradient(to right, var(--paper) 30%, transparent) left / 2rem 100%
      no-repeat local,
    linear-gradient(to left, var(--paper) 30%, transparent) right / 2rem 100%
      no-repeat local,
    radial-gradient(farthest-side at 0 50%, #0003, transparent) left / 0.6rem
      100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, #0003, transparent) right /
      0.6rem 100% no-repeat scroll;
}
th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  min-width: 6rem;
}
th {
  background: var(--surface-2);
  font-weight: 650;
  border-bottom-color: var(--line-strong);
}
.skip-link {
  position: fixed;
  left: 1rem;
  top: -8rem;
  z-index: 30;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 2px solid;
}
.skip-link:focus {
  top: 1rem;
}
.noscript-note {
  margin: 0;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* Header: logo, then icon-only actions. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--header-h);
  padding: 0 0.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--header);
  backdrop-filter: saturate(1.4) blur(8px);
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-right: auto;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.95rem;
  line-height: 1.2;
}
.site-logo img {
  flex: none;
  width: 2rem;
  height: 2rem;
}
.site-logo span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-logo strong {
  font-weight: 650;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover,
.icon-btn[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}
.icon-btn[aria-pressed="true"]:not(:hover) {
  background: transparent;
}
.icon-btn:focus-visible {
  outline-offset: 1px;
}
.icon-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}
/* Tooltips show on hover and keyboard focus; the accessible name comes from aria-label. */
.icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 20;
  padding: 0.25rem 0.5rem;
  border-radius: 0.3rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition:
    opacity 0.12s,
    transform 0.12s;
}
.icon-btn.tip-start[data-tip]::after {
  right: auto;
  left: 0;
}
@media (hover: hover) {
  .icon-btn[data-tip]:hover::after {
    opacity: 1;
    transform: none;
    transition-delay: 0.3s;
  }
}
.icon-btn[data-tip]:focus-visible::after {
  opacity: 1;
  transform: none;
  transition-delay: 0.3s;
}
:root[data-theme="dark"] #theme-toggle .lucide-moon,
:root:not([data-theme="dark"]) #theme-toggle .lucide-sun,
#menu-toggle .lucide-x,
#menu-toggle[aria-expanded="true"] .lucide-menu {
  display: none;
}
#menu-toggle[aria-expanded="true"] .lucide-x {
  display: block;
}
#menu-toggle {
  display: none;
}

/* Layout */
.site-layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr) 12rem;
  max-width: 1600px;
  margin: auto;
}
.lesson {
  min-width: 0;
  padding: 2rem clamp(1.5rem, 4vw, 4rem) 4rem;
  max-width: 1100px;
}
/* Prose keeps a reading measure; lab embeds may use the whole column. */
.lesson article > :where(:not(.lab-embed)),
.lesson-footer {
  max-width: 76ch;
}

/* Sidebar: one nested tree, current branch open. */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  padding: 1rem 0.6rem 2rem 0.9rem;
  font-size: 0.86rem;
  scrollbar-width: thin;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar li {
  margin: 0;
}
.sidebar ul ul {
  margin: 0.1rem 0 0.25rem 0.7rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
}
.nav-tree > li {
  margin-bottom: 0.1rem;
}
.nav-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.nav-row > a {
  flex: 1;
  min-width: 0;
}
.sidebar a,
.nav-label {
  display: block;
  padding: 0.3rem 0.55rem;
  border-radius: 0.35rem;
  text-decoration: none;
  color: var(--muted);
  line-height: 1.4;
}
.sidebar a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  box-shadow: inset 2px 0 var(--accent);
}
.nav-tree > li > a,
.nav-tree > li > .nav-row > a,
.nav-group-toggle {
  color: var(--ink);
  font-weight: 600;
}
.nav-twisty,
.nav-group-toggle {
  border: 0;
  background: none;
  color: var(--muted);
  border-radius: 0.35rem;
}
.nav-twisty {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.3rem 0.375rem 0.3rem 0.55rem;
  text-align: left;
  line-height: 1.4;
  font-size: inherit;
}
.nav-twisty:hover,
.nav-group-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-group {
  margin-top: 0.5rem;
}
.nav-twisty svg,
.nav-group-toggle svg {
  flex: none;
  width: 1rem;
  height: 1rem;
  transition: transform 0.14s var(--ease);
}
.nav-twisty[aria-expanded="true"] svg,
.nav-group-toggle[aria-expanded="true"] svg {
  transform: rotate(90deg);
}
.nav-reveal {
  animation: nav-reveal 0.16s var(--ease);
}
@media (pointer: coarse) {
  .nav-twisty {
    width: 2.25rem;
    height: 2.25rem;
  }
  .sidebar a,
  .nav-group-toggle {
    padding-block: 0.45rem;
  }
}
.nav-scrim {
  display: none;
}

/* On-this-page rail: h2 only, two lines per entry at most. */
.toc {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100dvh - var(--header-h));
  overflow: auto;
  padding: 2rem 1rem 1.5rem;
  font-size: 0.8rem;
}
.toc h2 {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.6rem;
  color: var(--muted);
}
.toc ul {
  padding: 0;
  margin: 0;
  list-style: none;
}
.toc li {
  margin: 0.4rem 0;
}
.toc a {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
}
.toc a:hover {
  color: var(--accent);
}

/* Lesson meta row under the H1: completion icon and provenance. */
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  margin: -0.4rem 0 1.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.completion {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: -0.45rem;
}
/* Hidden until site.mjs paints the saved state, so it never flashes the wrong one. */
.completion:not([data-ready]) {
  visibility: hidden;
}
.completion-status {
  font-weight: 550;
}
.complete-toggle[aria-pressed="true"] + .completion-status {
  color: var(--accent);
}
.complete-toggle {
  width: 2.1rem;
  height: 2.1rem;
}
.complete-icon {
  width: 1.4rem;
  height: 1.4rem;
  overflow: visible;
  transform-origin: center;
}
.complete-icon .ring {
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.6;
  transition:
    fill 0.18s,
    stroke 0.18s;
}
.complete-icon .check {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 0.22s var(--ease);
}
.complete-toggle:not([aria-pressed="true"]):hover .check {
  stroke-dashoffset: 0;
  opacity: 0.5;
}
.complete-toggle[aria-pressed="true"],
.complete-toggle[aria-pressed="true"]:hover {
  color: var(--accent);
}
.complete-toggle[aria-pressed="true"] .ring {
  fill: var(--accent);
  stroke: var(--accent);
}
.complete-toggle[aria-pressed="true"] .check {
  stroke: var(--accent-ink);
  stroke-dashoffset: 0;
}
.complete-toggle.just-completed .complete-icon {
  animation: complete-pop 0.42s var(--ease);
}
.complete-toggle.just-completed .check {
  animation: draw-check 0.32s 0.08s var(--ease) both;
}
.complete-toggle.just-completed::before {
  content: "";
  position: absolute;
  inset: 0.3rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  pointer-events: none;
  animation: ring-out 0.6s var(--ease) forwards;
}
.provenance-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
}
.provenance-badge svg {
  width: 0.85rem;
  height: 0.85rem;
  flex: none;
}
.provenance-badge:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Lesson footer: progress block, pager, source links. */
.lesson-footer {
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.lesson-progress {
  display: grid;
  gap: 0.6rem;
  padding: 1rem 0 1.1rem;
  border-top: 1px solid var(--line);
}
.lesson-progress-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.25rem;
}
.next-activity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin: 0;
  font-size: 0.92rem;
  animation: fade-in 0.2s var(--ease);
}
.next-activity[hidden] {
  display: none;
}
.next-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.next-activity a {
  font-weight: 600;
}
.next-activity a::after {
  content: " →";
}
.next-path {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.8rem;
}
#progress-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.progress-caveat {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}
.progress-tools {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.progress-tools summary {
  cursor: pointer;
  width: fit-content;
}
.progress-tools-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding-top: 0.75rem;
}
.progress-tools-body p {
  flex-basis: 100%;
  margin: 0;
}
.progress-tools button {
  padding: 0.35rem 0.7rem;
}
.progress-tools label {
  font-weight: 600;
  color: var(--ink);
}
.progress-tools input {
  max-width: 16rem;
  font-size: 0.8rem;
}
.lesson-progress-row .progress-tools[open] {
  flex-basis: 100%;
}
.progress-panel {
  display: grid;
  gap: 0.6rem;
  margin: 0 0 2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--surface);
}
.lesson-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-block: 1px solid var(--line);
  margin-bottom: 0.8rem;
}
.lesson-pager a {
  display: flex;
  flex-direction: column;
  max-width: 48%;
  text-decoration: none;
  line-height: 1.4;
}
.lesson-pager a:hover span {
  text-decoration: underline;
}
.lesson-pager small {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lesson-pager a[rel="next"] {
  margin-left: auto;
  text-align: right;
}
.lesson-source {
  margin: 0;
}
.site-footer {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 1.4rem 1.25rem 1.6rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--line);
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.25rem;
}
.site-footer p {
  margin: 0;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 40;
  max-width: min(32rem, calc(100% - 2rem));
  padding: 0.6rem 0.95rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  transform: translate(-50%, 0.5rem);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.18s,
    transform 0.18s var(--ease),
    visibility 0s linear 0.18s;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition:
    opacity 0.18s,
    transform 0.18s var(--ease),
    visibility 0s;
}
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 15;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
}
#reading-progress::-webkit-progress-bar {
  background: transparent;
}
#reading-progress::-webkit-progress-value {
  background: var(--accent);
}
#reading-progress::-moz-progress-bar {
  background: var(--accent);
}
body[data-page-id="README.md"] #reading-progress {
  display: none;
}

/* Learning paths: compact list on home, table on the learning-paths page. */
.path-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.1rem;
  border-top: 1px solid var(--line);
}
.path-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 1rem;
  margin: 0;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.path-link {
  font-weight: 600;
}
.path-meta {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.path-desc {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.path-list .path-status {
  grid-column: 1 / -1;
}
.path-status {
  font-size: 0.8rem;
  color: var(--accent);
}
.path-status progress {
  width: 6rem;
  height: 0.45rem;
  vertical-align: middle;
  accent-color: var(--accent);
}
.path-status > :not([hidden]) {
  animation: fade-in 0.2s var(--ease);
}
.path-note {
  font-size: 0.88rem;
  color: var(--muted);
}
.path-table td:nth-child(2),
.path-table td:nth-child(3) {
  white-space: nowrap;
}

/* Search: command palette. */
dialog {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: #0008;
}
:root[data-theme="dark"] dialog::backdrop {
  background: #000b;
}
dialog[open] {
  animation: dialog-in 0.14s var(--ease);
}
dialog[open]::backdrop {
  animation: fade-in 0.14s;
}
.palette {
  width: min(42rem, calc(100% - 2rem));
  max-height: min(78dvh, 42rem);
  margin: min(12vh, 6rem) auto auto;
  padding: 0;
  overflow: hidden;
}
.palette[open] {
  display: flex;
  flex-direction: column;
}
.palette-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.5rem 0.45rem 1rem;
  border-bottom: 1px solid var(--line);
}
.palette-bar > svg {
  width: 1.2rem;
  height: 1.2rem;
  flex: none;
  color: var(--muted);
}
#search-input {
  flex: 1;
  min-width: 0;
  height: 2.75rem;
  padding: 0 0.4rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.05rem;
  outline: none;
}
#search-input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-decoration {
  appearance: none;
}
.palette-bar:focus-within {
  box-shadow: inset 0 -2px var(--accent);
}
#search-clear {
  width: 2.1rem;
  height: 2.1rem;
}
#search-clear[hidden] {
  display: none;
}
#search-clear svg {
  width: 1.05rem;
  height: 1.05rem;
}
.palette-close {
  flex: none;
  padding: 0.3rem;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.palette-close kbd {
  font-size: 0.68rem;
}
.palette-close svg {
  display: none;
  width: 1.2rem;
  height: 1.2rem;
}
.palette-spinner {
  width: 1rem;
  height: 1rem;
  flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  visibility: hidden;
}
.palette.is-loading .palette-spinner {
  visibility: visible;
  animation: spin 0.7s linear infinite;
}
.palette-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}
.palette-meta label {
  font-weight: 600;
}
#search-section {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.8rem;
}
#search-status {
  flex: 1;
  min-width: 10rem;
  margin: 0;
  text-align: right;
}
.palette-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.35rem;
  scrollbar-width: thin;
}
#search-results {
  list-style: none;
  padding: 0;
  margin: 0;
}
#search-results li {
  margin: 0;
}
#search-results a {
  position: relative;
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 2.4rem 0.65rem 0.75rem;
  border-radius: 0.45rem;
  color: var(--ink);
  text-decoration: none;
}
#search-results [aria-selected="true"] a {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 var(--accent);
}
.result-crumb {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-lab .result-crumb {
  color: var(--accent);
}
.result-title {
  font-size: 0.97rem;
  font-weight: 620;
  line-height: 1.35;
}
[aria-selected="true"] .result-title {
  color: var(--accent);
}
.result-snippet {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}
.result-enter {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1rem;
  opacity: 0;
}
[aria-selected="true"] .result-enter {
  opacity: 1;
}
.palette-actions {
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0 0.4rem;
}
.palette-actions button {
  margin: 0.5rem 0;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
}
.palette-actions button[hidden] {
  display: none;
}
.palette-empty {
  padding: 0.5rem 0.65rem 0.75rem;
}
.palette-empty[hidden] {
  display: none;
}
.palette-heading {
  margin: 0.5rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.chip-list,
.topic-list {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip-list li,
.topic-list li {
  margin: 0;
}
.chip {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.84rem;
}
.topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.15rem 0.5rem;
}
.topic-list a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  color: var(--ink);
  font-size: 0.9rem;
  text-decoration: none;
}
.topic-list a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.topic-list svg {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--muted);
}
.palette-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.74rem;
}
.palette-foot kbd {
  margin-right: 0.15rem;
}
.palette-private {
  margin-left: auto;
}
@media (pointer: coarse) {
  .palette-close kbd,
  .palette-foot {
    display: none;
  }
  .palette-close svg {
    display: block;
  }
}

/* Interactive labs embedded in lessons. */
.lab-embed {
  margin: 2rem 0 2.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper);
  overflow: hidden;
}
.lab-embed-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.lab-embed-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.lab-embed-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}
.lab-embed-text {
  flex: 1;
  min-width: 0;
}
.lab-embed-text p {
  margin: 0;
}
.lab-embed-kicker {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lab-embed-title {
  font-weight: 650;
  line-height: 1.3;
}
.lab-embed-summary {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
.lab-embed-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
}
.lab-open {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.lab-open:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lab-open svg {
  width: 0.95rem;
  height: 0.95rem;
}
.lab-embed iframe {
  display: block;
  width: 100%;
  height: min(80vh, 56rem);
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
}
.lab-embed-noscript {
  margin: 0;
  padding: 1rem;
}

iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  min-height: 20rem;
}
iframe[src*="youtube"] {
  aspect-ratio: 16/9;
  height: auto;
  min-height: 0;
}
.katex-display {
  overflow: auto hidden;
  max-width: 100%;
  padding: 0.4rem 0;
}
.token.comment,
.token.prolog {
  color: var(--tok-comment);
  font-style: italic;
}
.token.keyword,
.token.boolean {
  color: var(--tok-keyword);
}
.token.string,
.token.char {
  color: var(--tok-string);
}
.token.number {
  color: var(--tok-number);
}
.token.function,
.token.class-name {
  color: var(--tok-function);
}
.token.annotation,
.token.punctuation {
  color: var(--muted);
}
.unavailable-reference {
  color: var(--muted);
  text-decoration: line-through;
}

/* 404 */
.not-found {
  margin: 0 auto;
  padding-top: 3rem;
}
.not-found-code {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font: 700 0.85rem / 1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.1em;
}
.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Knowledge check */
.quiz-counter {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
#knowledge-check {
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  margin: 1.5rem 0 2rem;
}
#knowledge-check h2 {
  margin-top: 0;
  font-size: 1.15rem;
}
#quiz-body form,
#quiz-body > p {
  animation: fade-in 0.16s var(--ease);
}
#knowledge-check fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
}
#knowledge-check legend {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}
.quiz-choice {
  display: flex;
  align-items: start;
  gap: 0.7rem;
  border: 1px solid var(--line);
  padding: 0.6rem 0.75rem;
  border-radius: 0.4rem;
  margin: 0.5rem 0;
  cursor: pointer;
  transition:
    background-color 0.12s,
    border-color 0.12s;
}
.quiz-choice input {
  margin-top: 0.4rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.quiz-choice:hover {
  border-color: var(--accent);
}
.quiz-choice:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.quiz-choice:has(input:disabled) {
  cursor: default;
}
#knowledge-check button {
  margin-right: 0.6rem;
}
#knowledge-check button[hidden] {
  display: none;
}
#knowledge-check button:disabled {
  cursor: default;
  opacity: 0.6;
}
#quiz-status {
  margin: 1rem 0 0;
}
#quiz-status:not(:empty) {
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0.3rem;
  animation: fade-in 0.16s var(--ease);
}

article details {
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.6rem 0.9rem;
  margin: 0.75rem 0;
}
article details summary {
  cursor: pointer;
  font-weight: 600;
}
article details[open] > summary {
  margin-bottom: 0.6rem;
}
article details[open] > :not(summary) {
  animation: fade-in 0.16s var(--ease);
}
article details > :last-child {
  margin-bottom: 0;
}
.reading-question {
  margin: 0.4rem 0;
}
.reading-question summary {
  font-size: 0.95rem;
  line-height: 1.5;
}
.reading-question ul {
  list-style: none;
  padding-left: 0;
}
.answer-key {
  margin-top: 1.25rem;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(-0.4rem) scale(0.99);
  }
}
@keyframes nav-reveal {
  from {
    opacity: 0;
    transform: translateY(-0.2rem);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes complete-pop {
  0% {
    transform: scale(0.82);
  }
  60% {
    transform: scale(1.1);
  }
}
@keyframes draw-check {
  from {
    stroke-dashoffset: 1;
  }
}
@keyframes ring-out {
  from {
    opacity: 0.55;
    transform: scale(0.7);
  }
  to {
    opacity: 0;
    transform: scale(1.45);
  }
}
@keyframes target-flash {
  from {
    background: var(--accent-soft);
  }
}

@media (min-width: 1700px) {
  .lesson {
    padding-inline: 5rem;
  }
}
@media (max-width: 1250px) {
  .site-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}
/* Mobile drawer: slides in over a scrim; site.mjs handles focus, Escape and inert. */
@media (max-width: 950px) {
  #menu-toggle {
    display: inline-grid;
  }
  .site-header {
    padding-left: 1rem;
  }
  .site-layout {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: min(20rem, 86vw);
    height: auto;
    z-index: 9;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: 0.5rem 0 2rem #0003;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.16s var(--ease),
      visibility 0s linear 0.16s;
  }
  .menu-open .sidebar {
    transform: none;
    visibility: visible;
    transition:
      transform 0.16s var(--ease),
      visibility 0s;
  }
  .nav-scrim {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0;
    z-index: 8;
    background: #0006;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.16s,
      visibility 0s linear 0.16s;
  }
  .menu-open .nav-scrim {
    opacity: 1;
    visibility: visible;
    transition:
      opacity 0.16s,
      visibility 0s;
  }
  body.menu-open {
    overflow: hidden;
  }
  .lesson {
    padding: 1.5rem 1.5rem 3rem;
    max-width: 58rem;
    margin: auto;
  }
}
@media (max-width: 560px) {
  .site-header {
    gap: 0.25rem;
    padding: 0 0.4rem 0 0.8rem;
  }
  .site-logo {
    font-size: 0.88rem;
    gap: 0.4rem;
  }
  .site-logo img {
    width: 1.75rem;
    height: 1.75rem;
  }
  .lesson {
    padding: 1.25rem 1rem 2.5rem;
  }
  h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
  }
  table {
    font-size: 0.86rem;
  }
  th,
  td {
    min-width: 0;
    padding: 0.5rem 0.6rem;
  }
  .path-list li {
    grid-template-columns: 1fr;
  }
  .lesson-pager a {
    max-width: none;
  }
  pre {
    margin-inline: -0.25rem;
    padding: 0.85rem;
    font-size: 0.8rem;
  }
  .callout {
    padding: 0.7rem 0.8rem;
  }
  .lab-embed {
    margin-inline: -0.5rem;
    border-radius: 0.6rem;
  }
  .lab-embed-head {
    flex-wrap: wrap;
    padding: 0.7rem 0.6rem 0.6rem 0.8rem;
  }
  .lab-embed-actions {
    width: 100%;
    justify-content: space-between;
  }
  .lab-embed-icon {
    display: none;
  }
  #knowledge-check {
    padding: 1rem;
  }
  .palette {
    width: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
    margin-top: 0.5rem;
  }
  #search-status {
    flex-basis: 100%;
    text-align: left;
  }
  .toast {
    bottom: 0.75rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
  .complete-toggle.just-completed::before {
    display: none;
  }
}
