:root {
  color-scheme: light;
  --lab-bg: #f4f7fb;
  --lab-surface: #ffffff;
  --lab-border: #d7deea;
  --lab-text: #213047;
  --lab-subtle: #607089;
  --lab-accent: #356fa8;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  margin: 0;
  background: var(--lab-bg);
  color: var(--lab-text);
  font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
}

body { padding: 0; }

.measurement-lab {
  width: min(1220px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.lab-controls {
  padding: 12px;
  border: 1px solid var(--lab-border);
  border-radius: 14px;
  background: var(--lab-surface);
  box-shadow: 0 8px 24px rgba(30, 49, 77, 0.08);
}

[data-applet-command-bar] {
  display: grid;
  grid-template-columns: minmax(460px, 1.4fr) minmax(0, 0.6fr) auto;
  gap: 14px;
  align-items: center;
}

[data-applet-command-left],
[data-applet-command-right] {
  display: flex;
  align-items: center;
  gap: 10px;
}

[data-applet-command-right] { justify-content: flex-end; }

.control {
  display: grid;
  gap: 6px;
  width: min(520px, 100%);
  min-width: 460px;
  font-size: 14px;
}

.control-title { font-weight: 650; }

select,
button {
  min-height: 40px;
  border: 1px solid var(--lab-border);
  border-radius: 10px;
  font: inherit;
}

select {
  width: 100%;
  padding: 7px 10px;
  background: #fff;
  color: var(--lab-text);
}

button {
  padding: 7px 11px;
  background: #f8fbff;
  color: #263954;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: #8ca5c5;
  background: #edf4ff;
  color: #133e73;
}

.simulation-speed-selector { display: flex; gap: 4px; }
.simulation-speed-selector button { min-width: 40px; padding-inline: 8px; }
.simulation-speed-selector button[aria-pressed="true"] {
  border-color: #7da3ca;
  background: #e6f1fd;
  color: #174d8d;
}

.lab-stage {
  position: relative;
  min-height: 360px;
  flex: 1 1 auto;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--lab-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(30, 49, 77, 0.06);
}

.balance-artwork {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 0;
  background: #fff;
}

.volume-scene {
  position: absolute;
  inset: 0;
}

.volume-scene[hidden],
.balance-artwork[hidden] { display: none; }

.volume-artwork {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: #fff;
  touch-action: none;
  user-select: none;
}

.body-picker-cluster {
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: 4px;
}

.body-picker-control {
  position: relative;
  min-width: 200px;
}

.body-picker-control[hidden] { display: none; }

.random-objects-button {
  flex: 0 0 auto;
  min-width: 132px;
  font-weight: 400;
  white-space: nowrap;
}

.random-objects-button[hidden] { display: none; }

.body-picker-control > summary {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--applet-control-height, 40px);
  min-height: var(--applet-control-height, 40px);
  padding: 0 36px 0 12px;
  border: 1px solid var(--applet-control-border, var(--lab-border));
  border-radius: var(--applet-control-radius, 10px);
  background: var(--applet-control-surface, #fff);
  color: var(--applet-control-text, var(--lab-text));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95);
  font: 400 .95rem/1.2 Inter, system-ui, sans-serif;
  cursor: pointer;
  list-style: none;
}

.body-picker-control > summary::-webkit-details-marker { display: none; }
.body-picker-control > summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--applet-control-muted, var(--lab-subtle));
  transform: translateY(-70%) rotate(45deg);
}

.body-picker-control > summary:hover {
  border-color: rgba(147, 160, 178, .96);
  background: #fff;
}

.body-picker-control > summary:focus-visible {
  outline: none;
  border-color: rgba(50, 103, 183, .94);
  box-shadow: 0 0 0 3px rgba(54, 111, 193, .16);
}

.body-picker-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  width: min(320px, calc(100vw - 36px));
  max-height: min(430px, 70vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--applet-control-border, var(--lab-border));
  border-radius: var(--applet-control-radius, 10px);
  background: var(--applet-control-surface, #fff);
  box-shadow: 0 12px 30px rgba(31, 50, 76, .16);
  color: var(--applet-control-text, var(--lab-text));
  font: 400 .92rem/1.3 Inter, system-ui, sans-serif;
}

.body-picker-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.body-picker-option:hover { background: var(--applet-control-soft-hover, #f1f6fc); }
.body-picker-option input { width: 16px; height: 16px; margin: 0; }
[data-volume-body] {
  cursor: grab;
  filter: hue-rotate(var(--body-hue, 0deg)) drop-shadow(0 2px 2px rgba(24, 53, 87, .2));
}

[data-balance-object] {
  filter: hue-rotate(var(--body-hue, 0deg));
}

:root[data-applet-theme="site"] .random-objects-button[data-applet-action] {
  font-weight: 500;
}

[data-volume-body].is-dragging {
  cursor: grabbing;
  filter: hue-rotate(var(--body-hue, 0deg)) drop-shadow(0 5px 4px rgba(24, 53, 87, .3));
}

[data-volume-shelf-handle] { cursor: ns-resize; }

.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .measurement-lab { padding: 9px; }
  [data-applet-command-bar] { grid-template-columns: 1fr auto; }
  [data-applet-command-center] { display: none; }
  .control { width: 100%; min-width: 0; }
  .balance-artwork { min-height: 300px; }
  .volume-artwork { min-height: 300px; }
  .lab-stage { min-height: 300px; overflow-x: auto; }
}

@media (max-width: 520px) {
  [data-applet-command-bar] { grid-template-columns: 1fr; }
  [data-applet-command-right] { justify-content: space-between; }
  .control { min-width: 0; }
  .balance-artwork { right: auto; width: 820px; min-height: 0; }
  .volume-artwork { width: 820px; min-height: 0; }
}
