.workflow-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.workflow-summary article {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 17px;
}

.workflow-summary span,
.workflow-summary strong,
.workflow-summary p {
  display: block;
}

.workflow-summary span {
  margin-bottom: 16px;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.workflow-summary strong {
  font-size: 0.75rem;
}

.workflow-summary p {
  margin: 2px 0 0;
  color: var(--text-tertiary);
  font-size: 0.65rem;
}

.workflow-lanes {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.workflow-stage {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 16px;
  padding: clamp(22px, 4vw, 38px);
}

.workflow-stage:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.stage-number {
  color: var(--text-tertiary);
  font-size: 0.73rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.stage-content > p {
  max-width: 850px;
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.stage-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.node {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 0.65rem;
  font-weight: 600;
}

.node-user { border-color: var(--user-border); background: var(--user-soft); color: var(--user); }
.node-data { border-color: var(--data-border); background: var(--data-soft); color: var(--data); }
.node-ai { border-color: var(--ai-border); background: var(--ai-soft); color: var(--ai); }

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

.branch-grid article {
  border: 1px solid var(--user-border);
  border-radius: 13px;
  background: var(--user-soft);
  padding: 14px;
}

.branch-grid strong {
  color: var(--user);
  font-size: 0.76rem;
}

.branch-grid p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.66rem;
}

.offline-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  background: var(--ai-soft);
  padding: 12px;
}

.offline-callout strong {
  color: var(--ai);
  font-size: 0.68rem;
}

.offline-callout span {
  color: var(--text-secondary);
  font-size: 0.66rem;
}

.approval-stage {
  min-width: 0;
  margin-top: 16px;
  border: 1px solid var(--user-border);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--user-soft), var(--surface-soft) 42%);
  padding: 16px;
}

.production-stage-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.production-stage-stack .approval-stage {
  margin-top: 0;
}

.generation-alignment {
  margin: 0 0 18px;
  border: 1px solid var(--user-border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--user) 5%, var(--surface));
  padding: 16px;
}

.generation-alignment > .field-helper {
  margin: 5px 0 13px;
}

.approval-stage.is-locked {
  border-color: var(--border);
  background: var(--surface-soft);
}

.generation-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  align-items: start;
  gap: 12px;
  margin-top: 16px;
}

.generation-prompt-control {
  display: grid;
  grid-column: 1 / -1;
  align-content: start;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.generation-prompt-control textarea {
  min-height: 260px;
  resize: vertical;
  letter-spacing: normal;
  line-height: 1.55;
  text-transform: none;
}

.generation-controls.is-disabled {
  opacity: 0.58;
}

.stage-upload-control {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  padding: 13px;
}

.stage-upload-control.has-file {
  border-style: solid;
  border-color: var(--user-border);
  background: var(--user-soft);
}

.stage-upload-copy {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.stage-upload-copy > div,
.stage-upload-file > div {
  min-width: 0;
}

.stage-upload-copy > div > strong,
.stage-upload-copy > div > span,
.stage-upload-copy > div > small,
.stage-upload-file strong,
.stage-upload-file span {
  display: block;
}

.stage-upload-copy > div > strong,
.stage-upload-file strong {
  color: var(--foreground);
  font-size: 0.7rem;
}

.stage-upload-copy > div > span,
.stage-upload-file span {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 0.62rem;
  line-height: 1.4;
}

.stage-upload-copy > div > span {
  white-space: normal;
}

.stage-upload-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-upload-copy > div > small {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.58rem;
  line-height: 1.4;
}

.stage-upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--user) 13%, var(--surface));
  color: var(--user);
  overflow: visible;
}

.stage-upload-icon svg {
  display: block;
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-upload-button {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
}

.stage-upload-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.stage-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.stage-upload-file {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
}

.stage-upload-file .button {
  flex: 0 0 auto;
}

.stage-image-large,
.stage-image-empty {
  min-height: 360px;
}

.stage-image-empty {
  display: grid;
  place-items: center;
  margin-top: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text-tertiary);
  font-size: 0.72rem;
  text-align: center;
}

.stage-selection-note {
  margin-top: 12px;
  border-radius: 10px;
  background: var(--user-soft);
  color: var(--user);
  padding: 10px 12px;
  font-size: 0.68rem;
  font-weight: 700;
}

