:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #121418;
  --panel-2: #181d23;
  --line: #2a2f36;
  --line-soft: #20252c;
  --text: #eef2f6;
  --muted: #9aa4af;
  --accent: #51b7ff;
  --accent-strong: #7bc8ff;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

input,
textarea {
  user-select: text;
}

.app {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 32px;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  min-width: 0;
  border-color: var(--line);
  background: #101216;
}

.topbar {
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.brand {
  flex: 0 1 auto;
  min-width: 132px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid #37556a;
  border-radius: 6px;
  background: #172637;
  color: var(--text);
  cursor: pointer;
}

.file-button:hover {
  border-color: var(--accent);
}

.file-button input {
  display: none;
}

.tool-button {
  height: 28px;
  padding: 0 12px;
  border-color: #33404d;
  border-radius: 6px;
}

.tool-button.active {
  border-color: var(--accent);
  background: #12304a;
  color: var(--accent-strong);
}

.file-hint {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.github-link {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.github-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.workspace {
  min-width: 0;
  min-height: 0;
}

.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  cursor: default;
}

.viewport.workspace-pan-ready {
  cursor: grab;
}

.viewport.workspace-panning {
  cursor: grabbing;
}

.viewport.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.world-scene {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
}

.window-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.connection-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: block;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

.workspace-boundary {
  position: absolute;
  z-index: 0;
  border: 3px dashed rgba(81, 183, 255, 0.34);
  box-shadow: inset 0 0 80px rgba(81, 183, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.workspace-boundary.visible {
  opacity: 1;
}

.node-connection-hit {
  fill: none;
  stroke: transparent;
  stroke-linecap: round;
  stroke-width: 18;
  cursor: pointer;
  pointer-events: stroke;
  vector-effect: non-scaling-stroke;
}

.node-connection {
  fill: none;
  stroke: #36df21;
  stroke-linecap: round;
  stroke-width: 4;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.node-connection.selected {
  stroke: #8fd7ff;
  stroke-width: 6;
  filter: drop-shadow(0 0 4px rgba(81, 183, 255, 0.9));
}

.node-connection.preview {
  opacity: 0.75;
  stroke-dasharray: 7 5;
}

.node-connection.invalid {
  stroke: #ff5c64;
}

.selection-graph-panel {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 100000;
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr);
  width: 300px;
  height: 220px;
  min-width: 180px;
  min-height: 140px;
  overflow: hidden;
  border: 1px solid #27313b;
  border-radius: 7px;
  background: rgba(10, 12, 15, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.selection-graph-panel.hidden {
  display: none;
}

.graph-titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  border-bottom: 1px solid #202832;
  background: #11151b;
  color: #c8d1dc;
  font-size: 11px;
  font-weight: 650;
  cursor: move;
}

.log-display-toggle {
  height: 24px;
  padding: 0 12px;
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #182028;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.log-display-toggle:hover {
  border-color: var(--accent);
}

.log-display-toggle.active {
  animation: logDisplayBlink 1.8s ease-in-out infinite;
}

@keyframes logDisplayBlink {
  0%, 100% {
    border-color: #7a4210;
    background: #3a2408;
    color: #ffb066;
  }
  50% {
    border-color: #ff9a2e;
    background: #ff9a2e;
    color: #1a0f00;
  }
}

.graph-titlebar span,
.graph-titlebar strong {
  justify-self: end;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-titlebar strong {
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  font-weight: 500;
}

.selection-graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.selection-graph-canvas:active {
  cursor: grabbing;
}

.graph-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
}

.graph-resize-handle::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #7b8794;
  border-bottom: 2px solid #7b8794;
  content: "";
}

.inspector.collapsed,
.picker-panel.collapsed,
.selection-graph-panel.collapsed {
  height: auto !important;
  min-height: 0;
  overflow: hidden;
}

.inspector.collapsed > :not(.panel-title),
.picker-panel.collapsed > :not(.panel-title),
.selection-graph-panel.collapsed > :not(.graph-titlebar) {
  display: none;
}

.image-window {
  position: absolute;
  display: grid;
  grid-template-rows: 28px minmax(0, 1fr);
  min-width: 220px;
  min-height: 160px;
  border: 1px solid #343a43;
  border-radius: 7px;
  overflow: visible;
  background: #050505;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.node-port {
  position: absolute;
  top: 14px;
  z-index: 6;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid #10220c;
  border-radius: 50%;
  background: #31df17;
  box-shadow: 0 0 0 1px rgba(69, 255, 39, 0.55);
  cursor: none;
  transform: translateY(-50%);
  touch-action: none;
}

.node-port::before,
.node-port::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.node-port::before {
  top: 50%;
  width: 20px;
  border-top: 2px dashed rgba(91, 255, 66, 0.9);
  opacity: 0;
  transform: translateY(-50%);
}

.node-port-input::before {
  right: 10px;
}

.node-port-output::before {
  left: 10px;
}

.node-port::after {
  inset: -7px;
  border: 2px solid rgba(91, 255, 66, 0.82);
  border-radius: 50%;
  opacity: 0;
}

.node-port:hover,
.node-port.connect-source,
.node-port.connect-target {
  background: #83ff6f;
  box-shadow: 0 0 0 3px rgba(69, 255, 39, 0.28);
}

.node-port:hover::before,
.node-port.connect-target::before {
  opacity: 1;
}

.viewport.connection-dragging .node-port::before {
  opacity: 0;
}

.node-port:hover::after,
.node-port.connect-source::after,
.node-port.connect-target::after {
  animation: node-port-pulse 850ms ease-out infinite;
}

@keyframes node-port-pulse {
  0% {
    opacity: 0.9;
    transform: scale(0.7);
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

.viewport.connection-dragging,
.viewport.connection-dragging * {
  cursor: none !important;
}

.connection-node-ghost {
  position: absolute;
  z-index: 2147483646;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  align-items: center;
  width: 148px;
  height: 42px;
  padding: 4px 9px 4px 12px;
  border: 1px solid rgba(81, 183, 255, 0.88);
  border-radius: 6px;
  background: rgba(10, 18, 25, 0.84);
  box-shadow: 0 0 0 1px rgba(81, 183, 255, 0.22), 0 8px 22px rgba(0, 0, 0, 0.42);
  color: #e8f5ff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.92);
  transform-origin: left center;
  transition: opacity 80ms ease, transform 80ms ease;
}

.connection-node-ghost::before,
.connection-node-ghost::after {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid #10220c;
  border-radius: 50%;
  background: #69f551;
  box-shadow: 0 0 0 2px rgba(69, 255, 39, 0.36);
  content: "";
  transform: translate(-50%, -50%);
}

.connection-node-ghost::before {
  left: 0;
}

.connection-node-ghost::after {
  left: 100%;
}

.connection-node-ghost.visible {
  opacity: 0.86;
  transform: translateY(-50%) scale(1);
}

.connection-node-ghost-kind {
  grid-row: 1 / 3;
  align-self: stretch;
  display: grid;
  place-items: center;
  margin-right: 8px;
  padding-right: 8px;
  border-right: 1px solid rgba(81, 183, 255, 0.28);
  color: #75caff;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.connection-node-ghost strong {
  align-self: end;
  font-size: 11px;
  line-height: 1.1;
}

.connection-node-ghost-hint {
  align-self: start;
  color: #93a6b8;
  font-size: 8px;
  line-height: 1.1;
}

@media (prefers-reduced-motion: reduce) {
  .node-port:hover::after,
  .node-port.connect-source::after,
  .node-port.connect-target::after {
    animation: none;
    opacity: 0.75;
  }

  .connection-node-ghost {
    transition: none;
    animation: none;
  }
}

.node-port-input {
  left: -8px;
}

.node-port-output {
  right: -8px;
}

.node-kind-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid #33404d;
  border-radius: 4px;
  color: #9fb0c2;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.node-kind-badge.glsl {
  border-color: #17649a;
  background: #12304a;
  color: var(--accent-strong);
}

.node-kind-badge.source {
  color: #b8c3cf;
}

.image-window.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(81, 183, 255, 0.35), 0 20px 42px rgba(0, 0, 0, 0.5);
}

.node-overview-label {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 8;
  display: none;
  max-width: 220px;
  padding: 3px 7px;
  overflow: hidden;
  border: 1px solid rgba(123, 200, 255, 0.85);
  border-radius: 4px;
  background: rgba(8, 15, 22, 0.94);
  color: #e8f5ff;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(var(--workspace-inverse-scale, 1));
  transform-origin: center;
}

.world-scene.workspace-overview .image-window.active .node-overview-label,
.world-scene.workspace-overview .image-window:hover .node-overview-label {
  display: block;
}

/* At graph-overview scales, keep the node silhouette and identity while
   removing controls that are too small to use accurately. */
.world-scene.workspace-compact .window-size,
.world-scene.workspace-compact .window-close {
  display: none;
}

.world-scene.workspace-compact .window-titlebar {
  grid-template-columns: minmax(0, 1fr) auto;
}

.world-scene.workspace-overview .window-title,
.world-scene.workspace-overview .window-close {
  display: none;
}

.world-scene.workspace-overview .window-titlebar {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0 4px;
}

.window-titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 24px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 8px;
  border-bottom: 1px solid #272d34;
  background: #15191f;
  cursor: grab;
  user-select: none;
  border-radius: 6px 6px 0 0;
}

.window-close {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #c8d1dc;
  font-size: 16px;
  line-height: 1;
}

.window-close:hover {
  border-color: #6b3131;
  background: #3a1717;
  color: #ffb4b4;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-title {
  min-width: 0;
  overflow: hidden;
  color: #dce7f3;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-size {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-window.pq-display {
  grid-template-rows: 46px minmax(0, 1fr);
}

.pq-display .window-titlebar {
  grid-template-columns: minmax(0, 1fr) auto 24px;
  grid-template-rows: 24px 18px;
  column-gap: 8px;
  row-gap: 0;
}

.pq-display .window-title {
  grid-column: 1;
  grid-row: 1;
}

.pq-display .node-kind-badge {
  grid-column: 2;
  grid-row: 1;
}

.pq-display .window-close {
  grid-column: 3;
  grid-row: 1;
}

.pq-display .window-size {
  grid-column: 1 / -1;
  grid-row: 2;
}

.window-body {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0 0 6px 6px;
  background: conic-gradient(
    #0d1014 25%,
    #090b0e 0 50%,
    #0d1014 0 75%,
    #090b0e 0
  ) 0 0 / 32px 32px;
}

.image-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.image-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.output-status {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.image-canvas.picker-mode {
  cursor: copy;
}

.image-canvas.picker-hover {
  cursor: grab;
}

.image-canvas.picker-moving {
  cursor: grabbing;
}

.image-canvas.panning {
  cursor: grabbing;
}

.image-resize-edge {
  position: absolute;
  z-index: 3;
  touch-action: none;
}

.resize-w,
.resize-e {
  top: 0;
  bottom: 10px;
  width: 7px;
  cursor: ew-resize;
}

.resize-w {
  left: 0;
}

.resize-e {
  right: 0;
}

.resize-s {
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 7px;
  cursor: ns-resize;
}

.resize-sw,
.resize-se {
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.resize-sw {
  left: 0;
  cursor: nesw-resize;
}

.resize-se {
  right: 0;
}

.resize-se::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #7b8794;
  border-bottom: 2px solid #7b8794;
  content: "";
}

.drop-prompt {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 24px;
  color: #dce7f3;
  font-size: 18px;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}

.drop-prompt span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.drop-prompt.hidden {
  display: none;
}

.inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100000;
  width: 280px;
  max-height: calc(100% - 24px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(18, 20, 24, 0.96);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
}

.picker-panel {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 100000;
  width: min(640px, calc(100% - 24px));
  max-height: min(360px, calc(100% - 24px));
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(18, 20, 24, 0.96);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
}

.picker-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  align-items: center;
  gap: 12px;
  height: 38px;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  height: 28px;
  overflow: hidden;
  border: 1px solid #33404d;
  border-radius: 6px;
  background: #080a0d;
}

.tab-button {
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.tab-button + .tab-button {
  border-left: 1px solid #33404d;
}

.tab-button.active {
  background: #12304a;
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.graph-value-mode {
  padding: 2px 7px;
  overflow: visible;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: none;
}

.selection-graph-panel[data-value-mode="linear"] .graph-value-mode {
  color: #58c8ff;
  background: rgba(88, 200, 255, 0.1);
}

.selection-graph-panel[data-value-mode="srgb"] .graph-value-mode {
  color: #d995ff;
  background: rgba(217, 149, 255, 0.1);
}

.selection-graph-panel[data-value-mode="code"] .graph-value-mode {
  color: #ffbd59;
  background: rgba(255, 189, 89, 0.1);
}

.selection-graph-panel[data-value-mode="srgb"] .graph-value-mode,
.selection-graph-panel[data-value-mode="code"] .graph-value-mode {
  animation: graphValueModePulse 2.4s ease-in-out infinite;
}

@keyframes graphValueModePulse {
  0%, 100% {
    opacity: 0.72;
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 7px currentColor;
  }
}

@media (prefers-reduced-motion: reduce) {
  .selection-graph-panel[data-value-mode="srgb"] .graph-value-mode,
  .selection-graph-panel[data-value-mode="code"] .graph-value-mode {
    animation: none;
    opacity: 1;
  }
}

.tab-button.selection-changing {
  animation: selectionTabPulse 1.05s ease-in-out infinite;
}

@keyframes selectionTabPulse {
  0%, 100% {
    background: rgba(255, 154, 46, 0.05);
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(255, 154, 46, 0.24);
  }
  50% {
    background: rgba(255, 154, 46, 0.19);
    color: #ffc27a;
    box-shadow: inset 0 0 0 1px rgba(255, 154, 46, 0.68);
  }
}

.picker-title .tool-button {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.picker-title select {
  height: 26px;
  font-size: 12px;
  font-weight: 700;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

#pickerValueMode[data-value-mode="linear"] {
  border-color: rgba(88, 200, 255, 0.7);
  background: rgba(24, 66, 86, 0.55);
  color: #58c8ff;
}

#pickerValueMode[data-value-mode="srgb"] {
  border-color: rgba(217, 149, 255, 0.7);
  background: rgba(67, 36, 84, 0.55);
  color: #d995ff;
}

#pickerValueMode[data-value-mode="code"] {
  border-color: rgba(255, 189, 89, 0.75);
  background: rgba(79, 55, 20, 0.58);
  color: #ffbd59;
}

#pickerValueMode option {
  background: #0b0d10;
}

#pickerValueMode option.value-mode-linear {
  color: #58c8ff;
}

#pickerValueMode option.value-mode-srgb {
  color: #d995ff;
}

#pickerValueMode option.value-mode-code {
  color: #ffbd59;
}

