#lab-mount { container: event-lab / inline-size; }

.lab-console {
  --lab-text: var(--ink, #dee5f1);
  --lab-muted: #aab8d0;
  --lab-line: #829bc82b;
  --lab-blue: #8ca9df;
  --lab-green: var(--lime, #b9dc89);
  --lab-warn: #e4b782;
  --lab-mono: var(--mono, ui-monospace, SFMono-Regular, Consolas, monospace);
  overflow: hidden;
  color: var(--lab-text);
  background: radial-gradient(ellipse at 9% 0, #425e8c22, transparent 57%), linear-gradient(145deg, #131e32a6, #111a2ac2 68%, #1424309e);
  border: 1px solid var(--glass-edge, #8ca6d733);
  border-radius: 22px;
  box-shadow: inset 0 1px 0 #a8bedb19, var(--glass-shadow);
}

.lab-console *, .lab-console *::before, .lab-console *::after { box-sizing: border-box; }

.lab-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--lab-line);
  background: linear-gradient(100deg, #91a9cf12, #7394cc08 53%, #8ab6bf12);
  font: 600 11px/1.25 var(--lab-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lab-console-id { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.lab-console-id > span { color: var(--lab-green); font-size: 16px; }
.lab-console-id small { color: var(--lab-muted); font: inherit; }

.lab-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lab-muted);
  text-align: right;
  padding: 4px 8px;
  border: 1px solid #8da6ce2e;
  border-radius: 999px;
  background: #0c162847;
}

.lab-status b { font: inherit; }
.lab-status > span { flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.lab-console[data-running="true"] .lab-status { color: var(--lab-green); border-color: #b2d58c46; background: #526b3826; }

.lab-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, 290px); }
.lab-monitor { min-width: 0; padding: 22px; }

.lab-pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lab-stage {
  --lab-stage-color: var(--lab-blue);
  --lab-transfer-distance: 14px;
  position: relative;
  display: grid;
  min-width: 0;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--lab-line);
  border-radius: 11px;
  background: linear-gradient(154deg, #334b734d, #13213d69 72%);
  box-shadow: inset 0 1px 0 #abc3e416;
}

.lab-stage:not(:last-child)::after {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 100%;
  width: 17px;
  height: 1px;
  background: #475a7d;
  content: "";
}

.lab-stage:not(:last-child)::before {
  position: absolute;
  z-index: 2;
  top: calc(50% - 2px);
  left: 100%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lab-stage-color);
  box-shadow: 0 0 6px var(--lab-stage-color);
  opacity: 0;
  content: "";
}

.lab-stage:nth-child(2) { --lab-transfer-delay: 0.22s; }
.lab-stage:nth-child(3) { --lab-transfer-delay: 0.44s; }
.lab-console[data-demand="high"] .lab-stage-ingress { --lab-transfer-duration: 0.84s; }
.lab-console[data-scenario="fault"] :is(.lab-stage-queue, .lab-stage-workers) { --lab-transfer-duration: 1.9s; }

@keyframes lab-transfer {
  0% { opacity: 0; transform: translateX(0); }
  24% { opacity: 0.85; }
  76% { opacity: 0.85; }
  100% { opacity: 0; transform: translateX(var(--lab-transfer-distance)); }
}

.lab-stage-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--lab-muted); }
.lab-stage-top svg { width: 19px; height: 19px; color: var(--lab-stage-color); }
.lab-stage-top > span { font: 500 10px/1 var(--lab-mono); }
.lab-stage strong { overflow-wrap: anywhere; font-size: 13px; line-height: 1.2; }
.lab-stage-value { font: 500 11px/1.25 var(--lab-mono); color: var(--lab-muted); }
.lab-stage-commit { --lab-stage-color: var(--lab-green); }
.lab-console[data-load="pressure"] .lab-stage-queue { --lab-stage-color: var(--lab-warn); border-color: #e4b78260; }
.lab-console[data-load="pressure"] .lab-stage-queue .lab-stage-value { color: var(--lab-warn); }
.lab-console[data-scenario="fault"] .lab-stage-workers { --lab-stage-color: var(--lab-warn); border-color: #e4b78250; }
.lab-console[data-scenario="fault"] .lab-stage-workers .lab-stage-value { color: var(--lab-warn); }

.lab-graph {
  margin-top: 16px;
  padding: 14px 14px 10px;
  border: 1px solid var(--lab-line);
  border-radius: 12px;
  background: radial-gradient(ellipse at bottom left, #20365343, transparent 76%), #0a1424a6;
  box-shadow: inset 0 2px 7px #0308134e;
}

.lab-graph-top { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 8px; }
.lab-graph-top h3, .lab-controls-heading h3 { margin: 0; font-size: 13px; line-height: 1.2; letter-spacing: 0; }
.lab-legend { display: flex; gap: 11px; color: var(--lab-muted); font: 500 10px/1.25 var(--lab-mono); }
.lab-legend > span { display: flex; align-items: center; gap: 5px; }
.lab-legend i { width: 10px; height: 2px; background: var(--lab-green); }
.lab-legend > span:last-child i { background: var(--lab-blue); }

.lab-chart-plot { display: grid; grid-template-columns: 23px minmax(0, 1fr); gap: 5px; margin-top: 5px; }
.lab-chart-axis { display: flex; flex-direction: column; justify-content: space-between; padding: 2px 0; text-align: right; }
.lab-chart { display: block; width: 100%; height: 100px; overflow: visible; }
.lab-chart-grid { fill: none; stroke: #273148; vector-effect: non-scaling-stroke; stroke-dasharray: 3 4; }
.lab-chart-area { fill: #5288ff; opacity: 0.17; }
.lab-chart-line { fill: none; stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.lab-chart-commits { stroke: var(--lab-green); }
.lab-chart-queue { stroke: var(--lab-blue); }

.lab-chart-ticks, .lab-chart-axis, .lab-load-limits {
  display: flex;
  justify-content: space-between;
  color: var(--lab-muted);
  font: 500 10px/1.25 var(--lab-mono);
}

.lab-chart-ticks { padding-left: 28px; }

.lab-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 15px 0 0;
  border: 1px solid var(--lab-line);
  border-radius: 11px;
  background: linear-gradient(155deg, #526f9a1c, #18305229 70%);
}

.lab-metrics > div { min-width: 0; padding: 11px 12px; }
.lab-metrics > div:not(:first-child) { border-left: 1px solid var(--lab-line); }
.lab-metrics dt { font: 500 10px/1.3 var(--lab-mono); color: var(--lab-muted); }
.lab-metrics dd { margin: 4px 0 0; overflow-wrap: anywhere; font: 600 clamp(12px, 2vw, 20px)/1.15 var(--lab-mono); letter-spacing: -0.06em; color: var(--lab-text); }
.lab-metrics > div:first-child dd { color: var(--lab-green); }
.lab-console[data-load="pressure"] .lab-metrics > div:nth-child(n + 3) dd { color: var(--lab-warn); }

.lab-controls {
  display: flex;
  flex-direction: column;
  gap: 19px;
  min-width: 0;
  padding: 22px 19px;
  border-left: 1px solid var(--lab-line);
  background: linear-gradient(158deg, #5a749d19, #101d3238 54%, #25425024);
}

.lab-controls-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.lab-controls-heading > span { color: var(--lab-blue); font: 600 9px/1.2 var(--lab-mono); letter-spacing: 0.1em; }
.lab-modes { min-width: 0; margin: 0; padding: 0; border: 0; }
.lab-modes legend, .lab-load label { margin: 0 0 8px; padding: 0; font-size: 12px; font-weight: 600; color: var(--lab-muted); }
.lab-mode-list { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; border: 1px solid var(--lab-line); border-radius: 11px; background: #0c16297a; box-shadow: inset 0 2px 5px #040b1965; }
.lab-mode-list label { position: relative; z-index: 1; min-width: 0; }

.lab-mode-list::before {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: calc((100% - 14px) / 3);
  border-radius: 8px;
  background: #6889bf42;
  box-shadow: inset 0 0 0 1px #9db7e054;
  transform: translateX(calc((100% + 4px) * var(--lab-mode-position, 0)));
  pointer-events: none;
  content: "";
}

.lab-console[data-scenario="burst"] .lab-mode-list { --lab-mode-position: 1; }
.lab-console[data-scenario="fault"] .lab-mode-list { --lab-mode-position: 2; }

.lab-mode-list input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.lab-mode-list label > span {
  display: block;
  padding: 8px 2px;
  border-radius: 8px;
  color: var(--lab-muted);
  text-align: center;
  font: 600 11px/1.25 var(--lab-mono);
  cursor: pointer;
}

.lab-mode-list label:hover > span { color: var(--lab-text); background: #8fafff1a; }
.lab-mode-list input:checked + span { color: #d7e3f6; background: transparent; }

.lab-load { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 6px; }
.lab-load output { color: var(--lab-green); font: 600 11px/1.4 var(--lab-mono); white-space: nowrap; }
.lab-load input {
  grid-column: 1 / -1;
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--lab-blue);
  color-scheme: dark;
  cursor: pointer;
}
.lab-load-limits { grid-column: 1 / -1; margin-top: 3px; }

.lab-mode-note, .lab-controls-caption {
  margin: 0;
  color: var(--lab-muted);
  font-size: 12px;
  line-height: 1.45;
}

.lab-mode-note { min-block-size: 4.35em; margin-top: -3px; }
.lab-actions { display: grid; grid-template-columns: 1fr 44px; gap: 8px; }

.lab-actions button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 44px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  font: 700 12px/1.25 var(--lab-mono);
  cursor: pointer;
}

.lab-actions svg { flex: none; width: 18px; height: 18px; }
.lab-run-icon { display: grid; width: 18px; height: 18px; flex: none; }
.lab-run-icon svg { grid-area: 1 / 1; }
.lab-run-icon svg:last-child, .lab-console[data-running="true"] .lab-run-icon svg:first-child { opacity: 0; }
.lab-console[data-running="true"] .lab-run-icon svg:last-child { opacity: 1; }
.lab-actions .lab-run { border-color: #a6cb785a; background: linear-gradient(152deg, #93b55d32, #47683d32 79%); box-shadow: inset 0 1px 0 #b6d99120; color: #c8e4a8; }
.lab-actions .lab-run:hover { background-color: #516c4273; }
.lab-console[data-running="true"] .lab-run { border-color: #8ca7d560; color: #c9d9f5; background-image: linear-gradient(152deg, #7495c631, #3c577b30 79%); box-shadow: inset 0 1px 0 #b0c8e61c; }
.lab-console[data-running="true"] .lab-run:hover { background-color: #526d9b35; }
.lab-actions .lab-reset { border-color: #8ca7d53d; background: linear-gradient(144deg, #91b0df22, #23395555); color: var(--lab-text); }
.lab-actions .lab-reset:hover { background-color: #526d9b35; }
.lab-console :focus-visible, .lab-mode-list input:focus-visible + span { outline: 2px solid var(--lab-blue); outline-offset: 3px; }

@container event-lab (max-width: 880px) {
  .lab-monitor { padding: 16px; }
  .lab-controls { padding: 16px; gap: 14px; }
  .lab-body { grid-template-columns: minmax(0, 1fr) minmax(215px, 240px); }
}

@container event-lab (max-width: 720px) {
  .lab-body { grid-template-columns: minmax(0, 1fr); }
  .lab-controls { border-top: 1px solid var(--lab-line); border-left: 0; }
  .lab-mode-note { min-block-size: 2.9em; }
}

@container event-lab (max-width: 425px) {
  .lab-top, .lab-monitor, .lab-controls { padding-left: 12px; padding-right: 12px; }
  .lab-top { font-size: 9px; }
  .lab-pipeline { gap: 7px; }
  .lab-stage { --lab-transfer-distance: 6px; padding: 7px 5px; gap: 6px; }
  .lab-stage-top { gap: 3px; }
  .lab-stage-top svg { width: 16px; height: 16px; }
  .lab-stage strong, .lab-stage-value { font-size: 10px; }
  .lab-stage:not(:last-child)::after { width: 8px; }
  .lab-stage:not(:last-child)::before { width: 3px; height: 3px; top: calc(50% - 1px); }
  .lab-metrics > div { padding: 8px 5px; }
  .lab-metrics dt { font-size: 9px; }
}

@media (prefers-reduced-motion: no-preference) {
  .lab-console[data-running="true"][data-viewable="true"] .lab-stage:not(:last-child)::before {
    animation: lab-transfer var(--lab-transfer-duration, 1.25s) linear var(--lab-transfer-delay, 0s) infinite;
  }

  .lab-status, .lab-stage { transition: color .18s ease, border-color .18s ease, background-color .18s ease; }
  .lab-mode-list::before { transition: transform .23s cubic-bezier(.2, .7, .3, 1); }
  .lab-mode-list label > span { transition: color .16s ease, background-color .16s ease; }
  .lab-actions button { transition: background-color .16s ease, border-color .16s ease, transform .16s ease; }
  .lab-actions button:active { transform: translateY(1px); }
  .lab-run-icon svg { transition: opacity .14s ease; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .lab-console { background: #14213a; }
  .lab-stage, .lab-controls, .lab-metrics { background: #1a2b46; }
  .lab-graph, .lab-mode-list { background: #0e192b; }
}

@media (forced-colors: active) {
  .lab-mode-list::before { display: none; }
  .lab-mode-list input:checked + span { color: HighlightText; background: Highlight; forced-color-adjust: none; }
}