.approval-stage-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.approval-stage-heading > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.approval-stage-heading h4 {
  margin: 5px 0 4px;
  font-size: 0.86rem;
}

.approval-stage-heading p {
  max-width: 620px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.66rem;
  line-height: 1.55;
}

.approval-stage-heading .role-label {
  flex: 0 0 auto;
  margin: 0;
}

.stage-approval-status {
  display: grid;
  width: min(360px, 42%);
  min-width: 220px;
  flex: 0 1 360px;
  gap: var(--space-2);
  justify-items: stretch;
}

.stage-approval-status .role-label {
  width: 100%;
  justify-content: center;
  justify-self: stretch;
}

.stage-generation-progress {
  display: grid;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 0.61rem;
  font-variant-numeric: tabular-nums;
}

.stage-generation-progress strong {
  justify-self: end;
  color: var(--foreground);
  font-size: 0.63rem;
}

.stage-generation-progress > i {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ai) 16%, transparent);
}

.stage-generation-progress > i > b {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: var(--ai);
  transition: transform 300ms ease;
}

.stage-generation-progress.has-error > i > b {
  background: var(--data);
}

.stage-generation-error {
  color: var(--data);
  font-size: 0.6rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-align: left;
}

.stage-number {
  color: var(--user);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.candidate-approval-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.approval-image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.approval-stage > .approval-image-card {
  margin-top: 14px;
}

.subject-image-shell {
  min-height: 0;
  aspect-ratio: 1 / 1;
}

.subject-image-shell.stage-image-large {
  min-height: 300px;
  aspect-ratio: auto;
}

.subject-image-shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.approval-image-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.approval-image-actions strong,
.approval-image-actions span {
  display: block;
}

.approval-image-actions strong {
  font-size: 0.7rem;
}

.approval-image-actions span {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.6rem;
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.button-ghost:hover {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--foreground);
}

.source-analysis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.source-palette-review {
  border: 1px solid color-mix(in srgb, var(--user) 38%, var(--border));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--user) 5%, var(--surface));
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.source-palette-review.is-approved {
  border-color: color-mix(in srgb, var(--user) 42%, var(--border));
  background: color-mix(in srgb, var(--user) 5%, var(--surface));
}

.source-palette-heading,
.source-palette-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.source-palette-heading h3 {
  margin: 9px 0 0;
  font-size: 0.94rem;
  letter-spacing: -0.02em;
}

.source-palette-heading p {
  margin: 5px 0 0;
  color: var(--text-tertiary);
  font-size: 0.66rem;
  line-height: 1.5;
}

.source-logo-extract,
.source-logo-empty {
  margin: 12px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.source-logo-extract {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  overflow: hidden;
}

.source-logo-extract-image {
  display: grid;
  min-height: 112px;
  place-items: center;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(45deg, var(--surface-soft) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-soft) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-soft) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-soft) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  padding: 18px;
}

.source-logo-extract-image img {
  display: block;
  width: 100%;
  max-width: 180px;
  max-height: 76px;
  object-fit: contain;
}

.source-logo-extract-image img[hidden],
.brand-folder-logo img[hidden] {
  display: none;
}

.source-logo-extract-image.is-file-only,
.brand-folder-logo.is-file-only {
  display: grid;
  place-content: center;
  text-align: center;
}

.logo-file-only-label,
.logo-file-only-label strong,
.logo-file-only-label small {
  display: block;
}

.logo-file-only-label strong {
  color: var(--foreground);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.logo-file-only-label small {
  margin-top: 6px;
  color: var(--text-tertiary);
  font-size: 0.65rem;
  font-weight: 600;
}

.brand-folder-logo .logo-file-only-label strong,
.brand-folder-logo .logo-file-only-label small {
  color: #fff;
}

.source-logo-extract figcaption,
.source-logo-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
}

.source-logo-extract figcaption {
  justify-content: space-between;
}

.source-logo-extract figcaption span,
.source-logo-extract strong,
.source-logo-extract small,
.source-logo-empty strong,
.source-logo-empty small {
  display: block;
}

.source-logo-extract strong,
.source-logo-empty strong {
  color: var(--foreground);
  font-size: 0.7rem;
}

.source-logo-extract small,
.source-logo-empty small {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.61rem;
  line-height: 1.45;
}

.source-logo-extract code,
.source-logo-empty code {
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
}

