/* Лаборатория «Архитектура компьютера»: доски, таблицы и редакторы. Цвета — токены приложения (обе темы). */
.lab,
.lab-board {
  --l-card: var(--panel);
  --l-border: var(--border);
  --l-fg: var(--text);
  --l-muted: var(--panel-2);
  --l-mfg: var(--muted);
  --l-accent: var(--active-bg);
  --l-primary: var(--accent);
  --l-ok: var(--s-accent);
  --l-okfg: var(--s-bg);
  --l-warn: var(--amber);
  --l-bad: var(--error);
  --l-badfg: #fff;
  --l-bg: var(--bg);
}

.lab {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.lab-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.lab-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}
.lab-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.lab-card-head h3 {
  margin: 0;
  font-size: 15px;
}
.lab-card-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.lab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.lab-clock {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  margin-right: 2px;
  border-right: 1px solid var(--border);
}
.lab-clock select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 6px;
  font: inherit;
  font-size: 13px;
}
.lab-clock .running {
  border-color: var(--green);
  color: var(--green);
}
.lab-edges {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lab-lock-hint {
  color: var(--amber);
}
.lab-board-wrap {
  position: relative;
}
.lab-flash {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 90%;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--amber);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
}

/* ---------- доска: контейнер, палитра, масштаб ---------- */
.lab-board {
  position: relative;
  display: block;
  padding-bottom: 6px;
}
.lab-palette {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: max(5.5rem, calc(100% - 15rem));
  transform: translateX(-50%);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.lab-pal-sq {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: grab;
  touch-action: none;
}
.lab-pal-sq:hover {
  border-color: var(--accent);
  background: var(--active-bg);
}
.lab-pal-sq svg {
  width: 36px;
  height: 22px;
}
.lab-pal-sq .gate-body {
  fill: var(--panel);
  stroke: var(--text);
  stroke-width: 3;
}
.lab-pal-sq .gate-extra,
.lab-pal-sq .gate-bubble {
  fill: none;
  stroke: var(--text);
  stroke-width: 3;
}
.lab-pal-sq.locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.lab-pal-lock {
  position: absolute;
  right: -2px;
  bottom: -4px;
  font-size: 11px;
}
.lab-zoom {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.lab-zoom button {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.lab-zoom button + button {
  border-left: 1px solid var(--border);
}
.lab-zoom button:hover {
  background: var(--active-bg);
}
.lab-zoom .pct {
  font-size: 11px;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}
.lab-ghost {
  position: fixed;
  z-index: 1200;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.9;
}
.lab-ghost .gate-body {
  fill: var(--panel);
  stroke: var(--text);
  stroke-width: 1.8;
}
.lab-ghost .gate-bubble {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
}
.lab-board-svg {
  min-height: 0;
}
.lab-board-svg .out-node .node-box {
  stroke-width: 2;
}

/* ---------- палитра блоков ---------- */
.lab-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.lab-block-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.lab-block-item:hover {
  border-color: var(--accent);
  background: var(--active-bg);
}
.lab-block-item.locked {
  opacity: 0.55;
}
.lab-block-name {
  font-size: 13px;
  font-weight: 600;
}
.lab-block-sub {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- заглянуть внутрь блока ---------- */
.lab-inspector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lab-inspector-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.lab-crumb {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.lab-crumb:hover {
  text-decoration: underline;
}
.lab-crumb-sep {
  color: var(--muted);
}
.lab-inspector-edit {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 13px;
}
.lab-inspector-edit p {
  margin: 0 0 8px;
}

/* ---------- таблица истинности ---------- */
.lab-badge {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.lab-badge.ok {
  border-color: var(--green);
  color: var(--s-accent);
}
.lab-tt-scroll {
  overflow: auto;
  max-height: 360px;
}
.lab-tt {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  text-align: center;
}
.lab-tt th,
.lab-tt td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-soft);
}
.lab-tt th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--panel);
}
.lab-tt .sep {
  border-left: 1px solid var(--border);
}
.lab-tt tr.current td {
  background: var(--active-bg);
}
.lab-tt .target {
  color: var(--muted);
}
.lab-tt .actual.ok {
  color: var(--s-accent);
}
.lab-tt .actual.bad {
  color: var(--error);
}
.lab-tt .actual.na,
.lab-tt .na-mark {
  color: var(--faint);
}
.lab-tt .ok-mark {
  color: var(--s-accent);
}
.lab-tt .bad-mark {
  color: var(--error);
}

/* ---------- сценарий ---------- */
.lab-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lab-step {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  opacity: 0.7;
}
.lab-step.active {
  opacity: 1;
  border-color: var(--accent);
  background: var(--active-bg);
}
.lab-step.done {
  opacity: 0.9;
  border-color: var(--green);
}
.lab-step-no {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--panel-2);
}
.lab-step.done .lab-step-no {
  background: var(--green);
  color: #fff;
}
.lab-step-text {
  margin: 0 0 4px;
  font-size: 13px;
}
.lab-step-req {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.lab-chip {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.lab-chip.hit {
  border-color: var(--green);
  color: var(--s-accent);
}
.lab-chip.pulses {
  border-color: var(--amber);
  color: var(--amber);
}
.lab-chip-sep {
  color: var(--muted);
}

/* ---------- временная диаграмма ---------- */
.lab-wave {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: var(--panel-2);
}
.lab-wave .wave-grid {
  stroke: var(--border);
  stroke-width: 1;
}
.lab-wave .wave-now {
  fill: color-mix(in srgb, var(--accent) 12%, transparent);
}
.lab-wave .wave-label {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.lab-wave .wave-line {
  fill: none;
  stroke: var(--s-accent);
  stroke-width: 2;
}
.lab-wave .out .wave-line {
  stroke: var(--s-blue);
}
.lab-wave .wave-x {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

/* ===== из lab/gate-board.css ===== */
.lab-board {
  position: relative;
  display: block;
  padding-bottom: 1.25rem;
}
.lab-board.fill {
  padding-bottom: 0;
}
.lab-board.fill .lab-board-svg {
  width: 100%;
  height: 100%;
  min-height: 0;
}
.lab .input-node.is-clock .node-box {
  stroke: color-mix(in srgb, var(--l-primary) 55%, transparent);
  stroke-width: 2;
}
.lab-board-svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid var(--l-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--l-muted) 30%, transparent);
}
.lab .grid-dot {
  fill: color-mix(in srgb, var(--l-mfg) 22%, transparent);
}
.lab .node-box {
  fill: var(--l-card);
  stroke: var(--l-border);
  stroke-width: 1.5;
  transition: fill 0.15s ease;
}
.lab .node-click {
  cursor: pointer;
}
.lab .node-click:hover .node-box {
  fill: var(--l-accent);
  stroke: color-mix(in srgb, var(--l-primary) 50%, transparent);
}
.lab .out-box {
  stroke: color-mix(in srgb, var(--l-primary) 45%, transparent);
  stroke-width: 2;
}
.lab .node-label {
  fill: var(--l-fg);
  font-size: 15px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}
.lab .node-chip {
  fill: var(--l-muted);
  stroke: var(--l-border);
  transition:
    fill 0.15s ease,
    stroke 0.15s ease;
}
.lab .node-chip.v1 {
  fill: var(--l-ok);
  stroke: color-mix(in srgb, var(--l-ok) 60%, transparent);
}
.lab .node-chip-text {
  fill: var(--l-mfg);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  transition: fill 0.15s ease;
}
.lab .node-chip.v1 + .node-chip-text {
  fill: var(--l-okfg);
}
.lab .gate {
  cursor: grab;
}
.lab .gate.dragging {
  cursor: grabbing;
}
.lab .gate-body {
  fill: var(--l-card);
  stroke: color-mix(in srgb, var(--l-fg) 75%, transparent);
  stroke-width: 1.8;
  transition: fill 0.15s ease;
}
.lab .gate:hover .gate-body {
  fill: var(--l-accent);
}
.lab .gate.dragging .gate-body {
  stroke: var(--l-primary);
  stroke-width: 2.2;
}
.lab .gate-bubble {
  fill: none;
  stroke: color-mix(in srgb, var(--l-fg) 75%, transparent);
  stroke-width: 1.8;
}
.lab .gate-label {
  fill: var(--l-fg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-anchor: middle;
  pointer-events: none;
}
.lab .gate-label.small {
  font-size: 9px;
  letter-spacing: 0;
}
.lab .gate-del {
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.lab .gate:hover .gate-del {
  opacity: 1;
}
.lab .gate-del circle {
  fill: var(--l-bad);
  stroke: var(--l-card);
  stroke-width: 1.5;
}
.lab .gate-del path {
  stroke: var(--l-badfg);
  stroke-width: 1.8;
  stroke-linecap: round;
  fill: none;
}
.lab .probe circle {
  fill: var(--l-card);
  stroke: var(--l-border);
  stroke-width: 1.2;
}
.lab .probe text {
  fill: var(--l-mfg);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.lab .pin {
  cursor: crosshair;
}
.lab .pin-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}
.lab .pin-dot {
  fill: var(--l-card);
  stroke: var(--l-warn);
  stroke-width: 2;
  transition:
    fill 0.15s ease,
    stroke 0.15s ease;
  pointer-events: none;
}
.lab .pin-dot.v1 {
  fill: var(--l-ok);
  stroke: color-mix(in srgb, var(--l-ok) 50%, transparent);
}
.lab .pin-dot.v0 {
  fill: var(--l-card);
  stroke: color-mix(in srgb, var(--l-mfg) 60%, transparent);
}
.lab .wire {
  cursor: pointer;
}
.lab .wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
}
.lab .wire-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke 0.15s ease;
}
.lab .wire-line.v1 {
  stroke: var(--l-ok);
  stroke-dasharray: 7 5;
  animation: wire-flow 0.5s linear infinite;
}
.lab .wire-line.v0 {
  stroke: color-mix(in srgb, var(--l-mfg) 55%, transparent);
}
.lab .wire-line.vx {
  stroke: var(--l-warn);
  stroke-dasharray: 3 5;
}
.lab .wire:hover .wire-line {
  stroke: var(--l-bad);
  animation: none;
}
@keyframes wire-flow {
  to {
    stroke-dashoffset: -12;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lab .wire-line.v1 {
    animation: none;
  }
}
.lab .wire-preview {
  fill: none;
  stroke: color-mix(in srgb, var(--l-mfg) 70%, transparent);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  pointer-events: none;
}
.lab .wire-auto {
  fill: none;
  stroke: hsl(217 91% 60% / 0.5);
  stroke-width: 1.5;
  stroke-dasharray: 5 6;
  stroke-linecap: round;
  pointer-events: none;

  animation: wire-auto-flow 0.7s linear infinite;
}
@keyframes wire-auto-flow {
  to {
    stroke-dashoffset: -11;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lab .wire-auto {
    animation: none;
  }
}
.lab .wire-preview.ok {
  stroke: var(--l-ok);
}
.lab .lab-ghost {
  position: fixed;
  z-index: 200;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 4px 10px rgb(0 0 0 / 0.25));
}
@keyframes guide-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 color-mix(in srgb, var(--l-ok) 0%, transparent));
  }
  50% {
    filter: drop-shadow(0 0 7px var(--l-ok));
  }
}
.lab .gate.guide-focus .gate-body,
.lab .wire.guide-focus .wire-line {
  animation: guide-pulse 1.1s ease-in-out 3;
}
.lab .wire.guide-focus .wire-line {
  stroke-width: 4;
}
.lab-board-bg {
  cursor: grab;
}
.lab-board-svg.panning,
.lab-board-svg.panning .lab-board-bg {
  cursor: grabbing;
}
.lab-board-svg.zoom-ready {
  outline: 2px solid color-mix(in srgb, var(--l-primary) 35%, transparent);
  outline-offset: -2px;
}

/* ===== из block-board.css ===== */
.lab-board {
  display: block;
  position: relative;
}
.lab .bb {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid var(--l-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--l-muted) 30%, transparent);
}
.lab .grid-dot {
  fill: color-mix(in srgb, var(--l-mfg) 22%, transparent);
}
.lab .bbox-rect {
  fill: var(--l-card);
  stroke: var(--l-border);
  stroke-width: 1.5;
}
.lab .bbox.top .bbox-rect {
  fill: color-mix(in srgb, var(--l-card) 60%, transparent);
  stroke-dasharray: 4 4;
}
.lab .bbox-head {
  fill: color-mix(in srgb, var(--l-muted) 70%, transparent);
  cursor: grab;
}
.lab .bbox-title {
  fill: var(--l-fg);
  font-size: 12.5px;
  font-weight: 700;
  pointer-events: none;
}
.lab .bbox-title.top {
  fill: var(--l-mfg);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.lab .bbtn {
  cursor: pointer;
}
.lab .bbtn circle {
  fill: var(--l-card);
  stroke: var(--l-border);
}
.lab .bbtn:hover circle {
  fill: var(--l-accent);
  stroke: color-mix(in srgb, var(--l-primary) 60%, transparent);
}
.lab .bbtn.del path {
  stroke: var(--l-mfg);
  stroke-width: 1.6;
  stroke-linecap: round;
  fill: none;
}
.lab .bbtn.del:hover circle {
  stroke: var(--l-bad);
}
.lab .bbtn .lens {
  fill: none;
  stroke: var(--l-mfg);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.lab .blabel {
  fill: var(--l-fg);
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
}
.lab .btype {
  fill: var(--l-mfg);
  font-weight: 500;
  font-size: 10px;
}
.lab .brow.dim {
  opacity: 0.28;
}
.lab .caret {
  cursor: pointer;
}
.lab .caret rect {
  fill: transparent;
}
.lab .caret:hover rect {
  fill: var(--l-accent);
}
.lab .caret text {
  fill: var(--l-mfg);
  font-size: 11px;
  pointer-events: none;
}
.lab .bpin-hit {
  fill: transparent;
  cursor: crosshair;
}
.lab .bpin-dot {
  fill: var(--l-card);
  stroke: var(--l-warn);
  stroke-width: 2;
  pointer-events: none;
  transition: stroke 0.15s ease;
}
.lab .brow.hover .bpin-dot {
  stroke: var(--l-ok);
  fill: color-mix(in srgb, var(--l-ok) 30%, transparent);
}
.lab .bb.readonly .bpin-hit {
  cursor: default;
}
.lab .bchip rect {
  fill: var(--l-muted);
  stroke: var(--l-border);
  transition: fill 0.15s ease;
}
.lab .bchip text {
  fill: var(--l-mfg);
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}
.lab .bchip:not(.static) {
  cursor: pointer;
}
.lab .bchip:not(.static):hover rect {
  stroke: color-mix(in srgb, var(--l-primary) 60%, transparent);
}
.lab .bchip.v1 rect {
  fill: var(--l-ok);
  stroke: color-mix(in srgb, var(--l-ok) 60%, transparent);
}
.lab .bchip.v1 text {
  fill: var(--l-okfg);
}
.lab .bchip.clk rect {
  stroke: color-mix(in srgb, var(--l-primary) 70%, transparent);
  stroke-width: 1.8;
}
.lab .bchip.out text {
  fill: var(--l-fg);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.lab .bwire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  cursor: pointer;
}
.lab .bb.readonly .bwire-hit {
  cursor: default;
}
.lab .bwire-line {
  fill: none;
  stroke-linecap: round;
  stroke-width: 2.5;
  pointer-events: none;
  transition: stroke 0.15s ease;
}
.lab .bwire.bus .bwire-line {
  stroke-width: 5;
}
.lab .bwire-line.v1 {
  stroke: var(--l-ok);
  stroke-dasharray: 7 5;
  animation: bwire-flow 0.5s linear infinite;
}
.lab .bwire-line.v0 {
  stroke: color-mix(in srgb, var(--l-mfg) 55%, transparent);
}
.lab .bwire-line.vx {
  stroke: var(--l-warn);
  stroke-dasharray: 3 5;
}
.lab .bwire-line.bus {
  stroke: color-mix(in srgb, var(--l-primary) 55%, transparent);
}
.lab .bwire-line.bus.vx {
  stroke: var(--l-warn);
  stroke-dasharray: 3 5;
}
.lab .bwire:hover .bwire-line {
  stroke: var(--l-bad);
  animation: none;
}
.lab .bb.readonly .bwire:hover .bwire-line {
  stroke-width: 3.5;
}
.lab .bwire-tag rect {
  fill: var(--l-card);
  stroke: var(--l-border);
}
.lab .bwire-tag text {
  fill: var(--l-fg);
  font-size: 10.5px;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  pointer-events: none;
}
.lab .bwire-preview {
  fill: none;
  stroke: var(--l-mfg);
  stroke-width: 3;
  stroke-dasharray: 6 5;
  stroke-linecap: round;
  pointer-events: none;
}
.lab .bwire-preview.ok {
  stroke: var(--l-ok);
}
@keyframes bwire-flow {
  to {
    stroke-dashoffset: -12;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lab .bwire-line.v1 {
    animation: none;
  }
}
.lab-board.fill {
  height: 100%;
}
.lab-board.fill .bb {
  height: 100%;
}
.lab .bb-bg {
  cursor: grab;
}
.lab .bb.panning,
.lab .bb.panning .bb-bg {
  cursor: grabbing;
}
.lab .bb.zoom-ready {
  outline: 2px solid color-mix(in srgb, var(--l-primary) 35%, transparent);
  outline-offset: -2px;
}
/* ---------- страница упражнения: список — полосой сверху, чтобы доске хватало ширины ---------- */
.lab-pr .pr-body:not(.single) {
  display: flex;
  flex-direction: column;
  /* .pr-body задаёт align-items: start для сетки; в колонке это сжимало карточку по ширине содержимого */
  align-items: stretch;
  gap: 10px;
}
.lab-pr .pr-main {
  width: 100%;
  box-sizing: border-box;
}
.lab-pr .pr-list {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  max-height: none;
  padding: 6px;
}
.lab-pr .pr-item {
  padding: 3px;
}
.lab-pr .pr-name {
  display: none;
}
.lab-pr .pr-item.on .pr-name {
  display: none;
}

/* ====================== ассемблер Мини-8 и RISC-V ====================== */
.lab-asm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  .lab-asm-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.lab-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.lab .mono,
.lab-mono {
  font-family:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
.lab-muted {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}
.lab-scroll {
  overflow-x: auto;
}
.lab-editor {
  box-sizing: border-box;
  width: 100%;
  min-height: 18rem;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
  resize: vertical;
}
.lab-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.lab-errors {
  margin: 10px 0 0;
  padding: 8px 12px 8px 24px;
  border: 1px solid color-mix(in srgb, var(--error) 50%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--error) 8%, transparent);
  font-size: 13px;
  line-height: 1.5;
}
.lab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.lab-table th {
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
.lab-table td {
  padding: 4px 8px;
  text-align: center;
  border-top: 1px solid var(--border-soft);
}
.lab-table .left {
  text-align: left;
}
.lab-table tbody tr {
  cursor: default;
}
.lab-table:not(.ref) tbody tr {
  cursor: pointer;
}
.lab-table:not(.ref) tbody tr:hover {
  background: color-mix(in srgb, var(--active-bg) 55%, transparent);
}
.lab-table tr.current {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.lab-table tr.selected td.f-op,
.lab-table tr.selected td.f-a,
.lab-table tr.selected td.f-b,
.lab-table tr.selected td.f-c {
  font-weight: 700;
}
.lab-table .f-op,
.lab .fld.op {
  color: var(--s-violet);
}
.lab-table .f-a,
.lab .fld.rs1 {
  color: var(--s-blue);
}
.lab-table .f-b,
.lab .fld.rd {
  color: var(--s-accent);
}
.lab-table .f-c,
.lab .fld.rs2 {
  color: var(--s-amber);
}
.lab .fld.f3,
.lab .fld.f7 {
  color: var(--muted);
}
.lab .fld.imm {
  color: var(--s-red);
}
.lab .fld + .fld {
  margin-left: 6px;
}
.lab-fields,
.lab-table td.left.mono:last-child {
  white-space: nowrap;
}
.lab-table tr.pseudo td:last-child::after {
  content: " ·";
  color: var(--muted);
}
.lab-table .explain-row td {
  border-top: none;
  padding-top: 0;
}
.lab-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 12px;
  text-align: left;
}
.lab-legend-item {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}
.lab-explain {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.lab-ref-sub {
  margin: 16px 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.lab-regs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.lab-regs.rv32 {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
}
.lab-reg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}
.lab-reg.changed {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 14%, transparent);
}
.lab-reg-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.lab-reg-name small {
  font-weight: 400;
  opacity: 0.7;
}
.lab-reg-val {
  font-size: 15px;
  font-weight: 700;
}
.lab-regs.rv32 .lab-reg-val {
  font-size: 14px;
}
.lab-reg-hex {
  font-size: 11px;
  color: var(--muted);
}
.lab-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.lab-seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}
.lab-seg button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.lab-seg button.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
}
/* итог проверки: компактная плашка в духе приложения — квадратные значок и кнопка, моноширинный шрифт */
.lab-alert {
  --alert-c: var(--amber);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--alert-c) 55%, var(--border));
  border-radius: 4px;
  background: color-mix(in srgb, var(--alert-c) 10%, var(--panel));
  font-family: "IBM Plex Mono", monospace;
}
.lab-alert.ok {
  --alert-c: var(--s-accent);
}
.lab-alert.bad {
  --alert-c: var(--amber);
}
.lab-alert-ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--alert-c);
  border-radius: 2px;
  color: var(--alert-c);
}
.lab-alert-ico svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lab-alert-body {
  min-width: 0;
}
.lab-alert-body p {
  margin: 0;
}
.lab-alert-title {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.lab-alert-title strong {
  color: var(--alert-c);
  font-weight: 600;
}
.lab-alert-text {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.lab-alert-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--alert-c);
  border-radius: 2px;
  background: var(--alert-c);
  color: var(--s-bg);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.lab-alert-next:hover {
  filter: brightness(1.08);
}
.lab-alert-next svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 560px) {
  .lab-alert {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .lab-alert-next {
    grid-column: 1 / -1;
    justify-content: center;
  }
}
.lab-regions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.lab-region {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
}
.lab-disk {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-x: auto;
  font-size: 12px;
}
.lab-disk-head,
.lab-disk-row {
  display: grid;
  grid-template-columns: 1.6rem repeat(16, minmax(1.45rem, 1fr)) 8.5rem;
  gap: 1px;
  align-items: center;
}
.lab-mem .lab-disk-head,
.lab-mem .lab-disk-row {
  grid-template-columns: 2.4rem repeat(16, minmax(1.45rem, 1fr)) 8.5rem;
}
.lab-disk-head {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.lab-addr {
  color: var(--muted);
  font-size: 11px;
}
.lab-cell {
  padding: 2px 0;
  text-align: center;
  border-radius: 3px;
  background: color-mix(in srgb, var(--panel-2) 80%, transparent);
  transition: background-color 0.2s ease;
}
.lab-cell.rg0,
.lab-region.rg0 {
  border-bottom: 2px solid color-mix(in srgb, var(--s-blue) 80%, transparent);
}
.lab-cell.rg1,
.lab-region.rg1 {
  border-bottom: 2px solid color-mix(in srgb, var(--s-accent) 80%, transparent);
}
.lab-cell.rg2,
.lab-region.rg2 {
  border-bottom: 2px solid color-mix(in srgb, var(--s-violet) 80%, transparent);
}
.lab-cell.changed {
  background: color-mix(in srgb, var(--amber) 30%, transparent);
}
.lab-cell.read {
  background: color-mix(in srgb, var(--s-blue) 40%, transparent);
}
.lab-cell.written {
  background: color-mix(in srgb, var(--s-accent) 50%, transparent);
  font-weight: 700;
}
.lab-ascii {
  display: flex;
  padding-left: 8px;
  letter-spacing: 0.04em;
}
.lab-ascii span {
  flex: 1;
  text-align: center;
}
.lab-ascii .dot {
  opacity: 0.35;
}
.lab-ascii-head {
  text-align: left;
  padding-left: 8px;
}
.lab-data-title {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.lab-data,
.lab-console {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
}
.lab-console {
  min-height: 3.5rem;
  background: #0b1217;
  color: #8fe3bf;
  white-space: pre-wrap;
}
.lab-caret {
  opacity: 0.6;
  animation: lab-blink 1s steps(2, start) infinite;
}
@keyframes lab-blink {
  to {
    visibility: hidden;
  }
}
.lab-dev {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.lab-dev-name {
  width: 7.5rem;
  font-size: 13px;
  font-weight: 600;
}
.lab-leds {
  display: inline-flex;
  gap: 6px;
}
.lab-led {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 10px;
  color: var(--muted);
  background: var(--panel-2);
}
.lab-led.sw {
  border-radius: 4px;
}
.lab-led.on {
  background: #e5484d;
  border-color: #e5484d;
  box-shadow: 0 0 8px #e5484d;
  color: #fff;
}
.lab-led.sw.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}
.lab-exit {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
}
.lab-file {
  max-height: 22rem;
  overflow: auto;
  white-space: pre;
}
.lab-native {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* узкая страница (три колонки меню) — программа и машина друг под другом */
.lab-asm {
  container-type: inline-size;
}
@container (max-width: 940px) {
  .lab-asm-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ручка под доской: за неё тянут, чтобы менять высоту, масштаб не меняется */
.lab-resize-grip {
  position: absolute;
  left: 50%;
  bottom: 2px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 1rem;
  padding: 0;
  transform: translateX(-50%);
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: ns-resize;
  touch-action: none;
}
.lab-resize-grip svg {
  width: 1.75rem;
  height: 0.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.lab-resize-grip:hover,
.lab-resize-grip:focus-visible {
  background: var(--active-bg);
  color: var(--text);
  outline: none;
}

/* кнопки лаборатории — как в остальном приложении: квадратные, моноширинные, мельче */
.lab .quiz-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 2px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}
.lab-zoom {
  border-radius: 2px;
}
.lab-zoom button {
  font-family: "IBM Plex Mono", monospace;
}
.lab-pal-sq {
  border-radius: 2px;
}
