/* lesson-lab.css -- typography and interactive widgets for lesson bodies.
 *
 * Loaded from inside lesson.content, which renders through {{ ...|safe }} on
 * courses/lesson_detail.html. That is the only place these rules apply, so
 * everything is scoped under .lesson-doc or .lab and nothing here can leak
 * into the rest of the app.
 *
 * Colour comes entirely from custom properties re-declared under
 * [data-bs-theme="dark"] -- the theme switcher in partials/switcher.html sets
 * that attribute on <html>, so the widgets follow the page without JS.
 *
 * Nothing here depends on the page stylesheet beyond Bootstrap's box-sizing
 * reset, because lesson_detail.html's own <style> block sits in a template
 * block the layout does not define, and has never actually applied.
 */

.lesson-doc {
  --ld-ink: #1f2933;
  --ld-ink-soft: #52606d;
  --ld-ink-faint: #7b8794;
  --ld-bg: #ffffff;
  --ld-panel: #f6f8f7;
  --ld-panel-2: #eef2f0;
  --ld-line: #dde3e0;
  --ld-line-soft: #e9edeb;

  /* Forest greens carry the course; amber is "watch out", clay is "wrong". */
  --ld-accent: #2f7d55;
  --ld-accent-soft: #e6f2eb;
  --ld-accent-ink: #1d5a3b;
  --ld-warn: #b3761a;
  --ld-warn-soft: #fdf3e2;
  --ld-bad: #b3403a;
  --ld-bad-soft: #fbeceb;
  --ld-info: #2a6f97;
  --ld-info-soft: #e8f1f7;

  --ld-code-bg: #f4f6f5;
  --ld-code-ink: #1f2933;
  --ld-term-bg: #eef2f0;

  --ld-radius: 10px;
  --ld-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
             "Liberation Mono", monospace;

  color: var(--ld-ink);
  font-size: 1.0rem;
  line-height: 1.75;

  /* The reading measure for prose, applied per element below -- NOT to the
     document. Capping .lesson-doc itself at 74ch was a real bug: it squeezed
     every widget, table and figure into a 640px column too, and the
     `max-width: none` overrides further down could not undo it, because a
     child cannot be wider than the parent that contains it. */
  --ld-measure: 74ch;
  --ld-measure-wide: 96ch;
}

[data-bs-theme="dark"] .lesson-doc {
  --ld-ink: #e3e8e6;
  --ld-ink-soft: #aab4b0;
  --ld-ink-faint: #8b9591;
  --ld-bg: #1b1f1e;
  --ld-panel: #232927;
  --ld-panel-2: #2b3230;
  --ld-line: #3a423f;
  --ld-line-soft: #313835;

  --ld-accent: #63b98a;
  --ld-accent-soft: #1e3229;
  --ld-accent-ink: #8fd3ad;
  --ld-warn: #e0a955;
  --ld-warn-soft: #33291a;
  --ld-bad: #e2837c;
  --ld-bad-soft: #351f1e;
  --ld-info: #6fb2d9;
  --ld-info-soft: #1a2a33;

  --ld-code-bg: #191d1c;
  --ld-code-ink: #dfe5e3;
  --ld-term-bg: #2b3230;
}

/* Prose carries the reading measure. Everything else gets the full column:
   long lines are hard to read, wide tables and charts are not. */
.lesson-doc > p,
.lesson-doc > ul,
.lesson-doc > ol,
.lesson-doc > h2,
.lesson-doc > h3,
.lesson-doc > h4,
.lesson-doc > blockquote,
.lesson-doc > pre,
.lesson-doc > .steps {
  max-width: var(--ld-measure);
}

/* Boxed prose reads fine a little wider -- it is already indented and tinted,
   so the eye has an edge to return to. */
.lesson-doc > .callout,
.lesson-doc > .objectives,
.lesson-doc > .keytake {
  max-width: var(--ld-measure-wide);
}

/* Full column: interactive widgets, data tables, figures. */
.lesson-doc > .lab,
.lesson-doc > .ld-scroll,
.lesson-doc > .ld-wide,
.lesson-doc > figure {
  max-width: none;
}

