* {
  box-sizing: border-box;
}

:root {
  --ink: #261c30;
  --muted: #756b7d;
  --muted-2: #9b92a2;
  --line: #e9dfea;
  --line-strong: #d8c9dc;
  --surface: #ffffff;
  --surface-soft: #faf7fc;
  --surface-tint: #f6effb;
  --purple: #7a3df0;
  --purple-dark: #472080;
  --purple-soft: #ede5ff;
  --pink: #ff3fa4;
  --pink-soft: #ffe4f2;
  --success: #15966d;
  --danger: #c43b62;
  --warning: #ad7000;
  --shadow: 0 18px 50px rgba(52, 28, 68, 0.11);
  --soft-shadow: 0 8px 24px rgba(52, 28, 68, 0.08);
  --radius: 20px;
  --header-height: 70px;
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f8f5fa;
}

html {
  min-height: 100%;
  background: #f8f5fa;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 5% 5%, rgba(255, 63, 164, 0.08), transparent 26rem),
    radial-gradient(circle at 94% 10%, rgba(122, 61, 240, 0.08), transparent 27rem),
    #f8f5fa;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(122, 61, 240, 0.26);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  min-height: var(--header-height);
  padding: 10px clamp(14px, 2vw, 30px);
  border-bottom: 1px solid rgba(224, 213, 227, 0.92);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  box-shadow: 0 9px 22px rgba(112, 54, 204, 0.25);
  font-family: "Fredoka", sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: "Fredoka", sans-serif;
  font-size: 20px;
  line-height: 1.05;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
}

.header-label,
.header-dimensions,
.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.header-label {
  color: var(--purple-dark);
  background: var(--purple-soft);
}

.header-dimensions {
  color: var(--muted);
  background: #f1edf3;
}

.status-pill {
  color: #11684d;
  background: #ddf8ef;
}

.status-pill[data-state="error"] {
  color: #8a2142;
  background: #ffe1ea;
}

.status-pill[data-state="working"],
.status-pill[data-state="loading"] {
  color: #4a3281;
  background: #eee8ff;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.button,
.compact-action,
.action-card,
.shape-card,
.segment,
.icon-button,
.rail-button,
.layer-icon-button,
.asset-card {
  border: 0;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    opacity 0.16s ease;
}

.button {
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 900;
}

.button:hover:not(:disabled),
.compact-action:hover:not(:disabled),
.action-card:hover:not(:disabled),
.shape-card:hover:not(:disabled),
.segment:hover:not(:disabled),
.rail-button:hover:not(:disabled),
.asset-card:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), #8f48ed);
  box-shadow: 0 10px 22px rgba(94, 42, 176, 0.22);
}

