.app-project-ai-action{
  align-self: end;
  display: flex;
  min-width: 190px;
}

.ai-design-open-button{
  width: 100%;
  white-space: nowrap;
}

.ai-design-modal[hidden]{
  display: none;
}

.ai-design-modal{
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.ai-design-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(10px);
}

.ai-design-dialog{
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, #17202c 0%, #111923 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  color: #f8fafc;
  padding: 24px;
}

.ai-design-header{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ai-design-header h2{
  margin: 6px 0 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.ai-design-icon-button{
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.68);
  color: #f8fafc;
  cursor: pointer;
  font: 600 24px/1 "IBM Plex Sans", sans-serif;
}

.ai-design-icon-button:hover{
  border-color: rgba(226, 232, 240, 0.42);
  background: rgba(30, 41, 59, 0.9);
}

.ai-design-description{
  margin: 14px 0 18px;
  color: #cbd5e1;
}

.ai-design-credit{
  display: grid;
  gap: 4px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.58);
}

.ai-design-credit strong{
  color: #f8fafc;
  font-size: 0.95rem;
}

.ai-design-credit span{
  color: #cbd5e1;
  font-size: 0.86rem;
}

.ai-design-credit[data-status="ready"]{
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(20, 83, 45, 0.18);
}

.ai-design-credit[data-status="loading"]{
  border-color: rgba(147, 197, 253, 0.28);
}

.ai-design-credit[data-status="error"]{
  border-color: rgba(248, 113, 113, 0.36);
  background: rgba(127, 29, 29, 0.18);
}

.ai-design-field{
  display: grid;
  gap: 8px;
}

.ai-design-field span{
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-design-field textarea{
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.86);
  color: #f8fafc;
  font: 500 0.98rem/1.5 "IBM Plex Sans", sans-serif;
  padding: 14px;
  outline: none;
}

.ai-design-field textarea:focus{
  border-color: rgba(56, 189, 248, 0.62);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.ai-design-field textarea::placeholder{
  color: rgba(203, 213, 225, 0.62);
}

.ai-design-status{
  min-height: 24px;
  margin-top: 12px;
  color: #cbd5e1;
  font-size: 0.92rem;
}

.ai-design-status[data-status="error"]{
  color: #fca5a5;
}

.ai-design-status[data-status="info"]{
  color: #93c5fd;
}

.ai-design-loading{
  margin-top: 4px;
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 700;
}

.ai-design-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.ai-design-modal-open{
  overflow: hidden;
}

@media (max-width: 720px){
  .app-project-ai-action{
    width: 100%;
  }

  .ai-design-open-button{
    min-height: 44px;
  }

  .ai-design-modal{
    align-items: end;
    padding: 12px;
  }

  .ai-design-dialog{
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .ai-design-actions{
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* --- AI modal premium generation states --- */
.ai-design-dialog .ai-design-loading,
.ai-design-dialog .ai-design-success {
  display: none;
}

.ai-design-dialog[data-ai-state="loading"] .ai-design-description,
.ai-design-dialog[data-ai-state="loading"] .ai-design-credit,
.ai-design-dialog[data-ai-state="loading"] .ai-design-credit-info,
.ai-design-dialog[data-ai-state="loading"] #aiDesignCreditInfo,
.ai-design-dialog[data-ai-state="loading"] .ai-design-field,
.ai-design-dialog[data-ai-state="loading"] label[for="aiDesignPromptInput"],
.ai-design-dialog[data-ai-state="loading"] .ai-design-status,
.ai-design-dialog[data-ai-state="loading"] .ai-design-actions {
  display: none;
}

.ai-design-dialog[data-ai-state="success"] .ai-design-description,
.ai-design-dialog[data-ai-state="success"] .ai-design-credit,
.ai-design-dialog[data-ai-state="success"] .ai-design-credit-info,
.ai-design-dialog[data-ai-state="success"] #aiDesignCreditInfo,
.ai-design-dialog[data-ai-state="success"] .ai-design-field,
.ai-design-dialog[data-ai-state="success"] label[for="aiDesignPromptInput"],
.ai-design-dialog[data-ai-state="success"] .ai-design-status,
.ai-design-dialog[data-ai-state="success"] .ai-design-actions,
.ai-design-dialog[data-ai-state="success"] .ai-design-loading {
  display: none;
}

.ai-design-dialog[data-ai-state="loading"] .ai-design-loading,
.ai-design-dialog[data-ai-state="success"] .ai-design-success {
  display: flex;
}

.ai-design-loading,
.ai-design-success {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 260px;
  margin-top: 10px;
  padding: 28px 22px;
  border-radius: 22px;
  border: 1px solid rgba(212, 175, 55, 0.22);
  background:
    radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.16), transparent 38%),
    linear-gradient(135deg, rgba(9, 18, 32, 0.96), rgba(18, 30, 46, 0.94));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 18px 42px rgba(3, 7, 18, 0.28);
  text-align: center;
}

.ai-weave-anim {
  display: grid;
  grid-template-columns: repeat(4, 18px);
  grid-template-rows: repeat(4, 18px);
  gap: 6px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(212, 175, 55, 0.2);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.05) 1px, transparent 1px),
    rgba(255,255,255,0.04);
  background-size: 12px 12px;
  box-shadow: 0 0 28px rgba(212, 175, 55, 0.12);
}