/* ---------------------------------------------------------------- prose -- */

.lesson-doc > *:first-child { margin-top: 0; }

.lesson-doc h2 {
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 2.6rem 0 0.9rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--ld-line);
  color: var(--ld-ink);
}

.lesson-doc h3 {
  font-size: 1.16rem;
  font-weight: 650;
  margin: 2rem 0 0.7rem;
  color: var(--ld-ink);
}

.lesson-doc h4 {
  font-size: 1.0rem;
  font-weight: 650;
  margin: 1.5rem 0 0.5rem;
  color: var(--ld-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

.lesson-doc p { margin: 0 0 1.05rem; }
.lesson-doc ul, .lesson-doc ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
.lesson-doc li { margin-bottom: 0.4rem; }
.lesson-doc li > ul, .lesson-doc li > ol { margin-top: 0.4rem; margin-bottom: 0.3rem; }
.lesson-doc strong { font-weight: 650; color: var(--ld-ink); }
.lesson-doc a { color: var(--ld-accent); text-underline-offset: 2px; }

.lesson-doc hr {
  border: 0;
  border-top: 1px solid var(--ld-line);
  margin: 2.2rem 0;
  opacity: 1;
}

.lesson-doc code {
  font-family: var(--ld-mono);
  font-size: 0.875em;
  background: var(--ld-code-bg);
  color: var(--ld-code-ink);
  padding: 0.13em 0.38em;
  border-radius: 4px;
  border: 1px solid var(--ld-line-soft);
  white-space: nowrap;
}

.lesson-doc pre {
  font-family: var(--ld-mono);
  font-size: 0.83rem;
  line-height: 1.62;
  background: var(--ld-code-bg);
  color: var(--ld-code-ink);
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  padding: 0.95rem 1.05rem;
  overflow-x: auto;
  margin: 0 0 1.2rem;
}

.lesson-doc pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

.lesson-doc blockquote {
  margin: 0 0 1.2rem;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 3px solid var(--ld-accent);
  color: var(--ld-ink-soft);
  font-style: italic;
}

/* Wide content -- tables and diagrams -- scrolls inside itself rather than
 * pushing the whole lesson column sideways. */
.ld-scroll { overflow-x: auto; margin: 0 0 1.3rem; }

.lesson-doc table.ld-table {
  border-collapse: collapse;
  font-size: 0.875rem;
  width: 100%;
  min-width: 30rem;
}

.lesson-doc table.ld-table th,
.lesson-doc table.ld-table td {
  border-bottom: 1px solid var(--ld-line-soft);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.lesson-doc table.ld-table thead th {
  border-bottom: 2px solid var(--ld-line);
  font-weight: 650;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ld-ink-soft);
  white-space: nowrap;
}

.lesson-doc table.ld-table tbody tr:hover { background: var(--ld-panel); }
.lesson-doc table.ld-table td.num,
.lesson-doc table.ld-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.lesson-doc table.ld-table code { white-space: nowrap; }

.lesson-doc figure { margin: 0 0 1.4rem; }
.lesson-doc figcaption {
  font-size: 0.82rem;
  color: var(--ld-ink-faint);
  margin-top: 0.55rem;
  line-height: 1.55;
}

/* ------------------------------------------------------------- callouts -- */

.callout {
  border: 1px solid var(--ld-line);
  border-left: 3px solid var(--ld-accent);
  background: var(--ld-panel);
  border-radius: var(--ld-radius);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.3rem;
  font-size: 0.94rem;
}

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

.callout-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ld-accent-ink);
  margin-bottom: 0.4rem;
}

.callout.is-tip     { border-left-color: var(--ld-accent); background: var(--ld-accent-soft); }
.callout.is-tip     .callout-label { color: var(--ld-accent-ink); }
.callout.is-warn    { border-left-color: var(--ld-warn); background: var(--ld-warn-soft); }
.callout.is-warn    .callout-label { color: var(--ld-warn); }
.callout.is-trap    { border-left-color: var(--ld-bad); background: var(--ld-bad-soft); }
.callout.is-trap    .callout-label { color: var(--ld-bad); }
.callout.is-field   { border-left-color: var(--ld-info); background: var(--ld-info-soft); }
.callout.is-field   .callout-label { color: var(--ld-info); }