.source-logo-download {
  display: inline-flex;
  min-height: 44px;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.61rem;
  font-weight: 700;
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease;
}

.source-logo-download:hover {
  border-color: color-mix(in srgb, var(--foreground) 52%, var(--border));
  background: var(--surface-strong);
  color: var(--foreground);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 12%, transparent);
}

.source-logo-download:focus-visible {
  outline: 0;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

.source-logo-download:disabled {
  cursor: wait;
  opacity: 0.58;
}

.source-logo-download svg,
.gradient-copy-button svg,
.folder-palette-heading button svg {
  width: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-logo-empty > span {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text-tertiary);
}

.source-logo-empty svg {
  width: 20px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-palette-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.source-palette-group {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 13px;
}

.source-palette-group.is-gradient {
  grid-column: 1 / -1;
}

.source-palette-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-palette-group-copy {
  min-width: 0;
}

.source-palette-label {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-palette-note {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 0.6rem;
  line-height: 1.5;
}

.source-palette-swatches {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.source-palette-group:not(.is-gradient) .source-palette-swatches {
  grid-template-columns: minmax(0, 1fr);
}

.palette-color-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.palette-color-row:has(.palette-remove-button) {
  grid-template-columns: minmax(0, 1fr) auto;
}

.palette-remove-button,
.palette-add-button {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text-tertiary);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.palette-remove-button:hover {
  border-color: color-mix(in srgb, var(--foreground) 52%, var(--border));
  background: var(--surface-strong);
  color: #e85d55;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 12%, transparent);
}

.palette-remove-button:focus-visible,
.palette-add-button:focus-visible {
  outline: 0;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

.palette-remove-button svg {
  width: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.palette-add-button svg {
  width: 17px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.palette-add-button:hover {
  border-color: color-mix(in srgb, var(--foreground) 52%, var(--border));
  background: var(--user-soft);
  color: var(--user);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 12%, transparent);
}

.source-palette-add-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.source-gradient-preview {
  display: flex;
  position: relative;
  min-height: 56px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 9px;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  background: var(--brand-gradient, var(--surface-soft));
  background-clip: border-box;
  padding: 6px 8px 6px 12px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 13%, transparent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
}

.gradient-angle-control {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 9px;
  background: rgba(17, 19, 25, 0.64);
  padding: 3px 7px 3px 10px;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: none;
  backdrop-filter: blur(8px);
}

.gradient-angle-control input {
  width: 68px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  padding: 0 6px 0 10px;
  color: #fff;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: left;
  outline: 0;
}

.gradient-angle-control input::-webkit-inner-spin-button {
  margin-left: 6px;
  opacity: 1;
}

.gradient-angle-control input:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--focus);
}

.gradient-angle-control input[aria-invalid="true"] {
  box-shadow: 0 0 0 2px #ff8a80;
}

.gradient-angle-control b {
  font-size: 0.72rem;
}

.source-palette-group.is-gradient .source-palette-swatches {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-palette-group.is-gradient .source-palette-swatches[data-gradient-stop-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.source-palette-heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.palette-header-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 0.61rem;
  font-weight: 700;
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease;
}

.palette-header-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--foreground);
}

.gradient-copy-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  margin: 0;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.61rem;
  font-weight: 700;
  line-height: 1.2;
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease;
}

.source-gradient-empty,
.folder-gradient-empty {
  display: flex;
  min-height: 44px;
  align-items: center;
  margin-top: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 10px 12px;
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 700;
}

.gradient-copy-button:hover,
.folder-palette-heading button:hover {
  border-color: color-mix(in srgb, var(--foreground) 52%, var(--border));
  background: var(--surface-strong);
  color: var(--foreground);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 12%, transparent);
}

.gradient-copy-button:focus-visible,
.folder-palette-heading button:focus-visible {
  outline: 0;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

.logo-text-style {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 13px;
}

.logo-text-style > strong {
  display: block;
  margin-top: 8px;
  color: var(--foreground);
  font-size: 0.7rem;
  line-height: 1.5;
}

.logo-text-style .source-palette-label {
  font-size: 0.61rem;
}

.logo-text-style textarea {
  width: 100%;
  min-height: 78px;
  margin: 0;
  resize: vertical;
  font-size: 0.64rem;
  line-height: 1.5;
}

.palette-color-editor {
  display: grid;
  min-width: 0;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 46px;
  align-items: center;
  gap: var(--space-2);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 5px 8px 5px 5px;
}

.palette-color-editor.has-position {
  grid-template-columns: 38px minmax(72px, 1fr) 70px clamp(32px, 14%, 44px);
  grid-template-rows: 38px;
  gap: var(--space-2);
}

[data-gradient-stop-count] .palette-color-editor.has-position,
[data-gradient-stop-count] .folder-color-editor.has-position {
  grid-template-columns: 28px minmax(36px, 1fr) 50px 20px;
  grid-template-rows: 34px;
  min-height: 42px;
  gap: 3px;
  padding: 4px;
}

[data-gradient-stop-count] .palette-color-editor.has-position > input[type="color"],
[data-gradient-stop-count] .folder-color-editor.has-position > input[type="color"] {
  width: 28px;
  min-height: 28px;
  height: 28px;
  aspect-ratio: 1;
}

[data-gradient-stop-count] .palette-color-editor.has-position > input[type="text"],
[data-gradient-stop-count] .folder-color-editor.has-position > input[type="text"] {
  min-height: 34px;
  padding-inline: 3px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.015em;
}

[data-gradient-stop-count] .palette-color-editor.has-position .gradient-position-control,
[data-gradient-stop-count] .folder-color-editor.has-position .gradient-position-control {
  width: 50px;
  grid-template-columns: minmax(0, 1fr) 12px;
}

[data-gradient-stop-count] .palette-color-editor.has-position .gradient-position-control input,
[data-gradient-stop-count] .folder-color-editor.has-position .gradient-position-control input {
  min-height: 32px;
  padding-inline: 4px 0;
  font-size: 0.56rem;
}

[data-gradient-stop-count] .gradient-position-stepper svg {
  width: 7px;
  height: 5px;
}

[data-gradient-stop-count] .gradient-drag-zone,
[data-gradient-stop-count] .folder-color-editor.has-position .gradient-drag-zone {
  margin: 0;
}

.folder-color-editor.has-position {
  grid-template-columns: 34px minmax(64px, 1fr) 70px clamp(32px, 14%, 44px);
  grid-template-rows: 38px;
}

.gradient-position-control {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-tertiary);
  transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.palette-color-editor.has-position .gradient-position-control,
.folder-color-editor.has-position .gradient-position-control {
  grid-column: 3;
  grid-row: 1;
  width: 70px;
  justify-self: start;
}

.palette-color-editor.has-position > input[type="color"],
.folder-color-editor.has-position > input[type="color"] {
  grid-column: 1;
  grid-row: 1;
}

.palette-color-editor.has-position > input[type="text"],
.folder-color-editor.has-position > input[type="text"] {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
}

.gradient-drag-zone {
  display: grid;
  min-width: 0;
  grid-column: 4;
  grid-row: 1;
  align-self: stretch;
  overflow: hidden;
  place-items: center;
  margin: 0;
  cursor: grab;
  border: 1px solid color-mix(in srgb, var(--foreground) 9%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 28%, transparent);
  transition: background var(--motion-fast) ease, border-color var(--motion-fast) ease;
}

.folder-color-editor.has-position .gradient-drag-zone {
  margin: 0;
  border-radius: 7px;
}

.gradient-drag-zone::after {
  width: 10px;
  height: 18px;
  opacity: 0.7;
  background: radial-gradient(circle, currentColor 1.35px, transparent 1.6px) 0 0 / 5px 6px;
  color: var(--text-tertiary);
  content: "";
  pointer-events: none;
}

[data-gradient-stop-card]:hover .gradient-drag-zone {
  border-color: color-mix(in srgb, var(--foreground) 16%, transparent);
  background: color-mix(in srgb, var(--foreground) 4%, var(--surface));
}

.palette-color-editor.has-position .gradient-position-control input,
.folder-color-editor.has-position .gradient-position-control input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 0;
  background: transparent;
  padding: 5px 0 5px 6px;
  color: var(--text-secondary);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.66rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
  outline: 0;
  appearance: textfield;
}

.gradient-position-stepper {
  display: grid;
  align-self: stretch;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  border-left: 1px solid color-mix(in srgb, var(--foreground) 10%, transparent);
}

.gradient-position-stepper button {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
}

.gradient-position-stepper button + button {
  border-top: 1px solid color-mix(in srgb, var(--foreground) 10%, transparent);
}

.gradient-position-stepper button:hover {
  background: color-mix(in srgb, var(--foreground) 10%, var(--surface));
  color: var(--foreground);
}

.gradient-position-stepper button:focus-visible {
  z-index: 1;
  outline: 0;
  box-shadow: inset 0 0 0 1px var(--foreground);
}

.gradient-position-stepper svg {
  width: 8px;
  height: 6px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gradient-position-control:hover {
  border-color: color-mix(in srgb, var(--foreground) 42%, var(--border));
  background: color-mix(in srgb, var(--foreground) 2%, var(--surface));
}

.gradient-position-control:focus-within {
  border-color: var(--foreground);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--foreground) 35%, transparent);
}

