/* AI Studio — Your Imagination, Our Threads */
:root {
  --ai-primary: #8868c9;
  --ai-secondary: #6542a9;
  --ai-glass: rgba(255, 255, 255, 0.72);
  --ai-glass-border: rgba(136, 104, 201, 0.22);
}

body.dark-mode {
  --ai-glass: rgba(24, 24, 32, 0.82);
  --ai-glass-border: rgba(136, 104, 201, 0.35);
}

.ai-hero {
  position: relative;
  background: linear-gradient(135deg, #5b3f9e 0%, #8868c9 40%, #6542a9 75%, #3d2a6e 100%);
  color: #fff;
  padding: 56px 0 48px;
  overflow: hidden;
}

.ai-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(255, 107, 107, 0.1) 0%, transparent 40%);
  pointer-events: none;
}

.ai-hero-mesh {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 18px, rgba(255,255,255,.06) 18px, rgba(255,255,255,.06) 19px);
  animation: aiMeshDrift 24s linear infinite;
}

@keyframes aiMeshDrift {
  from { transform: translateX(0); }
  to { transform: translateX(36px); }
}

.ai-hero .container { position: relative; z-index: 1; }

.ai-hero h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.75rem);
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.15;
}

.ai-hero h1 span {
  background: linear-gradient(45deg, #ffd700, #ff8a65);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ai-hero p {
  opacity: 0.92;
  max-width: 640px;
  margin: 0 auto 20px;
  font-size: 1.02rem;
}

.ai-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.ai-badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.78rem;
  font-weight: 600;
}

.ai-section { padding: 32px 0 64px; }

.ai-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  justify-content: center;
}

.ai-tab {
  border: 1.5px solid var(--ai-glass-border);
  background: var(--ai-glass);
  backdrop-filter: blur(12px);
  color: inherit;
  padding: 11px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-tab:hover,
.ai-tab.active {
  border-color: var(--ai-primary);
  background: linear-gradient(135deg, rgba(136, 104, 201, 0.18), rgba(101, 66, 169, 0.14));
  color: var(--ai-secondary);
  box-shadow: 0 4px 18px rgba(101, 66, 169, 0.18);
}

body.dark-mode .ai-tab {
  color: #c8c8d8;
}

body.dark-mode .ai-tab:hover {
  color: #e8e8f4;
}

body.dark-mode .ai-tab.active { color: #e9d5ff; }

.ai-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.ai-panel {
  background: var(--ai-glass);
  border: 1px solid var(--ai-glass-border);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 32px rgba(101, 66, 169, 0.08);
}

.ai-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-panel h3 i { color: var(--ai-primary); }

.ai-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #7a7f8c;
  margin-bottom: 6px;
  display: block;
}

body.dark-mode .ai-label { color: #a0a5b5; }

.ai-input,
.ai-select,
.ai-textarea {
  width: 100%;
  border: 1.5px solid #e7e7ef;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.9);
  color: inherit;
  transition: border-color 0.2s;
}

body.dark-mode .ai-input,
body.dark-mode .ai-select,
body.dark-mode .ai-textarea {
  background: rgba(30, 30, 40, 0.9);
  border-color: #3a3a48;
}

.ai-input:focus,
.ai-select:focus,
.ai-textarea:focus {
  outline: none;
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 3px rgba(136, 104, 201, 0.15);
}

.ai-textarea { min-height: 96px; resize: vertical; }

.ai-field { margin-bottom: 16px; }

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-chip {
  border: 1px solid #d8c9f0;
  background: rgba(136, 104, 201, 0.08);
  color: var(--ai-secondary);
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-chip:hover {
  background: var(--ai-primary);
  color: #fff;
  border-color: var(--ai-primary);
}

body.dark-mode .ai-chip { color: #c4b5fd; border-color: #4a3d6b; }

.ai-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.ai-btn-primary {
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
  color: #fff;
  box-shadow: 0 6px 20px rgba(101, 66, 169, 0.32);
  width: 100%;
}

.ai-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(101, 66, 169, 0.42);
}

.ai-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.ai-btn-primary.is-cooling {
  opacity: 0.85;
  background: #6b7280;
  border-color: #6b7280;
  box-shadow: none;
}

.ai-quota-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #6b7280;
}

body.dark-mode .ai-quota-hint {
  color: #9ca3af;
}

.ai-btn-ghost {
  background: transparent;
  border: 1.5px solid var(--ai-glass-border);
  color: var(--ai-secondary);
}

body.dark-mode .ai-btn-ghost { color: #c4b5fd; }

.ai-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.ai-preview {
  min-height: 380px;
  border-radius: 14px;
  background: #111;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-preview img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

.ai-preview-placeholder {
  text-align: center;
  color: #888;
  padding: 40px 20px;
}

.ai-preview-placeholder i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.ai-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  padding: 8px;
  position: relative;
}

.ai-compare-col {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a1a;
  min-height: 200px;
  cursor: zoom-in;
}

.ai-compare-col:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

.ai-compare-col span {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  z-index: 2;
}

.ai-compare-col img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  min-height: 200px;
}

.ai-result-single {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.ai-result-single img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  cursor: zoom-in;
}

.ai-hd-open-btn {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(20, 16, 28, .82);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(6px);
  transition: background .2s, transform .2s;
}

.ai-compare .ai-hd-open-btn {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 4px;
}

.ai-hd-open-btn:hover {
  background: rgba(101, 66, 169, .9);
  transform: translateY(-1px);
}

/* HD lightbox */
body.ai-hd-open {
  overflow: hidden;
}

.ai-hd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: stretch;
  justify-content: center;
}

.ai-hd-lightbox.is-open {
  display: flex;
}

.ai-hd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 14, 0.88);
  backdrop-filter: blur(4px);
}