/* Learning objectives, with a checkbox each that remembers itself. */
.objectives {
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  padding: 1rem 1.15rem;
  margin: 0 0 1.6rem;
  background: var(--ld-panel);
}

.objectives h4 { margin-top: 0; }
.objectives ul { list-style: none; padding: 0; margin: 0; }

.objectives li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 0.93rem;
  line-height: 1.6;
}

.objectives li:last-child { margin-bottom: 0; }

.objectives li .box {
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.28rem;
  border: 1.5px solid var(--ld-line);
  border-radius: 4px;
  background: var(--ld-bg);
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}

.objectives li.done .box { background: var(--ld-accent); border-color: var(--ld-accent); }

.objectives li.done .box::after {
  content: "";
  position: absolute;
  left: 0.3rem; top: 0.1rem;
  width: 0.28rem; height: 0.55rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.objectives li.done { color: var(--ld-ink-faint); }

/* Key takeaway, closing a lesson. */
.keytake {
  border: 1px solid var(--ld-accent);
  background: var(--ld-accent-soft);
  border-radius: var(--ld-radius);
  padding: 1rem 1.15rem;
  margin: 2rem 0 1.3rem;
}

.keytake h4 { margin-top: 0; color: var(--ld-accent-ink); }
.keytake > :last-child { margin-bottom: 0; }

/* Numbered step cards for procedures. */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1.4rem; }

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 0 2.6rem;
  margin-bottom: 1.1rem;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0.1rem;
  width: 1.75rem; height: 1.75rem;
  border-radius: 50%;
  background: var(--ld-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Glossary term: dotted underline, click to reveal the definition inline. */
.term {
  border-bottom: 1px dashed var(--ld-accent);
  cursor: help;
  font-weight: 550;
}

.term-def {
  display: none;
  background: var(--ld-term-bg);
  border-left: 2px solid var(--ld-accent);
  border-radius: 0 6px 6px 0;
  padding: 0.55rem 0.8rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.88rem;
  color: var(--ld-ink-soft);
}

.term-def.open { display: block; }

/* ---------------------------------------------------------------- lab -- */

.lab {
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  background: var(--ld-bg);
  margin: 0 0 1.6rem;
  overflow: hidden;
}

.lab-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.9rem;
  background: var(--ld-panel);
  border-bottom: 1px solid var(--ld-line);
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ld-ink-soft);
}

.lab-head .lab-kind {
  color: var(--ld-accent-ink);
  white-space: nowrap;
}

.lab-head .lab-name {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 550;
  color: var(--ld-ink-soft);
  font-size: 0.85rem;
  border-left: 1px solid var(--ld-line);
  padding-left: 0.55rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-body { padding: 0.9rem; }
.lab-body > :last-child { margin-bottom: 0; }
.lab-body > p:first-child { margin-top: 0; }

.lab-note {
  font-size: 0.88rem;
  color: var(--ld-ink-soft);
  margin: 0 0 0.75rem;
}

/* buttons */
.lab-btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--ld-line);
  background: var(--ld-bg);
  color: var(--ld-ink-soft);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.lab-btn:hover:not(:disabled) { background: var(--ld-panel-2); color: var(--ld-ink); }
.lab-btn:disabled { opacity: 0.5; cursor: default; }

.lab-btn.primary {
  background: var(--ld-accent);
  border-color: var(--ld-accent);
  color: #fff;
}