.picker-panel[data-value-mode="linear"] .selection-summary {
  box-shadow: inset 2px 0 #58c8ff;
}

.picker-panel[data-value-mode="srgb"] .selection-summary {
  box-shadow: inset 2px 0 #d995ff;
}

.picker-panel[data-value-mode="code"] .selection-summary {
  box-shadow: inset 2px 0 #ffbd59;
}

.picker-rows {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.panel-tab-content {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 76px 36px;
  min-height: 0;
}

.panel-tab-content.hidden {
  display: none;
}

.picker-empty {
  color: var(--muted);
  font-size: 13px;
}

.picker-row {
  display: grid;
  grid-template-columns: 16px 18px minmax(80px, 1fr) minmax(130px, 1.2fr) 26px;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #dce7f3;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.picker-row:last-child {
  border-bottom: 0;
}

.picker-row {
  cursor: pointer;
}

.picker-row.selected {
  background: rgba(53, 208, 255, 0.13);
  box-shadow: inset 2px 0 #35d0ff;
}

.picker-row.hovered {
  background: rgba(255, 54, 94, 0.18);
  box-shadow: inset 3px 0 #ff365e;
  color: #fff;
}

.picker-marker-chip,
.sample-chip {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.sample-chip {
  width: 18px;
  height: 18px;
}

.picker-remove {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.picker-copy-text {
  width: calc(100% - 16px);
  min-width: 0;
  margin: 0 8px;
  padding: 7px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090b0e;
  color: #c8d1dc;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

.copy-button {
  height: 28px;
  margin: 0;
  padding: 0 12px;
  font-size: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 3px 8px 8px;
}

.panel-actions select {
  width: 118px;
  height: 28px;
  font-size: 12px;
}

.panel-actions .tool-button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.selection-summary {
  min-height: 0;
  overflow: auto;
  padding: 8px;
  color: #dce7f3;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  white-space: pre;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.panel-title {
  height: 32px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: move;
}

.settings-form,
.empty-settings {
  padding: 9px 10px 10px;
}

.hidden {
  display: none;
}

.empty-settings {
  color: var(--muted);
  font-size: 13px;
}

.field,
.check-field {
  display: grid;
  gap: 4px;
  margin-bottom: 9px;
}

.field > span,
.check-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
}

.settings-form .compact-field {
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
}

.settings-form .compact-field > span {
  grid-column: 1;
}

.settings-form .compact-field > :not(span) {
  grid-column: 2;
}

.settings-form .output-field .output-status {
  margin-top: -1px;
}

.check-field input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

select,
input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0d10;
  color: var(--text);
}

select {
  padding: 0 8px;
}

input[type="number"] {
  padding: 0 9px;
}

.inline-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 6px;
}

button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #171b21;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #4d6475;
  background: #1d232b;
}

