:root {
  color-scheme: light;
  --ink: #24221f;
  --muted: #716a62;
  --line: #ded8cf;
  --panel: #fffdf9;
  --page: #f6f2ea;
  --accent: #2f7d6d;
  --accent-strong: #1f5f52;
  --accent-soft: #d8eee8;
  --berry: #b34d6a;
  --shadow: 0 12px 34px rgba(52, 46, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background:
    linear-gradient(140deg, rgba(47, 125, 109, 0.12), transparent 38%),
    linear-gradient(240deg, rgba(179, 77, 106, 0.11), transparent 35%),
    var(--page);
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.shell {
  width: 100%;
  margin: 0 auto;
  padding: 10px;
}

.workspace {
  min-height: calc(100vh - 20px);
}

.topbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.privacy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.privacy span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.studio {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.94);
  box-shadow: var(--shadow);
}

.controls,
.preview {
  min-width: 0;
  padding: 12px;
}

.dropzone {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 106px;
  padding: 16px;
  border: 1.5px dashed #b8aea3;
  border-radius: 8px;
  background: #fbf8f1;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone svg {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  margin-right: 14px;
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 3;
}

.dropzone strong {
  align-self: end;
  font-size: 17px;
  line-height: 1.2;
}

.dropzone span,
.note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.group {
  min-width: 0;
  margin-top: 16px;
}

.group-title,
label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.animal-grid {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-auto-flow: column;
  grid-auto-columns: minmax(128px, 38%);
  gap: 8px;
  overflow-x: auto;
  padding: 1px 10px 8px 1px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.animal-grid::-webkit-scrollbar {
  display: none;
}

.animal {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  scroll-snap-align: start;
}

.animal[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.animal svg {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.animal small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.15;
}

.two {
  display: grid;
  gap: 10px;
}

select {
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.generate,
.result-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  border-radius: 8px;
  font-weight: 850;
}

.generate {
  position: sticky;
  bottom: 10px;
  z-index: 5;
  width: 100%;
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(31, 95, 82, 0.22);
}

.generate:hover:not(:disabled) {
  background: var(--accent-strong);
}

button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note {
  margin: 12px 0 0;
}

.preview {
  display: grid;
  gap: 12px;
}

.preview-grid {
  display: grid;
  gap: 12px;
}

.image-box {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(47, 125, 109, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(47, 125, 109, 0.08) 25%, transparent 25%),
    #fbf8f1;
  background-size: 28px 28px;
}

.image-label {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  min-width: 46px;
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.92);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.image-box img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.image-box.has-image img {
  display: block;
}

.image-box.has-image .empty {
  display: none;
}

.empty {
  width: min(250px, 75%);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.loading {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  gap: 12px;
  background: rgba(255, 253, 249, 0.88);
  color: var(--accent-strong);
  font-weight: 850;
}

.loading.active {
  display: grid;
}

.loading span {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(47, 125, 109, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

.result-actions {
  display: grid;
  gap: 10px;
}

.result-actions button {
  width: 100%;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

#downloadBtn:not(:disabled) {
  border-color: var(--berry);
  background: var(--berry);
  color: #fff;
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.status.error {
  color: #9c2632;
}

@media (min-width: 560px) {
  .shell {
    width: min(100vw - 32px, 1240px);
    padding: 20px 0;
  }

  .workspace {
    min-height: calc(100vh - 40px);
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  h1 {
    font-size: 38px;
  }

  .two,
  .result-actions {
    grid-template-columns: 1fr 1fr;
  }

  .animal-grid {
    grid-auto-flow: unset;
    grid-auto-columns: unset;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    padding: 0;
  }

  .dropzone {
    min-height: 150px;
  }

  .preview-grid {
    grid-template-columns: 1fr 1fr;
  }

  .image-box {
    aspect-ratio: 1 / 1;
  }
}

@media (min-width: 980px) {
  .studio {
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 18px;
  }

  .controls,
  .preview {
    padding: 18px;
  }

  .dropzone {
    grid-template-columns: 1fr;
    place-items: center;
    min-height: 190px;
    text-align: center;
  }

  .dropzone svg {
    grid-row: auto;
    width: 64px;
    height: 64px;
    margin: 0 0 12px;
  }

  .generate {
    position: static;
  }

  .preview {
    min-height: 680px;
  }

  .image-box {
    aspect-ratio: auto;
    min-height: 520px;
  }

  .result-actions {
    display: flex;
    justify-content: flex-end;
  }

  .result-actions button {
    width: auto;
  }
}
