.lab {
  --lab-green: var(--accent, #356348);
  --lab-ink: var(--ink, #23342c);
  --lab-muted: var(--muted, #718075);
  --lab-line: var(--line, #e1e5dc);
  color: var(--lab-ink);
  background: var(--surface, #fff);
  border: 1px solid var(--lab-line);
  border-radius: 16px;
  padding: clamp(18px, 3vw, 30px);
  margin-block: 24px;
  min-width: 0;
  font-size: 14px;
  line-height: 1.65;
}
.lab *,
.lab *::before,
.lab *::after {
  box-sizing: border-box;
}
.lab h3,
.lab p {
  margin: 0;
}
.lab h3 {
  font-size: clamp(19px, 2.5vw, 23px);
  line-height: 1.3;
  letter-spacing: -0.025em;
  margin-top: 5px;
}
.lab code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}
.lab a {
  color: var(--lab-green);
  text-underline-offset: 3px;
}
.lab .lab-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.lab .lab-eyebrow {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.12em;
  color: var(--lab-green);
}
.lab .lab-tag {
  background: #eef3eb;
  color: #356348;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  white-space: nowrap;
}
.lab .lab-intro {
  margin-block: 13px 22px;
  color: #526357;
  max-width: 68ch;
}
.lab .lab-caption {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.055em;
  color: #59685d;
}
.lab .lab-matrices {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--paper, #fbfcf8);
  border: 1px solid var(--lab-line);
  border-radius: 10px;
  margin-bottom: 18px;
}
.lab .lab-matrices > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.lab .lab-matrix {
  font-size: 18px;
  line-height: 1.6;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}
.lab .lab-math-symbol {
  color: var(--lab-muted);
  font-size: 20px;
}
.lab .lab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block: 17px;
}
.lab .lab-button {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  color: var(--lab-ink);
  background: #fff;
  border: 1px solid #d2dbce;
  border-radius: 7px;
  min-height: 40px;
  padding: 8px 13px;
  cursor: pointer;
  line-height: 1.3;
}
.lab .lab-button:hover:not(:disabled) {
  background: #f1f5ed;
  border-color: var(--lab-green);
}
.lab .lab-button-primary {
  color: #fff;
  background: var(--lab-green);
  border-color: var(--lab-green);
}
.lab .lab-button-primary:hover:not(:disabled) {
  color: #fff;
  background: #294c37;
}
.lab .lab-button:disabled {
  cursor: default;
  opacity: 0.45;
}
.lab button:focus-visible,
.lab input:focus-visible,
.lab summary:focus-visible,
.lab a:focus-visible {
  outline: 3px solid #75967e;
  outline-offset: 4px;
}
.lab .lab-clock {
  margin-left: auto;
  font:
    11px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  font-weight: 650;
  color: var(--lab-green);
}
.lab .lab-flow-key {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  color: #59685d;
  margin: 15px 0 8px;
}
.lab .lab-array {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.lab .lab-pe {
  position: relative;
  padding: 13px;
  border: 1px solid var(--lab-line);
  border-radius: 10px;
  background: #f8faf5;
  min-height: 106px;
}
.lab .lab-pe:nth-child(odd)::after {
  content: "→";
  position: absolute;
  right: -11px;
  top: calc(50% - 11px);
  font-size: 14px;
  color: var(--lab-green);
  z-index: 1;
}
.lab .lab-pe:nth-child(-n + 2)::before {
  content: "↓";
  position: absolute;
  bottom: -17px;
  left: calc(50% - 4px);
  font-size: 14px;
  color: var(--lab-green);
  z-index: 1;
}
.lab .lab-pe-active {
  background: #eef5e9;
  border-color: #98b38e;
}
.lab .lab-pe-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: #59685d;
}
.lab .lab-pe-top strong {
  color: var(--lab-green);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.lab .lab-pe-equation {
  font:
    13px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  line-height: 1.6;
  margin: 10px 0 6px;
  overflow-wrap: anywhere;
}
.lab .lab-pe-stream {
  font-size: 10px;
  color: #53644f;
  font-variant-numeric: tabular-nums;
}
.lab .lab-note {
  font-size: 11px;
  line-height: 1.7;
  color: #5b6a60;
  margin-top: 13px;
}
.lab .lab-details {
  margin-block: 17px;
  border-top: 1px solid var(--lab-line);
  border-bottom: 1px solid var(--lab-line);
  padding-block: 12px;
}
.lab .lab-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--lab-green);
  min-height: 24px;
}
.lab .lab-details p {
  color: #5b6a60;
  font-size: 12px;
  margin-top: 12px;
}
.lab .lab-details .lab-table-wrap {
  margin-top: 16px;
}
.lab .lab-trace-heading {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
  margin-top: 18px;
}
.lab .lab-trace {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.lab .lab-trace:empty::after {
  content: "Step or play to inspect the first clock.";
  color: #5b6a60;
  font-size: 12px;
  padding-block: 6px;
}
.lab .lab-trace li {
  border-left: 2px solid #a9bca1;
  background: #f7f9f3;
  padding: 9px 12px;
  font:
    11px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.lab .lab-trace strong {
  font:
    650 11px system-ui,
    sans-serif;
  display: block;
  color: var(--lab-green);
  margin-bottom: 3px;
}
.lab .lab-sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 12px;
}
.lab .lab-slider {
  display: block;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
}
.lab .lab-slider > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lab .lab-slider output {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--lab-green);
  background: #eff4eb;
  border-radius: 4px;
  min-width: 40px;
  text-align: center;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.lab .lab-slider input {
  display: block;
  width: 100%;
  min-height: 32px;
  margin: 3px 0 0;
  accent-color: var(--lab-green);
  cursor: pointer;
}
.lab .lab-stages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}
.lab .lab-stages > div {
  display: grid;
  gap: 8px;
  padding: 13px 12px;
  background: #f7f9f3;
  border: 1px solid var(--lab-line);
  border-radius: 9px;
  min-width: 0;
}
.lab .lab-stages code {
  font-size: 11px;
  overflow-wrap: anywhere;
}
.lab .lab-stages strong {
  font-size: 25px;
  line-height: 1.3;
  color: var(--lab-green);
  font-variant-numeric: tabular-nums;
}
.lab .lab-stages .lab-stage-output {
  background: #eef4e8;
  border-color: #b6c9ad;
}
.lab .lab-equation {
  font:
    11px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  line-height: 1.8;
  padding: 12px;
  background: var(--paper, #fbfcf8);
  border-radius: 7px;
  margin-block: 12px 0;
  overflow-wrap: anywhere;
}
.lab .lab-activation-chart {
  display: block;
  width: min(100%, 470px);
  margin: 8px auto 0;
}
.lab svg text {
  fill: #59685d;
  font:
    10px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}
.lab .lab-chart-axis {
  stroke: #d1dccb;
  stroke-width: 1;
}
.lab .lab-chart-line {
  stroke: var(--lab-green);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.lab .lab-chart-point {
  fill: #a87036;
  stroke: #fff;
  stroke-width: 1.5;
}
.lab .lab-learning-rate {
  max-width: 360px;
}
.lab .lab-metrics {
  display: grid;
  grid-template-columns: 1fr 0.65fr 1.2fr;
  gap: 12px;
  background: #f4f7ef;
  border: 1px solid var(--lab-line);
  border-radius: 10px;
  padding: 15px;
  margin-block: 18px;
}
.lab .lab-metrics > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.lab .lab-metrics strong {
  font-size: 24px;
  line-height: 1.35;
  color: var(--lab-green);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.lab .lab-training-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 20px;
  align-items: start;
}
.lab .lab-table-wrap {
  overflow-x: auto;
  min-width: 0;
}
.lab .lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.lab .lab-table caption {
  text-align: left;
  color: #5b6a60;
  font-size: 10px;
  font-weight: 650;
  padding: 0 0 8px;
  white-space: normal;
}
.lab .lab-table th,
.lab .lab-table td {
  border-bottom: 1px solid var(--lab-line);
  padding: 7px 6px;
  text-align: right;
}
.lab .lab-table th:first-child,
.lab .lab-table td:first-child {
  text-align: left;
}
.lab .lab-table thead th {
  font-size: 10px;
  font-weight: 650;
  color: #5b6a60;
  background: #f7f9f3;
}
.lab .lab-table tbody th {
  font-weight: 500;
}
.lab .lab-prediction {
  font-size: 10px;
  color: #8c542d;
}
.lab .lab-prediction-match {
  color: var(--lab-green);
}
.lab .lab-loss-panel {
  min-width: 0;
}
.lab .lab-loss-chart {
  width: 100%;
  display: block;
  margin-top: 8px;
}
.lab .lab-loss-panel .lab-note {
  margin-top: 5px;
}
.lab .lab-parameters {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (max-width: 600px) {
  .lab .lab-heading {
    align-items: flex-start;
  }
  .lab .lab-tag {
    font-size: 9px;
    padding: 3px 7px;
    margin-top: 3px;
  }
  .lab .lab-matrices {
    gap: 8px;
    padding: 12px;
  }
  .lab .lab-matrix {
    font-size: 15px;
  }
  .lab .lab-matrices .lab-caption {
    font-size: 9px;
    letter-spacing: 0;
  }
  .lab .lab-clock {
    margin-left: 0;
    flex-basis: 100%;
    padding-top: 4px;
  }
  .lab .lab-pe {
    padding: 10px;
  }
  .lab .lab-pe-top {
    font-size: 9px;
  }
  .lab .lab-pe-top strong {
    font-size: 10px;
  }
  .lab .lab-pe-equation {
    font-size: 11px;
  }
  .lab .lab-pe-stream {
    font-size: 9px;
  }
  .lab .lab-flow-key {
    font-size: 9px;
  }
  .lab .lab-sliders {
    column-gap: 18px;
  }
  .lab .lab-stages {
    gap: 6px;
  }
  .lab .lab-stages > div {
    padding: 10px 8px;
    gap: 6px;
  }
  .lab .lab-stages .lab-caption {
    font-size: 8px;
    letter-spacing: 0;
  }
  .lab .lab-stages code {
    font-size: 9px;
  }
  .lab .lab-stages strong {
    font-size: 22px;
  }
  .lab .lab-training-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .lab .lab-loss-chart {
    max-width: 460px;
    margin-inline: auto;
  }
  .lab .lab-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
  }
  .lab .lab-metrics > div:first-child {
    grid-column: 1 / -1;
  }
  .lab .lab-metrics .lab-caption {
    font-size: 8px;
    letter-spacing: 0;
  }
  .lab .lab-metrics strong {
    font-size: 21px;
  }
}
@media (max-width: 380px) {
  .lab {
    padding: 14px;
  }
  .lab .lab-heading {
    display: block;
  }
  .lab .lab-tag {
    display: inline-block;
    margin-top: 10px;
  }
  .lab .lab-matrices {
    padding: 9px;
    gap: 5px;
  }
  .lab .lab-matrix {
    font-size: 13px;
  }
  .lab .lab-pe-top {
    flex-wrap: wrap;
  }
  .lab .lab-flow-key {
    flex-wrap: wrap;
  }
  .lab .lab-button {
    padding-inline: 10px;
  }
}