.gradient-position-control:has(input[aria-invalid="true"]) {
  border-color: #e85d55;
}

.palette-color-editor input[type="color"],
.folder-color-editor input[type="color"] {
  width: 38px;
  min-height: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--foreground) 16%, transparent);
  border-radius: 8px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.palette-color-editor input[type="color"]::-webkit-color-swatch-wrapper,
.folder-color-editor input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.palette-color-editor input[type="color"]::-webkit-color-swatch,
.folder-color-editor input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 7px;
}

.palette-color-editor input[type="text"] {
  min-width: 0;
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  padding: 7px 5px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.palette-color-editor input[type="text"]:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.source-folder-save {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  border: 1px dashed color-mix(in srgb, var(--user) 38%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--user) 4%, var(--surface));
  padding: 13px;
}

.source-folder-save > div:first-child {
  min-width: 0;
}

.source-folder-save strong,
.source-folder-save span {
  display: block;
}

.source-folder-save strong {
  font-size: 0.72rem;
}

.source-folder-save span {
  margin-top: 3px;
  color: var(--text-tertiary);
  font-size: 0.62rem;
  line-height: 1.45;
}

.source-folder-save > div:last-child {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.source-palette-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.field-error {
  margin: 8px 0 0;
  color: var(--data);
  font-size: 0.68rem;
  line-height: 1.45;
}

.generated-result {
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--ai-border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.generated-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
}

.generated-result-actions > span {
  color: var(--text-tertiary);
  font-size: 0.64rem;
}

.generated-image-shell {
  display: grid;
  min-height: 180px;
  place-items: center;
  overflow: hidden;
  background: #0d0f14;
}

.generated-image-shell img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
}

