/* Compact, accessible finishing layer for the ideas flow and creative feedback. */
.em-ideas-page {
  width: min(1040px, 100%);
  margin: 0 auto;
  color: #f4f1fb;
}

.em-ideas-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 4px 0 36px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgba(225, 220, 255, .1);
  border-radius: 20px;
  background: radial-gradient(ellipse at 16% 0, rgba(125, 91, 164, .2), transparent 52%), linear-gradient(135deg, #1b1724, #13111a);
}

.em-ideas-kicker {
  margin: 0 0 12px;
  color: #c1a8dd;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

.em-ideas-heading h1 {
  margin: 0;
  color: #f4f1fb;
  font: 700 clamp(30px, 4vw, 43px)/1.08 Manrope, sans-serif;
  letter-spacing: -.045em;
}

.em-ideas-intro {
  max-width: 550px;
  margin: 12px 0 0;
  color: #ada5ba;
  font-size: 14px;
  line-height: 1.6;
}

.em-ideas-open,
.em-ideas-dialog .em-ideas-submit {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 19px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(112deg, #fff0fb 0%, #f8b2ed 52%, #ee77df 100%);
  box-shadow: 0 5px 16px rgba(198, 130, 175, .12);
  color: #111 !important;
  font: 700 13px/1.2 'DM Sans', sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.em-ideas-open:hover,
.em-ideas-dialog .em-ideas-submit:hover {
  background: linear-gradient(112deg, #fff5fd 0%, #ffc4f3 52%, #f78ce9 100%);
}

.em-ideas-saved-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.em-ideas-saved-head h2 {
  margin: 0;
  color: #f4f1fb;
  font: 600 20px/1.25 Manrope, sans-serif;
  letter-spacing: -.025em;
}

.em-ideas-saved-head > span {
  color: #827b8e;
  font-size: 11px;
}

.em-ideas-page .em-idea-list { margin: 0; }
.em-ideas-page .em-ideas-loading {
  display: flex;
  min-height: 92px;
  align-items: center;
  margin: 0;
  padding: 20px;
  border: 1px dashed rgba(225, 220, 255, .15);
  border-radius: 14px;
  color: #a29caf;
  font-size: 12px;
}

/* Native dialog remains closed until its owning script calls showModal(). */
dialog.em-ideas-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(590px, calc(100vw - 28px));
  max-width: 590px;
  max-height: min(88dvh, 820px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(19px, 3.5vw, 29px);
  border: 1px solid rgba(194, 164, 220, .28);
  border-radius: 19px;
  background: radial-gradient(ellipse at 90% 0, rgba(110, 76, 139, .15), transparent 44%), #1b1525;
  color: #f4f1fb;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
}

dialog.em-ideas-dialog:not([open]) { display: none; }
dialog.em-ideas-dialog::backdrop { background: rgba(8, 5, 13, .82); backdrop-filter: blur(8px); }

.em-ideas-dialog .em-dialog-close {
  float: right;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  margin: -8px -8px 0 10px;
  padding: 0;
  border: 1px solid rgba(225, 220, 255, .12);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  color: #d4cddd;
  font: 400 25px/1 'DM Sans', sans-serif;
  cursor: pointer;
}

.em-ideas-dialog .em-dialog-close:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.em-ideas-dialog h2 {
  margin: 4px 54px 22px 0;
  color: #f4f1fb;
  font: 700 clamp(22px, 4vw, 27px)/1.2 Manrope, sans-serif;
  letter-spacing: -.035em;
}

.em-ideas-dialog .em-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid rgba(225, 220, 255, .08);
  border-radius: 13px;
  background: rgba(7, 6, 11, .34);
}

.em-ideas-dialog .em-mode-tabs [role="tab"] {
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #ada5ba;
  font: 600 13px/1.2 'DM Sans', sans-serif;
  cursor: pointer;
}

.em-ideas-dialog .em-mode-tabs [role="tab"][aria-selected="true"] {
  border-color: rgba(194, 174, 255, .26);
  background: linear-gradient(110deg, rgba(86, 65, 115, .4), rgba(46, 37, 60, .78));
  color: #f4efff;
}

.em-ideas-dialog form > div:not([hidden]) > p {
  margin: 0 0 13px;
  color: #b4acbf;
  font-size: 13px;
  line-height: 1.55;
}

.em-ideas-dialog .em-ideas-file-label,
.em-ideas-dialog .em-ideas-prompt-label {
  display: block;
  margin: 0 0 7px;
  color: #e5dff0;
  font-size: 12px;
  font-weight: 600;
}

.em-ideas-dialog .em-ideas-file {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 8px;
  border: 1px dashed rgba(199, 185, 255, .28);
  border-radius: 12px;
  background: rgba(11, 10, 17, .42);
  color: #c9c1d1;
  font: 12px/1.4 'DM Sans', sans-serif;
}

.em-ideas-dialog .em-ideas-file::file-selector-button {
  min-height: 36px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid rgba(225, 220, 255, .14);
  border-radius: 8px;
  background: #292335;
  color: #e8ddf3;
  font: 600 11px 'DM Sans', sans-serif;
  cursor: pointer;
}

.em-ideas-dialog textarea {
  display: block;
  width: 100%;
  min-height: 116px;
  max-height: 34dvh;
  padding: 12px 13px;
  resize: vertical;
  border: 1px solid rgba(225, 220, 255, .14);
  border-radius: 12px;
  outline: none;
  background: #211b2b;
  color: #f4f1fb;
  font: 13px/1.55 'DM Sans', sans-serif;
}

.em-ideas-dialog textarea::placeholder { color: #8f879b; opacity: 1; }
.em-ideas-dialog textarea:focus-visible,
.em-ideas-dialog .em-ideas-file:focus-visible,
.em-ideas-dialog button:focus-visible,
.em-ideas-open:focus-visible {
  outline: 2px solid #c6a9f2;
  outline-offset: 3px;
}

.em-ideas-dialog .em-ideas-submit {
  width: 100%;
  min-height: 48px;
  justify-content: space-between;
  margin-top: 17px;
  padding: 0 15px;
}

.em-ideas-price {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid rgba(0, 0, 0, .18);
  color: #111;
  font: 700 12px/1 'DM Sans', sans-serif;
}

.em-ideas-price .em-gem { width: 12px; height: 11px; background: #111; }
.em-ideas-dialog .em-error { margin: 10px 0 0; color: #ffb3c9; font-size: 12px; line-height: 1.5; }
.em-ideas-dialog .em-idea-list { margin: 12px 0 0; }

/* Results: pending, progress and failure are confined to the creative output. */
.em-studio-page .em-output.em-output-pending {
  isolation: isolate;
  position: relative;
  aspect-ratio: 9 / 12;
  min-height: 0;
  max-height: 420px;
  background: #191622;
}

.em-studio-page .em-output.em-output-pending::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(105deg, transparent 25%, rgba(192, 174, 220, .12) 48%, transparent 68%);
  content: "";
  animation: em-output-skeleton 1.5s ease-in-out infinite alternate;
}

.em-studio-page .em-output-progress {
  position: absolute;
  inset: 50% 12px auto;
  transform: translateY(-50%);
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(225, 220, 255, .12);
  border-radius: 11px;
  background: rgba(15, 13, 22, .9);
  color: #eee9fa;
  font-size: 12px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
}
.em-output-progress .em-pending-spinner { grid-row: span 2; }
.em-output-progress > span:last-child { grid-column: 2; color: #b8afc4; font-size: 11px; }

.em-pending-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(214, 197, 247, .25);
  border-top-color: #d0b9ff;
  border-radius: 50%;
  animation: em-feedback-spin .8s linear infinite;
}

.em-studio-page .em-output-failed {
  border-color: rgba(255, 158, 181, .25);
  background: linear-gradient(145deg, #261821, #19151e);
}

.em-studio-page .em-output-failed .em-output-status { color: #f1b7c7; }

.em-studio-page .em-output-failed {
  transition: opacity .18s ease, transform .18s ease;
}

.em-studio-page .em-output-failed.is-dismissing {
  opacity: 0;
  transform: translateY(-4px);
}

.em-studio-page .em-output-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 220, 235, .18);
  border-radius: 10px;
  background: rgba(18, 14, 22, .72);
  color: #f6dce7;
  font: 400 23px/1 'DM Sans', sans-serif;
  cursor: pointer;
}

.em-studio-page .em-output-failed .em-output-status { padding-right: 48px; }

.em-studio-page .em-output-dismiss:hover {
  background: rgba(255, 220, 235, .14);
  color: #fff;
}

#em-create-button[aria-busy="true"] {
  position: relative;
  cursor: progress;
  opacity: .78;
}

#em-create-button[aria-busy="true"]::after {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid rgba(17, 17, 17, .25);
  border-top-color: #111;
  border-radius: 50%;
  content: "";
  animation: em-feedback-spin .75s linear infinite;
}

.em-toast {
  position: fixed;
  z-index: 1000;
  inset: 50% auto auto 50%;
  width: fit-content;
  max-width: min(430px, calc(100vw - 28px));
  margin: 0;
  transform: translate(-50%, -50%);
  padding: 12px 16px;
  border: 1px solid rgba(225, 220, 255, .16);
  border-radius: 12px;
  background: #211b2b;
  color: #f4f1fb;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
  font: 500 13px/1.45 'DM Sans', sans-serif;
}

dialog.em-image-viewer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  overflow: auto;
  margin: 0;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  border: 0;
  background: transparent;
  color: #f4f1fb;
}

dialog.em-image-viewer:not([open]) { display: none; }
dialog.em-image-viewer::backdrop { background: rgba(9, 8, 14, .76); }
dialog.em-image-viewer > :is(img, video) {
  display: block;
  width: auto;
  height: auto;
  max-width: min(88vw, 1500px);
  max-height: 84dvh;
  object-fit: contain;
  border-radius: 10px;
  background: #121018;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .38);
}

.em-image-viewer .em-image-close,
.em-image-viewer .em-image-download {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(225, 220, 255, .16);
  border-radius: 11px;
  background: rgba(19, 16, 26, .88);
  color: #f4f1fb;
  font: 600 12px/1 'DM Sans', sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.em-image-viewer .em-image-close {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 36px;
  line-height: 1;
}
.em-image-viewer .em-image-download { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }

.em-studio-page .em-result-open {
  position: relative;
  display: block;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.em-studio-page .em-result-open :is(img, video) { display: block; width: 100%; max-height: 550px; object-fit: contain; background: #121018; }
.em-studio-page .em-result-open video { pointer-events: none; }
.em-toast[hidden] { display: none !important; }
.em-idea-secondary { min-height: 44px; margin: 8px 0 0 8px; padding: 0 12px; border: 1px solid #4b4058; border-radius: 10px; background: #221b2d; color: #cfc6da; cursor: pointer; }

.em-studio-page .em-result-buttons { z-index: 2; }
.em-result-video-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(12, 9, 18, .72);
  color: #fff;
  font-size: 13px;
  pointer-events: none;
}
.em-studio-page .em-result-buttons .is-copied { color: #d9caff; }
.em-studio-page .em-idea-secondary {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(225, 220, 255, .13);
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  color: #cfc6da;
  cursor: pointer;
}

.em-studio-page .em-idea-secondary:hover { border-color: rgba(194, 174, 255, .35); color: #fff; }

@keyframes em-output-skeleton {
  from { opacity: .35; }
  to { opacity: 1; }
}

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

@media (max-width: 767px) {
  .em-ideas-heading { align-items: stretch; flex-direction: column; gap: 20px; margin-bottom: 27px; padding: 22px 18px; }
  .em-ideas-open { width: 100%; }
  .em-ideas-saved-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  dialog.em-ideas-dialog { width: calc(100vw - 20px); max-height: 90dvh; padding: 19px 16px; border-radius: 16px; }
  .em-ideas-dialog textarea { max-height: 30dvh; }
  .em-studio-page .em-output-progress { inset: auto 8px 8px; min-height: 44px; padding: 8px 10px; }
  dialog.em-image-viewer {
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }
  dialog.em-image-viewer > :is(img, video) { max-width: 88vw; max-height: 84dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .em-studio-page .em-output.em-output-pending,
  .em-studio-page .em-output.em-output-pending::after,
  .em-pending-spinner,
  #em-create-button[aria-busy="true"]::after {
    animation: none;
  }
}
