:root {
  --canvas-render-size: 512px;
  --canvas-render-width: 512px;
  --canvas-render-height: 512px;
  --canvas-aspect-ratio: 1;
  --canvas-display-size: min(100vw, 100vh);
  --canvas-display-width: min(100vw, calc(100vh * var(--canvas-aspect-ratio)));
  --canvas-display-height: min(100vh, calc(100vw / var(--canvas-aspect-ratio)));
  --menu-height: 34px;
  --floating-panel-bg: rgba(48, 52, 58, 0.94);
}

body {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: #111418;
  color: #16181c;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.antialiased {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.06), transparent 46%),
    #111418;
}

.app-menu {
  position: fixed;
  z-index: 900;
  left: 0;
  top: 0;
  width: 100vw;
  min-height: var(--menu-height);
  box-sizing: border-box;
  padding: 3px 8px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  color: #edf1f4;
  background: rgba(31, 35, 40, 0.96);
  border-bottom: 1px solid #15181c;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 10px 24px rgba(0, 0, 0, 0.28);
  overflow: visible;
  scrollbar-width: thin;
}

.menu-group {
  position: relative;
}

.menu-trigger {
  min-width: 54px;
  min-height: 27px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}

.menu-trigger:hover,
.menu-group:focus-within .menu-trigger {
  background: #3d444d;
}

.menu-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 224px;
  max-height: calc(100vh - 48px);
  box-sizing: border-box;
  padding: 6px;
  display: none;
  grid-template-columns: 1fr;
  gap: 2px;
  overflow-y: auto;
  color: #f4f5f6;
  background: rgba(38, 43, 49, 0.98);
  border: 1px solid #171a1e;
  border-radius: 6px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
}

.menu-group:focus-within .menu-popover,
.menu-group.is-open .menu-popover {
  display: grid;
}