.lab-btn.primary:hover:not(:disabled) { filter: brightness(1.07); color: #fff; }

.lab-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.lab-status {
  font-size: 0.79rem;
  color: var(--ld-ink-faint);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.lab-status.busy { color: var(--ld-warn); }
.lab-status.ok { color: var(--ld-accent); }
.lab-status.bad { color: var(--ld-bad); }

/* ------------------------------------------------------ python runner -- */

.lab-editor-wrap {
  border: 1px solid var(--ld-line);
  border-radius: 8px;
  background: var(--ld-code-bg);
  display: flex;
  overflow: hidden;
  font-family: var(--ld-mono);
  font-size: 0.83rem;
  line-height: 1.62;
}

.lab-gutter {
  flex: 0 0 auto;
  padding: 0.7rem 0.55rem 0.7rem 0.75rem;
  text-align: right;
  color: var(--ld-ink-faint);
  background: var(--ld-panel);
  border-right: 1px solid var(--ld-line-soft);
  user-select: none;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.lab-editor {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--ld-code-ink);
  font: inherit;
  padding: 0.7rem 0.8rem;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  min-height: 4.5rem;
}

.lab-out {
  display: none;
  margin-top: 0.75rem;
  border: 1px solid var(--ld-line);
  border-radius: 8px;
  overflow: hidden;
}

.lab-out.open { display: block; }

.lab-out-head {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ld-ink-faint);
  padding: 0.4rem 0.75rem;
  background: var(--ld-panel);
  border-bottom: 1px solid var(--ld-line-soft);
}

.lab-out pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--ld-bg);
  font-size: 0.8rem;
  max-height: 26rem;
  padding: 0.75rem 0.85rem;
}

.lab-out.is-err .lab-out-head { color: var(--ld-bad); background: var(--ld-bad-soft); }
.lab-out.is-err pre { color: var(--ld-bad); }

.lab-plots { padding: 0.75rem; background: var(--ld-bg); border-top: 1px solid var(--ld-line-soft); }
.lab-plots:empty { display: none; }
.lab-plots img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 0.6rem;
  border-radius: 6px;
  /* Matplotlib renders on white. In dark mode an untouched PNG glares, so it
   * gets a light card of its own rather than being inverted -- inverting a
   * chart changes what the colours mean. */
  background: #fff;
  padding: 0.35rem;
}
.lab-plots img:last-child { margin-bottom: 0; }

.lab-boot {
  font-size: 0.8rem;
  color: var(--ld-ink-faint);
  margin-top: 0.6rem;
  display: none;
}

.lab-boot.open { display: block; }

