.cg-studio {
  --cg-surface: var(--surface, #fff);
  --cg-subtle: var(--surface-alt, #f1f5f9);
  --cg-border: var(--border, #e2e8f0);
  --cg-text: var(--text, #0f172a);
  --cg-muted: var(--muted, #475569);
  --cg-primary: #047857;
  --cg-primary-hover: #065f46;
  --cg-focus: var(--accent-2, #4f46e5);
  --cg-stage-height: clamp(280px, 34vw, 416px);
  width: 100%;
  min-width: 0;
  color: var(--cg-text);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.45;
  text-align: left;
}

.cg-studio *,
.cg-studio *::before,
.cg-studio *::after {
  box-sizing: border-box;
}

.cg-studio p {
  margin: 0;
}

.cg-studio [hidden] {
  display: none !important;
}

.cg-studio :is(button, input, select) {
  font: inherit;
}

.cg-studio :is(button, input, select, canvas):focus-visible,
.cg-studio:focus-visible {
  outline: 2px solid var(--cg-focus);
  outline-offset: 2px;
}

.cg-studio .cg-muted {
  color: var(--cg-muted);
  font-size: 12px;
}

.cg-studio .cg-source,
.cg-studio .cg-workbench {
  border: 1px solid var(--cg-border);
  border-radius: 12px;
  background: var(--cg-surface);
  box-shadow: 0 1px 2px rgb(15 23 42 / 6%);
}

.cg-studio .cg-source {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.cg-studio .cg-upload,
.cg-studio .cg-demos {
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.cg-studio .cg-upload {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
}

.cg-studio .cg-demos {
  display: flex;
  flex-wrap: wrap;
}

.cg-studio .cg-limits {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.cg-studio .cg-demos > span {
  margin-inline-end: 2px;
  font-weight: 600;
}

.cg-studio .cg-button,
.cg-studio .cg-tabs button,
.cg-studio select {
  max-width: 100%;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid var(--cg-border);
  border-radius: 8px;
  background: var(--cg-surface);
  color: var(--cg-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.cg-studio :is(.cg-button, .cg-tabs button, select):hover:not(:disabled) {
  border-color: #aab7c7;
  background: var(--cg-subtle);
}

.cg-studio :is(button, select, input):disabled {
  cursor: default;
  opacity: .53;
}

.cg-studio .cg-upload-button {
  min-height: 44px;
  padding-inline: 15px;
  border-color: var(--cg-text);
  background: var(--cg-text);
  color: var(--cg-surface);
  font-size: 14px;
}

.cg-studio .cg-upload-button:hover:not(:disabled) {
  border-color: #334155;
  background: #334155;
}

.cg-studio .cg-demo {
  position: relative;
  padding-inline: 9px;
  border-radius: 999px;
}

.cg-studio :is(.cg-demo[data-recommended], .cg-button[aria-pressed="true"]) {
  border-color: #a5b4fc;
  background: #eef2ff;
  color: #3730a3;
}

.cg-studio[data-dragging] .cg-source {
  border-color: var(--cg-focus);
  background: #eef2ff;
}

.cg-studio .cg-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef2ff;
  color: #312e81;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.cg-studio .cg-status:empty {
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}

.cg-studio .cg-status[data-tone="error"] {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.cg-studio .cg-status[data-tone="success"] {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.cg-studio .cg-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.63fr) minmax(0, 1fr);
}

.cg-studio .cg-stage,
.cg-studio .cg-inspector {
  min-width: 0;
  padding: 16px;
}

.cg-studio .cg-inspector {
  border-inline-start: 1px solid var(--cg-border);
}

.cg-studio .cg-stage-toolbar,
.cg-studio .cg-stage-details,
.cg-studio .cg-point-actions,
.cg-studio .cg-quick,
.cg-studio .cg-playback,
.cg-studio .cg-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cg-studio .cg-stage-toolbar,
.cg-studio .cg-stage-details,
.cg-studio .cg-point-actions {
  justify-content: space-between;
}

.cg-studio .cg-stage-toolbar {
  margin-bottom: 12px;
}

.cg-studio .cg-backdrop {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--cg-muted);
  font-size: 12px;
  font-weight: 600;
}

.cg-studio select {
  padding-inline: 8px;
  text-align: start;
}

.cg-studio .cg-viewport {
  position: relative;
  display: grid;
  min-height: var(--cg-stage-height);
  padding: 12px;
  place-items: center;
  border: 1px solid var(--cg-border);
  border-radius: 8px;
  background: #fff;
}

.cg-studio .cg-viewport[data-backdrop-style="checker"] {
  background: conic-gradient(#e4e9ef 25%, #f7f9fc 0 50%, #e4e9ef 0 75%, #f7f9fc 0) top left / 20px 20px;
}

.cg-studio .cg-viewport[data-backdrop-style="discord"] {
  border-color: #313338;
  background: #313338;
}

.cg-studio .cg-viewport[data-backdrop-style="dark"] {
  border-color: #111827;
  background: #111827;
}

.cg-studio[data-dragging] .cg-viewport {
  box-shadow: inset 0 0 0 2px var(--cg-focus);
}

.cg-studio .cg-empty,
.cg-studio .cg-original {
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--cg-border);
  border-radius: 8px;
  background: var(--cg-surface);
  color: var(--cg-muted);
  font-weight: 600;
  text-align: center;
}

.cg-studio .cg-original {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 4px 8px;
  font-size: 12px;
  pointer-events: none;
}

.cg-studio .cg-image {
  position: relative;
  width: min(100%, var(--cg-image-width, 360px), calc(var(--cg-image-ratio, 1) * (var(--cg-stage-height) - 26px)));
  aspect-ratio: var(--cg-image-ratio, 1);
}

.cg-studio canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.cg-studio .cg-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cg-studio .cg-pin,
.cg-studio .cg-cursor {
  position: absolute;
  top: var(--cg-pin-y);
  left: var(--cg-pin-x);
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #312e81;
}

.cg-studio .cg-pin {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-content: center;
  background: #4338ca;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.cg-studio .cg-pin:hover {
  background: #312e81;
}

.cg-studio .cg-cursor {
  display: none;
  width: 16px;
  height: 16px;
  background: transparent;
  pointer-events: none;
}

.cg-studio canvas:focus-visible ~ .cg-cursor {
  display: block;
}

.cg-studio .cg-stage-details {
  min-height: 44px;
  padding-block: 4px;
}

.cg-studio .cg-hint {
  flex: 1 1 200px;
}

.cg-studio .cg-check {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.cg-studio input:is([type="checkbox"], [type="range"]) {
  min-width: 0;
  margin: 0;
  accent-color: var(--cg-focus);
  cursor: pointer;
}

.cg-studio input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.cg-studio .cg-pin-toggle {
  font-size: 12px;
  white-space: nowrap;
}

.cg-studio .cg-playback {
  align-items: end;
}

.cg-studio .cg-transport button {
  min-width: 36px;
}

.cg-studio .cg-play {
  min-width: 65px;
}

.cg-studio :is([data-prev], [data-next]) {
  font-size: 20px;
}

.cg-studio .cg-scrub {
  display: grid;
  min-width: 0;
  flex: 1 1 104px;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cg-studio input[type="range"] {
  width: 100%;
  height: 20px;
}

.cg-studio .cg-file-info {
  margin-top: 10px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.cg-studio .cg-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--cg-subtle);
}

.cg-studio .cg-tabs button {
  min-width: 0;
  padding-inline: 4px;
  border-color: transparent;
  background: transparent;
  overflow-wrap: anywhere;
}

.cg-studio .cg-tabs [aria-selected="true"] {
  border-color: var(--cg-border);
  background: var(--cg-surface);
  color: #3730a3;
  box-shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

.cg-studio .cg-mode-panel,
.cg-studio .cg-refine,
.cg-studio .cg-export {
  display: grid;
  gap: 8px;
}

.cg-studio .cg-mode-panel {
  min-height: 98px;
  align-content: start;
  padding-block: 12px;
}

.cg-studio .cg-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cg-studio .cg-swatches:empty {
  display: none;
}

.cg-studio .cg-swatch {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.cg-studio .cg-swatch i {
  width: 13px;
  height: 13px;
  border: 1px solid rgb(15 23 42 / 25%);
  border-radius: 4px;
}

.cg-studio .cg-link-button {
  border-color: transparent;
  color: #4338ca;
}

.cg-studio .cg-refine {
  padding-block: 12px;
  border-top: 1px solid var(--cg-border);
  border-bottom: 1px solid var(--cg-border);
}

.cg-studio .cg-range {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 8px;
  font-size: 13px;
  font-weight: 600;
}

.cg-studio .cg-range input {
  grid-column: 1 / -1;
}

.cg-studio .cg-range output {
  color: var(--cg-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.cg-studio .cg-export {
  padding-top: 12px;
}

.cg-studio .cg-primary,
.cg-studio .cg-secondary {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}

.cg-studio .cg-primary {
  border-color: var(--cg-primary);
  background: var(--cg-primary);
  color: #fff;
}

.cg-studio .cg-primary:hover:not(:disabled) {
  border-color: var(--cg-primary-hover);
  background: var(--cg-primary-hover);
}

.cg-studio .cg-progress {
  display: grid;
  gap: 4px;
  color: var(--cg-muted);
  font-size: 12px;
}

.cg-studio .cg-progress progress {
  width: 100%;
  accent-color: var(--cg-primary);
}

.cg-studio .cg-privacy {
  text-wrap: pretty;
}

@media (max-width: 820px) {
  .cg-studio {
    --cg-stage-height: clamp(236px, 65vw, 360px);
  }

  .cg-studio .cg-workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .cg-studio .cg-inspector {
    border-top: 1px solid var(--cg-border);
    border-inline-start: 0;
  }

  .cg-studio :is(.cg-button, .cg-tabs button, select) {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .cg-studio :is(.cg-stage, .cg-inspector) {
    padding: 12px;
  }

  .cg-studio .cg-stage-details {
    gap: 0;
  }

  .cg-studio .cg-scrub {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cg-studio .cg-source,
  .cg-studio :is(.cg-button, .cg-tabs button, select) {
    transition: none;
  }
}