.generated-result-actions {
  border-top: 1px solid var(--border);
}

.final-result {
  margin-top: 18px;
}

.brand-library {
  margin-top: 36px;
}

.brand-library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.brand-library-heading h3 {
  margin: 5px 0 4px;
  font-size: 1.08rem;
}

.brand-library-heading p {
  max-width: 650px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.55;
}

.brand-library:not(.character-library) .brand-library-heading > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-library:not(.character-library) .brand-library-heading p {
  max-width: none;
}

.brand-folder-count {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 11px;
  color: var(--text-secondary);
  font-size: 0.64rem;
  font-weight: 700;
}

.library-heading-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: var(--space-2);
}

.character-folder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.character-folder-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.character-folder-visual {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-raised) 82%, var(--background));
}

.character-folder-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-side-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: 1px solid color-mix(in srgb, var(--user) 42%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  padding: 6px 9px;
  color: var(--user);
  font-size: 0.57rem;
  font-weight: 750;
  backdrop-filter: blur(8px);
}

.character-side-badge.is-muted {
  border-color: var(--border);
  color: var(--text-secondary);
}

.character-folder-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.character-folder-body h4 {
  margin: 4px 0 0;
  font-size: 0.88rem;
}

.character-folder-body > p {
  overflow: hidden;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-folder-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.character-folder-footer > span {
  color: var(--text-tertiary);
  font-size: 0.59rem;
}

.character-folder-footer .button {
  min-height: 40px;
  padding: 7px 11px;
}

.empty-character-folders {
  grid-column: 1 / -1;
  display: grid;
  min-height: 210px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  padding: 28px;
  text-align: center;
}

.empty-character-folders > div {
  max-width: 390px;
}

.empty-character-folders svg {
  width: 40px;
  color: var(--text-tertiary);
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-character-folders h4 {
  margin: 12px 0 5px;
  font-size: 0.88rem;
}

.empty-character-folders p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.55;
}

.brand-folder-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.empty-brand-folders {
  grid-column: 1 / -1;
  display: grid;
  min-height: 230px;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  padding: 28px;
  text-align: center;
}

.empty-brand-folders > div {
  max-width: 390px;
}

.empty-brand-folders svg {
  width: 40px;
  color: var(--text-tertiary);
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-brand-folders h4 {
  margin: 12px 0 5px;
  font-size: 0.88rem;
}

.empty-brand-folders p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.55;
}

.brand-folder-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

.brand-folder-card.is-selected {
  border-color: color-mix(in srgb, var(--user) 72%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--user) 18%, transparent), var(--shadow-sm);
}