.ai-hd-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  padding: 16px;
}

.ai-hd-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ai-hd-modes {
  display: inline-flex;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.ai-hd-mode {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.78);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.ai-hd-mode.active {
  background: linear-gradient(135deg, #8868c9, #6542a9);
  color: #fff;
}

.ai-hd-actions {
  display: flex;
  gap: 8px;
}

.ai-hd-tool {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
}

.ai-hd-tool:hover {
  background: rgba(136, 104, 201, .85);
}

.ai-hd-stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-hd-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  align-items: stretch;
}

.ai-hd-panel {
  margin: 0;
  background: #0d0b12;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ai-hd-panel figcaption {
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.ai-hd-panel img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  background: #000;
}

.ai-hd-panel-solo {
  width: min(100%, 1100px);
}

.ai-hd-panel-solo img {
  max-height: calc(100vh - 130px);
}

.ai-hd-empty {
  color: rgba(255,255,255,.7);
}

@media (max-width: 768px) {
  .ai-compare {
    grid-template-columns: 1fr;
  }

  .ai-hd-compare {
    grid-template-columns: 1fr;
  }

  .ai-hd-shell {
    padding: 10px;
  }

  .ai-hd-panel img,
  .ai-hd-panel-solo img {
    max-height: none;
  }
}

.ai-loading {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 5;
}

.ai-loading.active { display: flex; }

.ai-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: aiSpin 0.9s linear infinite;
  margin-bottom: 14px;
}

@keyframes aiSpin { to { transform: rotate(360deg); } }

.ai-loading p { font-size: 0.88rem; opacity: 0.9; }

.ai-design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.ai-design-card {
  border: 2px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #f5f5f8;
  transition: all 0.2s;
}

body.dark-mode .ai-design-card { background: #2a2a35; }

.ai-design-card.selected {
  border-color: var(--ai-primary);
  box-shadow: 0 4px 16px rgba(136, 104, 201, 0.35);
}

.ai-design-card img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}

.ai-design-card small {
  display: block;
  padding: 6px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-upload-zone {
  border: 2px dashed var(--ai-glass-border);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(136, 104, 201, 0.04);
}

.ai-upload-zone:hover,
.ai-upload-zone.dragover {
  border-color: var(--ai-primary);
  background: rgba(136, 104, 201, 0.1);
}

.ai-upload-zone i { font-size: 2rem; color: var(--ai-primary); margin-bottom: 8px; }

.ai-upload-preview {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  max-height: 160px;
}

.ai-upload-preview img { width: 100%; object-fit: cover; display: block; }

.ai-disclaimer {
  font-size: 0.72rem;
  color: #9aa0ad;
  margin-top: 14px;
  line-height: 1.5;
}

body.dark-mode .ai-disclaimer { color: #9090a8; }

body.dark-mode .ai-panel h3 { color: #f0f0f8; }

body.dark-mode .ai-design-card small { color: #c8c8d8; }

.ai-error {
  background: #fff0f0;
  border: 1px solid #ffc9c9;
  color: #c0392b;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  margin: 0 0 18px;
  display: none;
}

.ai-error.visible { display: block; }

body.dark-mode .ai-error { background: #3a2020; border-color: #6b3030; color: #ff8a8a; }

.ai-tab-pane { display: none; }
.ai-tab-pane.active { display: block; }

.ai-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  border-radius: 50px;
  padding: 14px 24px;
  box-shadow: 0 8px 28px rgba(101, 66, 169, 0.45);
}

@media (max-width: 992px) {
  .ai-workspace { grid-template-columns: 1fr; }
  .ai-fab { display: inline-flex; }
}

@media (max-width: 576px) {
  .ai-compare { grid-template-columns: 1fr; }
  .ai-design-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}