.inline-input button {
  height: 28px;
  font-size: 12px;
}

.export-settings {
  margin: 1px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 10, 13, 0.45);
}

.export-settings summary {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.export-settings summary::-webkit-details-marker {
  display: none;
}

.export-settings summary::before {
  width: 14px;
  color: var(--accent);
  content: "▸";
}

.export-settings[open] summary::before {
  content: "▾";
}

.export-settings[open] summary {
  border-bottom: 1px solid var(--line-soft);
}

.export-settings-body {
  padding: 9px 9px 10px;
}

.export-sub-options {
  padding: 7px 7px 0;
  margin-bottom: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.018);
}

.export-separate-field {
  margin: 2px 0 8px;
}

.export-size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.export-size-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 5px;
  align-items: center;
}

.export-size-field.hidden {
  display: none;
}

.export-size-field span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.export-size-field small {
  color: var(--muted);
  font-size: 10px;
}

.export-description {
  min-height: 30px;
  margin: 1px 0 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.export-button {
  width: 100%;
  height: 30px;
  border-color: #37556a;
  background: #172637;
  font-size: 12px;
  font-weight: 650;
}

.export-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

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

.gamma-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ev-buttons button,
.gamma-buttons button {
  height: 24px;
  padding: 0 6px;
  font-size: 11px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.segmented button {
  height: 27px;
  padding: 0 4px;
  font-size: 12px;
}

.segmented button.active {
  border-color: var(--accent);
  background: #12304a;
  color: var(--accent-strong);
}

.meta {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.meta div {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.meta span {
  color: var(--muted);
  font-size: 11px;
}

.meta strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusbar {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(180px, 1.2fr) minmax(0, 1fr) 160px;
  gap: 12px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

#hoveredPickerValue {
  color: #ff365e;
  font-weight: 700;
  text-align: center;
}

.statusbar div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusbar div:last-child {
  text-align: right;
}

.glsl-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 100000;
  width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 16px);
  display: grid;
  grid-template-rows: 36px auto auto minmax(120px, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(18, 20, 24, 0.97);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

.glsl-panel.hidden {
  display: none;
}

.glsl-panel.collapsed {
  height: auto !important;
  min-height: 0;
  grid-template-rows: 36px;
  overflow: hidden;
}

.glsl-panel.collapsed > :not(.panel-title) {
  display: none;
}

.glsl-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  height: 9px;
  cursor: ns-resize;
  touch-action: none;
}

.glsl-resize-handle::after {
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 40px;
  height: 2px;
  border-radius: 2px;
  background: #526171;
  content: "";
  transform: translateX(-50%);
}

.glsl-resize-handle:hover::after {
  background: var(--accent);
}

.glsl-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#glslTitleText {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glsl-close {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #c8d1dc;
  font-size: 15px;
  line-height: 1;
}

.glsl-close:hover {
  border-color: #6b3131;
  background: #3a1717;
  color: #ffb4b4;
}

.glsl-fields {
  display: grid;
  gap: 6px;
  padding: 10px 12px 8px;
}

.glsl-field {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.glsl-field > span {
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.glsl-field > strong {
  min-width: 0;
  overflow: hidden;
  color: #c8d1dc;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glsl-size {
  display: flex;
  align-items: center;
  gap: 6px;
}

.glsl-size input {
  width: 78px;
}

.glsl-size > span {
  color: var(--muted);
}

.glsl-signature {
  overflow: hidden;
  padding: 0 12px;
  color: #6f7c8b;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glsl-code {
  width: calc(100% - 24px);
  min-height: 120px;
  margin: 4px 12px;
  padding: 8px;
  overflow: auto;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090b0e;
  color: #d7e2ee;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre;
}

.glsl-status {
  max-height: 92px;
  padding: 8px 12px 10px;
  overflow: auto;
  color: #8fce9a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.glsl-status.pending {
  color: var(--muted);
}

.glsl-status.error {
  color: #ff9b9b;
}

@media (max-width: 760px) {
  .inspector {
    width: min(280px, calc(100% - 24px));
  }

  .statusbar {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  #linearValue,
  #srgbValue,
  #viewState {
    display: none;
  }

  .picker-row {
    grid-template-columns: 16px 18px minmax(64px, 0.8fr) minmax(120px, 1.1fr) 26px;
  }
}
