.ai-image-builder {
  display: grid;
  gap: 0.8rem;
  align-content: start;
}

.ai-image-page {
  width: min(1200px, calc(100% - 1.5rem));
  margin: 0.8rem auto 1.4rem;
  display: grid;
  gap: 0.8rem;
}

.ai-image-builder--modal {
  width: 100%;
}

.ai-image-builder--page .ai-image-grid {
  grid-template-columns: 1fr;
}

.ai-image-builder--page .ai-image-card--controls {
  border: 0;
  background: transparent !important;
  padding: 0;
  border-radius: 0;
}

.ai-image-builder--page .ai-image-control-shell {
  grid-template-columns: minmax(0, 1fr) minmax(190px, auto) minmax(170px, auto) auto;
  align-items: center;
  gap: 0.8rem;
  border-radius: 999px;
  padding: 0.45rem 0.5rem 0.45rem 0.55rem;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(0, 0, 0, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.ai-image-builder--page .ai-image-prompt-shell {
  min-height: 62px;
  padding: 0 0.4rem 0 0.95rem;
  gap: 0.75rem;
  border-radius: 999px;
  background: transparent;
}

.ai-image-builder--page .ai-image-style-select-wrap,
.ai-image-builder--page .ai-image-mode-select-wrap {
  position: relative;
  min-width: 170px;
}

.ai-image-style-select {
  width: 100%;
  min-height: 54px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.8rem 2.75rem 0.8rem 1.2rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.ai-image-builder--page .ai-image-mode-select {
  width: 100%;
  min-height: 62px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.8rem 2.75rem 0.8rem 1.2rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.ai-image-builder--page .ai-image-style-select {
  min-height: 62px;
  font-size: 1.05rem;
}

.ai-image-style-select-wrap::after,
.ai-image-builder--page .ai-image-mode-select-wrap::after {
  content: "\f078";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.7;
}

.ai-image-builder--page .ai-image-prompt-icon {
  color: color-mix(in srgb, currentColor 70%, transparent);
}

.ai-image-builder--page .ai-image-prompt-input {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.75rem 0;
}

.ai-image-builder--page .ai-image-choice-card--compact {
  min-width: 150px;
  min-height: 60px;
  padding: 0.75rem 1.05rem;
  background: rgba(255, 255, 255, 0.52);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.ai-image-builder--page .ai-image-choice-card--compact.is-selected {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(0, 0, 0, 0.2);
}

.ai-image-builder--page .ai-image-choice-copy--compact {
  gap: 0.5rem;
}

.ai-image-builder--page .ai-image-actions--shell .ai-image-btn {
  min-height: 62px;
  min-width: 210px;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-size: 1.05rem;
}

.ai-image-builder--page .ai-image-actions--shell {
  justify-content: flex-end;
}

.ai-image-hero {
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.ai-image-hero h1 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: clamp(1.4rem, 2vw, 1.95rem);
}

.ai-image-hero p {
  margin: 0.42rem 0 0;
  max-width: 72ch;
  font-size: 1rem;
  line-height: 1.45;
}

.ai-image-grid {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
}

.ai-image-card {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  padding: 0.95rem;
  display: grid;
  gap: 0.8rem;
  align-content: start;
  justify-content: stretch;
  align-items: start;
  justify-items: stretch;
  height: fit-content;
}

.ai-image-card h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.12rem;
}

.ai-image-label {
  font-size: 0.95rem;
  font-weight: 800;
}

.ai-image-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-image-quota {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.ai-image-control-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, auto) auto auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.3);
}

.ai-image-style-select-wrap {
  position: relative;
  min-width: 170px;
}

.ai-image-prompt-shell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.45rem 0 0.8rem;
}

.ai-image-prompt-icon {
  font-size: 1rem;
  opacity: 0.7;
  flex: 0 0 auto;
}

.ai-image-prompt-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.72rem 0;
}

.ai-image-prompt-input::placeholder {
  color: inherit;
  opacity: 0.6;
}

.ai-image-prompt-input:focus {
  outline: none;
}

.ai-image-form-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 0.86rem;
  font-weight: 800;
}

.ai-image-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.ai-image-choice-card {
  position: relative;
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

.ai-image-choice-card:hover {
  transform: translateY(-1px);
}

.ai-image-choice-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ai-image-choice-card.is-selected {
  border-color: rgba(0, 0, 0, 0.42);
  background: rgba(255, 255, 255, 0.28);
}

.ai-image-choice-visual {
  position: relative;
  min-height: 108px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.56);
  overflow: hidden;
}