.brand-folder-preview {
  min-width: 0;
}

.brand-folder-visual {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  cursor: pointer;
  place-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.09), transparent 44%),
    #17181c;
  color: inherit;
  font: inherit;
  padding: 0;
}

.brand-folder-visual:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.brand-folder-open-indicator {
  position: absolute;
  right: 9px;
  bottom: 9px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: rgba(7, 9, 13, 0.7);
  color: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
}

.brand-folder-open-indicator svg {
  width: 15px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--motion-fast) ease;
}

.brand-folder-card.is-selected .brand-folder-open-indicator {
  border-color: color-mix(in srgb, var(--user) 58%, rgba(255, 255, 255, 0.16));
  background: color-mix(in srgb, var(--user) 28%, rgba(7, 9, 13, 0.78));
  color: #fff;
}

.brand-folder-logo {
  position: relative;
  display: grid;
  width: min(64%, 170px);
  min-height: 64px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.055) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.055) 75%),
    rgba(255, 255, 255, 0.06);
  background-position: 0 0, 7px 7px;
  background-size: 14px 14px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.brand-folder-logo img {
  display: block;
  width: 100%;
  max-height: 52px;
  object-fit: contain;
}

.brand-folder-no-logo {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 12, 17, 0.72);
  padding: 6px 9px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.58rem;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.brand-folder-body {
  min-width: 0;
  padding: 12px;
}

.brand-package-details-dialog {
  width: min(1180px, calc(100% - 32px));
  max-width: none;
  max-height: min(900px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  padding: 0;
  color: var(--foreground);
  box-shadow: var(--shadow-lg);
}

.brand-package-details-dialog::backdrop {
  background: rgba(5, 7, 11, 0.76);
  backdrop-filter: blur(6px);
}

.brand-package-details-shell {
  display: grid;
  max-height: min(900px, calc(100dvh - 32px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.brand-package-dialog-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 15px 18px;
}

.brand-package-dialog-heading > div {
  min-width: 0;
}

.brand-package-dialog-heading .brand-folder-kicker {
  margin-bottom: 2px;
}

.brand-package-dialog-heading h2 {
  overflow: hidden;
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-package-dialog-heading button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.brand-package-dialog-heading button:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--foreground);
}

.brand-package-dialog-heading button svg {
  width: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

#brand-package-details-content {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.brand-package-dialog-layout {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(240px, 0.68fr) minmax(0, 2fr);
}

.brand-package-dialog-preview {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-soft) 76%, transparent);
  padding: 18px;
}

.brand-package-dialog-logo {
  display: grid;
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 9;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.09), transparent 44%),
    #17181c;
}

.brand-package-dialog-logo + .brand-folder-link {
  margin-top: 12px;
  padding: 0 2px;
}

.brand-package-dialog-layout > .brand-folder-body {
  padding: 18px;
}

.brand-folder-preview-bar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
}

.brand-folder-link {
  min-width: 0;
  overflow: hidden;
}

.brand-folder-link a,
.brand-folder-link span {
  display: block;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.66rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-folder-link a:hover {
  color: var(--foreground);
}

.brand-folder-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--user);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-folder-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.brand-folder-actions button {
  display: grid;
  width: 44px;
  height: 44px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text-secondary);
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, color var(--motion-fast) ease;
}

.brand-folder-actions button:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--foreground);
}

.brand-folder-actions button.is-active {
  border-color: color-mix(in srgb, var(--user) 70%, var(--border));
  background: color-mix(in srgb, var(--user) 13%, var(--surface));
  color: var(--user);
}