.button-ghost {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.button-soft {
  width: 100%;
  color: var(--purple-dark);
  border: 1px solid #ded0e7;
  background: #faf6ff;
}

.button-danger {
  color: #a2254a;
  border: 1px solid #f0bfd0;
  background: #fff0f5;
}

.full-button {
  width: 100%;
}

.editor-shell {
  display: grid;
  grid-template-columns: 74px 310px minmax(0, 1fr);
  align-items: start;
  width: 100%;
  min-height: calc(100vh - var(--header-height));
}

.editor-shell.drawer-collapsed {
  grid-template-columns: 74px minmax(0, 1fr);
}

.editor-shell.drawer-collapsed .workspace {
  grid-column: 2;
}

.tool-rail {
  position: sticky;
  top: var(--header-height);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  height: calc(100vh - var(--header-height));
  padding: 12px 8px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.rail-group {
  display: grid;
  gap: 7px;
}

.rail-actions {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.rail-button {
  position: relative;
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  padding: 7px 4px;
  border: 1px solid transparent;
  border-radius: 15px;
  color: #665d70;
  background: transparent;
}

.rail-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-button span:last-child {
  max-width: 64px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-symbol {
  font-size: 24px;
  line-height: 1;
}

.rail-button:hover {
  color: var(--purple);
  background: var(--surface-tint);
}

.rail-button.is-active {
  color: #fff;
  background: linear-gradient(145deg, var(--purple), #9850e9);
  box-shadow: 0 11px 22px rgba(100, 47, 183, 0.25);
}

.rail-button:disabled {
  opacity: 0.35;
  transform: none;
}

.tool-drawer {
  position: sticky;
  top: var(--header-height);
  z-index: 45;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: calc(100vh - var(--header-height));
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 12px 0 35px rgba(48, 26, 62, 0.035);
}

.tool-drawer.is-collapsed {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 71px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--purple);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.13em;
}

.drawer-header h2 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 24px;
  line-height: 1;
}

.drawer-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tool-panel {
  display: none;
  padding: 18px;
}

.tool-panel.is-active {
  display: block;
}

.panel-intro {
  margin-bottom: 17px;
}

.panel-intro strong,
.panel-intro p {
  display: block;
}

.panel-intro strong {
  font-size: 14px;
}

.panel-intro p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.48;
}

.compact-intro {
  margin-bottom: 12px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 14px;
  background: #f1edf4;
}

.segment {
  min-height: 42px;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.segment.is-active {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 7px 15px rgba(31, 20, 37, 0.16);
}

.control-group {
  margin-top: 17px;
}

.control-group:first-child {
  margin-top: 0;
}

.control-group > label,
.control-label-row label {
  display: block;
  margin-bottom: 7px;
  color: #4d4156;
  font-size: 11px;
  font-weight: 900;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-label-row output {
  color: var(--purple);
  font-size: 11px;
  font-weight: 900;
}

.select-control,
.text-control {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
}

.select-control {
  min-height: 43px;
  padding: 8px 11px;
}

.text-control {
  padding: 11px 12px;
}

.text-area {
  resize: vertical;
  min-height: 84px;
}

.font-select {
  font-family: "Fredoka", sans-serif;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--purple);
}

.two-column-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.stacked-actions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-card {
  display: grid;
  min-height: 68px;
  place-items: center;
  gap: 4px;
  padding: 10px 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 850;
  text-align: center;
}

.action-card > span {
  color: var(--purple);
  font-size: 20px;
  line-height: 1;
}

.action-danger {
  color: #a52d50;
  border-color: #efc3d2;
  background: #fff2f6;
}

.action-danger > span {
  color: var(--danger);
}

.tip-card {
  display: grid;
  gap: 4px;
  margin-top: 17px;
  padding: 13px;
  border: 1px solid #ddd0f7;
  border-radius: 14px;
  color: #50366f;
  background: #f5f0ff;
  font-size: 11px;
  line-height: 1.45;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.shape-card {
  display: grid;
  min-height: 94px;
  place-items: center;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 850;
}

.shape-preview {
  display: block;
  color: var(--pink);
}

.shape-rect {
  width: 42px;
  height: 29px;
  border-radius: 5px;
  background: currentColor;
}

.shape-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: currentColor;
}

.shape-triangle {
  width: 0;
  height: 0;
  border-right: 22px solid transparent;
  border-bottom: 38px solid currentColor;
  border-left: 22px solid transparent;
}

.shape-diamond {
  width: 31px;
  height: 31px;
  background: currentColor;
  transform: rotate(45deg);
}

.shape-star,
.shape-heart {
  font-size: 42px;
  line-height: 1;
}

.shape-line {
  width: 48px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-18deg);
}

.color-dock {
  display: none;
  margin: 0 18px 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, #fff, #fbf7ff);
}

.tool-drawer[data-active-panel="draw"] .color-dock,
.tool-drawer[data-active-panel="fill"] .color-dock,
.tool-drawer[data-active-panel="text"] .color-dock,
.tool-drawer[data-active-panel="shapes"] .color-dock,
.tool-drawer[data-active-panel="select"] .color-dock {
  display: block;
}

.color-dock-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.color-dock-heading span,
.color-dock-heading strong {
  display: block;
}

.color-dock-heading span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.color-dock-heading strong {
  margin-top: 2px;
  font-size: 12px;
}

.color-dock input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #d8ccd9;
}

.swatch.is-active {
  box-shadow:
    0 0 0 3px var(--purple),
    0 6px 13px rgba(62, 30, 84, 0.15);
}

.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.subtle-danger {
  width: 100%;
  min-height: 39px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: calc(100vh - 250px);
  padding: 1px 4px 3px 1px;
  overflow-y: auto;
}

.asset-card {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.asset-card img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 76px;
  max-height: 76px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 5px 8px rgba(49, 24, 66, 0.14));
}

