.studio-layout {
  display: grid;
  grid-template-columns: minmax(290px, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
  gap: clamp(24px, 4vw, 64px);
}

.studio-controls {
  min-width: 0;
  padding: clamp(22px, 3vw, 36px);
  border: 1px solid var(--line, #40364e);
  border-radius: var(--radius, 24px);
  background: var(--panel, #211b31);
  color: var(--ink, #f4eddc);
}

.studio-control-heading {
  margin-bottom: 30px;
}

.studio-control-heading h2 {
  margin: 10px 0 12px;
  font: 400 clamp(32px, 3.5vw, 48px) / 1.08 Georgia, serif;
  letter-spacing: -0.04em;
}

.studio-control-heading p {
  margin: 0;
  max-width: 35ch;
  color: var(--muted, #bdb5cf);
  font-size: 15px;
  line-height: 1.6;
}

.studio-field {
  display: block;
  min-width: 0;
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}

.studio-field > label,
.studio-field legend,
.studio-label-row label {
  display: block;
  margin-bottom: 10px;
  padding: 0;
  color: var(--ink, #f4eddc);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
}

.studio-field select,
.studio-field textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line, #40364e);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--bg, #161322);
  color: var(--ink, #f4eddc);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  color-scheme: dark;
}

.studio-field select {
  padding-right: 28px;
}

.studio-field textarea {
  min-height: 104px;
  resize: vertical;
}

.studio-field textarea::placeholder {
  color: var(--muted, #bdb5cf);
  opacity: 0.75;
}

.studio-field select:focus-visible,
.studio-field textarea:focus-visible,
.studio-actions button:focus-visible {
  outline: 2px solid var(--accent, #d7f57b);
  outline-offset: 3px;
}

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

.studio-segments label,
.studio-swatch {
  position: relative;
  cursor: pointer;
}

.studio-segments input,
.studio-swatch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
}

.studio-segments span {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid var(--line, #40364e);
  border-radius: 10px;
  padding: 10px 4px;
  color: var(--muted, #bdb5cf);
  font-size: 13px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.studio-segments input:checked + span {
  border-color: var(--accent, #d7f57b);
  background: var(--accent, #d7f57b);
  color: #211b31;
}

.studio-segments input:focus-visible + span,
.studio-swatch input:focus-visible + span {
  outline: 2px solid var(--ink, #f4eddc);
  outline-offset: 4px;
}

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

.studio-swatch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 80px;
  padding: 5px 3px;
  color: var(--muted, #bdb5cf);
  font-size: 11px;
  line-height: 1.4;
}

.studio-swatch-dot {
  display: block;
  box-sizing: border-box;
  width: 38px;
  height: 38px;
  border: 3px solid transparent;
  border-radius: 50%;
  background-clip: padding-box;
}

.studio-swatch-cream { background-color: #f3ebda; }
.studio-swatch-lilac { background-color: #d6c1f0; }
.studio-swatch-lime { background-color: #d7f57b; }

.studio-swatch input:checked + .studio-swatch-dot {
  box-shadow: 0 0 0 2px var(--panel, #211b31), 0 0 0 4px var(--accent, #d7f57b);
}

.studio-swatch input:checked ~ span:last-child {
  color: var(--ink, #f4eddc);
}

.studio-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.studio-label-row label span {
  color: var(--muted, #bdb5cf);
  font-weight: 400;
}

.studio-label-row output {
  flex-shrink: 0;
  color: var(--muted, #bdb5cf);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.studio-help,
.studio-storage-note,
.studio-export-status,
.studio-preview-tip {
  margin: 10px 0 0;
  color: var(--muted, #bdb5cf);
  font-size: 12px;
  line-height: 1.6;
}

.studio-actions {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.studio-actions .button {
  min-height: 48px;
}

.studio-actions .button-primary {
  flex: 1 1 150px;
}

.studio-actions .button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.studio-storage-note {
  margin-top: 16px;
}

.studio-export-status {
  color: var(--accent, #d7f57b);
}

.studio-export-status:empty {
  display: none;
}

.studio-status-warning {
  color: var(--peach, #ffbb84);
}

.studio-preview {
  position: sticky;
  top: 100px;
  min-width: 0;
}

.studio-preview-top,
.studio-preview-bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  color: var(--muted, #bdb5cf);
  font-size: 11px;
  line-height: 1.5;
}

.studio-preview-top {
  margin: 4px 0 16px;
}

.studio-preview-top > :last-child {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.studio-canvas-stage {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  min-height: 260px;
  border: 1px solid var(--line, #40364e);
  border-radius: var(--radius, 24px);
  padding: clamp(16px, 3.1vw, 40px);
  background:
    radial-gradient(ellipse at 15% 10%, rgba(170, 133, 235, 0.08), transparent 65%),
    #1b1728;
}

.studio-canvas-stage canvas {
  display: block;
  width: 100%;
  max-width: 540px;
  height: auto;
  max-height: 730px;
  object-fit: contain;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.23);
}

.studio-canvas-stage canvas[hidden],
.studio-preview-message[hidden] {
  display: none;
}

.studio-preview-message {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 540px;
  aspect-ratio: var(--studio-aspect, 4 / 5);
  margin: 0;
  padding: 24px;
  box-sizing: border-box;
  color: var(--muted, #bdb5cf);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.studio-preview-bottom {
  margin-top: 16px;
  flex-wrap: wrap;
}

.studio-preview-bottom > :first-child {
  color: var(--ink, #f4eddc);
}

.studio-preview-tip {
  margin-top: 12px;
}

.studio-empty {
  padding: 28px;
  border: 1px solid var(--line, #40364e);
  border-radius: var(--radius, 24px);
  background: var(--panel, #211b31);
  color: var(--muted, #bdb5cf);
  line-height: 1.6;
}

@media (max-width: 800px) {
  .studio-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .studio-preview {
    position: static;
  }

  .studio-controls {
    padding: 22px;
  }

  .studio-canvas-stage canvas {
    max-width: 440px;
  }
}

@media (max-width: 380px) {
  .studio-controls {
    padding: 18px;
  }

  .studio-segments {
    gap: 5px;
  }

  .studio-segments span {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .studio-segments span {
    transition: none;
  }
}