.lab-boot .bar {
  height: 3px;
  background: var(--ld-line);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.lab-boot .bar span {
  display: block;
  height: 100%;
  width: 30%;
  background: var(--ld-accent);
  border-radius: 2px;
  animation: labslide 1.15s ease-in-out infinite;
}

@keyframes labslide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

@media (prefers-reduced-motion: reduce) {
  .lab-boot .bar span { animation: none; width: 100%; opacity: 0.5; }
}

/* --------------------------------------------------------------- quiz -- */

.lab-q { margin-bottom: 1.3rem; }
.lab-q:last-of-type { margin-bottom: 0.4rem; }

.lab-q-text {
  font-weight: 600;
  margin: 0 0 0.7rem;
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
}

.lab-q-text .n {
  flex: 0 0 auto;
  color: var(--ld-accent);
  font-variant-numeric: tabular-nums;
}

.lab-opts { list-style: none; padding: 0; margin: 0; }

.lab-opts li {
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.45rem;
  cursor: pointer;
  font-size: 0.93rem;
  line-height: 1.55;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  transition: background 0.12s, border-color 0.12s;
}

.lab-opts li:hover { background: var(--ld-panel); }
.lab-opts li .key {
  flex: 0 0 1.4rem;
  font-family: var(--ld-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ld-ink-faint);
  text-transform: uppercase;
}

.lab-opts li.picked { border-color: var(--ld-accent); background: var(--ld-accent-soft); }
.lab-opts li.picked .key { color: var(--ld-accent-ink); }

.lab-q.graded .lab-opts li { cursor: default; }
.lab-q.graded .lab-opts li:hover { background: inherit; }
.lab-q.graded .lab-opts li.right {
  border-color: var(--ld-accent);
  background: var(--ld-accent-soft);
}
.lab-q.graded .lab-opts li.wrong {
  border-color: var(--ld-bad);
  background: var(--ld-bad-soft);
}
.lab-q.graded .lab-opts li.right .key { color: var(--ld-accent-ink); }
.lab-q.graded .lab-opts li.wrong .key { color: var(--ld-bad); }

.lab-q.graded .lab-opts li.right::after,
.lab-q.graded .lab-opts li.wrong::after {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  align-self: center;
}
.lab-q.graded .lab-opts li.right::after { content: "benar"; color: var(--ld-accent-ink); }
.lab-q.graded .lab-opts li.wrong::after { content: "keliru"; color: var(--ld-bad); }

.lab-explain {
  display: none;
  margin-top: 0.55rem;
  padding: 0.6rem 0.85rem;
  border-left: 2px solid var(--ld-info);
  background: var(--ld-info-soft);
  border-radius: 0 6px 6px 0;
  font-size: 0.88rem;
  line-height: 1.62;
  color: var(--ld-ink-soft);
}

.lab-explain.open { display: block; }
.lab-explain > :last-child { margin-bottom: 0; }

.lab-score {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  border-radius: 7px;
  margin-top: 0.9rem;
  display: none;
}

.lab-score.open { display: block; }
.lab-score.pass { background: var(--ld-accent-soft); color: var(--ld-accent-ink); }
.lab-score.fail { background: var(--ld-warn-soft); color: var(--ld-warn); }

/* ---------------------------------------------------- fill in the blank -- */

.lab-blank-code {
  font-family: var(--ld-mono);
  font-size: 0.83rem;
  line-height: 2.1;
  background: var(--ld-code-bg);
  border: 1px solid var(--ld-line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--ld-code-ink);
}

.lab-blank-code input {
  font: inherit;
  font-size: 0.83rem;
  background: var(--ld-bg);
  border: 1px solid var(--ld-accent);
  border-radius: 5px;
  color: var(--ld-code-ink);
  padding: 0.1rem 0.4rem;
  width: 8.5rem;
  text-align: center;
  outline: none;
}

.lab-blank-code input:focus { box-shadow: 0 0 0 2px var(--ld-accent-soft); }
.lab-blank-code input.right { border-color: var(--ld-accent); background: var(--ld-accent-soft); }
.lab-blank-code input.wrong { border-color: var(--ld-bad); background: var(--ld-bad-soft); }

/* --------------------------------------------------------- ordering -- */

.lab-order { list-style: none; padding: 0; margin: 0; counter-reset: ordn; }

.lab-order li {
  counter-increment: ordn;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.45rem;
  background: var(--ld-bg);
  font-size: 0.92rem;
  cursor: grab;
}

.lab-order li::before {
  content: counter(ordn);
  flex: 0 0 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--ld-panel-2);
  color: var(--ld-ink-faint);
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lab-order li.dragging { opacity: 0.45; cursor: grabbing; }
.lab-order li.right { border-color: var(--ld-accent); background: var(--ld-accent-soft); }
.lab-order li.wrong { border-color: var(--ld-bad); background: var(--ld-bad-soft); }
.lab-order li .txt { flex: 1 1 auto; min-width: 0; }

.lab-order .move {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lab-order .move button {
  font: inherit;
  font-size: 0.6rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--ld-line);
  background: var(--ld-bg);
  color: var(--ld-ink-faint);
  cursor: pointer;
  border-radius: 3px;
}

.lab-order .move button:hover { background: var(--ld-panel-2); color: var(--ld-ink); }

/* --------------------------------------------------------- matching -- */

.lab-match { display: grid; gap: 0.5rem; }

.lab-match .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 0.6rem;
  align-items: center;
}

.lab-match .left {
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  padding: 0.5rem 0.75rem;
  background: var(--ld-panel);
  font-family: var(--ld-mono);
  font-size: 0.82rem;
  color: var(--ld-ink);
  overflow-x: auto;
  white-space: nowrap;
}

.lab-match select {
  font: inherit;
  font-size: 0.88rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  background: var(--ld-bg);
  color: var(--ld-ink);
}

.lab-match select.right { border-color: var(--ld-accent); background: var(--ld-accent-soft); }
.lab-match select.wrong { border-color: var(--ld-bad); background: var(--ld-bad-soft); }

/* --------------------------------------------------- explorer widgets -- */

.lab-explore-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin-bottom: 0.9rem;
}

