html.lab-modal-open { overflow: hidden; }
dialog.vortex-workbench {
  --lab-bg: #111b1f;
  --lab-surface: #172327;
  --lab-line: #354447;
  --lab-ink: #eef2ec;
  --lab-muted: #adbbb9;
  --lab-cyan: #91dbd6;
  box-sizing: border-box;
  width: min(1240px, calc(100% - 48px));
  max-width: none;
  height: fit-content;
  max-height: calc(100dvh - 48px);
  inset: 0;
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #526363;
  border-radius: 14px;
  background: var(--lab-bg);
  color: var(--lab-ink);
  font: 400 15px/1.5 "Instrument Sans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  text-align: left;
  color-scheme: dark;
  scrollbar-width: thin;
  scrollbar-color: #516365 var(--lab-bg);
}
.vortex-workbench::backdrop { background: rgb(2 9 12 / 84%); }
.vortex-workbench *, .vortex-workbench *::before, .vortex-workbench *::after { box-sizing: border-box; }
.vortex-workbench ::selection { color: #101b1c; background: #ade2d9; }
.vortex-workbench :is(button, input, summary):focus-visible {
  outline: 2px solid #d5faf0;
  outline-offset: 3px;
}
.vortex-workbench .lab-shell { padding: clamp(21px, 3vw, 36px); }
.vortex-workbench .lab-titlebar { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin: 0 0 24px; }
.vortex-workbench .lab-titlebar h2 {
  font: inherit;
  font-weight: 640;
  font-size: clamp(26px, 3vw, 37px);
  letter-spacing: -.025em;
  line-height: 1.2;
  margin: 0;
  color: var(--lab-ink);
}
.vortex-workbench .lab-titlebar p { margin: 8px 0 0; font-size: 15px; line-height: 1.55; color: var(--lab-muted); }
.vortex-workbench button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 42px;
  padding: 0 15px;
  margin: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  border-radius: 5px;
  background: transparent;
  color: var(--lab-ink);
  border: 1px solid var(--lab-line);
}
.vortex-workbench button:hover { border-color: #8fa3a1; background: #233135; }
.vortex-workbench .lab-close { width: 41px; height: 41px; padding: 0; border-radius: 50%; flex-shrink: 0; }
.vortex-workbench .lab-comparison {
  display: grid;
  grid-template-columns: repeat(var(--group-count), minmax(0, 1fr));
  gap: 1px;
  background: var(--lab-line);
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  overflow: hidden;
}
.vortex-workbench .lab-panel { --trial-color: var(--lab-cyan); min-width: 0; background: var(--lab-surface); padding: 17px 20px 20px; }
.vortex-workbench .lab-panel-head,
.vortex-workbench .lab-reading > div:first-child {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; 
}
.vortex-workbench .lab-panel-head span { font-size: 12px; color: var(--lab-muted); }
.vortex-workbench .lab-panel-head h3 { color: var(--trial-color); margin: 0; font: inherit; font-weight: 600; line-height: 1.4; }
.vortex-workbench .lab-canvas {
  display: block;
  margin: 9px 0 12px;
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 150;
  max-height: 185px;
}
.vortex-workbench:not(.lab-theater) .lab-canvas {
  background: radial-gradient(ellipse at 45% 65%, #263438 0%, transparent 69%);
}
.vortex-workbench .lab-params { min-width: 0; border-top: 1px solid var(--lab-line); padding-top: 13px; }
.vortex-workbench .lab-parameter { margin: 0; border: 0; padding: 0; min-width: 0; }
.vortex-workbench :is(.lab-parameter, .lab-weight) { font-size: 14px; }
.vortex-workbench .lab-time { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 4px; }
.vortex-workbench output { font-family: "IBM Plex Mono", Consolas, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: 0; }
.vortex-workbench input[type='range'] { margin: 0; width: 100%; height: 32px; grid-column: 1 / -1; cursor: pointer; accent-color: var(--trial-color, var(--lab-cyan)); }
.vortex-workbench .lab-weight { min-height: 32px; display: flex; width: fit-content; align-items: center; gap: 8px; cursor: pointer; }
.vortex-workbench .lab-weight input { width: 17px; height: 17px; margin: 0; accent-color: var(--trial-color); cursor: pointer; }
.vortex-workbench .lab-slot-field legend { padding: 0 0 8px; color: var(--lab-ink); }
.vortex-workbench .lab-slot-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid #526163; border-radius: 4px; overflow: hidden; }
.vortex-workbench .lab-slot-options label { position: relative; min-width: 0; }
.vortex-workbench .lab-slot-options label + label { border-inline-start: 1px solid #526163; }
.vortex-workbench .lab-slot-options input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.vortex-workbench .lab-slot-options span { display: block; text-align: center; background: var(--lab-bg); padding: 6px 1px; font-variant-numeric: tabular-nums; }
.vortex-workbench .lab-slot-options input:hover + span { background: #334247; }
.vortex-workbench .lab-slot-options input:checked + span { background: var(--trial-color); color: #182626; font-weight: 650; }
.vortex-workbench .lab-slot-options input:focus-visible + span { box-shadow: inset 0 0 0 2px #fff; }
.vortex-workbench .lab-reading { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--lab-line); }
.vortex-workbench .lab-reading span { color: var(--lab-muted); font-size: 13px; }
.vortex-workbench .lab-reading output { font-size: 23px; line-height: 1.25; font-weight: 550; color: var(--trial-color); }
.vortex-workbench .lab-meter { height: 3px; background: #354548; margin-top: 8px; }
.vortex-workbench .lab-meter i { height: 100%; width: 100%; display: block; background: var(--trial-color); transform-origin: left center; }
.vortex-workbench .lab-transport { display: flex; align-items: center; gap: 27px; padding: 22px 0 16px; }
.vortex-workbench .lab-transport-buttons { display: flex; gap: 8px; }
.vortex-workbench .lab-play { color: #102526; background: #a9ded8; border-color: #a9ded8; }
.vortex-workbench .lab-play:hover { color: #101d1e; background: #c2e8e2; border-color: #c2e8e2; }
.vortex-workbench .lab-play:disabled { color: var(--lab-muted); background: var(--lab-bg); border-color: var(--lab-line); cursor: wait; }
.vortex-workbench .lab-time { flex: 1; min-width: 0; color: var(--lab-muted); font-size: 12px; }
.vortex-workbench .lab-time input { height: 22px; }
.vortex-workbench .lab-timer { color: #d3dedb; }
@media (max-width: 640px) {
  dialog.vortex-workbench { width: calc(100% - 16px); max-height: calc(100dvh - 20px); border-radius: 10px; }
  .vortex-workbench .lab-shell { padding: 17px 13px; }
  .vortex-workbench .lab-titlebar { margin-bottom: 15px; }
  .vortex-workbench .lab-titlebar h2 { font-size: 25px; }
  .vortex-workbench .lab-titlebar p { font-size: 13px; margin-top: 6px; }
  .vortex-workbench .lab-panel { padding: 12px 10px 14px; }
  .vortex-workbench .lab-canvas { height: auto; min-height: 105px; aspect-ratio: 1.45; margin: 5px 0; }
  .vortex-workbench .lab-panel-head h3 { font-size: 14px; }
  .vortex-workbench .lab-panel-head span { font-size: 11px; }
  .vortex-workbench .lab-params { padding-top: 9px; }
  .vortex-workbench :is(.lab-weight, .lab-slot-field) { font-size: 12px; }
  .vortex-workbench .lab-reading > div:first-child { flex-wrap: wrap; }
  .vortex-workbench .lab-reading { margin-top: 8px; }
  .vortex-workbench .lab-reading span { font-size: 12px; }
  .vortex-workbench .lab-reading output { font-size: 20px; }
  .vortex-workbench .lab-transport { flex-wrap: wrap; gap: 12px; padding: 16px 0 12px; }
  .vortex-workbench .lab-time { min-width: 150px; }
  .vortex-workbench .lab-time input { height: 30px; }
}
@media (max-width: 385px) {
  .vortex-workbench .lab-panel { padding-inline: 7px; }
}
@media (min-width: 641px) and (max-height: 720px) {
  .vortex-workbench .lab-shell { padding: 19px 25px; }
  .vortex-workbench .lab-titlebar { margin-bottom: 14px; }
  .vortex-workbench .lab-canvas { max-height: 132px; }
  .vortex-workbench .lab-transport { padding-block: 14px; }
}
.vortex-workbench .lab-gap-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.vortex-workbench .lab-weight { margin-top: 6px; }
.vortex-workbench .lab-fit { margin: 8px 0 0; color: var(--lab-muted); font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.vortex-workbench .lab-chart-caption { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; color: var(--lab-muted); }
.vortex-workbench .lab-chart-caption strong { font-size: 14px; color: var(--lab-ink); font-weight: 550; }
.vortex-workbench .lab-chart { display: block; width: 100%; height: clamp(84px, 10vh, 104px); margin-top: 3px; }
@media (max-width: 640px) {
  .vortex-workbench .lab-fit { font-size: 11px; }
}

@media (min-width: 1080px) and (min-height: 760px) {
  .vortex-workbench .lab-canvas { max-height: clamp(170px, 22vh, 235px); }
  .vortex-workbench .lab-panel { padding-inline: 24px; }
  .vortex-workbench .lab-panel-head h3 { font-size: 18px; }
  .vortex-workbench .lab-slot-options span { padding-block: 8px; font-size: 16px; }
  .vortex-workbench .lab-reading output { font-size: 28px; }
}

@media (min-width: 641px) and (max-height: 930px) {
  .vortex-workbench .lab-shell { padding: 20px 25px; }
  .vortex-workbench .lab-titlebar { margin-bottom: 16px; }
  .vortex-workbench .lab-canvas { max-height: clamp(100px, 18vh, 162px); }
  .vortex-workbench .lab-chart { height: 76px; }
  .vortex-workbench .lab-transport { padding-block: 12px; }
  .vortex-workbench .lab-panel { padding-block: 13px; }
}
.vortex-workbench .lab-count {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 0;
  padding: 0;
  margin: 0 0 17px;
}
.vortex-workbench .lab-count legend {
  float: left;
  padding: 0;
  color: var(--lab-ink);
  font-size: 14px;
  font-weight: 550;
}
.vortex-workbench .lab-count-options { display: inline-flex; padding: 3px; gap: 3px; background: #0b1418; border: 1px solid #344448; border-radius: 6px; }
.vortex-workbench .lab-count-options label { position: relative; }
.vortex-workbench .lab-count-options input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; opacity: 0; }
.vortex-workbench .lab-count-options span { display: block; border-radius: 3px; padding: 5px 13px; color: var(--lab-muted); font-size: 13px; }
.vortex-workbench .lab-count-options input:checked + span { background: #33474a; color: #d2f4e9; }
.vortex-workbench .lab-count-options input:hover + span { color: white; }
.vortex-workbench .lab-count-options input:focus-visible + span { outline: 2px solid #d5faf0; outline-offset: -2px; }
.vortex-workbench .lab-legend, .vortex-workbench .lab-legend span { display: inline-flex; align-items: center; }
.vortex-workbench .lab-legend { flex-wrap: wrap; gap: 3px 12px; }
.vortex-workbench .lab-legend span { gap: 4px; white-space: nowrap; }
.vortex-workbench .lab-chart-caption { flex-wrap: wrap; gap: 3px 10px; }
@media (min-width: 641px) {
  .vortex-workbench:not(.lab-theater) [data-groups="1"] .lab-panel {
    display: grid;
    grid-template-columns: 1.2fr minmax(170px, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 4%;
    align-items: start;
  }
  .vortex-workbench:not(.lab-theater) [data-groups="1"] .lab-panel-head { grid-column: 1 / -1; }
  .vortex-workbench:not(.lab-theater) [data-groups="1"] .lab-canvas { grid-row: 2 / span 2; max-height: 189px; }
  .vortex-workbench:not(.lab-theater) [data-groups="1"] .lab-params { border: 0; }
}
@media (max-width: 800px) {
  .vortex-workbench:not(.lab-theater) .lab-comparison { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vortex-workbench:not(.lab-theater) [data-groups="1"] { grid-template-columns: minmax(0, 1fr); }
  .vortex-workbench:not(.lab-theater) [data-groups="3"] > :last-child { grid-column: 1 / -1; }
  .vortex-workbench:not(.lab-theater) [data-groups="3"] > :last-child .lab-canvas { max-height: 105px; }
  .vortex-workbench:not(.lab-theater) :is([data-groups="3"], [data-groups="4"]) .lab-canvas { height: 83px; min-height: 0; }
}
@media (max-width: 425px) {
  .vortex-workbench .lab-count { gap: 8px; }
  .vortex-workbench .lab-count-options span { padding-inline: 9px; }
  .vortex-workbench .lab-chart-caption > .lab-legend { order: 3; flex-basis: 100%; }
}

/* A second native modal keeps the paused configuration visible beneath optical blur. */
dialog.vortex-workbench.lab-theater {
  width: min(1740px, calc(100% - clamp(26px, 6vw, 100px)));
  height: min(94dvh, 1160px);
  max-height: none;
  overflow: auto;
  border-color: #526669;
  background: #111b1e;
}
.vortex-workbench.lab-theater::backdrop { background: rgb(4 12 15 / 53%); backdrop-filter: blur(10px); }
html:has(.lab-theater[open]) .vortex-workbench:not(.lab-theater) { filter: blur(5px); }
.vortex-workbench .lab-theater-shell {
  height: 100%;
  min-height: 270px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.6vh, 22px);
  padding: clamp(14px, 2.4vw, 36px);
}
.vortex-workbench .lab-theater-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vortex-workbench .lab-theater-head h2 { margin: 0; font: 650 clamp(22px, 2.4vw, 37px)/1.3 var(--sans, sans-serif); letter-spacing: -.023em; }
.vortex-workbench .lab-theater-nav { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.lab-theater .lab-comparison { min-height: 0; grid-template-rows: minmax(0, 1fr); }
.lab-theater [data-groups="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.lab-theater .lab-panel {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(10px, 1.5vw, 24px);
}
.lab-theater .lab-panel-head { flex-wrap: wrap; gap: 2px 10px; }
.lab-theater .lab-panel-head h3 { font-size: clamp(14px, 1.45vw, 22px); }
.lab-theater .lab-panel-head span { color: #c5d0ce; font-size: clamp(12px, 1.15vw, 17px); }
.lab-theater .lab-panel .lab-canvas { width: 100%; height: 100%; min-height: 0; max-height: none; margin: 0; aspect-ratio: auto; }
.lab-theater .lab-reading { margin: 0; padding-top: 8px; }
.lab-theater .lab-reading span { font-size: clamp(12px, 1.15vw, 17px); }
.lab-theater .lab-reading output { font-size: clamp(20px, 2.3vw, 37px); }
.lab-theater .lab-reading .lab-meter { margin-top: 5px; }
.lab-theater .lab-transport { padding: 0; }
.lab-theater .lab-transport-buttons button { width: 44px; height: 44px; padding: 0; }
.lab-theater .lab-time { font-size: 13px; }
@media (max-width: 700px) {
  dialog.vortex-workbench.lab-theater { width: calc(100% - 16px); height: calc(100dvh - 24px); }
  .vortex-workbench .lab-theater-shell { padding: 12px; }
  .vortex-workbench .lab-theater-head h2 { font-size: 21px; }
  .vortex-workbench .lab-theater-nav { gap: 6px; }
  .vortex-workbench .lab-theater-nav button { height: 36px; padding: 0 9px; font-size: 12px; }
  .vortex-workbench .lab-theater-nav .lab-close { width: 36px; padding: 0; }
  .lab-theater .lab-panel { padding: 10px; }
  .lab-theater .lab-transport { gap: 7px 13px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .lab-theater [data-groups="2"] { grid-template-columns: 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .lab-theater [data-groups="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .lab-theater [data-groups="3"] > :last-child { grid-column: 1 / -1; }
  .lab-theater :is([data-groups="3"], [data-groups="4"]) .lab-panel-head { display: block; }
  .lab-theater :is([data-groups="3"], [data-groups="4"]) .lab-panel-head span { display: block; margin-top: 2px; font-size: 11px; }
  .lab-theater :is([data-groups="3"], [data-groups="4"]) .lab-reading output { font-size: 19px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  dialog.vortex-workbench.lab-theater { height: calc(100dvh - 10px); width: calc(100% - 14px); }
  .vortex-workbench .lab-theater-shell { gap: 5px; padding: 6px 10px; }
  .lab-theater .lab-comparison { grid-template-columns: repeat(var(--group-count), minmax(0, 1fr)); grid-template-rows: 1fr; }
  .lab-theater .lab-panel { padding: 6px 7px; }
  .lab-theater .lab-theater-head h2 {font-size: 18px;}
  .lab-theater .lab-reading { padding-top: 3px; }
  .lab-theater .lab-theater-nav button { height: 32px; }
}
/* The stage and its live reading share a tile, leaving the full height for the apparatus. */
.lab-theater .lab-panel {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: radial-gradient(ellipse at 38% 35%, #2a393c 0%, #1b282c 48%, #111c20 100%);
}
.lab-theater .lab-panel-head {
  position: absolute;
  z-index: 1;
  top: clamp(9px, 1.25vw, 18px);
  left: clamp(10px, 1.5vw, 24px);
  right: clamp(10px, 1.5vw, 24px);
}
.lab-theater .lab-reading {
  position: absolute;
  bottom: clamp(9px, 1.3vw, 19px);
  left: clamp(10px, 1.5vw, 24px);
  border: 0;
  padding: 0;
  min-width: 76px;
}
.lab-theater .lab-reading > div:first-child { display: grid; gap: 0; }
.lab-theater .lab-reading span { font-size: clamp(11px, .85vw, 14px); }
.lab-theater .lab-reading output { font-size: clamp(19px, 2vw, 34px); }
@media (max-width: 700px) and (orientation: portrait) {
  .lab-theater .lab-panel { padding: 36px 6px; }
  /* Keep C at the same optical scale as A and B even though its row spans both columns. */
  .lab-theater [data-groups="3"] > :last-child .lab-canvas {
    width: calc(50% - 6.5px);
    justify-self: center;
  }
  .lab-theater .lab-panel-head { top: 8px; left: 9px; right: 9px; }
  .lab-theater .lab-reading { bottom: 8px; left: 9px; min-width: 62px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .lab-theater .lab-panel { padding-block: 26px; }
  .lab-theater .lab-panel-head { top: 5px; left: 7px; right: 7px; }
  .lab-theater .lab-reading { bottom: 5px; left: 7px; min-width: 52px; }
  .lab-theater .lab-reading > div:first-child { display: flex; gap: 4px; }
  .lab-theater .lab-reading output { font-size: 16px; }
}

/* Fixed children of the active native dialog stay in its keyboard and pointer scope. */
dialog.vortex-workbench.lab-with-nav {
  --lab-nav-offset: var(--site-nav-height, 65px);
  --lab-height: calc(100dvh - var(--lab-nav-offset));
  inset-block: var(--lab-nav-offset) 0;
  max-height: calc(var(--lab-height) - 24px);
}
.vortex-workbench.lab-with-nav > .site-header {
  position: fixed;
  inset: 0 0 auto;
  width: 100%;
  z-index: 6;
  font: 400 16px/1.6 var(--sans, sans-serif);
  color: var(--text);
}
dialog.vortex-workbench.lab-theater.lab-with-nav {
  height: min(calc(var(--lab-height) - 24px), 1160px);
}
@media (max-width: 700px) {
  dialog.vortex-workbench.lab-with-nav { --lab-nav-offset: var(--site-nav-height, 59px); max-height: calc(var(--lab-height) - 16px); }
  dialog.vortex-workbench.lab-theater.lab-with-nav { height: calc(var(--lab-height) - 16px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  dialog.vortex-workbench.lab-with-nav { max-height: calc(var(--lab-height) - 8px); }
  dialog.vortex-workbench.lab-theater.lab-with-nav { height: calc(var(--lab-height) - 8px); }
}
