:root {
  color-scheme: dark;
  --studio-black: #0c0b10;
  --studio-panel: #131217;
  --studio-raised: #19181e;
  --studio-inset: #0f0e13;
  --studio-line: rgba(255, 255, 255, 0.09);
  --studio-line-strong: rgba(255, 255, 255, 0.17);
  --ink: #f7f5fa;
  --ink-secondary: #aaa6b2;
  --ink-muted: #716d79;
  --signal: #a970ff;
  --signal-hot: #c29aff;
  --success: #52e0b4;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--studio-black); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 14%, rgba(169, 112, 255, 0.07), transparent 26rem),
    var(--studio-black);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--studio-line);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--signal); }
.brand-mark svg { width: 19px; fill: none; stroke: white; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-tag { padding: 3px 6px; border: 1px solid var(--studio-line-strong); border-radius: 5px; color: var(--ink-muted); font-size: 10px; letter-spacing: .08em; }
.status { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); font-size: 12px; }
.status > span { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(82, 224, 180, .09); }

.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 364px minmax(0, 1fr); }
.editor { padding: 32px 28px; border-right: 1px solid var(--studio-line); background: rgba(19, 18, 23, .68); }
.section-heading, .preview-heading { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 6px; color: var(--signal-hot); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.035em; text-wrap: balance; }
h1 { font-size: 24px; line-height: 1.15; }
h2 { font-size: 21px; }
.icon-button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border: 1px solid var(--studio-line); border-radius: 10px; background: var(--studio-raised); cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: var(--ink-secondary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { border-color: var(--studio-line-strong); background: #1e1d24; }
.icon-button:active, .download-button:active { transform: scale(.97); }

#controls { margin-top: 32px; display: grid; gap: 24px; }
.field { display: grid; gap: 9px; }
.field-label { display: flex; justify-content: space-between; color: var(--ink-secondary); font-size: 12px; font-weight: 600; }
.field-label span:last-child { color: var(--ink-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.input-wrap { position: relative; }
.at { position: absolute; z-index: 1; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); font-weight: 600; }
input[type="text"], textarea {
  width: 100%; border: 1px solid var(--studio-line); border-radius: var(--radius-sm); outline: none;
  color: var(--ink); background: var(--studio-inset); font-size: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input[type="text"] { height: 44px; padding: 0 14px 0 36px; }
textarea { min-height: 118px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
input[type="text"]:focus, textarea:focus { border-color: rgba(169, 112, 255, .7); box-shadow: 0 0 0 3px rgba(169, 112, 255, .12); }

.color-row { display: flex; align-items: center; gap: 10px; }
.swatch, .custom-color { width: 32px; height: 32px; border-radius: 9px; }
.swatch { position: relative; padding: 0; border: 0; background: var(--swatch); cursor: pointer; }
.swatch::after { content: ""; position: absolute; inset: -4px; border: 1px solid transparent; border-radius: 12px; }
.swatch.active::after { border-color: rgba(255, 255, 255, .7); }
.swatch:hover { transform: translateY(-1px); }
.custom-color { position: relative; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--studio-line-strong); cursor: pointer; }
.custom-color input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.custom-color svg { width: 15px; fill: none; stroke: var(--ink-secondary); stroke-width: 1.8; stroke-linecap: round; }

.advanced { border-top: 1px solid var(--studio-line); }
.advanced summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; list-style: none; color: var(--ink-secondary); font-size: 13px; font-weight: 600; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform 160ms ease; }
.advanced[open] summary svg { transform: rotate(180deg); }
.advanced-body { display: grid; gap: 20px; padding: 4px 0 8px; }
.range-field { display: grid; gap: 10px; }
.range-field > span { display: flex; justify-content: space-between; color: var(--ink-secondary); font-size: 12px; }
.range-field output { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 4px; appearance: none; border-radius: 2px; background: #2a2830; accent-color: var(--signal); }
input[type="range"]::-webkit-slider-thumb { width: 16px; height: 16px; appearance: none; border: 3px solid var(--studio-panel); border-radius: 50%; background: var(--signal-hot); box-shadow: 0 0 0 1px rgba(255,255,255,.14); cursor: pointer; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--studio-inset); border: 1px solid var(--studio-line); }
.segmented button { min-height: 34px; border: 0; border-radius: 7px; color: var(--ink-muted); background: transparent; font-size: 12px; cursor: pointer; }
.segmented button.active { color: var(--ink); background: #27252d; box-shadow: 0 1px 2px rgba(0,0,0,.3); }

.stage-panel { min-width: 0; display: flex; flex-direction: column; padding: 32px 40px 28px; }
.preview-heading { margin-bottom: 24px; }
.dimensions { padding: 7px 10px; border: 1px solid var(--studio-line); border-radius: 7px; color: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dimensions span { color: var(--ink-secondary); }
.stage {
  position: relative; flex: 1; min-height: 420px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid var(--studio-line); border-radius: var(--radius-lg); background-color: #17161b;
}
.stage-grid { position: absolute; inset: 0; opacity: .28; background-image: linear-gradient(45deg,#232127 25%,transparent 25%),linear-gradient(-45deg,#232127 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#232127 75%),linear-gradient(-45deg,transparent 75%,#232127 75%); background-position: 0 0,0 8px,8px -8px,-8px 0; background-size: 16px 16px; }
#previewCanvas { position: relative; z-index: 1; display: block; max-width: min(84%, 980px); max-height: 72%; width: auto; height: auto; filter: drop-shadow(0 14px 28px rgba(0,0,0,.28)); }
.corner { position: absolute; width: 18px; height: 18px; opacity: .45; }
.corner-tl { top: 18px; left: 18px; border-top: 1px solid var(--ink-muted); border-left: 1px solid var(--ink-muted); }
.corner-tr { top: 18px; right: 18px; border-top: 1px solid var(--ink-muted); border-right: 1px solid var(--ink-muted); }
.corner-bl { bottom: 18px; left: 18px; border-bottom: 1px solid var(--ink-muted); border-left: 1px solid var(--ink-muted); }
.corner-br { bottom: 18px; right: 18px; border-bottom: 1px solid var(--ink-muted); border-right: 1px solid var(--ink-muted); }

.export-bar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 22px; }
.export-note { display: flex; align-items: center; gap: 12px; }
.export-note > svg { width: 20px; fill: none; stroke: var(--ink-secondary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.export-note div { display: grid; gap: 3px; }
.export-note strong { font-size: 13px; }
.export-note span { color: var(--ink-muted); font-size: 11px; }
.export-actions { display: flex; align-items: center; gap: 8px; }
.scale-select select { height: 44px; padding: 0 30px 0 12px; border: 1px solid var(--studio-line); border-radius: 9px; color: var(--ink-secondary); background: var(--studio-raised); font-size: 12px; outline: none; }
.download-button { height: 44px; display: flex; align-items: center; gap: 18px; padding: 0 16px 0 18px; border: 0; border-radius: 9px; background: var(--signal); color: white; font-size: 13px; font-weight: 700; cursor: pointer; transition: background-color 150ms ease, transform 120ms ease; }
.download-button:hover { background: #b680ff; }
.download-button:focus-visible, .icon-button:focus-visible, .swatch:focus-visible, .segmented button:focus-visible { outline: 2px solid var(--signal-hot); outline-offset: 2px; }
.download-button svg { width: 17px; fill: none; stroke: white; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 24px; display: flex; align-items: center; gap: 9px; padding: 11px 16px; border: 1px solid var(--studio-line-strong); border-radius: 10px; background: #24222a; box-shadow: 0 12px 30px rgba(0,0,0,.35); font-size: 13px; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 180ms ease, transform 180ms cubic-bezier(.23,1,.32,1); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast span { color: var(--success); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .editor { padding: 28px 22px; }
  .stage-panel { padding: 28px 24px 24px; }
  .export-bar { align-items: flex-end; }
  .export-note span { display: none; }
}

@media (max-width: 720px) {
  .topbar { height: 56px; padding: 0 18px; }
  .status { display: none; }
  .workspace { display: flex; min-height: auto; flex-direction: column; }
  .editor { padding: 24px 18px; border-right: 0; border-bottom: 1px solid var(--studio-line); }
  #controls { margin-top: 24px; }
  .stage-panel { padding: 24px 18px; }
  .stage { min-height: 340px; }
  #previewCanvas { max-width: 90%; }
  .export-bar { align-items: stretch; flex-direction: column; gap: 16px; }
  .export-actions { width: 100%; }
  .download-button { flex: 1; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