.menu-popover button,
.menu-popover a,
.menu-submenu-popover button,
.menu-submenu-popover a {
  width: 100%;
  min-height: 28px;
  box-sizing: border-box;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #f6f7f8;
  text-align: left;
  text-decoration: none;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.menu-popover button:hover,
.menu-popover a:hover,
.menu-popover button[aria-pressed="true"],
.menu-submenu-popover button:hover,
.menu-submenu-popover a:hover,
.menu-submenu-popover button[aria-pressed="true"],
.menu-submenu:focus-within > .menu-submenu-trigger,
.menu-submenu:hover > .menu-submenu-trigger {
  background: #454b53;
}

.menu-popover button:disabled,
.menu-submenu-popover button:disabled {
  color: #858d98;
  cursor: default;
  background: transparent;
}

.menu-submenu {
  position: relative;
}

.menu-submenu-trigger {
  font-weight: 800;
}

.menu-submenu-popover {
  position: absolute;
  z-index: 1;
  top: -6px;
  left: calc(100% + 6px);
  min-width: 236px;
  max-height: min(70vh, 620px);
  box-sizing: border-box;
  padding: 6px;
  display: none;
  grid-template-columns: 1fr;
  gap: 2px;
  overflow-y: auto;
  color: #f4f5f6;
  background: rgba(38, 43, 49, 0.99);
  border: 1px solid #171a1e;
  border-radius: 6px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
}

.menu-submenu:hover > .menu-submenu-popover,
.menu-submenu:focus-within > .menu-submenu-popover {
  display: grid;
}

.menu-submenu-arrow {
  position: relative;
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
}

.menu-submenu-arrow::before {
  position: absolute;
  top: 1px;
  right: 2px;
  width: 6px;
  height: 6px;
  content: "";
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.menu-shortcut {
  color: #aeb7c2;
  font-size: 11px;
}

.menu-separator {
  height: 1px;
  margin: 4px 2px;
  background: rgba(255, 255, 255, 0.12);
}

.menu-label {
  padding: 7px 8px 3px;
  color: #aeb7c2;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.menu-quick-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.menu-quick-action {
  position: relative;
  flex: 0 0 auto;
  min-width: max-content;
  min-height: 27px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  color: #f6f7f8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
  background: rgba(69, 75, 83, 0.72);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.menu-quick-action::after {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 1200;
  min-width: max-content;
  max-width: 220px;
  padding: 5px 7px;
  color: #f6f7f8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  content: attr(data-tooltip);
  background: rgba(18, 20, 24, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.menu-quick-action:hover::after,
.menu-quick-action:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.menu-quick-action:hover,
.menu-quick-action:focus-visible,
.menu-quick-action[aria-pressed="true"] {
  background: #5a626c;
}

.menu-quick-action.wide {
  width: auto;
}

.menu-quick-divider {
  flex: 0 0 auto;
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.16);
}

#main {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#error {
  position: relative;
  z-index: -1;
  grid-area: 1 / 1;
  width: var(--canvas-display-width);
  height: var(--canvas-display-height);
  box-sizing: border-box;
  padding: 50px;
  text-align: center;
  background: #DFDFDF;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  color: #f6f7f8;
  background: rgba(10, 12, 15, 0.88);
  transition: opacity 160ms ease, visibility 160ms ease;
}

.loading-overlay[hidden],
.loading-overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-overlay.is-error {
  background: rgba(10, 12, 15, 0.94);
}

.loading-card {
  min-width: 240px;
  max-width: min(760px, calc(100vw - 32px));
  padding: 18px 20px;
  background: rgba(36, 41, 47, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.loading-title {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.loading-status {
  color: #aeb7c2;
  font-size: 12px;
}

.loading-detail {
  margin-top: 6px;
  color: #8e98a5;
  font-size: 11px;
}

.loading-steps {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.loading-steps[hidden] {
  display: none;
}

.loading-step {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 6px 8px;
  color: #b8c2ce;
  font-size: 11px;
  line-height: 1.3;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.loading-step::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(174, 183, 194, 0.52);
}

.loading-step[data-step-state="running"] {
  color: #f6f7f8;
  background: rgba(87, 139, 202, 0.18);
  border-color: rgba(128, 178, 238, 0.38);
}

.loading-step[data-step-state="running"]::before {
  background: #8ec5ff;
  box-shadow: 0 0 0 3px rgba(142, 197, 255, 0.18);
}

.loading-step[data-step-state="done"] {
  color: #c6d4c2;
}

.loading-step[data-step-state="done"]::before {
  background: #83c47d;
}

.loading-step[data-step-state="error"] {
  color: #ffd4d4;
  background: rgba(106, 37, 42, 0.36);
  border-color: rgba(255, 123, 123, 0.34);
}

.loading-step[data-step-state="error"]::before {
  background: #ff8d8d;
}

.loading-step-label {
  min-width: 0;
}

.loading-step-state {
  color: #8e98a5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.loading-step[data-step-state="running"] .loading-step-state {
  color: #a8ceff;
}

.loading-step[data-step-state="done"] .loading-step-state {
  color: #94c88e;
}

.loading-step[data-step-state="error"] .loading-step-state {
  color: #ffb7b7;
}

.loading-error {
  margin-top: 14px;
  color: #ffe8e8;
  background: rgba(62, 20, 24, 0.72);
  border: 1px solid rgba(255, 123, 123, 0.34);
  border-radius: 6px;
  overflow: hidden;
}

.loading-error[hidden] {
  display: none;
}

.loading-error-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(87, 31, 36, 0.86);
}

.loading-error-header strong {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.loading-error-copy {
  width: 28px;
  min-height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
}

.loading-error-copy svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.loading-error pre {
  max-height: min(44vh, 360px);
  margin: 0;
  padding: 10px;
  overflow: auto;
  color: #fff7f7;
  font: 12px/1.45 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.loading-overlay.is-error .loading-spinner {
  display: none;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  margin-bottom: 12px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #f6f7f8;
  border-radius: 999px;
  animation: loading-spin 800ms linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

canvas {
  position: relative;
  z-index: 0;
  grid-area: 1 / 1;
  width: var(--canvas-display-width);
  height: var(--canvas-display-height);
  aspect-ratio: var(--canvas-aspect-ratio);
  border-radius: 0;
  background: #050607;
  outline: 1px solid rgba(214, 224, 236, 0.22);
  outline-offset: -1px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 0 0 2px rgba(255, 255, 255, 0.08),
    0 24px 64px rgba(0, 0, 0, 0.42);
  touch-action: none; /* Need this to prevent scrolling on iOS 15+ */
}

canvas:fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  object-fit: contain;
  background: #050607;
  border-radius: 0;
}

#app-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #050607;
}

#app-shell:fullscreen canvas {
  box-shadow: none;
}

#app-shell:fullscreen .app-menu,
#app-shell:fullscreen .floating-window,
#app-shell:fullscreen .benchmark-standing-panel {
  z-index: 1000;
}

canvas.focus-pick-mode {
  cursor: crosshair;
}

.floating-window {
  position: fixed;
  z-index: 100;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #f4f5f6;
  background: var(--floating-panel-bg);
  border: 1px solid #25282d;
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -28px 48px rgba(0, 0, 0, 0.22),
    inset 0 0 18px rgba(0, 0, 0, 0.22),
    0 18px 42px rgba(0, 0, 0, 0.34);
  resize: both;
}

.floating-window[hidden] {
  display: none;
}

.floating-window.is-collapsed {
  height: auto !important;
  resize: none;
}

.floating-window.is-collapsed .floating-window-body {
  display: none;
}

.floating-window-titlebar {
  min-height: 34px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  color: #edf1f4;
  background:
    linear-gradient(180deg, rgba(58, 64, 72, 0.98), rgba(35, 39, 45, 0.98));
  border-bottom: 1px solid rgba(21, 24, 28, 0.82);
  cursor: move;
  user-select: none;
}

.floating-window-titlebar strong {
  overflow: hidden;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.floating-window-actions {
  display: flex;
  gap: 5px;
}

.floating-window-actions button {
  width: 23px;
  min-width: 23px;
  min-height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #dfe7ef;
  background: rgba(20, 24, 29, 0.72);
  border-color: rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 2px rgba(0, 0, 0, 0.28);
  line-height: 1;
}

.floating-window-actions button:hover {
  color: #ffffff;
  background: rgba(78, 88, 101, 0.96);
}

.floating-window-actions button[data-window-command="collapse"]:hover {
  background: rgba(89, 105, 126, 0.96);
}

.floating-window-actions button[data-window-command="close"]:hover {
  background: #9b3c42;
  border-color: rgba(255, 191, 196, 0.34);
}

.window-command-icon {
  position: relative;
  display: block;
  width: 11px;
  height: 11px;
}

.window-command-collapse::before,
.window-command-close::before,
.window-command-close::after {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 5px;
  height: 2px;
  content: "";
  background: currentColor;
  border-radius: 999px;
}

.window-command-close::before {
  transform: rotate(45deg);
}

.window-command-close::after {
  transform: rotate(-45deg);
}

.floating-window-body {
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#controls {
  top: 48px;
  right: 18px;
  width: 360px;
  height: min(74vh, 680px);
}

#scene-tree-window {
  top: 48px;
  left: 18px;
  width: 320px;
  height: min(74vh, 680px);
}

#log-panel {
  left: 18px;
  bottom: 18px;
  width: 560px;
  height: min(40vh, 360px);
}

.log-panel .floating-window-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.log-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-panel-toolbar .section-title {
  flex: 1 1 auto;
}

.log-panel-toolbar button {
  flex: 0 0 auto;
  min-width: 62px;
}

.log-panel-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #aeb7c2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.log-panel-summary span {
  padding: 3px 6px;
  background: rgba(18, 22, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.log-entry-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 8px 9px;
  overflow: auto;
  color: #dce8f6;
  background: #20252b;
  border: 1px solid rgba(137, 163, 193, 0.18);
  border-left: 3px solid #83aee6;
  border-radius: 4px;
  font: 11px/1.45 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.scene-tree-header {
  position: relative;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scene-tree-summary {
  color: #aeb7c2;
  font-size: 12px;
}

.scene-tree-list {
  display: grid;
  gap: 4px;
}

.scene-tree-list button {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-color: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.scene-tree-list button[data-selection-state="primary"] {
  color: #ffffff;
  background: #2f6fbf;
  border-color: rgba(168, 207, 255, 0.62);
  box-shadow:
    inset 3px 0 0 #a8cfff,
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 4px rgba(0, 0, 0, 0.26);
}

.scene-tree-list button[data-selection-state="primary"]:hover {
  background: #367bcf;
}

.scene-tree-list button[data-selection-state="secondary"] {
  color: #f4f7fb;
  background: #43505d;
  border-color: rgba(168, 207, 255, 0.36);
  box-shadow:
    inset 3px 0 0 rgba(168, 207, 255, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.scene-tree-list button[data-selection-state="secondary"]:hover {
  background: #4b5968;
}

.scene-tree-list button[draggable="true"] {
  cursor: grab;
}

.scene-tree-list button[draggable="true"]:active {
  cursor: grabbing;
}

.scene-tree-list button[data-drag-state="source"] {
  opacity: 0.66;
}

.scene-tree-list button[data-drop-state="target"] {
  outline: 2px solid #83c7ff;
  outline-offset: 2px;
}

.scene-tree-list[data-drop-state="target"] {
  outline: 1px dashed rgba(131, 199, 255, 0.72);
  outline-offset: 4px;
}

.scene-tree-row {
  min-width: 0;
}

.scene-tree-component-row {
  margin-top: 4px;
  display: grid;
  grid-template-columns: minmax(58px, 0.74fr) minmax(0, 1.26fr);
  align-items: center;
  gap: 6px;
  min-height: 22px;
  box-sizing: border-box;
  padding: 3px 6px;
  color: #dce4ed;
  background: rgba(36, 40, 46, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  pointer-events: none;
}

.scene-tree-component-row + .scene-tree-component-row {
  margin-top: 3px;
}

.scene-tree-component-row span,
.scene-tree-component-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-tree-component-row span {
  color: #aeb7c2;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scene-tree-component-row strong {
  color: #edf1f4;
  font-size: 11px;
}

.scene-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-tree-chevron {
  flex: 0 0 16px;
  align-items: center;
  color: #aeb7c2;
}

.scene-tree-chevron[data-expanded]::before {
  width: 0;
  height: 0;
  content: "";
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
  transition: transform 120ms ease;
}

.scene-tree-chevron[data-expanded="true"]::before {
  transform: rotate(90deg);
}

.scene-tree-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.scene-tree-selection-count {
  grid-column: 1 / -1;
  min-height: 26px;
  box-sizing: border-box;
  padding: 5px 7px;
  color: #c8d2dd;
  font-size: 12px;
  background: #24282e;
  border: 1px solid #191c20;
  border-radius: 5px;
}

.scene-tree-create {
  position: relative;
  margin-bottom: 12px;
}

.scene-tree-add-button {
  width: 28px;
  min-width: 28px;
  min-height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #f6f7f8;
  background: #3f4a56;
  border: 1px solid #1f2227;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.28);
}

.scene-tree-add-button:hover,
.scene-tree-add-button[aria-pressed="true"] {
  background: #4b5663;
}

.scene-tree-create summary {
  width: max-content;
  min-height: 28px;
  box-sizing: border-box;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #f6f7f8;
  font-size: 12px;
  font-weight: 800;
  background: #3f4a56;
  border: 1px solid #1f2227;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  list-style: none;
}

.scene-tree-create summary::-webkit-details-marker {
  display: none;
}

.scene-tree-create summary:hover {
  background: #4b5663;
}

.scene-tree-add-plus {
  position: relative;
  width: 11px;
  height: 11px;
}

.scene-tree-add-plus::before,
.scene-tree-add-plus::after {
  position: absolute;
  left: 0;
  top: 5px;
  width: 11px;
  height: 2px;
  content: "";
  background: currentColor;
  border-radius: 999px;
}

.scene-tree-add-plus::after {
  transform: rotate(90deg);
}

.scene-tree-add-popover {
  position: absolute;
  z-index: 250;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(38, 43, 49, 0.98);
  border: 1px solid #171a1e;
  border-radius: 6px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.34);
}

.scene-tree-add-popover[hidden] {
  display: none;
}

.scene-tree-create:not([open]) .scene-tree-add-popover {
  display: none;
}

.scene-tree-tools .section-title,
.scene-tree-selection-count,
.scene-tree-create .wide-control,
.scene-tree-add-popover .wide-control {
  grid-column: 1 / -1;
}

.scene-tree-tools button,
.scene-tree-create button,
.scene-tree-add-popover button {
  width: 100%;
  text-align: left;
}

.scene-tree-create .wide-control,
.scene-tree-add-popover .wide-control {
  text-align: center;
}

.control-panel {
  display: grid;
  gap: 12px;
}

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

.inspector-section {
  border-left: 3px solid var(--section-accent, #4a90e2);
  border-radius: 6px;
  background: rgb(12 16 22 / 68%);
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--section-accent, #4a90e2) 36%, transparent);
}

.inspector-section + .inspector-section {
  margin-top: 8px;
}

.inspector-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px 7px 10px;
  color: #eef4fb;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.inspector-section > summary::-webkit-details-marker {
  display: none;
}

.inspector-section > summary::before {
  width: 0;
  height: 0;
  content: "";
  color: var(--section-accent, #4a90e2);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  transition: transform 120ms ease;
}

.inspector-section[open] > summary::before {
  transform: rotate(90deg);
}

.inspector-section > .control-panel {
  padding: 0 10px 10px;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.button-row.two-up {
  grid-template-columns: repeat(2, 1fr);
}

.resolution-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primitive-actions {
  grid-template-columns: 1fr 1fr;
}

.primitive-actions .section-title,
.primitive-actions .wide-control {
  grid-column: 1 / -1;
}

.primitive-actions button {
  width: 100%;
  text-align: left;
}

.primitive-actions .wide-control {
  text-align: center;
}

.camera-playback {
  width: 100%;
  min-height: 34px;
  margin-bottom: -4px;
  background: #59616c;
  font-weight: 700;
}

.camera-playback:hover {
  background: #626b78;
}

.render-pause-toggle {
  width: 100%;
  min-height: 32px;
  background: #4c5662;
  font-weight: 700;
}

.render-pause-toggle:hover {
  background: #566270;
}

.render-pause-toggle[aria-pressed="true"] {
  background: #6b5a3d;
}

.render-pause-toggle[aria-pressed="true"]:hover {
  background: #766546;
}

.control-section {
  display: grid;
  gap: 8px;
}

.render-settings,
.render-state-controls,
.camera-settings,
.color-settings,
.bloom-settings {
  gap: 8px;
}

.render-state-controls {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.camera-settings,
.color-settings,
.bloom-settings {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.field {
  display: grid;
  gap: 4px;
}

.field label,
.section-title {
  color: #d6d9de;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-title {
  min-height: 24px;
  box-sizing: border-box;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  color: #f0f4f8;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left: 3px solid var(--section-accent, #8fa3b8);
  border-radius: 4px;
}

.slider-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slider-value {
  min-width: 24px;
  padding: 1px 6px;
  color: #ffffff;
  text-align: center;
  background: #24282e;
  border: 1px solid #1c1f24;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.08);
}

button,
select,
input {
  font: inherit;
}

button,
select {
  min-height: 28px;
  color: #f6f7f8;
  background: #454b53;
  border: 1px solid #1f2227;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(0, 0, 0, 0.28);
}

button {
  padding: 5px 8px;
  cursor: pointer;
}

button:hover,
select:hover {
  background: #505762;
}

button:active {
  background: #3a3f46;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.32);
}

button:disabled:hover,
select:disabled:hover {
  background: #454b53;
}

select {
  width: 100%;
  padding: 4px 8px;
}

input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  min-height: 28px;
  padding: 4px 8px;
  color: #f6f7f8;
  background: #454b53;
  border: 1px solid #1f2227;
  border-radius: 5px;
}

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  accent-color: #83aee6;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, #405060, #83aee6);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  background: #f4f7fb;
  border: 2px solid #83aee6;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.38);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: linear-gradient(90deg, #405060, #83aee6);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: #f4f7fb;
  border: 2px solid #83aee6;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.38);
}

input:disabled,
button:disabled,
select:disabled {
  opacity: 0.48;
}

input[type="range"]:disabled::-webkit-slider-runnable-track {
  background: #30363d;
}

input[type="range"]:disabled::-moz-range-track {
  background: #30363d;
}

.checkbox-field {
  min-height: 28px;
  box-sizing: border-box;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #f2f4f6;
  background: #3c434c;
  border: 1px solid #1f2227;
  border-radius: 5px;
}

.checkbox-field input[type="checkbox"] {
  flex: 0 0 auto;
}

.field-help {
  padding: 7px 8px;
  color: #b9c4d0;
  font-size: 12px;
  line-height: 1.35;
  background: rgba(23, 29, 36, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

.component-row {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  padding: 6px 8px;
  color: #dce4ed;
  background: #24282e;
  border: 1px solid #191c20;
  border-radius: 5px;
}

.component-row span,
.component-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.component-row span {
  color: #aeb7c2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.component-row strong {
  color: #f2f4f6;
  font-size: 12px;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px;
  background: #24282e;
  border: 1px solid #191c20;
  border-radius: 5px;
}

input[type="color"] {
  width: 48px;
  height: 30px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
}

input[type="color"]::-moz-color-swatch {
  border: 0;
}

.color-control-swatch {
  flex: 1 1 auto;
  min-height: 22px;
  background:
    linear-gradient(90deg, #ffffff, #ffd27a 34%, #ff7878 56%, #7aa7ff 78%, #6dffbf),
    #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.32);
}

.presets {
  grid-template-columns: 1fr 1fr;
}

.presets .section-title {
  grid-column: 1 / -1;
}

.presets button {
  width: 100%;
  text-align: left;
}

.presets .reset-all {
  grid-column: 1 / -1;
  text-align: center;
  background: #5a4850;
}

.presets .reset-all:hover {
  background: #66515b;
}

.color-reset {
  width: 100%;
  margin-top: 2px;
  background: #3f464e;
}

.color-reset:hover {
  background: #48515b;
}

.light-cycle-toggle,
.focus-pick-toggle {
  width: 100%;
  background: #4c5662;
}

.light-cycle-toggle:hover,
.focus-pick-toggle:hover {
  background: #566270;
}

.light-cycle-toggle[aria-pressed="true"],
.focus-pick-toggle[aria-pressed="true"] {
  background: #6b5a3d;
}

.light-cycle-toggle[aria-pressed="true"]:hover,
.focus-pick-toggle[aria-pressed="true"]:hover {
  background: #766546;
}

.gpu-status {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  color: #edf1f4;
  background: #24282e;
  border: 1px solid #191c20;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.22);
}

.gpu-status strong {
  color: #b9c0c9;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gpu-status span {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.selection-readout,
.export-status {
  min-height: 28px;
  box-sizing: border-box;
  padding: 6px 8px;
  color: #f2f4f6;
  background: #24282e;
  border: 1px solid #191c20;
  border-radius: 5px;
}

.export-status {
  color: #aeb7c2;
  font-size: 12px;
}

.gpu-status.is-preferred {
  border-color: rgba(109, 183, 126, 0.72);
}

.gpu-status.is-fallback {
  border-color: rgba(218, 171, 85, 0.72);
}

.benchmark-panel {
  position: fixed;
  z-index: 96;
  top: 48px;
  right: 390px;
  width: 320px;
  max-width: min(340px, calc(100vw - 36px));
  height: min(74vh, 680px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  color: #edf1f4;
  background: var(--floating-panel-bg);
  border: 1px solid #25282d;
  border-radius: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -28px 48px rgba(0, 0, 0, 0.22),
    inset 0 0 18px rgba(0, 0, 0, 0.22),
    0 18px 42px rgba(0, 0, 0, 0.34);
}

.benchmark-panel[hidden] {
  display: none;
}

.benchmark-panel.is-collapsed {
  height: auto;
}

.benchmark-panel.is-collapsed .benchmark-panel-body {
  display: none;
}

.benchmark-titlebar {
  min-height: 34px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  color: #edf1f4;
  background:
    linear-gradient(180deg, rgba(58, 64, 72, 0.98), rgba(35, 39, 45, 0.98));
  border-bottom: 1px solid rgba(21, 24, 28, 0.82);
  cursor: move;
  touch-action: none;
  user-select: none;
}

.benchmark-titlebar strong {
  overflow: hidden;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.benchmark-titlebar-end {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.benchmark-titlebar-end .floating-window-actions {
  flex: 0 0 auto;
}

.benchmark-titlebar .benchmark-source {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.benchmark-panel-body {
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.benchmark-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.benchmark-source {
  color: #aeb7c2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.benchmark-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.benchmark-gpu-label {
  margin-top: 6px;
  padding: 5px 8px;
  background: #1f2328;
  border-radius: 6px;
  color: #8b949e;
  font-size: 11px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.benchmark-metric {
  min-width: 0;
  padding: 7px 8px;
  background: #1f2328;
  border: 1px solid #191c20;
  border-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.22);
}

.benchmark-metric[title] {
  cursor: help;
}

.benchmark-metric strong,
.benchmark-metric span {
  display: block;
}

.benchmark-metric strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.benchmark-metric span {
  margin-top: 2px;
  color: #aeb7c2;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.benchmark-runner {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.benchmark-runner .section-title {
  margin-bottom: 6px;
}

.benchmark-runner .button-row {
  gap: 6px;
  margin-bottom: 6px;
}

.benchmark-result-actions {
  margin-bottom: 7px;
}

.benchmark-runner label {
  display: grid;
  grid-template-columns: auto minmax(52px, 1fr);
  align-items: center;
  gap: 6px;
  color: #d6d9de;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.benchmark-runner input[type="number"] {
  min-height: 25px;
  padding: 3px 6px;
}

.benchmark-runner button {
  min-height: 25px;
  padding: 4px 7px;
  font-size: 12px;
  line-height: 1.2;
}

.benchmark-runner-summary {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.benchmark-runner-summary:not(:empty) {
  margin-top: 8px;
  padding: 8px;
  background: rgba(18, 22, 27, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.benchmark-runner-card {
  padding: 7px 9px;
  color: #edf1f4;
  background: #20252b;
  border: 1px solid rgba(137, 163, 193, 0.22);
  border-left: 3px solid #83aee6;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.benchmark-runner-table {
  width: 100%;
  color: #d6d9de;
  font-size: 11px;
  border-collapse: collapse;
  background: #20252b;
  border: 1px solid rgba(137, 163, 193, 0.18);
  border-radius: 5px;
  overflow: hidden;
}

.benchmark-runner-table th,
.benchmark-runner-table td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}

.benchmark-runner-table th {
  color: #aeb7c2;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.06);
}

.benchmark-runner-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.035);
}

.benchmark-runner-table td:last-child {
  color: #dce8f6;
  font-weight: 700;
}

a {
  color: inherit;
}

#glossiness-factor {
  display: none;
  margin-top: 8px;
  padding: 8px;
  color: #d6d9de;
  font-size: 12px;
  background: rgba(31, 36, 43, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
}

#glossiness-factor[style*="inline"] {
  display: grid !important;
}

#glossiness-factor input[type="range"] {
  width: 100%;
}

@media (max-width: 980px) {
  :root {
    --canvas-display-size: min(100vw, 100vh);
  }

  .app-menu {
    overflow: visible;
  }

  .menu-quick-actions {
    margin-left: 0;
  }

  .menu-popover {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }

  .menu-submenu-popover {
    position: static;
    min-width: 0;
    max-height: none;
    margin: 2px 0 4px 10px;
    box-shadow: none;
  }

  .menu-submenu-arrow::before {
    transform: rotate(45deg);
  }

  .floating-window,
  #controls,
  #scene-tree-window,
  #log-panel {
    left: 12px;
    right: auto;
    width: calc(100vw - 24px);
    min-width: 0;
    max-width: calc(100vw - 24px);
  }

  #controls {
    top: 44px;
    height: min(52vh, 520px);
  }

  #scene-tree-window {
    top: calc(44px + min(52vh, 520px) + 10px);
    height: min(28vh, 260px);
  }

  .benchmark-panel {
    top: auto;
    right: auto;
    bottom: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    height: min(46vh, 420px);
  }

  .benchmark-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .benchmark-runner label {
    grid-template-columns: 1fr;
  }
}
