:root {
  --lab-accent: #197d74;
  --lab-accent-strong: #125f58;
  --lab-ink: #26333c;
  --lab-muted: #64747e;
  --lab-line: #d4dde1;
  --lab-canvas: #f4f6f6;
  --lab-surface: #ffffff;
  --lab-warning: #9a641f;
  --lab-danger: #a33f45;
  --lab-success: #2b7855;
}

/* The shared shell's 768px document floor conflicts with the browser's vertical
   scrollbar at the supported 768px tablet width. Lab pages own a tablet layout,
   so their stylesheet removes that document-level minimum. */
html {
  min-width: 0;
}

body.lab-page {
  --wb-primary: var(--lab-accent);
  --wb-rail-active: #356872;
  --wb-canvas: var(--lab-canvas);
  color: var(--lab-ink);
  background: var(--lab-canvas);
  min-width: 0;
}

body.lab-page .workbench-rail__link {
  min-height: 104px;
}

body.lab-page > .topbar {
  align-items: center;
}

.lab-topbar__identity {
  min-width: 0;
}

.lab-topbar__identity h1 {
  margin: 0;
  font-size: clamp(1.1rem, 1.5vw, 1.45rem);
  letter-spacing: -0.025em;
}

.lab-topbar__identity p {
  max-width: 64ch;
  margin: 2px 0 0;
  color: var(--lab-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab-status-chip,
.lab-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--lab-line);
  border-radius: 4px;
  background: #fff;
  color: var(--lab-ink);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.lab-status-chip {
  border-color: color-mix(in srgb, var(--lab-accent) 44%, var(--lab-line));
  color: var(--lab-accent-strong);
}

.lab-status-chip svg,
.lab-meta-chip svg {
  width: 15px;
  height: 15px;
}

.lab-button,
.lab-icon-button {
  min-height: 40px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--lab-line);
  border-radius: 4px;
  background: #fff;
  color: var(--lab-ink);
  font: 700 0.78rem/1 "DM Sans", "Segoe UI", sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.lab-button:hover,
.lab-icon-button:hover {
  border-color: color-mix(in srgb, var(--lab-accent) 55%, var(--lab-line));
  background: #f8fbfa;
}

.lab-button:active,
.lab-icon-button:active {
  transform: translateY(1px);
}

.lab-button:disabled,
.lab-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.lab-button svg,
.lab-icon-button svg {
  width: 15px;
  height: 15px;
}

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

.lab-button--primary:hover {
  border-color: var(--lab-accent-strong);
  background: var(--lab-accent-strong);
}

.lab-button--danger {
  border-color: var(--lab-danger);
  background: var(--lab-danger);
  color: #fff;
}

.lab-button--danger:hover {
  border-color: #833238;
  background: #833238;
}

.lab-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--lab-line);
  border-radius: 5px;
  background: var(--lab-surface);
  overflow: hidden;
}

.lab-panel__header {
  min-height: 38px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--lab-line);
  background: #f7f9f9;
}

.lab-panel__header h2,
.lab-panel__header h3 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.015em;
}

