:root {
  --bg: #f3efe4;
  --panel: rgba(252, 248, 239, 0.9);
  --panel-strong: #fffaf0;
  --ink: #171411;
  --muted: #61584f;
  --accent: #ca5b2d;
  --accent-dark: #8f3c1d;
  --line: rgba(23, 20, 17, 0.12);
  --shadow: 0 20px 60px rgba(56, 33, 12, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Hiragino Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(202, 91, 45, 0.18), transparent 32%),
    radial-gradient(circle at bottom right, rgba(36, 81, 104, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f5ec 0%, var(--bg) 100%);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero__text {
  max-width: 56ch;
  margin: 18px 0 0;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

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

.status-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-card {
  padding: 18px 20px;
}

.status-card__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.status-card__text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
}

.panel {
  padding: 22px;
}

.panel--gallery {
  position: relative;
  overflow: hidden;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field span,
.panel__header h2 {
  font-size: 0.92rem;
  font-weight: 700;
}

.field textarea,
.field select,
.field input {
  width: 100%;
  border: 1px solid rgba(23, 20, 17, 0.16);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 14px 16px;
  font: inherit;
}

.field__hint {
  color: var(--muted);
  line-height: 1.5;
}

.field textarea {
  resize: vertical;
  min-height: 180px;
}

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

.field--compact {
  max-width: 220px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #e08f3e 100%);
  color: #fffaf3;
  padding: 14px 24px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
  box-shadow: 0 14px 26px rgba(202, 91, 45, 0.28);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.button-secondary {
  background: rgba(23, 20, 17, 0.08);
  color: var(--ink);
  box-shadow: none;
}

.button-secondary:hover {
  background: rgba(23, 20, 17, 0.12);
}

.status-message {
  margin: 0;
  color: var(--muted);
}

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

.panel__header h2 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(23, 20, 17, 0.06);
  color: var(--muted);
  font-size: 0.85rem;
}

.prompt-info {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(23, 20, 17, 0.04);
}

.prompt-info__row {
  display: grid;
  gap: 8px;
}

.prompt-info__label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.prompt-info__text {
  margin: 0;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.loading-state {
  position: absolute;
  inset: 76px 22px 22px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 250, 240, 0.84);
  backdrop-filter: blur(8px);
  z-index: 3;
  text-align: center;
}

.loading-state[hidden] {
  display: none;
}

.loading-state__spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(202, 91, 45, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.loading-state__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.loading-state__text {
  margin: 0;
  max-width: 30ch;
  color: var(--muted);
  line-height: 1.6;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  overflow: hidden;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid rgba(23, 20, 17, 0.08);
  animation: card-in 280ms ease both;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: rgba(23, 20, 17, 0.06);
}

.image-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 14px;
}

.image-card__filename {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card__link {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@media (max-width: 900px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .panel {
    padding: 18px;
  }

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