/* Standalone lab pages. Self-contained: site.css is never loaded here, so these rules
   cannot collide with lesson styles, including when a lab is framed inside a lesson. */
:root {
  color-scheme: light;
  --paper: #f8faf8;
  --surface: #fff;
  --surface-2: #f1f5f2;
  --ink: #182b26;
  --muted: #52665e;
  --line: #d7e1dc;
  --field: #8fa59b;
  --accent: #09684e;
  --accent-soft: #e8f4ed;
  --accent-ink: #fff;
  --secondary: #3d5249;
  --secondary-ink: #fff;
  --focus: #92500b;
  --code: #f1f5f2;
  --banner: #0d3b2e;
  --banner-ink: #f2f7f4;
  --banner-muted: #c4dccf;
  --banner-link: #a9e3c6;
  /* Figure palette. Canvas plots read these at draw time (plot-theme.mjs); SVG
     figures use the classes below. Series hues keep their meaning in both themes. */
  --figure: #f7faf8;
  --figure-line: #c3d1ca;
  --plot-surface: #fff;
  --plot-frame: #889999;
  --plot-ink: #182b26;
  --plot-muted: #506071;
  --plot-blue: #076baf;
  --plot-orange: #c45b00;
  --plot-green: #26743a;
  --plot-band: #dcebdc;
  --plot-body: #e4edf4;
  --plot-body-line: #263f55;
  --plot-red: #a32b15;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0a0e;
  --surface: #131118;
  --surface-2: #1a1720;
  --ink: #e9e6f0;
  --muted: #a39fb1;
  --line: #27232f;
  --field: #4a4456;
  --accent: #b6a4ea;
  --accent-soft: #1f1a2c;
  --accent-ink: #0b0a0e;
  --secondary: #2a2633;
  --secondary-ink: #e9e6f0;
  --focus: #c9b6ff;
  --code: #1a1720;
  --banner: #131118;
  --banner-ink: #e9e6f0;
  --banner-muted: #a39fb1;
  --banner-link: #c8baf0;
  --figure: #16141c;
  --figure-line: #3d3748;
  --plot-surface: #1c1924;
  --plot-frame: #5a5468;
  --plot-ink: #e9e6f0;
  --plot-muted: #a39fb1;
  --plot-blue: #6cb6f2;
  --plot-orange: #f5a05a;
  --plot-green: #72cf8c;
  --plot-band: #1f3327;
  --plot-body: #252a36;
  --plot-body-line: #a9bdd2;
  --plot-red: #ff8a73;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}
input,
select,
button {
  font: inherit;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.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;
}

/* Lab banner */
body > header {
  background: var(--banner);
  color: var(--banner-ink);
  padding: 1.3rem max(1rem, calc((100% - 1200px) / 2));
  border-bottom: 1px solid var(--line);
}
body > header a {
  color: var(--banner-link);
}
body > header p {
  margin: 0.35rem 0 0;
  color: var(--banner-muted);
}
h1,
h2,
h3 {
  line-height: 1.2;
}
h1 {
  margin: 0.35rem 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}
h3 {
  font-size: 1rem;
}
main {
  max-width: 1200px;
  margin: auto;
  padding: 1rem;
}
.intro,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
  min-width: 0;
}
.intro ol {
  padding-left: 1.3rem;
}
.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 1rem;
}
.controls {
  display: grid;
  gap: 0.65rem;
}
main label {
  display: grid;
  grid-template-columns: 1fr 7rem;
  gap: 0.5rem;
  align-items: center;
}
/* Preset menus hold long option names ("Gravity compensation"), so they get a full row. */
main label:has(> select) {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
}
main input[type="number"],
main select {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--field);
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--ink);
}
main input[type="checkbox"] {
  justify-self: start;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}