.lab-panel__body {
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.lab-kicker {
  color: var(--lab-accent-strong);
  font: 700 0.7rem/1.2 "IBM Plex Mono", Consolas, monospace;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.lab-catalog-shell {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: 218px minmax(360px, 1fr) minmax(370px, 0.82fr);
  gap: 10px;
  overflow: hidden;
}

.lab-filter-panel__intro {
  padding: 12px 10px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-filter-panel__intro h2 {
  margin: 5px 0 4px;
  font-size: 1rem;
}

.lab-filter-panel__intro p {
  margin: 0;
  color: var(--lab-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.lab-filter-list {
  display: grid;
  align-content: start;
}

.lab-filter-list button {
  min-height: 50px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-bottom: 1px solid var(--lab-line);
  border-left: 3px solid transparent;
  background: #fff;
  color: var(--lab-ink);
  font: 700 0.76rem/1.25 "DM Sans", "Segoe UI", sans-serif;
  text-align: left;
  cursor: pointer;
}

.lab-filter-list button:hover {
  background: #f7faf9;
}

.lab-filter-list button.is-active {
  border-left-color: var(--lab-accent);
  background: #edf5f3;
  color: var(--lab-accent-strong);
}

.lab-filter-list small {
  color: var(--lab-muted);
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.lab-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-search label {
  display: block;
  margin-bottom: 4px;
  color: var(--lab-muted);
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
}

.lab-search input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--lab-line);
  background: #fff;
  color: var(--lab-ink);
  font: inherit;
}

.lab-task-list {
  min-height: 0;
  overflow: auto;
}

.lab-task-row {
  width: 100%;
  min-height: 62px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(7.5rem, 0.4fr);
  align-items: start;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--lab-line);
  border-left: 3px solid transparent;
  background: #fff;
  color: var(--lab-ink);
  text-align: left;
  cursor: pointer;
}

.lab-task-row:hover {
  background: #f7faf9;
}

.lab-task-row.is-selected {
  border-left-color: var(--lab-accent);
  background: #edf5f3;
}

.lab-task-row__rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--lab-line);
  border-radius: 50%;
  color: var(--lab-accent-strong);
  font: 700 0.75rem/1 "IBM Plex Mono", Consolas, monospace;
}

.lab-task-row__main,
.lab-task-row__meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.lab-task-row__main strong {
  display: block;
  font-size: 0.82rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.lab-task-row__main span,
.lab-task-row__meta span {
  color: var(--lab-muted);
  font-size: 0.68rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.lab-task-row__meta {
  align-content: start;
  justify-items: end;
  font-family: "IBM Plex Mono", Consolas, monospace;
  text-align: right;
}

.lab-task-row__meta span {
  max-width: 100%;
}

.lab-detail {
  outline: none;
}

.lab-detail__body {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.lab-detail__body:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--lab-accent) 55%, white);
  outline-offset: -3px;
}

.lab-detail__header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-detail__header h2 {
  margin: 6px 0 5px;
  font-size: 1.18rem;
  letter-spacing: -0.025em;
}

.lab-detail__header p {
  margin: 0;
  color: var(--lab-muted);
  font-size: 0.82rem;
  line-height: 1.48;
}

.lab-definition-list {
  margin: 0;
}

.lab-definition-list > div {
  padding: 9px 14px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-definition-list dt {
  color: var(--lab-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.lab-definition-list dd {
  margin: 0;
  font-size: 0.77rem;
  line-height: 1.45;
}

.lab-definition-list code,
.lab-source-list code {
  display: inline-block;
  margin: 0 3px 3px 0;
  padding: 2px 4px;
  border: 1px solid var(--lab-line);
  border-radius: 3px;
  background: #f7f9f9;
  font-size: 0.68rem;
}

.lab-boundary {
  margin: 12px 14px;
  padding: 10px;
  border-left: 3px solid var(--lab-warning);
  background: #fbf7ef;
}

.lab-boundary strong {
  font-size: 0.76rem;
}

.lab-boundary p {
  margin: 3px 0 0;
  color: #71552d;
  font-size: 0.73rem;
  line-height: 1.45;
}

.lab-detail__actions {
  padding: 12px 14px;
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
  border-top: 1px solid var(--lab-line);
  background: var(--lab-surface);
}

.lab-empty,
.lab-inline-error {
  padding: 18px;
  color: var(--lab-muted);
  text-align: center;
}

.lab-empty strong,
.lab-inline-error strong {
  display: block;
  color: var(--lab-ink);
}

.lab-empty p,
.lab-inline-error p {
  margin: 5px auto 0;
  max-width: 56ch;
  font-size: 0.78rem;
}

.lab-inline-error {
  margin: 12px;
  border: 1px solid color-mix(in srgb, var(--lab-danger) 48%, var(--lab-line));
  background: #fff5f5;
}

.lab-task-skeleton {
  min-height: 62px;
  padding: 10px;
  display: grid;
  grid-template-columns: 34px 1fr 100px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--lab-line);
  color: #98a5ad;
}

.lab-task-skeleton i {
  display: block;
  height: 9px;
  background: #e8edef;
}

.lab-workbench-shell {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.lab-workbench-grid {
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.55fr) minmax(390px, 0.88fr) minmax(500px, 1.27fr);
  gap: 9px;
}

.lab-procedure-panel,
.lab-editor-panel,
.lab-evidence-panel {
  min-height: 0;
}

.lab-procedure-scroll,
.lab-evidence-scroll {
  min-height: 0;
  overflow: auto;
}

.lab-task-summary {
  padding: 10px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-task-summary h2 {
  margin: 4px 0 3px;
  font-size: 0.98rem;
}

.lab-task-summary p {
  margin: 0;
  color: var(--lab-muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.lab-task-meta {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-task-meta span {
  padding: 3px 5px;
  border: 1px solid var(--lab-line);
  border-radius: 3px;
  color: var(--lab-muted);
  font: 600 0.75rem/1.2 "IBM Plex Mono", Consolas, monospace;
}

.lab-section-heading {
  margin: 0;
  padding: 9px 10px 7px;
  border-bottom: 1px solid var(--lab-line);
  background: #f7f9f9;
  color: var(--lab-muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lab-collapsible {
  border-bottom: 1px solid var(--lab-line);
}

.lab-collapsible__toggle {
  width: 100%;
  min-height: 40px;
  padding: 6px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: #f7f9f9;
  color: var(--lab-ink);
  font: 700 0.78rem/1.2 "DM Sans", "Segoe UI", sans-serif;
  cursor: pointer;
}

.lab-collapsible__toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 120ms ease;
}

.lab-collapsible__toggle[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.lab-collapsible__body {
  padding: 9px 10px;
}

.lab-collapsible__body p {
  margin: 0;
  color: var(--lab-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

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

.lab-checkpoint {
  min-height: 48px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--lab-line);
}

.lab-checkpoint[data-status="active"] {
  border-left: 3px solid var(--lab-accent);
  background: #edf5f3;
}

.lab-checkpoint[data-status="complete"] {
  color: var(--lab-success);
}

.lab-checkpoint__index {
  color: var(--lab-muted);
  font: 600 0.68rem/1 "IBM Plex Mono", Consolas, monospace;
}

.lab-checkpoint strong {
  display: block;
  font-size: 0.78rem;
}

.lab-checkpoint small {
  display: block;
  margin-top: 2px;
  color: var(--lab-muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.lab-checkpoint__state {
  color: var(--lab-muted);
  font: 600 0.7rem/1 "IBM Plex Mono", Consolas, monospace;
  text-transform: uppercase;
}

.lab-feedback {
  margin: 9px;
  padding: 8px 9px;
  border-left: 3px solid var(--lab-accent);
  background: #f2f7f6;
}

.lab-feedback[data-tone="error"] {
  border-left-color: var(--lab-danger);
  background: #fff3f3;
}

.lab-feedback[data-tone="success"] {
  border-left-color: var(--lab-success);
  background: #f1f8f4;
}

.lab-feedback code {
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.lab-feedback p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

.lab-editor-header {
  min-height: 42px;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--lab-line);
  background: #f7f9f9;
}

.lab-language-tabs,
.lab-editor-actions,
.lab-runbar,
.lab-camera-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.lab-editor-actions {
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.lab-language-tabs button {
  min-height: 40px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--lab-muted);
  font: 700 0.78rem/1 "DM Sans", "Segoe UI", sans-serif;
  cursor: pointer;
}

.lab-language-tabs button[aria-selected="true"] {
  border-color: var(--lab-line);
  background: #fff;
  color: var(--lab-accent-strong);
}

.lab-editor-surface {
  min-height: 0;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.lab-code-panel {
  width: 100%;
  height: 100%;
  min-height: 0;
}

#labPythonPanel {
  display: flex;
  flex-direction: column;
}

#labPythonPanel[hidden] {
  display: none;
}

.lab-editor-note {
  margin: 0;
  padding: 6px 10px;
  border-bottom: 1px solid var(--lab-line);
  background: #eef2f3;
  color: var(--lab-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

#labBlocklyEditor,
#labPythonEditor {
  width: 100%;
  height: 100%;
}

#labPythonEditor {
  display: block;
  flex: 1;
  min-height: 0;
  resize: none;
  padding: 14px;
  border: 0;
  outline: none;
  background: #19252c;
  color: #eff5f4;
  font: 500 0.78rem/1.58 "IBM Plex Mono", Consolas, monospace;
  tab-size: 2;
}

#labPythonEditor:focus-visible {
  outline: 3px solid #7fd4c8;
  outline-offset: -3px;
  box-shadow: inset 0 0 0 1px #123e3b;
}

.lab-more-actions {
  position: relative;
}

.lab-more-actions > summary {
  list-style: none;
}

.lab-more-actions > summary::-webkit-details-marker {
  display: none;
}

.lab-more-actions > div {
  position: absolute;
  z-index: 12;
  top: calc(100% + 5px);
  right: 0;
  width: max-content;
  max-width: min(320px, 80vw);
  padding: 6px;
  border: 1px solid var(--lab-line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(25, 37, 44, 0.16);
}

.lab-runbar {
  min-height: 44px;
  padding: 6px 8px;
  border-top: 1px solid var(--lab-line);
  background: #f7f9f9;
  flex-wrap: wrap;
}

.lab-runbar__status {
  min-width: 180px;
  flex: 1;
  color: var(--lab-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.lab-runbar__status[data-tone="error"] { color: var(--lab-danger); }
.lab-runbar__status[data-tone="success"] { color: var(--lab-success); }
.lab-runbar__status[data-tone="warning"] { color: var(--lab-warning); }
.lab-runbar__status[data-tone="running"] { color: var(--lab-accent-strong); }

.lab-preview-stage {
  position: relative;
  min-height: 390px;
  height: min(54vh, 440px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-bottom: 1px solid var(--lab-line);
  background: #f7f8fa;
  overflow: hidden;
}

.lab-stage-toolbar {
  position: relative;
  z-index: 3;
  min-height: 40px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--lab-line);
  background: rgba(255, 255, 255, 0.97);
}

.lab-stage-toolbar__label {
  color: var(--lab-muted);
  font: 700 0.75rem/1.2 "DM Sans", "Segoe UI", sans-serif;
}

.lab-stage-stop {
  min-height: 30px;
  padding-block: 5px;
}

#labRobotPreview,
#labRobotPreview > .robot-sim,
#labRobotPreview .robot-sim--three,
#labRobotPreview .robot-sim-3d__viewport,
#labRobotPreview .lab-arm-preview,
#labRobotPreview .arm-preview-3d,
#labRobotPreview .arm-preview-3d__viewport {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.lab-preview-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border: 0;
  background: #9cabb0;
}

.lab-preview-stage:fullscreen #labRobotPreview,
.lab-preview-stage:fullscreen #labRobotPreview > .robot-sim,
.lab-preview-stage:fullscreen #labRobotPreview .robot-sim--three,
.lab-preview-stage:fullscreen #labRobotPreview .robot-sim-3d__viewport,
.lab-preview-stage:fullscreen #labRobotPreview .lab-arm-preview,
.lab-preview-stage:fullscreen #labRobotPreview .arm-preview-3d,
.lab-preview-stage:fullscreen #labRobotPreview .arm-preview-3d__viewport {
  min-height: 0;
}

#labRobotPreview .robot-sim-3d__toolbar,
#labRobotPreview .arm-preview-3d__toolbar {
  display: none;
}

.lab-preview-status {
  position: relative;
  z-index: 3;
  min-height: 31px;
  max-width: 100%;
  margin: 0;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(88, 105, 114, 0.38);
  background: rgba(255, 255, 255, 0.97);
  color: var(--lab-muted);
  font-size: 0.75rem;
  line-height: 1.3;
  pointer-events: none;
}

.lab-preview-status[data-tone="running"] {
  color: var(--lab-accent-strong);
  background: #edf7f5;
}

.lab-preview-status[data-tone="warning"] {
  color: #71552d;
  background: #fbf7ef;
}

.lab-preview-status[data-tone="error"] {
  color: var(--lab-danger);
  background: #fff3f3;
}

.lab-preview-status[data-tone="success"] {
  color: var(--lab-success);
  background: #f1f8f4;
}

.lab-camera-controls {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
}

.lab-camera-controls .lab-icon-button {
  width: 40px;
  min-height: 40px;
  padding: 5px;
  justify-content: center;
  font-size: 0.65rem;
}

.lab-camera-controls .lab-icon-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lab-camera-controls [aria-pressed="false"] {
  color: var(--lab-muted);
  text-decoration: line-through;
}

.lab-evidence-scroll {
  flex: 1;
}

.lab-table-wrap {
  max-height: 190px;
  overflow: auto;
}

.lab-state-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.lab-state-table th,
.lab-state-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--lab-line);
  text-align: left;
  vertical-align: top;
}

.lab-state-table thead th {
  position: sticky;
  top: 0;
  background: #f7f9f9;
  color: var(--lab-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.lab-state-table tbody th {
  font-weight: 700;
}

.lab-evidence-list,
.lab-command-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lab-evidence {
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 2px 8px;
  border-bottom: 1px solid var(--lab-line);
  font-size: 0.75rem;
}

.lab-evidence strong {
  font-size: 0.69rem;
}

.lab-evidence > span:last-child {
  grid-column: 2;
  color: var(--lab-muted);
}

.lab-provenance {
  color: var(--lab-accent-strong);
  font: 600 0.59rem/1.35 "IBM Plex Mono", Consolas, monospace;
  text-transform: uppercase;
}

.lab-command-list li {
  min-height: 42px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: start;
  gap: 7px;
  border-bottom: 1px solid var(--lab-line);
  font-size: 0.75rem;
}

.lab-command-list li[data-tone="error"] {
  border-left: 3px solid var(--lab-danger);
  background: #fff5f5;
}

.lab-command-list strong,
.lab-command-list small {
  display: block;
}

.lab-command-list small {
  margin-top: 2px;
  color: var(--lab-muted);
  line-height: 1.3;
}

.lab-command-list > li > span:last-child {
  color: var(--lab-muted);
  font: 600 0.68rem/1.3 "IBM Plex Mono", Consolas, monospace;
}

.lab-task-select {
  min-width: 210px;
  max-width: 310px;
  min-height: 40px;
  padding: 6px 28px 6px 8px;
  border: 1px solid var(--lab-line);
  background: #fff;
  color: var(--lab-ink);
  font: 700 0.78rem/1.2 "DM Sans", "Segoe UI", sans-serif;
}

.lab-preview-stage[data-run-state="fault"] {
  box-shadow: inset 0 0 0 3px var(--lab-danger);
}

@media (max-width: 1420px) and (min-width: 1201px) {
  .lab-workbench-shell {
    overflow: auto;
  }

  .lab-workbench-grid {
    min-height: 620px;
    grid-template-columns: minmax(520px, 1.15fr) minmax(430px, 0.85fr);
    grid-template-rows: minmax(360px, 1fr) minmax(250px, 0.68fr);
    grid-template-areas:
      "evidence editor"
      "evidence procedure";
  }

  .lab-procedure-panel { grid-area: procedure; }
  .lab-editor-panel { grid-area: editor; }
  .lab-evidence-panel { grid-area: evidence; }

  .lab-editor-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lab-editor-actions .lab-button {
    width: 100%;
    padding-inline: 6px;
  }

  .lab-preview-stage {
    min-height: 390px;
    height: min(58vh, 470px);
  }
}

.lab-workbench-loading {
  grid-column: 2;
  grid-row: 2;
  padding: 14px;
  display: grid;
  grid-template-columns: 0.7fr 1.2fr 1fr;
  gap: 10px;
}

.lab-workbench-loading > div {
  min-height: 520px;
  border: 1px solid var(--lab-line);
  background: #fff;
}

@media (max-width: 1200px) {
  .lab-catalog-shell {
    grid-template-columns: 205px minmax(0, 1fr);
    overflow: auto;
  }

  .lab-catalog-shell .lab-detail {
    grid-column: 1 / -1;
    min-height: 430px;
  }

  .lab-workbench-shell {
    overflow: auto;
  }

  .lab-workbench-grid {
    min-height: 620px;
    grid-template-columns: minmax(390px, 1.12fr) minmax(340px, 0.88fr);
    grid-template-rows: minmax(350px, 1fr) minmax(230px, 0.65fr);
    grid-template-areas:
      "evidence editor"
      "evidence procedure";
  }

  .lab-procedure-panel { grid-area: procedure; }
  .lab-editor-panel { grid-area: editor; }
  .lab-evidence-panel { grid-area: evidence; }

  .lab-editor-header {
    flex-wrap: wrap;
  }

  .lab-editor-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lab-editor-actions .lab-button {
    justify-content: center;
    padding-inline: 6px;
  }

  .lab-preview-stage {
    min-height: 360px;
    height: min(55vh, 440px);
  }
}

@media (max-width: 850px) {
  body.lab-workbench-page {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  body.lab-workbench-page > .topbar {
    min-height: 0;
    padding: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .lab-workbench-page .lab-topbar__identity {
    grid-column: 1;
    grid-row: 1;
    max-width: calc(100% - 142px);
  }

  .lab-workbench-page .lab-topbar__identity p {
    max-width: none;
  }

  .lab-workbench-page > .topbar .topbar__controls {
    grid-column: 1 / -1;
    grid-row: 1 / 3;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .lab-workbench-page > .topbar #labBackLink {
    grid-column: 3;
    grid-row: 1;
  }

  .lab-workbench-page > .topbar .lab-task-select {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .lab-workbench-page > .topbar .lab-status-chip {
    grid-column: 2;
    grid-row: 3;
  }

  .lab-workbench-page > .topbar #labEmergencyStop {
    grid-column: 3;
    grid-row: 3;
  }

  .lab-workbench-page .lab-task-select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  body.lab-page > .topbar {
    align-items: flex-start;
  }

  .lab-topbar__identity p {
    max-width: 280px;
  }

  .lab-catalog-shell,
  .lab-workbench-grid {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .lab-workbench-grid {
    min-height: 0;
    grid-template-areas:
      "evidence"
      "editor"
      "procedure";
    grid-template-rows: auto;
  }

  .lab-filter-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .lab-filter-list button {
    min-height: 62px;
    display: grid;
    justify-items: center;
    border-left: 0;
    border-bottom: 3px solid transparent;
    text-align: center;
  }

  .lab-filter-list button.is-active {
    border-bottom-color: var(--lab-accent);
  }

  .lab-catalog-shell .lab-detail {
    grid-column: 1;
  }

  .lab-editor-panel {
    min-height: 650px;
  }

  .lab-evidence-panel {
    min-height: 630px;
  }

  .lab-procedure-panel {
    min-height: 520px;
  }

  .lab-preview-stage {
    min-height: 380px;
    height: min(50vh, 460px);
  }

  .lab-button,
  .lab-icon-button,
  .lab-task-select,
  .lab-language-tabs button,
  .lab-collapsible__toggle {
    min-height: 44px;
  }

  .lab-camera-controls .lab-icon-button {
    width: 44px;
    min-height: 44px;
  }

  .lab-stage-toolbar {
    min-height: 54px;
  }

  .lab-task-row {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .lab-task-row__meta {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab-button,
  .lab-icon-button,
  .lab-collapsible__toggle svg {
    transition: none;
  }
}
