:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #211a2d;
  background: #faf8f6;
  --muted: #655e70;
  --accent: #5c38b8;
  --accent-dark: #4b2b9a;
  --line: #e8e0e8;
  --panel: #fff;
  --ink-panel: #221a30;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 25% 0%, #f2eafa 0%, transparent 53%);
}

h1, h2, h3, p, figure {
  margin: 0;
}

.page-width {
  width: min(1232px, calc(100% - 64px));
  margin-inline: auto;
}

.site-header {
  background: rgb(255 255 255 / 78%);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.brand {
  display: flex;
  align-items: center;
}

.header-inner {
  min-height: 68px;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  gap: 10px;
  color: inherit;
  font-size: 1.0625rem;
  font-weight: 750;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  color: white;
  background: var(--accent);
  font-size: 1.15rem;
}

.quota {
  border: 1px solid #e4d9f2;
  border-radius: 999px;
  padding: 7px 12px;
  color: #50338e;
  background: #f7f0fc;
  font-size: 0.8125rem;
  font-weight: 650;
  text-align: center;
}

.workspace {
  padding-block: 44px 56px;
}

.intro {
  margin-bottom: 30px;
}

h1 {
  font-size: clamp(2rem, 5.1vw, 3.75rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1.16;
}

h1 span {
  color: var(--accent);
}

.intro p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.65;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 348px) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}

.controls,
.comparison {
  min-width: 0;
  padding: 22px;
  border-radius: 20px;
}

.controls {
  display: grid;
  gap: 19px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 32px rgb(45 24 60 / 5%);
}

h2 {
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.upload-field {
  min-width: 0;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 13px;
  border: 1px dashed #bda8d9;
  border-radius: 13px;
  color: #4a2c88;
  background: #faf5ff;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #efe4fd;
}

.upload-icon,
.upload-thumbnail {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 11px;
}

.upload-icon {
  background: #ebdffc;
  font-size: 1.25rem;
}

.upload-thumbnail {
  object-fit: cover;
}

.upload-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.upload-copy strong {
  font-size: 0.875rem;
}

.file-name,
.file-meta,
.note {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#file-help {
  margin-top: 7px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 700;
}

.style-grid,
.ratio-grid {
  display: grid;
  gap: 8px;
}

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

.style-card,
.ratio-option {
  position: relative;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}

.style-card {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 10px 11px;
}

.style-card:hover,
.ratio-option:hover {
  border-color: #bda8d9;
}

.style-card:has(input:checked),
.ratio-option:has(input:checked) {
  border-color: var(--accent);
  color: #4a2c88;
  background: #f5eeff;
}

.style-name {
  font-size: 0.875rem;
}

.style-description {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

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

.ratio-option {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  min-height: 54px;
  font-size: 0.8125rem;
  font-weight: 650;
  white-space: nowrap;
}

.ratio-shape {
  align-self: center;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.ratio-shape.square { width: 13px; height: 13px; }
.ratio-shape.portrait { width: 12px; height: 16px; }
.ratio-shape.tall { width: 9px; height: 16px; }
.ratio-shape.wide { width: 16px; height: 9px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding-inline: 14px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  color: #fff;
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button:disabled,
fieldset:disabled label,
#image:disabled + .drop-zone {
  opacity: 0.68;
  cursor: not-allowed;
}

:is(.button, .brand):focus-visible,
#image:focus-visible + .drop-zone,
label:has(input:focus-visible) {
  outline: 2px solid #9464e0;
  outline-offset: 3px;
}

.error:empty {
  display: none;
}

.error {
  margin-top: -7px;
  border: 1px solid #efd2dc;
  border-radius: 9px;
  padding: 9px 11px;
  color: #872e46;
  background: #fff1f4;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.privacy-note {
  margin-top: -9px;
  text-align: center;
}

.comparison {
  color: #fff9ff;
  background: var(--ink-panel);
  box-shadow: 0 16px 34px rgb(36 22 49 / 14%);
}

.comparison-header,
.comparison-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.comparison-header {
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: 12px;
}

.comparison-actions {
  justify-content: flex-end;
}

.button-download {
  min-height: 36px;
  color: #302049;
  background: #f0e3ff;
}

.button-download:hover {
  background: #fff;
}

.status,
.result-meta {
  color: #ded0ec;
  font-size: 0.8125rem;
}

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

.preview-card {
  min-width: 0;
}

.preview-card h3 {
  margin-bottom: 8px;
  color: #eadcf4;
  font-size: 0.8125rem;
}

.preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #554467;
  border-radius: 13px;
  background-color: #2d233c;
  background-image: radial-gradient(#695679 0.65px, transparent 0.65px);
  background-size: 13px 13px;
}

.preview > img,
.example,
.example img,
.generation-progress {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview > img {
  object-fit: contain;
  background: #21192c;
}

.source-placeholder,
.generation-progress {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: #eddef8;
  font-size: 0.8125rem;
  text-align: center;
}

.placeholder-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #746187;
  border-radius: 10px;
  background: #352846;
}

.example img {
  object-fit: cover;
}

.example figcaption {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border-radius: 6px;
  color: #fff;
  background: rgb(25 15 33 / 82%);
  font-size: 0.75rem;
}

.generation-progress {
  background: #30213f;
}

.spinner,
.button-primary[aria-busy="true"] > span:first-child {
  border: 2px solid #5c4971;
  border-top-color: #dfbcff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.spinner {
  width: 34px;
  height: 34px;
  border-width: 3px;
}

.button-primary[aria-busy="true"] > span:first-child {
  width: 15px;
  height: 15px;
  font-size: 0;
}

.result-meta {
  margin-top: 8px;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .button-primary[aria-busy="true"] > span:first-child {
    animation: none;
  }
}

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

  .controls,
  .comparison {
    padding: 17px;
  }
}

@media (max-width: 760px) {
  .page-width {
    width: calc(100% - 36px);
  }

  .workspace {
    padding-block: 30px 38px;
  }

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

@media (max-width: 400px) {
  .header-inner {
    min-height: 60px;
  }

  .brand {
    font-size: 0.9375rem;
  }

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

  .quota {
    padding-inline: 8px;
    font-size: 0.75rem;
  }

  .preview-grid {
    gap: 8px;
  }

  .preview {
    border-radius: 9px;
  }
}
