/* Shared controls (js/ui/controls.js) */

.ctl {
  display: flex;
  min-width: 0;
}
.ctl.disabled {
  opacity: 0.45;
  pointer-events: none;
}
.ctl-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scrub {
  cursor: ew-resize;
  touch-action: none;
}
body.scrubbing,
body.scrubbing * {
  cursor: ew-resize !important;
}

/* Slider */
.ctl-slider {
  flex-direction: column;
  gap: 6px;
  padding: 2px 0;
}
.ctl-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ctl-slider .ctl-num-input {
  width: 58px;
  min-height: 24px;
  padding: 2px 6px;
  text-align: right;
  font-size: 11.5px;
  background: transparent;
  border-color: transparent;
  color: var(--text);
}
.ctl-slider .ctl-num-input:hover {
  border-color: var(--line-soft);
}
.ctl-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --pct: 50%;
}
.ctl-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) 0 var(--pct), var(--line) var(--pct) 100%);
}
.ctl-range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}
.ctl-range::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--accent);
}
.ctl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px var(--shadow);
  transition: transform var(--t-fast) var(--spring), box-shadow var(--t-fast);
}
.ctl-range:hover::-webkit-slider-thumb {
  transform: scale(1.18);
}
.ctl-range:active::-webkit-slider-thumb {
  transform: scale(1.18);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 0 5px var(--accent-soft), 0 2px 6px var(--shadow);
}
.ctl-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px var(--shadow);
  transition: transform var(--t-fast) var(--spring), box-shadow var(--t-fast);
}
.ctl-range:hover::-moz-range-thumb {
  transform: scale(1.18);
}
.ctl-range:active::-moz-range-thumb {
  transform: scale(1.18);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 0 5px var(--accent-soft), 0 2px 6px var(--shadow);
}
.ctl-range:focus-visible {
  box-shadow: none;
}
.ctl-range:focus-visible::-webkit-slider-thumb {
  box-shadow: var(--focus);
}
.ctl-range:focus-visible::-moz-range-thumb {
  box-shadow: var(--focus);
}
.ctl-range:disabled {
  cursor: not-allowed;
}

/* Number field */
.ctl-number {
  align-items: center;
  gap: 0;
  height: 30px;
  border-radius: var(--r-s);
  background: var(--panel2);
  border: 1px solid var(--line-soft);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ctl-number:hover {
  border-color: var(--line);
}
.ctl-number:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ctl-num-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 100%;
  padding-left: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}
.ctl-num-label:hover {
  color: var(--accent);
}
.ctl-number .ctl-num-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 0;
  height: 100%;
  padding: 0 8px 0 6px;
  border: 0;
  background: transparent;
  box-shadow: none !important;
  font-size: 12px;
}

/* Switch */
.ctl-toggle {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}
.ctl-toggle .ctl-label {
  cursor: pointer;
}
.ctl-switch {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 20px;
  background: var(--panel2);
  border: 1px solid var(--line);
  transition: background var(--t), border-color var(--t);
}
.ctl-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--t) var(--spring), background var(--t);
}
.ctl-switch.on {
  background: var(--accent);
  border-color: var(--accent);
}
.ctl-switch.on .knob {
  transform: translateX(14px);
  background: var(--ink);
}
.ctl-switch:not(.on):hover {
  border-color: var(--muted);
}
.ctl-switch:not(.on):hover .knob {
  background: var(--text);
}
.ctl-switch.on:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--text));
}
.ctl-switch.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.ctl-switch.sm {
  width: 28px;
  height: 16px;
}
.ctl-switch.sm .knob {
  width: 10px;
  height: 10px;
}
.ctl-switch.sm.on .knob {
  transform: translateX(12px);
}

/* Segmented */
.ctl-seg {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  gap: 2px;
  border-radius: var(--r-s);
  background: var(--panel2);
  border: 1px solid var(--line-soft);
}
.ctl-seg.full {
  display: flex;
  width: 100%;
}
.ctl-seg.full .seg {
  flex: 1;
}
.ctl-seg .seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 30px;
  height: 24px;
  padding: 0 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast);
}
.ctl-seg .seg:hover {
  color: var(--text);
  background: var(--hover);
}
.ctl-seg .seg.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow), inset 0 0 0 1px var(--line-soft);
}
.ctl-seg .seg.on:focus-visible {
  box-shadow: var(--focus);
}
.ctl-seg.sm .seg {
  height: 22px;
  min-width: 24px;
  padding: 0 6px;
}
.ctl-seg .seg:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ctl-seg .seg:disabled:not(.on):hover {
  color: var(--muted);
  background: transparent;
}

.ctl-select {
  width: 100%;
  min-height: 30px;
  font-size: 12px;
}

/* Swatch */
.ctl-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-s);
  overflow: hidden;
  border: 1px solid var(--line);
  background: repeating-conic-gradient(#8a8a8a 0 25%, #cfcfcf 0 50%) 50% / 10px 10px;
  transition: transform var(--t-fast) var(--spring), box-shadow var(--t-fast);
}
.ctl-swatch .fill {
  position: absolute;
  inset: 0;
}
.ctl-swatch:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ctl-swatch.none .fill {
  background: linear-gradient(135deg, transparent 46%, var(--red) 46% 54%, transparent 54%) !important;
}
.ctl-swatch.sm {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

/* Field / row */
.ctl-field {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
.ctl-field-body {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ctl-field-body > * {
  min-width: 0;
}
.ctl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ctl-row > .ctl-number {
  flex: 1;
}

/* Inspector section */
.sec {
  border-top: 1px solid var(--line-soft);
  padding: 4px 14px 12px;
}
.sec:first-child {
  border-top: 0;
}
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
}
.sec-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  height: 32px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: left;
}
.sec-chev {
  color: var(--faint);
  transition: transform var(--t) var(--ease), color var(--t-fast);
}
.sec .sec-title:hover span,
.sec-title:hover .sec-chev {
  color: var(--text);
}
.sec.closed .sec-chev {
  transform: rotate(-90deg);
}
.sec-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sec-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.sec.closed .sec-body {
  display: none;
}
.sec.off .sec-title span {
  color: var(--muted);
}
.sec.closed {
  padding-bottom: 4px;
}