.brand-folder-actions button.is-danger:hover {
  border-color: color-mix(in srgb, #dc2626 50%, var(--border));
  background: color-mix(in srgb, #dc2626 10%, var(--surface));
  color: #e85d55;
}

.brand-folder-actions svg {
  width: 17px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-folder-details-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand-folder-details-heading > div {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-folder-details-heading h4 {
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.35;
}

.brand-package-details-meta {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
}

.brand-package-details-meta > span {
  color: var(--text-tertiary);
  font-size: 0.62rem;
  white-space: nowrap;
}

.brand-folder-edit-field {
  display: grid;
  min-width: 0;
  gap: 6px;
  margin-top: 12px;
}

.brand-folder-details-heading .brand-folder-edit-field {
  margin-top: 0;
}

.brand-folder-edit-field > span,
.brand-folder-logo-style > span {
  color: var(--text-tertiary);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-folder-edit-field input,
.brand-folder-logo-style textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--foreground);
  font: inherit;
}

.brand-folder-edit-field input {
  min-height: 44px;
  padding: 9px 11px;
}

.brand-folder-logo-style textarea {
  min-height: 108px;
  resize: vertical;
  padding: 11px;
  font-size: 0.72rem;
  line-height: 1.55;
}

.brand-folder-edit-field input:focus,
.brand-folder-logo-style textarea:focus {
  border-color: var(--focus);
  outline: 2px solid color-mix(in srgb, var(--focus) 32%, transparent);
  outline-offset: 1px;
}

.folder-palette-editor {
  --folder-palette-row-height: 42px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.folder-palette-group {
  min-width: 0;
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 8px;
}

.folder-palette-group.is-gradient {
  grid-column: auto;
}

.folder-palette-heading {
  display: grid;
  min-height: var(--folder-palette-row-height);
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.folder-palette-heading > span {
  display: flex;
  min-height: 0;
  flex: 0 0 auto;
  align-items: center;
  line-height: 1;
  color: var(--text-tertiary);
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.folder-palette-heading-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.folder-palette-heading button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  padding: 6px 9px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.2;
}

.folder-palette-heading button:disabled {
  cursor: not-allowed;
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text-tertiary);
  opacity: 0.48;
  box-shadow: none;
}

.folder-gradient-preview {
  display: flex;
  position: relative;
  min-height: var(--folder-palette-row-height);
  height: var(--folder-palette-row-height);
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: var(--brand-gradient, var(--surface));
  background-clip: border-box;
  padding: 6px 7px 6px 10px;
  color: #fff;
  font-size: 0.56rem;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--foreground) 13%, transparent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.72);
}

/* The shared source-editor control is taller than a saved-package row. */
.folder-gradient-preview .gradient-angle-control {
  min-height: 30px;
  height: 30px;
  gap: 0;
  border-radius: 8px;
  padding: 0;
}

.folder-gradient-preview .gradient-angle-control > span {
  padding: 0 9px;
}

.folder-gradient-preview .gradient-angle-control input {
  width: 54px;
  min-height: 30px;
  height: 30px;
  border-radius: 0 7px 7px 0;
  padding: 0 7px;
  text-align: center;
}

.folder-gradient-preview .gradient-angle-control input:focus-visible {
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--focus);
}

.palette-color-row.is-gradient-stop,
.folder-color-editor.has-position {
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.palette-color-row.is-gradient-stop,
.folder-color-editor.has-position {
  position: relative;
}

[data-gradient-stop-card].is-dragging {
  z-index: 4;
  opacity: 0.82;
  pointer-events: none;
  cursor: grabbing;
  box-shadow: var(--shadow-lg);
  will-change: transform;
}

[data-gradient-stop-card].drop-before {
  box-shadow: inset 3px 0 0 var(--user);
}

[data-gradient-stop-card].drop-after {
  box-shadow: inset -3px 0 0 var(--user);
}

.folder-palette-group.is-gradient .folder-palette-colors {
  grid-template-columns: minmax(0, 1fr);
}

.folder-palette-group.is-gradient .folder-palette-colors[data-gradient-stop-count="3"] {
  grid-template-columns: minmax(0, 1fr);
}

.folder-palette-colors {
  display: grid;
  gap: 6px;
}

.folder-color-editor {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: var(--folder-palette-row-height);
  height: var(--folder-palette-row-height);
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  padding: 3px 7px 3px 3px;
}

.folder-color-editor.has-remove {
  grid-template-columns: 34px minmax(0, 1fr) 30px;
}

.folder-color-remove {
  display: grid;
  width: 30px;
  height: 30px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.folder-color-remove:hover {
  border-color: color-mix(in srgb, #dc2626 50%, var(--border));
  color: #e85d55;
}

.folder-color-remove svg {
  width: 15px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.folder-color-editor input[type="color"] {
  width: 34px;
  min-height: 34px;
  height: 34px;
  border-radius: 7px;
}

.folder-color-editor input[type="text"] {
  min-width: 0;
  min-height: 32px;
  border: 0;
  background: transparent;
  padding: 5px 2px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.folder-color-editor input[type="text"]:focus {
  outline: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--focus) 9%, transparent);
  box-shadow: inset 0 0 0 2px var(--focus);
}

.folder-color-editor.is-empty {
  border-style: dashed;
  color: var(--text-tertiary);
}

.folder-color-editor.is-readonly.has-position {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  cursor: default;
  user-select: text;
}

.folder-color-readonly-swatch {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--folder-color);
}

.folder-color-readonly-value {
  min-width: 0;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.folder-gradient-position-readout {
  justify-self: end;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 7px 8px;
  color: var(--text-secondary);
  font-size: 0.62rem;
  font-weight: 800;
}

.folder-gradient-angle-readout {
  border-radius: 8px;
  background: rgba(12, 14, 19, 0.58);
  padding: 9px 10px;
  color: #fff;
}

.brand-folder-logo-style {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 12px;
}

.brand-folder-logo-style p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.brand-folder-done {
  width: 100%;
  margin-top: 12px;
}

.folder-color-empty-swatch {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface-strong);
}

.folder-color-empty-text {
  min-width: 0;
  color: var(--text-tertiary);
  font-size: 0.62rem;
  font-weight: 700;
}

.app-dialog {
  width: min(520px, calc(100% - 32px));
  max-width: none;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--foreground);
  padding: 0;
}

.app-dialog::backdrop {
  background: rgba(4, 6, 10, 0.68);
  backdrop-filter: blur(5px);
}

.app-dialog-card {
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.app-dialog-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 22px;
}

.app-dialog-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: var(--user-soft);
  color: var(--user);
}

.app-dialog-icon.is-danger {
  background: color-mix(in srgb, #dc2626 12%, var(--surface));
  color: #e85d55;
}

.app-dialog-icon svg {
  width: 21px;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-dialog-heading h2 {
  margin: 1px 0 5px;
  font-size: 1rem;
}

.app-dialog-heading p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.55;
}

.app-dialog [hidden] {
  display: none !important;
}

.app-dialog-error {
  min-height: 1.35em;
  margin: 10px 0 0;
  color: #e85d55;
  font-size: 0.66rem;
  line-height: 1.4;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: 18px;
}

.existing-character-dialog {
  width: min(720px, calc(100% - 32px));
}

.existing-character-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-upload-field {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  padding: 14px;
  transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease;
}

.dialog-upload-field:hover {
  border-color: var(--border-strong);
}

.dialog-upload-field > span,
.dialog-upload-field strong,
.dialog-upload-field small {
  display: block;
}

.dialog-upload-field strong {
  font-size: 0.72rem;
}

.dialog-upload-field small {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.61rem;
  line-height: 1.45;
}

.dialog-file-control {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.63rem;
  line-height: 1.2;
}

.dialog-file-button {
  display: inline-flex;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 9px 13px;
  color: var(--foreground);
  font-weight: 750;
}

.dialog-file-selection {
  min-width: 0;
  overflow: hidden;
  padding: 9px 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-upload-field:hover .dialog-file-control {
  border-color: color-mix(in srgb, var(--focus) 48%, var(--border-strong));
}

.dialog-upload-field:has(.dialog-file-input:focus-visible) .dialog-file-control {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
}

.dialog-upload-field .dialog-file-input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.dialog-upload-field b {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.61rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.existing-character-folder-field {
  margin-top: 14px;
}

.existing-character-folder-field.is-empty select {
  color: var(--text-tertiary);
}

.existing-character-actions {
  display: grid;
  grid-template-columns: auto auto;
}