.asset-message {
  grid-column: 1 / -1;
  display: grid;
  min-height: 118px;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.asset-message[data-state="error"] {
  color: var(--danger);
  border-color: rgba(189, 49, 87, 0.3);
  background: #fff1f5;
}

.asset-grid[aria-busy="true"] {
  opacity: 0.72;
}

.asset-retry-button {
  min-height: 36px;
  margin-top: 10px;
  padding: 8px 13px;
  border: 1px solid rgba(189, 49, 87, 0.24);
  border-radius: 999px;
  color: #9b274b;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
}

.upload-box {
  display: grid;
  place-items: center;
  padding: 22px 16px;
  border: 2px dashed #d8c5e3;
  border-radius: 18px;
  background: linear-gradient(145deg, #fff, #faf4ff);
  text-align: center;
}

.upload-box strong {
  margin-top: 11px;
  font-size: 14px;
}

.upload-box p {
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.upload-illustration {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--pink), var(--purple));
  box-shadow: 0 13px 25px rgba(113, 48, 185, 0.23);
  font-family: "Fredoka", sans-serif;
  font-size: 19px;
  font-weight: 700;
}

.mini-checklist {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
}

.mini-checklist strong {
  color: var(--ink);
}

.mini-checklist input {
  accent-color: var(--success);
}

.layers-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.layers-toolbar strong,
.layers-toolbar span {
  display: block;
}

.layers-toolbar strong {
  font-size: 14px;
}

.layers-toolbar > div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.drag-legend {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 850;
}

.layer-opacity-control {
  margin-bottom: 13px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.layers-list {
  display: grid;
  gap: 7px;
}

.layers-empty {
  padding: 24px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  text-align: center;
}

.layer-row {
  display: grid;
  grid-template-columns: 22px 33px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(53, 28, 67, 0.035);
}

.layer-row[draggable="true"] {
  cursor: grab;
}

.layer-row.is-dragging {
  opacity: 0.42;
}

.layer-row.is-selected {
  border-color: #a77af7;
  background: #f4efff;
  box-shadow: 0 0 0 2px rgba(122, 61, 240, 0.09);
}

.layer-row.is-hidden {
  opacity: 0.55;
}

.layer-row.is-locked .layer-name::after {
  content: " · bloqueada";
  color: var(--muted);
  font-size: 9px;
}

.layer-handle {
  color: #b2a9b6;
  font-size: 17px;
  text-align: center;
}

.layer-thumb {
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border-radius: 9px;
  color: var(--purple);
  background: var(--purple-soft);
  font-size: 16px;
  font-weight: 900;
}

.layer-info {
  min-width: 0;
}

.layer-name,
.layer-type {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-name {
  font-size: 11px;
  font-weight: 900;
}

.layer-type {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.layer-actions {
  display: grid;
  grid-template-columns: repeat(2, 27px);
  gap: 3px;
}

.layer-icon-button {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: #665a6e;
  background: #f5f1f7;
  font-size: 12px;
}

.layer-icon-button:hover {
  color: var(--purple);
  background: var(--purple-soft);
}

.layer-icon-button.layer-delete:hover {
  color: var(--danger);
  background: #ffe6ee;
}

.layer-static {
  cursor: default;
  background: #f8f5fa;
}

.layers-help {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.workspace {
  min-width: 0;
  padding: clamp(12px, 1.5vw, 22px);
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.workspace-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--purple);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.13em;
}

.workspace-title strong {
  font-family: "Fredoka", sans-serif;
  font-size: 19px;
}

.workspace-actions {
  display: flex;
  gap: 7px;
}

.compact-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-size: 10px;
  font-weight: 900;
}

.mobile-drawer-button {
  display: none;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) var(--preview-panel-width, 275px);
  gap: clamp(12px, 1.4vw, 20px);
  align-items: start;
}

.editor-pane,
.preview-card {
  min-width: 0;
}

.canvas-card {
  padding: clamp(10px, 1.4vw, 18px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.canvas-stage {
  position: relative;
  width: min(100%, 790px);
  aspect-ratio: 585 / 559;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 15px;
  background:
    linear-gradient(45deg, #f1edf4 25%, transparent 25%),
    linear-gradient(-45deg, #f1edf4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1edf4 75%),
    linear-gradient(-45deg, transparent 75%, #f1edf4 75%),
    #fff;
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  box-shadow: inset 0 0 0 1px #ddd1df;
  touch-action: none;
}

.canvas-stage .canvas-container {
  width: 100% !important;
  height: 100% !important;
}

.canvas-stage canvas {
  width: 100% !important;
  height: 100% !important;
}

.template-guide {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.2s ease;
}

.drop-hint {
  position: absolute;
  inset: 16px;
  z-index: 12;
  display: grid;
  place-items: center;
  border: 3px dashed var(--pink);
  border-radius: 16px;
  color: var(--purple-dark);
  background: rgba(255, 245, 251, 0.9);
  font-size: clamp(18px, 3vw, 30px);
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.canvas-stage.is-dragging .drop-hint {
  opacity: 1;
}

.workspace-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
}

.preview-card {
  position: sticky;
  top: calc(var(--header-height) + 12px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--soft-shadow);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  min-height: 42px;
  padding: 0 3px 7px;
}

.preview-kicker {
  display: block;
  margin-bottom: 1px;
  color: var(--purple);
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.preview-header strong {
  font-size: 13px;
}

.preview-status {
  padding: 5px 7px;
  border-radius: 999px;
  color: #624691;
  background: #eee8ff;
  font-size: 8px;
  font-weight: 900;
  white-space: nowrap;
}

.preview-status[data-state="ready"] {
  color: #11684d;
  background: #ddf8ef;
}

.preview-status[data-state="error"] {
  color: #8a2142;
  background: #ffe1ea;
}

.preview-stage {
  position: relative;
  width: 100%;
  min-height: 330px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid #e1d6e6;
  border-radius: 15px;
  background:
    radial-gradient(circle at 50% 23%, rgba(255, 255, 255, 0.98), rgba(246, 236, 255, 0.92) 44%, rgba(235, 221, 247, 0.92)),
    #f5edfb;
  touch-action: none;
  user-select: none;
}

#avatar3dCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#avatar3dCanvas:active {
  cursor: grabbing;
}

.preview-loading,
.preview-fallback {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 20px;
  color: var(--purple-dark);
  background: rgba(249, 243, 253, 0.88);
  text-align: center;
}

.preview-loading[hidden],
.preview-fallback[hidden] {
  display: none !important;
}

.preview-fallback span {
  max-width: 220px;
  color: var(--muted);
  font-size: 10px;
}

.spinner {
  width: 27px;
  height: 27px;
  border: 3px solid rgba(111, 53, 216, 0.18);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: preview-spin 0.9s linear infinite;
}

@keyframes preview-spin {
  to { transform: rotate(360deg); }
}

.gesture-hint {
  position: absolute;
  left: 50%;
  bottom: 9px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid rgba(72, 38, 98, 0.12);
  border-radius: 999px;
  color: #5a3c73;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(58, 29, 77, 0.1);
  font-size: 8px;
  font-weight: 850;
  transform: translateX(-50%);
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.preview-actions .button {
  min-height: 37px;
  padding-inline: 8px;
  font-size: 9px;
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  color: var(--muted);
  font-size: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 120;
  min-width: 220px;
  max-width: calc(100% - 32px);
  padding: 12px 17px;
  border-radius: 999px;
  color: #fff;
  background: var(--purple-dark);
  box-shadow: 0 15px 35px rgba(36, 20, 46, 0.24);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1300px) {
  .editor-shell {
    grid-template-columns: 68px 285px minmax(0, 1fr);
  }

  .studio-grid {
    grid-template-columns: minmax(490px, 1fr) var(--preview-panel-width, 250px);
  }

  .preview-stage {
    min-height: 300px;
  }

  .header-center .header-label {
    display: none;
  }
}

@media (max-width: 1080px) {
  .studio-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-card {
    position: static;
    width: min(100%, 430px);
    justify-self: center;
  }

  .preview-stage {
    min-height: 280px;
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 860px) {
  :root {
    --header-height: 64px;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: var(--header-height);
    padding-inline: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 17px;
  }

  .brand small,
  .header-center,
  .header-actions .button-ghost {
    display: none;
  }

  .header-actions .button-primary {
    min-height: 40px;
    padding-inline: 11px;
  }

  .editor-shell,
  .editor-shell.drawer-collapsed {
    display: grid;
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .tool-rail {
    position: sticky;
    top: var(--header-height);
    z-index: 70;
    grid-row: 1;
    flex-direction: row;
    align-items: center;
    width: 100%;
    height: auto;
    padding: 7px 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 18px rgba(53, 29, 66, 0.05);
  }

  .rail-group {
    display: flex;
    gap: 5px;
  }

  .rail-actions {
    margin-left: auto;
    padding: 0 0 0 6px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .rail-button {
    flex: 0 0 52px;
    min-height: 50px;
    border-radius: 12px;
  }

  .rail-button span:last-child {
    font-size: 8px;
  }

  .tool-drawer {
    position: fixed;
    inset: auto 10px 10px;
    z-index: 100;
    width: auto;
    height: auto;
    max-height: min(72vh, 650px);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 28px 70px rgba(39, 21, 51, 0.28);
  }

  .drawer-header {
    min-height: 60px;
    border-radius: 22px 22px 0 0;
  }

  .drawer-scroll {
    max-height: calc(min(72vh, 650px) - 118px);
  }

  .drawer-close {
    display: grid;
  }

  .workspace,
  .editor-shell.drawer-collapsed .workspace {
    grid-column: 1;
    grid-row: 2;
    padding: 10px;
  }

  .mobile-drawer-button {
    display: inline-flex;
  }

  .workspace-help {
    flex-direction: column;
    gap: 3px;
  }

  .preview-card {
    width: min(100%, 520px);
  }

  .app-footer {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
}

@media (max-width: 520px) {
  .header-actions .button-primary span {
    display: none;
  }

  .workspace-toolbar {
    align-items: flex-end;
  }

  .workspace-title strong {
    font-size: 17px;
  }

  .compact-action {
    min-height: 42px;
    padding-inline: 10px;
  }

  .compact-action span:last-child {
    display: none;
  }

  .canvas-card {
    padding: 7px;
    border-radius: 17px;
  }

  .canvas-stage {
    border-radius: 12px;
  }

  .preview-stage {
    min-height: 250px;
  }

  .tool-panel {
    padding: 16px;
  }

  .color-dock {
    margin-inline: 16px;
  }

  .action-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-card {
    min-height: 65px;
  }

  .shape-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .shape-card {
    min-height: 86px;
    padding-inline: 5px;
  }

  .asset-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 42vh;
  }

  .layer-row {
    grid-template-columns: 19px 30px minmax(0, 1fr) auto;
    gap: 6px;
  }
}

@media (max-width: 390px) {
  .brand span:last-child {
    display: none;
  }

  .rail-button {
    flex-basis: 49px;
  }

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

  .two-column-controls {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* =========================================================
   V4.1 — Montserrat + painel 3D redimensionável
   ========================================================= */

body,
button,
input,
select,
textarea {
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  font-size: 14px;
  font-weight: 400;
}

.brand strong,
.drawer-header h2,
.workspace-title strong,
.upload-illustration {
  font-family: "Montserrat", system-ui, sans-serif;
}

.brand strong {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand small {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.header-label,
.header-dimensions,
.status-pill {
  font-size: 12px;
  font-weight: 500;
}

.button {
  font-size: 13px;
  font-weight: 600;
}

.rail-button span:last-child {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.drawer-kicker,
.workspace-kicker,
.preview-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.drawer-header h2 {
  font-size: 21px;
  font-weight: 600;
}

.panel-intro strong,
.layers-toolbar strong {
  font-size: 15px;
  font-weight: 600;
}

.panel-intro p {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

.segment {
  font-size: 13px;
  font-weight: 500;
}

.control-group > label,
.control-label-row label {
  font-size: 12px;
  font-weight: 500;
}

.control-label-row output {
  font-size: 12px;
  font-weight: 500;
}

.select-control,
.text-control {
  font-size: 13px;
  font-weight: 400;
}

.font-select {
  font-family: "Montserrat", system-ui, sans-serif;
}

.action-card {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}

.tip-card,
.upload-box p,
.mini-checklist,
.asset-message,
.layers-help {
  font-size: 12px;
  font-weight: 400;
}

.tip-card strong,
.upload-box strong,
.mini-checklist strong {
  font-weight: 600;
}

.shape-card {
  font-size: 11px;
  font-weight: 500;
}

.color-dock-heading span {
  font-size: 11px;
  font-weight: 400;
}

.color-dock-heading strong {
  font-size: 13px;
  font-weight: 500;
}

.asset-retry-button {
  font-size: 12px;
  font-weight: 500;
}

.layers-toolbar > div span,
.drag-legend {
  font-size: 11px;
  font-weight: 400;
}

.layer-name {
  font-size: 12px;
  font-weight: 500;
}

.layer-type {
  font-size: 10px;
  font-weight: 400;
}

.layer-row.is-locked .layer-name::after {
  font-size: 10px;
}

.workspace-title strong {
  font-size: 21px;
  font-weight: 600;
}

.compact-action {
  font-size: 11px;
  font-weight: 500;
}

.workspace-help {
  font-size: 11px;
  font-weight: 400;
}

.preview-header strong {
  font-size: 14px;
  font-weight: 600;
}

.preview-status,
.gesture-hint {
  font-size: 10px;
  font-weight: 500;
}

.preview-actions .button {
  font-size: 10px;
  font-weight: 500;
}

.app-footer {
  font-size: 11px;
  font-weight: 400;
}

.toast {
  font-size: 13px;
  font-weight: 500;
}

.preview-card {
  position: sticky;
  min-width: 220px;
  max-width: 520px;
}

.preview-resize-handle {
  position: absolute;
  left: -9px;
  bottom: 16px;
  z-index: 8;
  display: grid;
  width: 18px;
  height: 54px;
  place-items: center;
  padding: 0;
  border: 1px solid #d9cbe1;
  border-radius: 999px;
  color: #725288;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 7px 18px rgba(48, 25, 63, 0.14);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.preview-resize-handle::before,
.preview-resize-handle::after,
.preview-resize-handle span {
  content: "";
  display: block;
  width: 2px;
  height: 24px;
  border-radius: 999px;
  background: currentColor;
}

.preview-resize-handle {
  grid-template-columns: repeat(3, 2px);
  gap: 2px;
}

.preview-resize-handle:hover,
.preview-resize-handle:focus-visible {
  color: var(--purple);
  border-color: #b995ef;
  background: #faf6ff;
}

body.is-resizing-preview {
  cursor: ew-resize;
  user-select: none;
}

body.is-resizing-preview iframe,
body.is-resizing-preview canvas {
  pointer-events: none;
}

.preview-card.is-resizing {
  box-shadow:
    0 0 0 3px rgba(122, 61, 240, 0.12),
    0 18px 42px rgba(50, 26, 65, 0.16);
}

@media (max-width: 1080px) {
  .preview-resize-handle {
    display: none;
  }

  .preview-card {
    min-width: 0;
    max-width: 520px;
  }
}

@media (max-width: 860px) {
  .brand strong {
    font-size: 18px;
  }

  .rail-button span:last-child {
    font-size: 9px;
  }

  .drawer-header h2 {
    font-size: 20px;
  }

  .workspace-title strong {
    font-size: 19px;
  }
}



.garment-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 6px;
  border: 1px solid #e9e2f1;
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  box-shadow: 0 10px 22px rgba(46, 23, 63, 0.06);
}

.garment-tab {
  min-width: 86px;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #6b5b77;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.garment-tab:hover,
.garment-tab:focus-visible {
  color: #4d3566;
  background: #f7f1ff;
}

.garment-tab.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, #a85ff6 0%, #7a3df0 100%);
  box-shadow: 0 10px 18px rgba(122, 61, 240, 0.24);
}

.workspace-toolbar {
  flex-wrap: wrap;
}

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

@media (max-width: 860px) {
  .garment-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-left: 0;
    margin-top: 2px;
  }

  .garment-tab {
    flex: 1 1 0;
    min-width: 0;
  }
}
