:root {
  color-scheme: light;
  --paper: #fffaf4;
  --paper-strong: rgba(255, 255, 255, 0.94);
  --ink: #1c1712;
  --muted: rgba(28, 23, 18, 0.62);
  --line: rgba(28, 23, 18, 0.08);
  --yellow: #ffd400;
  --yellow-deep: #ffb800;
  --pink: #ff4aa5;
  --pink-deep: #e9288f;
  --green: #2bb673;
  --shadow-soft: 0 20px 60px rgba(148, 118, 88, 0.14);
  --shadow-card: 0 18px 42px rgba(32, 23, 14, 0.08);
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 20px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 212, 0, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 74, 165, 0.18), transparent 28%),
    linear-gradient(180deg, #fffefb 0%, #fff6eb 100%);
  color: var(--ink);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

body {
  position: relative;
}

button,
textarea {
  font: inherit;
}

.page-glow {
  position: fixed;
  inset: auto;
  pointer-events: none;
  width: 32vw;
  height: 32vw;
  filter: blur(72px);
  opacity: 0.45;
}

.page-glow-left {
  top: -12vw;
  left: -10vw;
  background: radial-gradient(circle, rgba(255, 212, 0, 0.46), transparent 72%);
}

.page-glow-right {
  right: -10vw;
  bottom: -12vw;
  background: radial-gradient(circle, rgba(255, 74, 165, 0.34), transparent 70%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.brand-block h1,
.section-head h2,
.preview-header h2,
.gallery-header h2 {
  margin: 0;
  font-family: "Bricolage Grotesque", "Arial Black", sans-serif;
  letter-spacing: -0.04em;
}

.brand-block h1 {
  font-size: clamp(3rem, 6vw, 6rem);
  line-height: 0.92;
}

.intro-copy,
.section-copy,
.status-message,
.rule-card p,
.detail-row dd {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(28, 23, 18, 0.48);
}

.topbar-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 440px;
}

.meta-pill,
.gallery-count,
.model-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(28, 23, 18, 0.08);
  box-shadow: 0 10px 24px rgba(255, 255, 255, 0.24);
  font-size: 0.92rem;
  font-weight: 700;
}

.meta-pill-live,
.model-pill {
  background: linear-gradient(135deg, rgba(255, 212, 0, 0.18), rgba(255, 74, 165, 0.12));
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.82fr);
  gap: 18px;
  margin-bottom: 18px;
}

.studio-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(255, 252, 247, 0.92)),
    var(--paper-strong);
  border: 1px solid var(--line);
  box-shadow:
    var(--shadow-card),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.studio-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 212, 0, 0.14), transparent 24%),
    linear-gradient(325deg, rgba(255, 74, 165, 0.12), transparent 22%);
  opacity: 0.65;
}

.composer-card,
.preview-card,
.gallery-card {
  padding: 28px;
}

.generation-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

.field-label,
.rule-title,
.detail-row dt {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(28, 23, 18, 0.1);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
  color: var(--ink);
  line-height: 1.5;
}

textarea:focus {
  outline: 3px solid rgba(255, 212, 0, 0.24);
  border-color: rgba(255, 184, 0, 0.34);
}

.prompt-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hint-chip,
.refresh-button {
  border: 1px solid rgba(28, 23, 18, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

.hint-chip,
.refresh-button,
.generate-button {
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.hint-chip:hover,
.refresh-button:hover,
.generate-button:hover,
.gallery-item:hover {
  transform: translateY(-2px);
}

.form-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.status-block {
  display: grid;
  gap: 8px;
}

.status-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-ready {
  background: rgba(43, 182, 115, 0.12);
  color: #12794a;
}

.status-working {
  background: rgba(255, 212, 0, 0.18);
  color: #8b6700;
}

.status-error {
  background: rgba(255, 74, 165, 0.14);
  color: #b10d64;
}

.generate-button {
  border: 0;
  min-width: 210px;
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  color: #23170c;
  box-shadow: 0 18px 34px rgba(255, 74, 165, 0.18);
}

.generate-button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.rules-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.rule-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(28, 23, 18, 0.08);
}

.rule-card p {
  margin: 8px 0 0;
  font-size: 0.96rem;
  line-height: 1.45;
}

.preview-card {
  display: grid;
  gap: 18px;
  align-content: start;
}

.preview-header,
.gallery-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.preview-frame {
  position: relative;
  z-index: 1;
  min-height: 420px;
  display: grid;
  place-items: center;
  border-radius: 30px;
  border: 1px solid rgba(28, 23, 18, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 247, 237, 0.84)),
    #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

#preview-image {
  width: min(100%, 520px);
  max-height: 520px;
  object-fit: contain;
}

.preview-placeholder {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

.placeholder-emoji {
  font-size: 4rem;
  line-height: 1;
  color: rgba(255, 212, 0, 0.72);
}

.detail-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  margin: 0;
}

.detail-row {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(28, 23, 18, 0.08);
}

.detail-row dd {
  margin: 0;
  line-height: 1.45;
}

.gallery-card {
  display: grid;
  gap: 20px;
}

.gallery-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.gallery-item,
.gallery-empty {
  border-radius: 24px;
  border: 1px solid rgba(28, 23, 18, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.gallery-item {
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.gallery-item.is-selected {
  border-color: rgba(255, 74, 165, 0.3);
  box-shadow: var(--shadow-soft);
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  object-fit: cover;
  background: linear-gradient(180deg, rgba(255, 212, 0, 0.08), rgba(255, 74, 165, 0.08));
}

.gallery-caption {
  display: grid;
  gap: 6px;
  padding: 12px 4px 4px;
}

.gallery-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-prompt {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.95rem;
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

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

  .preview-frame {
    min-height: 340px;
  }

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

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    padding: 18px 0 24px;
  }

  .topbar,
  .form-footer,
  .preview-header,
  .gallery-header {
    flex-direction: column;
  }

  .rules-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .composer-card,
  .preview-card,
  .gallery-card {
    padding: 20px;
  }

  .brand-block h1 {
    font-size: clamp(2.8rem, 18vw, 4.6rem);
  }

  .generate-button,
  .refresh-button {
    width: 100%;
  }
}
