:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #faf6ff;
  background: #30263e;
  --muted: #dfd5ed;
  --line: #514162;
  --panel: #21192b;
  --accent: #ffd659;
  --button: #7132c7;
  --edge: linear-gradient(90deg, #fa5708, #fe0070, #8338eb, #3a86fe);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 5% 15%, #ad437753, transparent 43%),
              radial-gradient(ellipse at 95% 60%, #4c70d24d, transparent 48%),
              linear-gradient(155deg, #552744, #30263e 54%, #293655);
}
.wrap { width: min(1180px, calc(100% - 3rem)); margin-inline: auto; }
.site-header {
  background: #1b1424e8;
  border-bottom: 2px solid transparent;
  border-image: var(--edge) 1;
  box-shadow: 0 8px 20px #100a1b55;
}
.top { display: flex; align-items: center; justify-content: center; min-height: 3.6rem; }
.brand { color: inherit; font-size: 1.15rem; font-weight: 700; text-decoration: none; }
main { padding-block: clamp(1rem, 3vw, 2.25rem) 3rem; }
.hero {
  margin-bottom: 1rem;
  padding: clamp(1.25rem, 4vw, 2.6rem);
  background: radial-gradient(ellipse at 100% 0, #925ae399, transparent 66%),
              radial-gradient(ellipse at 0 110%, #7b414c, transparent 55%),
              linear-gradient(115deg, #291c39, #223457);
  border: 1px solid #664e83;
  border-radius: 1.35rem;
  text-align: center;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
p { line-height: 1.5; }
.hero p { max-width: 40rem; margin: .75rem auto 0; }
.hero p, small, .frame p { color: var(--muted); }

form, figure {
  min-width: 0;
  margin: 0;
  padding: clamp(1rem, 2.4vw, 1.45rem);
  background: linear-gradient(140deg, #322743ce, #1a1426d9);
  border: 1px solid var(--line);
  border-radius: .95rem;
}
form { display: grid; justify-items: center; gap: .95rem; text-align: center; }
form > div { width: min(100%, 31rem); min-width: 0; }
label, legend, figcaption { font-weight: 650; }
input[type="file"] {
  display: block;
  width: min(100%, 31rem);
  padding: .4rem;
  margin: .55rem auto;
  color: inherit;
  font: inherit;
  background: #191321;
  border: 1px solid var(--line);
  border-radius: .6rem;
}
input[type="file"]::file-selector-button {
  margin-inline-end: .65rem;
  padding: .55rem .75rem;
  color: var(--accent);
  font: inherit;
  font-weight: 650;
  background: #322348;
  border: 0;
  border-radius: .4rem;
  cursor: pointer;
}
fieldset { min-width: 0; max-width: 100%; border: 0; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
legend { padding: 0; margin: 0 auto .55rem; }
.mode {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem .75rem;
  border: 1px solid #675180;
  border-radius: .65rem;
  cursor: pointer;
}
.mode:has(:checked) { color: var(--accent); background: #3d2a55; border-color: #a177eb; }
.mode:hover { background: #4b3566; border-color: #a177eb; }
.mode input { accent-color: #a587f7; }
.background-group { display: contents; }
.background-option { text-align: left; }
.background-option small { display: block; font-weight: 400; }
.background-swatch {
  width: 1.4rem;
  height: 1.4rem;
  flex: none;
  background: var(--swatch);
  border: 1px solid #fff5;
  border-radius: .35rem;
}
[data-background="warm-white"] { --swatch: #fff0d9; }
[data-background="pearl"] { --swatch: #d2d1d9; }
[data-background="ice"] { --swatch: #c9eaff; }
[data-background="graphite"] { --swatch: #444852; }
[data-background="burgundy"] { --swatch: #6e2946; }
[data-background="emerald"] { --swatch: #246351; }
[data-background="concrete"] { --swatch: linear-gradient(#a9a5a4 55%, #716e70 55%); }
[data-background="sand"] { --swatch: linear-gradient(#eee0b2 55%, #c0a469 55%); }
[data-background="neon"] { --swatch: linear-gradient(145deg, #bf45c9, #333480); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, a { font: inherit; font-weight: 650; }
button { cursor: pointer; }
#generate {
  justify-self: center;
  padding: .65rem 1rem;
  background: linear-gradient(125deg, #873def, #6426ad);
  color: white;
  border: 1px solid #9c6ce8;
  border-radius: .7rem;
}
#generate:hover { background: #5e28b2; }
#editor.is-processing #generate { border-color: #c8a3ff; }
button:disabled { opacity: .65; cursor: wait; }
#status { margin: 0; }
#status:empty { display: none; }
.comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
figure { text-align: center; }
.frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: #18131f;
  border: 1px solid #3c314a;
  border-radius: .65rem;
  margin-top: .65rem;
  overflow: hidden;
  text-align: center;
}
.frame img { display: block; width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.frame p { padding: .75rem; }
#downloads { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: .55rem 1rem; margin-top: .8rem; }
#downloads a, #download-square { color: var(--accent); text-underline-offset: .2em; }
#download-square { background: transparent; padding: 0; border: 0; text-decoration: underline; }
#export-status:not(:empty) { display: block; margin-top: .5rem; }

.tool-panel {
  margin-top: 1rem;
  padding: clamp(1rem, 2.4vw, 1.45rem);
  text-align: center;
  background: linear-gradient(140deg, #322743ce, #1a1426d9);
  border: 1px solid var(--line);
  border-radius: .95rem;
}
.tool-panel h2 { margin: 0 0 .75rem; }
#account, #trial-wallet { margin: 0 0 1rem; }
#guest-preview { margin: 0 0 1rem; }
.feature-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  max-width: 52rem;
  padding: 0;
  margin: .9rem auto;
  list-style: none;
}
.feature-list li {
  display: grid;
  gap: .25rem;
  padding: .8rem;
  background: #2c213a;
  border: 1px solid var(--line);
  border-radius: .65rem;
}
.feature-list span { color: var(--muted); line-height: 1.4; }
#account-login form { margin: .75rem auto 0; max-width: 24rem; }
#account-login input {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem .75rem;
  color: inherit;
  font: inherit;
  background: #191321;
  border: 1px solid var(--line);
  border-radius: .55rem;
}
#account-email { overflow-wrap: anywhere; }
.tool-panel p { margin: .6rem auto; max-width: 43rem; color: var(--muted); }
.tool-panel p:empty { display: none; }
.tool-panel button, .tool-panel select {
  padding: .5rem .8rem;
  color: inherit;
  font: inherit;
  background: #322348;
  border: 1px solid #675180;
  border-radius: .55rem;
}
.tool-panel button:hover:not(:disabled) {
  color: var(--accent);
  background: #4b3566;
  border-color: #a177eb;
}
.tool-panel input[type="file"] { margin-block: .75rem; }
.tool-panel small { display: block; margin-top: .55rem; }
.editing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.editing-column { display: flex; flex-direction: column; align-items: center; min-width: 0; gap: .65rem; }
.editing-column h3 { margin: 0; }
.range-control { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .35rem .6rem; }
.range-control input { width: 7rem; accent-color: #a587f7; }
.frame-ranges { display: grid; gap: .4rem; }
.editing-column canvas { display: block; max-width: 100%; max-height: 480px; object-fit: contain; border: 1px solid var(--line); border-radius: .6rem; }
#download-frame, #run-batch { background: #7132c7; }
#batch-errors { display: inline-block; max-width: 100%; text-align: left; overflow-wrap: anywhere; }

.glass {
  position: relative;
  isolation: isolate;
  box-shadow: 0 14px 30px #100a1b55, inset 0 1px 0 #ffffff22;
}

.glass::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse 8rem 2px at var(--cursor-x, 50%) 0, #e1cbff, transparent),
    radial-gradient(ellipse 8rem 2px at var(--cursor-x, 50%) 100%, #c0adff, transparent),
    radial-gradient(ellipse 2px 5rem at 0 var(--cursor-y, 50%), #e1cbff, transparent),
    radial-gradient(ellipse 2px 5rem at 100% var(--cursor-y, 50%), #c0adff, transparent),
    radial-gradient(circle 12rem at var(--cursor-x, 50%) var(--cursor-y, 50%), #c8aaff19, transparent);
}

.glass.is-tracking::after, .glass:focus-within::after { opacity: 1; }
#generate:active, #download-square:active, .mode:active, input[type="file"]::file-selector-button:active {
  box-shadow: 0 0 14px #ab77ff99;
}

@supports (backdrop-filter: blur(12px)) {
  .site-header, .glass { backdrop-filter: blur(12px); }
}

@media (prefers-reduced-motion: no-preference) {
  .glass::after { transition: opacity 180ms ease; }
  .mode, #generate, #download-square, input[type="file"] { transition: background-color 170ms ease, border-color 170ms ease, box-shadow 170ms ease; }
  .frame img:not([hidden]), #downloads:not([hidden]) { animation: appear 240ms ease-out both; }
  #editor.is-processing #generate { animation: working 1.25s ease-in-out infinite alternate; }
  @keyframes appear {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes working {
    from { box-shadow: 0 0 5px #ab77ff33; }
    to { box-shadow: 0 0 19px #ab77ff99; }
  }
}

@media (max-width: 580px) {
  .wrap { width: calc(100% - 1.5rem); }
  .comparison { grid-template-columns: 1fr; }
  .editing-grid { grid-template-columns: 1fr; }
  .feature-list { grid-template-columns: 1fr; }
  .mode { justify-content: center; min-height: 2.75rem; }
  .site-header, .glass { backdrop-filter: none; }
  #download-square { min-height: 2.75rem; }
}

@media (max-width: 380px) {
  fieldset { display: grid; width: 100%; }
  .mode { width: 100%; }
}