.ai-image-choice-copy {
  display: grid;
  gap: 0.2rem;
}

.ai-image-choice-copy i {
  font-size: 1.15rem;
}

.ai-image-choice-copy strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.ai-image-choice-copy small {
  font-size: 0.86rem;
  line-height: 1.4;
}

.ai-image-choice-card--simple {
  min-height: 96px;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.ai-image-choice-card--compact {
  min-height: 54px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  gap: 0;
  justify-items: center;
  align-content: center;
  text-align: center;
  min-width: 150px;
}

.ai-image-choice-copy--simple {
  justify-items: center;
  gap: 0.35rem;
}

.ai-image-choice-copy--compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.ai-image-choice-copy--compact strong {
  font-size: 0.98rem;
}

.ai-image-locked-note {
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  display: grid;
  gap: 0.6rem;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-image-locked-note p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  font-weight: 800;
  color: #ffffff;
}

.ai-image-locked-note .ai-image-btn {
  color: inherit !important;
}

.ai-image-locked-note .ai-image-btn i {
  color: inherit !important;
}

.ai-image-choice-visual-classic {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.55rem;
  padding: 0.8rem;
  align-items: center;
}

.ai-image-choice-chip,
.ai-image-choice-accent,
.ai-image-choice-lines span,
.ai-image-choice-screen,
.ai-image-choice-desk,
.ai-image-choice-ground {
  display: block;
  background: currentColor;
  opacity: 0.75;
}

.ai-image-choice-chip {
  width: 22px;
  height: 22px;
  border-radius: 8px;
}

.ai-image-choice-accent {
  position: absolute;
  left: 0.8rem;
  bottom: 0.8rem;
  width: 34px;
  height: 10px;
  border-radius: 999px;
}

.ai-image-choice-lines {
  display: grid;
  gap: 0.42rem;
}

.ai-image-choice-lines span {
  height: 8px;
  border-radius: 999px;
}

.ai-image-choice-lines span:nth-child(2) {
  width: 82%;
}

.ai-image-choice-lines span:nth-child(3) {
  width: 68%;
}

.ai-image-choice-visual-editorial,
.ai-image-choice-visual-scene,
.ai-image-choice-visual-colour,
.ai-image-choice-visual-outline {
  padding: 0.8rem;
}

.ai-image-choice-figure,
.ai-image-choice-person {
  position: absolute;
  left: 0.95rem;
  bottom: 0.95rem;
  width: 42px;
  height: 54px;
  border: 3px solid currentColor;
  border-radius: 20px 20px 14px 14px;
  opacity: 0.75;
}

.ai-image-choice-figure::before,
.ai-image-choice-person::before {
  content: "";
  position: absolute;
  top: -22px;
  left: 9px;
  width: 18px;
  height: 18px;
  border: 3px solid currentColor;
  border-radius: 50%;
}

.ai-image-choice-screen {
  position: absolute;
  right: 0.95rem;
  top: 1rem;
  width: 68px;
  height: 44px;
  border-radius: 10px;
}

.ai-image-choice-desk {
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  bottom: 0.95rem;
  height: 8px;
  border-radius: 999px;
}

.ai-image-choice-object {
  position: absolute;
  right: 1rem;
  bottom: 1.15rem;
  width: 52px;
  height: 40px;
  border: 3px solid currentColor;
  border-radius: 16px;
  opacity: 0.65;
}

.ai-image-choice-ground {
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0.8rem;
  height: 8px;
  border-radius: 999px;
}

.ai-image-choice-dot {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.ai-image-choice-dot-one {
  left: 1rem;
  top: 1rem;
  background: #1f2a44;
}

.ai-image-choice-dot-two {
  left: 2.75rem;
  top: 2rem;
  background: #2bb3b1;
}

.ai-image-choice-dot-three {
  left: 4.5rem;
  top: 1rem;
  background: #f2c14e;
}

.ai-image-choice-dot-four {
  left: 6.15rem;
  top: 2rem;
  background: #b48ae6;
}

.ai-image-choice-outline-box {
  position: absolute;
  inset: 1rem;
  border: 4px solid currentColor;
  border-radius: 16px;
  opacity: 0.75;
}

.ai-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-image-actions--shell {
  justify-content: flex-end;
}

.ai-image-download-split {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: visible;
}

.ai-image-btn {
  border: none;
  border-radius: 999px;
  min-height: 54px;
  padding: 0.75rem 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.ai-image-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download-split > button {
  border-radius: 0 !important;
}

.download-split > .ai-image-btn:first-child {
  border-top-left-radius: 999px !important;
  border-bottom-left-radius: 999px !important;
}

.download-size-toggle {
  min-width: 92px;
  border-left: 2px solid rgba(255, 255, 255, 0.34);
  padding-left: 0.7rem;
  padding-right: 0.7rem;
  background-image: linear-gradient(rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.16));
}

.download-split > .download-size-toggle {
  border-top-right-radius: 999px !important;
  border-bottom-right-radius: 999px !important;
}

.download-split > .download-size-toggle:hover,
.download-split > .download-size-toggle:focus-visible {
  background-image: linear-gradient(rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.22));
  outline: none;
}

.download-size-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1600;
  min-width: 120px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.download-size-menu button {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #222222;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.download-size-menu button:hover,
.download-size-menu button:focus-visible {
  background: rgba(0, 0, 0, 0.08);
  outline: none;
}

.download-size-menu button.active {
  background: rgba(0, 0, 0, 0.12);
}

.ai-image-prompt-input:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.ai-image-preview-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  border-radius: 12px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.12);
  max-width: min(420px, calc(100% - 1rem));
}