.ai-weave-anim span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.08);
  animation: aiWeavePulse 1.45s ease-in-out infinite;
}

.ai-weave-anim span:nth-child(1) { animation-delay: 0s; }
.ai-weave-anim span:nth-child(2) { animation-delay: .06s; }
.ai-weave-anim span:nth-child(3) { animation-delay: .12s; }
.ai-weave-anim span:nth-child(4) { animation-delay: .18s; }
.ai-weave-anim span:nth-child(5) { animation-delay: .06s; }
.ai-weave-anim span:nth-child(6) { animation-delay: .12s; }
.ai-weave-anim span:nth-child(7) { animation-delay: .18s; }
.ai-weave-anim span:nth-child(8) { animation-delay: .24s; }
.ai-weave-anim span:nth-child(9) { animation-delay: .12s; }
.ai-weave-anim span:nth-child(10) { animation-delay: .18s; }
.ai-weave-anim span:nth-child(11) { animation-delay: .24s; }
.ai-weave-anim span:nth-child(12) { animation-delay: .30s; }
.ai-weave-anim span:nth-child(13) { animation-delay: .18s; }
.ai-weave-anim span:nth-child(14) { animation-delay: .24s; }
.ai-weave-anim span:nth-child(15) { animation-delay: .30s; }
.ai-weave-anim span:nth-child(16) { animation-delay: .36s; }

@keyframes aiWeavePulse {
  0%, 100% {
    transform: scale(1);
    background: rgba(255,255,255,0.1);
    box-shadow: none;
  }
  45% {
    transform: scale(1.12);
    background: rgba(212, 175, 55, 0.72);
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.42);
  }
}

.ai-loading-title,
.ai-success-title {
  color: #f8fafc;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ai-loading-desc,
.ai-success-desc {
  max-width: 430px;
  margin: 0;
  color: rgba(248, 250, 252, 0.72);
  font-size: 0.9rem;
  line-height: 1.55;
}

.ai-show-design-btn {
  margin-top: 8px;
  min-width: 170px;
}

@media (max-width: 640px) {
  .ai-design-loading,
  .ai-design-success {
    min-height: 220px;
    padding: 22px 16px;
  }

  .ai-weave-anim {
    grid-template-columns: repeat(4, 15px);
    grid-template-rows: repeat(4, 15px);
    gap: 5px;
    padding: 14px;
  }

  .ai-weave-anim span {
    width: 15px;
    height: 15px;
  }
}