.lab-ctl { flex: 1 1 12rem; min-width: 11rem; }

.lab-ctl label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--ld-ink-soft);
  margin-bottom: 0.3rem;
}

.lab-ctl label .val {
  font-family: var(--ld-mono);
  font-weight: 700;
  color: var(--ld-accent-ink);
  font-variant-numeric: tabular-nums;
}

.lab-ctl input[type="range"] { width: 100%; accent-color: var(--ld-accent); }

.lab-ctl select {
  font: inherit;
  font-size: 0.85rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--ld-line);
  border-radius: 6px;
  background: var(--ld-bg);
  color: var(--ld-ink);
}

.lab-chart { width: 100%; }
.lab-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.lab-chart .axis line, .lab-chart .axis path { stroke: var(--ld-line); }
.lab-chart .grid line { stroke: var(--ld-line-soft); }
.lab-chart text { fill: var(--ld-ink-soft); font-size: 11px; }
.lab-chart text.title { fill: var(--ld-ink); font-size: 12px; font-weight: 650; }
.lab-chart .bar { fill: var(--ld-accent); }
.lab-chart .bar.alt { fill: var(--ld-info); }
.lab-chart .dot { fill: var(--ld-accent); fill-opacity: 0.55; }
.lab-chart .fit { stroke: var(--ld-bad); stroke-width: 2; fill: none; }
.lab-chart .resid { stroke: var(--ld-warn); stroke-width: 1; stroke-opacity: 0.55; }
.lab-chart .line { stroke: var(--ld-accent); stroke-width: 2; fill: none; }
.lab-chart .band { fill: var(--ld-accent); fill-opacity: 0.15; }

.lab-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.lab-readout .stat {
  flex: 1 1 7rem;
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  padding: 0.5rem 0.7rem;
  background: var(--ld-panel);
}

.lab-readout .stat .k {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ld-ink-faint);
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.lab-readout .stat .v {
  font-family: var(--ld-mono);
  font-size: 1.02rem;
  font-weight: 650;
  color: var(--ld-ink);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------ data preview -- */

.lab-filter {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.lab-filter input, .lab-filter select {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--ld-line);
  border-radius: 6px;
  background: var(--ld-bg);
  color: var(--ld-ink);
}

.lab-filter input { flex: 1 1 12rem; min-width: 9rem; }

.lab-grid-wrap { overflow: auto; max-height: 24rem; border: 1px solid var(--ld-line); border-radius: 8px; }

table.lab-grid {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--ld-mono);
  font-size: 0.78rem;
}

table.lab-grid th {
  position: sticky;
  top: 0;
  background: var(--ld-panel);
  border-bottom: 1px solid var(--ld-line);
  padding: 0.45rem 0.7rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ld-ink-soft);
  font-weight: 700;
}

table.lab-grid th:hover { color: var(--ld-ink); }
table.lab-grid th .arrow { color: var(--ld-accent); }

table.lab-grid td {
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid var(--ld-line-soft);
  white-space: nowrap;
  color: var(--ld-ink);
}

table.lab-grid td.flag { background: var(--ld-bad-soft); color: var(--ld-bad); font-weight: 650; }
table.lab-grid td.blank { background: var(--ld-warn-soft); }
table.lab-grid td.blank::after { content: "kosong"; color: var(--ld-warn); font-size: 0.7rem; }
table.lab-grid tbody tr:hover td { background: var(--ld-panel); }

.lab-count { font-size: 0.78rem; color: var(--ld-ink-faint); margin-top: 0.5rem; }

/* ---------------------------------------------------------- fallback -- */

.lab-fallback {
  font-size: 0.86rem;
  color: var(--ld-ink-soft);
  border: 1px dashed var(--ld-line);
  border-radius: 7px;
  padding: 0.7rem 0.85rem;
  background: var(--ld-panel);
}

.lab noscript { display: block; }

@media (max-width: 640px) {
  .lesson-doc { font-size: 0.96rem; }
  .lab-match .row { grid-template-columns: minmax(0, 1fr); }
  .lab-status { margin-left: 0; width: 100%; }
}