.ai-image-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.14);
  border-top-color: rgba(0, 0, 0, 0.72);
  animation: ai-image-spin 0.85s linear infinite;
  flex: 0 0 auto;
}

.ai-image-progress-copy {
  display: grid;
  gap: 0.18rem;
  justify-items: start;
}

.ai-image-progress-copy strong,
.ai-image-progress-copy span,
.ai-image-progress-copy small {
  font-size: 0.95rem;
  line-height: 1.35;
}

.ai-image-progress-copy small {
  font-size: 0.84rem;
  opacity: 0.82;
}

.ai-image-status {
  margin: 0;
  min-height: 1rem;
  font-size: 0.92rem;
  font-weight: 800;
}

.ai-image-status.error {
  color: #8f1515;
}

.ai-image-preview-wrap {
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  padding: 0.9rem;
  align-self: start;
}

.ai-image-preview {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background-color: #f7f7f7;
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.08) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.75rem;
  box-sizing: border-box;
  align-self: start;
}

.ai-image-preview.is-loading {
  padding: 1rem;
}

.ai-image-preview svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ai-image-palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.ai-image-quota-card {
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.3rem;
}

.ai-image-quota-card-label {
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ai-image-colour-card {
  display: grid;
  gap: 0.35rem;
}

.ai-image-colour-card label {
  font-size: 0.92rem;
  font-weight: 800;
}

.ai-image-colour-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.ai-image-colour-row input[type="color"] {
  width: 56px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.ai-image-colour-row input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  min-height: 42px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.95rem;
}

@keyframes ai-image-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .ai-image-grid {
    grid-template-columns: 1fr;
  }

  .ai-image-control-shell {
    grid-template-columns: 1fr;
    border-radius: 18px;
  }

  .ai-image-mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-image-choice-card--compact,
  .ai-image-actions--shell .ai-image-btn,
  .ai-image-download-split {
    width: 100%;
  }

  .ai-image-builder--page .ai-image-control-shell {
    grid-template-columns: 1fr;
    border-radius: 26px;
    padding: 0.55rem;
  }

  .ai-image-builder--page .ai-image-style-select-wrap,
  .ai-image-builder--page .ai-image-mode-select-wrap,
  .ai-image-builder--page .ai-image-actions--shell .ai-image-btn,
  .ai-image-builder--page .ai-image-download-split {
    width: 100%;
    min-width: 0;
  }

  .ai-image-builder--page .ai-image-actions--shell {
    justify-content: stretch;
  }

  .download-split > .ai-image-btn:first-child,
  .download-split > .download-size-toggle {
    min-width: 0;
    flex: 1 1 auto;
  }
}

@media (max-width: 640px) {
  .ai-image-page {
    width: min(100%, calc(100% - 1rem));
  }

  .ai-image-preview {
    min-height: 280px;
  }

  .ai-image-palette {
    grid-template-columns: 1fr;
  }

  .ai-image-mode-toggle {
    grid-template-columns: 1fr;
  }
}