main input[type="file"] {
  max-width: 100%;
  color: var(--muted);
}
main button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  border-radius: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
main button:hover {
  filter: brightness(1.08);
}
main button.secondary {
  background: var(--secondary);
  color: var(--secondary-ink);
  border-color: var(--line);
}
.buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
main canvas,
main svg {
  display: block;
  width: 100%;
  max-width: 100%;
  background: var(--figure);
  border: 1px solid var(--figure-line);
  border-radius: 0.35rem;
  color: var(--plot-ink);
}
main canvas {
  height: 260px;
}
main svg text {
  fill: var(--plot-ink);
}
main svg .plot-area {
  fill: var(--plot-surface);
  stroke: var(--plot-frame);
}
main svg .plot-band {
  fill: var(--plot-band);
}
main svg .is-blue {
  --series: var(--plot-blue);
}
main svg .is-orange {
  --series: var(--plot-orange);
}
main svg .is-green {
  --series: var(--plot-green);
}
main svg .plot-point,
main svg text.plot-label {
  fill: var(--series);
}
main svg .plot-line {
  fill: none;
  stroke: var(--series);
}
main svg .robot-body {
  fill: var(--plot-body);
  stroke: var(--plot-body-line);
}
main svg .robot-module {
  fill: var(--plot-body-line);
}
main svg text.robot-center {
  fill: var(--plot-red);
}
/* Wide result tables scroll sideways inside their card instead of widening the page
   (a lesson frame can be ~310px). Focusable so keyboard users can scroll it; vertical
   swipes still reach the page. */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
main table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
main caption {
  padding: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}
main td,
main th {
  text-align: left;
  padding: 0.35rem;
  border-bottom: 1px solid var(--line);
}
main th {
  font-weight: 650;
}
.note {
  color: var(--muted);
  font-size: 0.95rem;
}
code {
  background: var(--code);
  padding: 0.1rem 0.25rem;
  border-radius: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.88em;
}
footer {
  max-width: 1200px;
  margin: auto;
  padding: 1rem;
}
.status {
  font-variant-numeric: tabular-nums;
}
noscript {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 1rem;
}

/* Course bar added by the site builder. */
.course-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  min-height: 3.25rem;
  padding: 0.35rem max(0.75rem, calc((100% - 1200px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.course-toolbar a {
  text-decoration: none;
}
.course-toolbar a:hover {
  text-decoration: underline;
}
.course-home {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-weight: 650;
}
.course-sep {
  color: var(--muted);
}
.course-spacer {
  flex: 1;
}
.course-toolbar svg {
  width: 1.2rem;
  height: 1.2rem;
}
.course-toolbar .icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.course-toolbar .icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.course-toolbar .icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  z-index: 20;
  padding: 0.25rem 0.5rem;
  border-radius: 0.3rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
@media (hover: hover) {
  .course-toolbar .icon-btn[data-tip]:hover::after {
    opacity: 1;
    transition-delay: 0.3s;
  }
}
.course-toolbar .icon-btn[data-tip]:focus-visible::after {
  opacity: 1;
}
:root[data-theme="dark"] #theme-toggle .lucide-moon,
:root:not([data-theme="dark"]) #theme-toggle .lucide-sun {
  display: none;
}
.provenance-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0.6rem 0.12rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}
.course-toolbar .provenance-badge svg {
  width: 0.85rem;
  height: 0.85rem;
}
.completion {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.completion:not([data-ready]) {
  visibility: hidden;
}
.complete-toggle[aria-pressed="true"],
.complete-toggle[aria-pressed="true"] + .completion-status {
  color: var(--accent);
}
.complete-icon {
  width: 1.35rem;
  height: 1.35rem;
  overflow: visible;
  transform-origin: center;
}
.complete-icon .ring {
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: fill 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;
}
.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 cubic-bezier(0.2, 0.7, 0.3, 1);
}
.complete-toggle.just-completed .check {
  animation: draw-check 0.32s 0.08s both;
}
@keyframes complete-pop {
  0% {
    transform: scale(0.82);
  }
  60% {
    transform: scale(1.1);
  }
}
@keyframes draw-check {
  from {
    stroke-dashoffset: 1;
  }
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  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;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.18s,
    visibility 0s linear 0.18s;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.18s;
}

/* Embedded in a lesson (?embed=1, same origin only): the lesson supplies the title,
   course links and completion control, and sizes the frame to this content. */
:root[data-embed="1"] body > header,
:root[data-embed="1"] .course-toolbar,
:root[data-embed="1"] .toast {
  display: none;
}
:root[data-embed="1"] main {
  max-width: none;
  padding: 0.25rem 1rem 1rem;
}
:root[data-embed="1"] .intro,
:root[data-embed="1"] .card {
  margin: 0.75rem 0;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  body > header {
    padding: 1rem;
  }
  main label {
    grid-template-columns: 1fr 6rem;
  }
  .completion-status,
  .course-sep,
  .course-home span {
    display: none;
  }
  :root[data-embed="1"] main {
    padding: 0.25rem 0.6rem 0.75rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
