/* ─────────────────────────────────────────────
   Generator page
   ───────────────────────────────────────────── */

.gen-wrap {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--bnav-h, 68px);
  z-index: 550;
  background: #fff;
  display: flex;
  flex-direction: column;
  /* translateY(100%) = высота элемента (viewport − bnav-h); чтобы убрать панель
     ПОЛНОСТЬЮ за нижнюю границу viewport (а не оставить полоску высотой bnav-h,
     которую раньше прикрывал только nav-bar), докатываем её ещё на bnav-h.
     Task #563 — гарантия неналожения. */
  transform: translateY(calc(100% + var(--bnav-h, 68px)));
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
              visibility 0s linear 0.38s;
  will-change: transform;
}

.gen-wrap.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
              visibility 0s linear 0s;
}

/* Tab-isolation: генератор живёт в document.body root; скрывается при уходе с
   вкладки, на которой был открыт (Task #563). */
.gen-wrap.gen-wrap--tab-hidden {
  display: none !important;
}

/* ── Header (spacer под кнопку назад) ── */
.gen-header {
  height: var(--app-safe-head-top);
  border-bottom: 0px solid #efefef;
  flex-shrink: 0;
}

/* ── Back button — абсолютная позиция, не скроллится ── */
.gen-back {
  position: absolute;
  top: var(--app-safe-btn-top);
  left: 10px;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.gen-back:active {
  background: rgba(255, 255, 255, 0.90);
}

.gen-back svg {
  width: 35px;
  height: 35px;
  stroke: #000000;
  stroke-width: 1.5;
  transform: translateX(-2px);
}

/* ── Scrollable body ── */
.gen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 150px 10px calc(env(safe-area-inset-bottom, 0px) + 80px);
}

.gen-body::-webkit-scrollbar {
  display: none;
}

#gen-wrap.has-pin-cover {
  background-image:
    linear-gradient(to bottom, rgba(255,255,255,0.5) 0px, #ffffff 300px),
    var(--gen-pin-cover);
  background-size: 100% 100%, 100% auto;
  background-position: top left, center -130px;
  background-repeat: no-repeat, no-repeat;
}

/* ── Section label ── */
.gen-section-label {
  font-size: 12px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
  text-align: center;
}

/* ─────────────────────────────────────────────
   Photo upload section
   ───────────────────────────────────────────── */

.gen-upload-section {
  margin-bottom: 26px;
}

.gen-upload-area {
  border: 2px dashed #e0e0e0;
  background: #fff;
  border-radius: 18px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
  padding: 20px 18px;
}

.gen-upload-area:active {
  border-color: #e60023;
  background: #fff5f6;
}

.gen-upload-area.has-photos {
  display: none;
}

.gen-upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #bbb;
}

.gen-upload-icon svg {
  width: 24px;
  height: 24px;
}

.gen-upload-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gen-upload-main {
  font-size: 15px;
  font-weight: 600;
  color: #222;
}

.gen-upload-hint {
  font-size: 12px;
  color: #bbb;
}

/* Photo thumbs grid */
.gen-photos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0;
}

.gen-photos-grid:empty {
  display: none;
}

/* ─────────────────────────────────────────────
   Recent photos strip
   ───────────────────────────────────────────── */

.gen-recent-section {
  margin-top: 12px;
}

.gen-recent-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}

.gen-recent-icon {
  width: 13px;
  height: 13px;
  color: #aaa;
  flex-shrink: 0;
}

.gen-recent-label {
  font-size: 11px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.gen-recent-strip-wrap {
  position: relative;
}

.gen-recent-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.gen-recent-strip::-webkit-scrollbar {
  display: none;
}

/* Right-side arrow hint */
.gen-recent-arrow {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 2px;
  width: 44px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.96) 55%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
  pointer-events: none;
  transition: opacity 0.25s;
}

.gen-recent-arrow svg {
  width: 10px;
  height: 18px;
  stroke: #bbb;
  flex-shrink: 0;
}

.gen-recent-chip {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  border: 2.5px solid transparent;
  box-sizing: border-box;
  transition: border-color 0.15s, opacity 0.15s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
  background: #ebebeb;
  padding: 0;
}

.gen-recent-chip:active {
  opacity: 0.72;
  transform: scale(0.94);
}

.gen-recent-chip.selected {
  border-color: #e60023;
}

.gen-recent-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.gen-recent-chip.loaded img {
  opacity: 1;
}

/* Skeleton shimmer */
.gen-recent-chip--skeleton {
  cursor: default;
  pointer-events: none;
}

.gen-recent-chip--skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #ebebeb 0%,
    #d8d8d8 40%,
    #ebebeb 80%
  );
  background-size: 200% 100%;
  animation: gen-recent-shimmer 1.3s linear infinite;
  border-radius: 8px;
}

@keyframes gen-recent-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.gen-photo-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 14px;
  overflow: hidden;
  background: #f0f0f0;
  flex-shrink: 0;
}

.gen-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-photo-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  color: #fff;
}

.gen-photo-remove svg {
  width: 12px;
  height: 12px;
}

.gen-add-more {
  width: 76px;
  height: 76px;
  border-radius: 14px;
  border: 2px dashed #e0e0e0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: #ccc;
  transition: border-color 0.15s, color 0.15s;
}

.gen-add-more:active {
  border-color: #e60023;
  color: #e60023;
}

.gen-add-more svg {
  width: 22px;
  height: 22px;
}

/* ─────────────────────────────────────────────
   Chip selectors
   ───────────────────────────────────────────── */

.gen-chips-section {
  margin-bottom: 15px;
}

.gen-chips-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.gen-chips-row:last-child {
  margin-bottom: 0;
}

.gen-chip {
  flex: 1;
  min-width: 0;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid #e8e8e8;
  background: #fafafa;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.gen-chip:active {
  background: #fff5f6;
  border-color: #e60023;
}

.gen-chip.active {
  background: #e60023;
  border-color: #e60023;
  color: #fff;
}

/* ─────────────────────────────────────────────
   Price block
   ───────────────────────────────────────────── */

.gen-model-badge {
  font-size: 11px;
  font-weight: 500;
  color: #888;
  background: #f2f2f2;
  border-radius: 20px;
  padding: 3px 9px;
  white-space: nowrap;
  align-self: center;
}

.gen-price-section {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  background: #f8f8f8;
  border-radius: 16px;
  padding: 16px 18px;
}

.gen-price-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.gen-price-label {
  font-size: 15px;
  color: #666;
  font-weight: 500;
}

.gen-price-value {
  font-size: 20px;
  font-weight: 700;
  color: #111;
}

/* ─────────────────────────────────────────────
   Generate button
   ───────────────────────────────────────────── */

.gen-btn {
  width: 100%;
  height: 64px;
  border-radius: 16px;
  border: none;
  background: #e60023;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 24px;
  font-family: inherit;
}

.gen-btn-label {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

.gen-btn-vid-len {
  font: inherit;
  font-weight: 650;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.gen-btn-cost {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1;
}

.gen-btn-cost:empty {
  display: none;
}

.gen-btn .gen-model-badge {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
}

#owngen-btn .gen-btn-cost {
  font-size: 14px;
  margin-top: 3px;
}

.gen-btn:active {
  opacity: 0.82;
}

.gen-btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Spinner inside button */
.gen-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gen-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ─────────────────────────────────────────────
   Result block
   ───────────────────────────────────────────── */

/* ── Pending placeholder (grey container shown during generation) ── */
.gen-pending {
  display: none;
  margin-top: 16px;
  border-radius: 18px;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: #dddce4;
}

.gen-pending.visible {
  display: flex;
}

/* Two blurred background images that cross-fade */
.gen-pending-bg {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  overflow: hidden;
}

.gen-pending-img {
  position: absolute;
  inset: -30px;
  width: calc(100% + 60px);
  height: calc(100% + 60px);
  object-fit: cover;
  filter: blur(20px) saturate(0.6);
  will-change: opacity;
}

.gen-pending-img--a {
  animation: gen-pending-fade-a 5s ease-in-out infinite;
}

.gen-pending-img--b {
  animation: gen-pending-fade-b 5s ease-in-out infinite;
}

@keyframes gen-pending-fade-a {
  0%, 100% { opacity: 0.40; }
  50%       { opacity: 0.06; }
}

@keyframes gen-pending-fade-b {
  0%, 100% { opacity: 0.06; }
  50%       { opacity: 0.40; }
}

.gen-pending-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(91, 92, 246, 0.22);
  border-top-color: #5b5cf6;
  border-radius: 50%;
  animation: gen-pending-spin 0.85s linear infinite;
  position: relative;
  z-index: 1;
}

@keyframes gen-pending-spin {
  to { transform: rotate(360deg); }
}

/* ── Face similarity analysis block ───────────────────────────────────────── */
.gen-analysis {
  display: none;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f4f3fa;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.gen-analysis.visible {
  display: flex;
}

/* Spinner state */
.gen-analysis-spinner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gen-analysis-spinner-icon {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(91, 92, 246, 0.20);
  border-top-color: #5b5cf6;
  border-radius: 50%;
  animation: gen-pending-spin 0.85s linear infinite;
  flex-shrink: 0;
}

.gen-analysis-spinner-text {
  font-size: 13px;
  color: #6b6b8a;
  font-weight: 500;
}

/* Result state */
.gen-analysis-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.gen-analysis-stars {
  display: flex;
  gap: 4px;
}

.gen-star {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.gen-star--filled polygon {
  fill: #f5a623;
  stroke: #e0941a;
  stroke-width: 0.5;
}

.gen-star--empty polygon {
  fill: #d8d7e4;
  stroke: #c4c3d4;
  stroke-width: 0.5;
}

.gen-analysis-verdict {
  font-size: 12.5px;
  color: #4a4a6a;
  text-align: center;
  line-height: 1.45;
  font-weight: 500;
}

.gen-result {
  display: none;
  flex-direction: column;
  margin-top: 16px;
}

.gen-result.visible {
  display: flex;
}

.gen-result-img {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: #f0f0f0;
  position: relative;
}

.gen-result-img img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
}

/* ── Pending shimmer: shown while generation is in progress ── */
.gen-result-shimmer {
  display: none;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  background: #dddce4;
  align-items: center;
  justify-content: center;
}

.gen-result--pending .gen-result-shimmer {
  display: flex;
}

/* Hide only the real result photo while pending (not shimmer crossfade images) */
.gen-result--pending #gen-result-photo {
  display: none;
}

/* Video result */
#gen-result-video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: #000;
  outline: none;
}

.gen-result--pending #gen-result-video {
  display: none;
}

.gen-result--pending .gen-fb-pill {
  display: none;
}

/* Shimmer: override gen-pending defaults — full-brightness crossfade */
.gen-result-shimmer .gen-pending-img {
  filter: blur(30px) saturate(1.0);
}

.gen-result-shimmer .gen-pending-img--a {
  animation: gen-shimmer-fade-a 4s ease-in-out infinite;
}

.gen-result-shimmer .gen-pending-img--b {
  animation: gen-shimmer-fade-b 4s ease-in-out infinite;
}

@keyframes gen-shimmer-fade-a {
  0%, 100% { opacity: 0.90; }
  50%       { opacity: 0.0; }
}

@keyframes gen-shimmer-fade-b {
  0%, 100% { opacity: 0.0; }
  50%       { opacity: 0.90; }
}

.gen-result-img:active {
  opacity: 0.88;
}

/* ── Swipe slide animations ── */
@keyframes _gen-slide-out-up {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-32px); }
}
@keyframes _gen-slide-out-down {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(32px); }
}
@keyframes _gen-slide-in-from-down {
  from { opacity: 0; transform: translateY(32px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes _gen-slide-in-from-up {
  from { opacity: 0; transform: translateY(-32px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes _gen-bounce-top {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-14px); }
}
@keyframes _gen-bounce-bot {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(14px); }
}
.gen-result-img--slide-out-up    { animation: _gen-slide-out-up   0.18s ease forwards; pointer-events: none; }
.gen-result-img--slide-out-down  { animation: _gen-slide-out-down 0.18s ease forwards; pointer-events: none; }
.gen-result-img--slide-in-from-down { animation: _gen-slide-in-from-down 0.23s ease forwards; }
.gen-result-img--slide-in-from-up   { animation: _gen-slide-in-from-up   0.23s ease forwards; }
.gen-result-img--bounce-top      { animation: _gen-bounce-top 0.36s ease; }
.gen-result-img--bounce-bot      { animation: _gen-bounce-bot 0.36s ease; }

.gen-result-tap-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 12px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   Generation error message
   ───────────────────────────────────────────── */

.gen-error {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fff0f2;
  border: 1px solid #ffc7ce;
  border-radius: 12px;
  font-size: 14px;
  color: #c0001a;
  line-height: 1.45;
}

/* ─────────────────────────────────────────────
   Result action buttons
   ───────────────────────────────────────────── */

.gen-result-actions {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.gen-result-actions.visible {
  display: flex;
}

.gen-result-action-btn {
  flex: 1;
  height: 46px;
  border-radius: 14px;
  border: none;
  background: #e60023;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.gen-result-action-btn:active {
  opacity: 0.82;
}

.gen-result-action-btn--outline {
  background: transparent;
  border: 2px solid #e60023;
  color: #e60023;
}

.gen-result-action-btn--share {
  flex: 1 1 100%;
  background: #f6f6f4;
  color: #111;
  border: 1px solid #e1e1e0;
}

/* ─────────────────────────────────────────────
   Generator share sheet
   ───────────────────────────────────────────── */

.gen-share-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2300;
  background: rgba(0,0,0,0.5);
  display: none;
}

.gen-share-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2301;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 8px 0 calc(16px + env(safe-area-inset-bottom, 0px));
  display: none;
  animation: gen-share-slide-up 0.22s ease;
}

@keyframes gen-share-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.gen-share-handle {
  width: 36px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 8px auto 16px;
}

.gen-share-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 20px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: #111;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}

.gen-share-row:active {
  background: #f5f5f5;
}

.gen-share-row-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #333;
}

.gen-share-divider {
  height: 1px;
  background: #f0f0f0;
  margin: 0 16px;
}

/* ─────────────────────────────────────────────
   Generator media viewer (fullscreen)
   ───────────────────────────────────────────── */

.gen-media-viewer {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
}

.gen-media-viewer.open {
  display: flex;
}

/* Blur backdrop when 3-dot menu is open */
.gen-media-viewer.mv-menu-open .gen-mv-img,
.gen-media-viewer.mv-menu-open .gen-mv-back {
  filter: blur(6px);
  transition: filter 0.18s ease;
}

.gen-mv-img,
.gen-mv-back {
  transition: filter 0.18s ease;
}

.gen-mv-back {
  position: absolute;
  top: calc(var(--app-safe-btn-top) + 10px);
  left: 10px;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  color: #111;
}

.gen-mv-back:active {
  background: rgba(255, 255, 255, 0.90);
}

.gen-mv-back svg {
  width: 35px;
  height: 35px;
  stroke: #000;
  stroke-width: 1.5;
  transform: translateX(-2px);
}

.gen-mv-img {
  max-width: 100%;
  max-height: 100vh;
  object-fit: contain;
  display: block;
  user-select: none;
  touch-action: none;
  transform-origin: center center;
  will-change: transform;
}

.gen-mv-video {
  max-width: 100%;
  max-height: 100dvh;
  object-fit: contain;
  display: block;
}

.gen-media-viewer.mv-menu-open .gen-mv-video {
  filter: blur(6px);
  transition: filter 0.18s ease;
}

/* 3-dot menu in viewer */
.gen-mv-more-wrap {
  position: absolute;
  top: calc(var(--app-safe-btn-top) + 10px);
  right: 10px;
  z-index: 10;
}

.gen-mv-more-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: #111;
}

.gen-mv-more-btn:active {
  background: rgba(255, 255, 255, 0.90);
}

.gen-mv-more-btn svg {
  width: 22px;
  height: 22px;
}

.gen-mv-more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  overflow: hidden;
  min-width: 170px;
  z-index: 11;
}

.gen-mv-more-menu.open {
  display: block;
}

.gen-mv-more-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: #111;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.gen-mv-more-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: #444;
}

.gen-mv-more-item + .gen-mv-more-item {
  border-top: 1px solid #f0f0f0;
}

.gen-mv-more-item:active {
  background: #f5f5f5;
}

.gen-mv-more-item--danger {
  color: #e60023;
}

.gen-mv-more-item--danger svg {
  stroke: #e60023;
}

/* ─────────────────────────────────────────────
   Feedback pill (ephemeral overlay on result image)
   ───────────────────────────────────────────── */

.gen-fb-pill {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 50px;
  border: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s ease;
  white-space: nowrap;
  z-index: 2;
}

.gen-fb-pill.visible {
  opacity: 0.9;
  pointer-events: auto;
}

.gen-fb-pill.faded {
  opacity: 0.9;
}

/* Pill inner: default (two buttons) */
.gen-fb-pill-default {
  display: flex;
  align-items: center;
}

.gen-fb-pill.thanks .gen-fb-pill-default {
  display: none;
}

/* Pill inner: thanks state */
.gen-fb-thanks {
  display: none;
  height: 44px;
  padding: 0 22px;
  align-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.gen-fb-pill.thanks .gen-fb-thanks {
  display: flex;
}

/* Like / dislike buttons inside pill */
.gen-fb-like,
.gen-fb-dislike {
  height: 44px;
  padding: 0 18px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-size: 21px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.gen-fb-like:active,
.gen-fb-dislike:active {
  background: rgba(255, 255, 255, 0.15);
}

.gen-fb-pill-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

/* Heart pop animation */
.gen-fb-like-icon {
  display: inline-block;
  transform-origin: center;
}

@keyframes gen-fb-heart-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.55); }
  60%  { transform: scale(0.88); }
  80%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.gen-fb-like-icon.pop {
  animation: gen-fb-heart-pop 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
}

/* ─────────────────────────────────────────────
   Feedback dislike sheet
   ───────────────────────────────────────────── */

.gen-fb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.gen-fb-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.gen-fb-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1101;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 28px);
  /* roll fully past the viewport (+ bottom-nav height) */
  transform: translateY(calc(100% + var(--bnav-h, 68px)));
  /* hard cutoff when closed, delayed until the slide-out finishes so no ghost
     fragment can paint over other sections (iOS/Telegram webview footgun) */
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
              visibility 0s linear 0.38s;
}

.gen-fb-sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
              visibility 0s linear 0s;
}

.gen-fb-handle {
  width: 36px;
  height: 4px;
  background: #e2e2e2;
  border-radius: 2px;
  margin: 0 auto 20px;
}

.gen-fb-sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: #111;
  margin-bottom: 6px;
}

/* Options list */
.gen-fb-opts-list {
  margin: 0 -4px;
}

.gen-fb-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 4px;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid #f2f2f2;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #222;
  text-align: left;
  transition: color 0.15s;
  border-radius: 0;
}

.gen-fb-opt:last-child {
  border-bottom: none;
}

.gen-fb-opt:active {
  background: #fafafa;
}

.gen-fb-opt.selected {
  color: #e60023;
}

.gen-fb-opt-emoji {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.gen-fb-opt-label {
  flex: 1;
}

/* Checkmark at right */
.gen-fb-opt-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  color: transparent;
}

.gen-fb-opt-check svg {
  width: 12px;
  height: 12px;
  stroke: #fff;
}

.gen-fb-opt.selected .gen-fb-opt-check {
  background: #e60023;
  border-color: #e60023;
  color: #fff;
}

/* "Другое" textarea */
.gen-fb-other-area {
  display: none;
  margin-top: 4px;
  margin-bottom: 2px;
}

.gen-fb-other-area.visible {
  display: block;
}

.gen-fb-textarea {
  width: 100%;
  border: 1.5px solid #e8e8e8;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: #111;
  resize: none;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.gen-fb-textarea:focus {
  border-color: #e60023;
}

/* Send button */
.gen-fb-send {
  width: 100%;
  height: 52px;
  margin-top: 18px;
  border-radius: 14px;
  border: none;
  background: #e60023;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
  font-family: inherit;
}

.gen-fb-send:active {
  opacity: 0.82;
}

.gen-fb-send:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ─────────────────────────────────────────────
   Retry dropdown
   ───────────────────────────────────────────── */

.pc-retry-wrap {
  flex: 2;
  position: relative;
}

.pc-retry-wrap .pc-btn-retry {
  flex: unset;
  width: 100%;
}

.pc-retry-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 190px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.13);
  overflow: hidden;
  display: none;
  flex-direction: column;
  z-index: 20;
  animation: gen-menu-in 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  transform-origin: bottom left;
}

@keyframes gen-menu-in {
  from { opacity: 0; transform: scale(0.9) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pc-retry-menu.open {
  display: flex;
}

.pc-retry-menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 500;
  color: #111;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  width: 100%;
  font-family: inherit;
}

.pc-retry-menu-item:active {
  background: rgba(0, 0, 0, 0.05);
}

.pc-retry-menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #777;
}

.pc-retry-menu-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   Generation history sidebar (right strip)
   ───────────────────────────────────────────── */

/* Row container: gen-body + gen-history side by side */
.gen-content-row {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.gen-history {
  /* Collapsed: takes no flex space */
  width: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-bottom: 0px;
  pointer-events: none;
  overflow: hidden;
  position: relative;
  transition: width 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: width;
}

.gen-history.has-items {
  pointer-events: auto;
}

.gen-history.open {
  width: 79px;
}

/* ─────────────────────────────────────────────
   Ready toast (generation complete notification)
   ───────────────────────────────────────────── */

.gen-ready-toast {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 22;
}

.gen-ready-toast__pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(16, 16, 24, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  border-radius: 30px;
  padding: 11px 18px 11px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(72px);
  transition: transform 0.42s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.25s ease;
  will-change: transform, opacity;
}

.gen-ready-toast.visible .gen-ready-toast__pill {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.gen-ready-toast.dismiss-left .gen-ready-toast__pill {
  opacity: 0;
  transform: translateX(-120px) translateY(0);
  transition: transform 0.26s ease, opacity 0.2s ease;
  pointer-events: none;
}

.gen-ready-toast.dismiss-right .gen-ready-toast__pill {
  opacity: 0;
  transform: translateX(120px) translateY(0);
  transition: transform 0.26s ease, opacity 0.2s ease;
  pointer-events: none;
}

.gen-ready-toast__check {
  width: 18px;
  height: 18px;
  color: #4cd964;
  flex-shrink: 0;
}

.gen-ready-toast__arrow {
  width: 14px;
  height: 14px;
  color: rgba(255, 255, 255, 0.65);
  flex-shrink: 0;
}

/* ── Tail tab — абсолютная позиция в gen-wrap, не зависит от ширины sidebar ── */
.gen-hist-tab {
  position: absolute;
  top: var(--st-btn, 95px);
  right: 0;
  width: 30px;
  height: 50px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 14px 0 0 14px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: right 0.32s cubic-bezier(0.32, 0.72, 0, 1), background 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.gen-wrap.hist-open .gen-hist-tab {
  right: 79px;
}

.gen-hist-tab:active {
  background: rgba(0, 0, 0, 0.18);
}

.gen-wrap.hist-open .gen-hist-tab svg {
  transform: rotate(180deg);
}

.gen-hist-tab svg {
  width: 10px;
  height: 35px;
  color: rgba(0, 0, 0, 0.55);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  flex-shrink: 0;
}

/* Cards area: offset from the tab */
.gen-hist-list {
  width: calc(100% - 14px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  padding: 5px 0;
  margin-left: 14px;
}

.gen-hist-list::-webkit-scrollbar {
  display: none;
}

/* Individual history card */
.gen-hist-card {
  width: 60px;
  height: 60px;
  border-radius: 13px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: 2.5px solid transparent;
  background: #e8e8e8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  transition: border-color 0.18s ease, transform 0.15s ease;
}

.gen-hist-card:active {
  transform: scale(0.94);
}

.gen-hist-card.active {
  border-color: #5b5cf6;
}

.gen-hist-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-hist-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Play-icon overlay for video results in the history grid */
.gen-hist-card .gen-hist-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.gen-hist-card .gen-hist-play svg {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
  opacity: 0.95;
}

/* Pending overlay with spinner */
.gen-hist-card .gen-hist-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Error overlay */
.gen-hist-card.error .gen-hist-overlay {
  background: rgba(0, 0, 0, 0.46);
}

.gen-hist-card .gen-hist-overlay svg {
  width: 22px;
  height: 22px;
  color: #fff;
}

/* ── "New generation" slot card ─────────────────────────────────── */
.gen-hist-card--new {
  background: #d8d8de;
}

.gen-hist-card--new .gen-hist-overlay--new {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gen-hist-card--new .gen-hist-overlay--new svg {
  width: 26px;
  height: 26px;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

/* Mini spinner inside card */
.gen-hist-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gen-hist-spin 0.75s linear infinite;
}

@keyframes gen-hist-spin {
  to { transform: rotate(360deg); }
}


/* gen-body inside flex row — takes remaining width */
.gen-content-row .gen-body {
  flex: 1;
  min-width: 0;
}

/* ── Floating generation bubbles (above navbar) ────────────────────────── */
.gen-bubbles {
  position: fixed;
  bottom: calc(var(--nav-height, 68px) + 10px);
  left: 12px;
  width: 64px;
  height: 64px;
  z-index: 99999;
  pointer-events: auto;
  overflow: visible;
  cursor: grab;
}
.gen-bubbles:active {
  cursor: grabbing;
}

.gen-bubble-slot {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.gen-bubble {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background: #1a1a1a;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s;
  outline: 1px solid rgba(255, 255, 255, 1);
  opacity: 0.82;
}

.gen-bubble:active {
  transform: scale(0.91);
}

.gen-bubble__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-bubble__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
}

.gen-bubble--done .gen-bubble__overlay {
  background: rgba(0, 0, 0, 0.22);
}

.gen-bubble__spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, 0.30);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gen-spin 0.7s linear infinite;
}

.gen-bubble__check {
  width: 26px;
  height: 26px;
  stroke: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.gen-bubble__cross {
  width: 24px;
  height: 24px;
  stroke: #ff5252;
}

.gen-bubble-count {
  position: absolute;
  right: -9px;
  bottom: -7px;
  background: #111;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 999;
  border: 1.5px solid rgba(255,255,255,0.9);
  box-sizing: border-box;
}

.gen-bubbles--video .gen-bubble-count {
  right: auto;
  bottom: auto;
  left: -9px;
  top: -7px;
}

@keyframes gen-bubble-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  70%  { transform: scale(1.10); }
  100% { transform: scale(1);   opacity: 1; }
}

.gen-bubble--enter {
  animation: gen-bubble-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes gen-bubble-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.gen-bubble--pulse {
  animation: gen-bubble-pulse 0.42s ease forwards;
}

/* Shake animation for generate button when no photo */
@keyframes gen-btn-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.gen-btn--shake {
  animation: gen-btn-shake 0.45s ease;
}


/* ─────────────────────────────────────────────
   Персонализация accordion
   Card-style toggle: gradient bg, icon, badge, chevron.
   Mobile-first, iOS-safe, compact height.
   ───────────────────────────────────────────── */

.gen-extra-section {
  margin-bottom: 20px;
}

.gen-extra-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px 8px 8px;
  background: linear-gradient(135deg, #fff5f6 0%, #fff8f7 100%);
  border: 1.5px solid rgba(230, 0, 35, 0.15);
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  box-shadow: 0 1px 4px rgba(230, 0, 35, 0.06),
              inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
              background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.gen-extra-toggle:active {
  background: linear-gradient(135deg, #ffe8eb 0%, #fff0ee 100%);
  border-color: rgba(230, 0, 35, 0.32);
  box-shadow: 0 1px 6px rgba(230, 0, 35, 0.12);
}

.gen-extra-toggle[aria-expanded="true"] {
  border-color: rgba(230, 0, 35, 0.25);
  box-shadow: 0 2px 8px rgba(230, 0, 35, 0.09),
              inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* ── Left side: icon + title group ── */
.gen-extra-toggle-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gen-extra-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e60023 0%, #ff5040 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(230, 0, 35, 0.32);
}

.gen-extra-icon svg {
  width: 16px;
  height: 16px;
}

.gen-extra-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  align-items: flex-start
}

.gen-extra-label-text {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.gen-extra-subtitle {
  font-size: 11px;
  font-weight: 400;
  color: rgba(230, 0, 35, 0.5);
  letter-spacing: 0;
  line-height: 1.2;
}

/* ── Right side: badge + chevron ── */
.gen-extra-toggle-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.gen-extra-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 99px;
  background: rgba(230, 0, 35, 0.09);
  color: #c8001f;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.gen-extra-badge:empty {
  display: none;
}

.gen-extra-chevron {
  width: 18px;
  height: 18px;
  stroke: rgba(230, 0, 35, 0.45);
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              stroke      0.18s ease;
}

.gen-extra-toggle[aria-expanded="true"] .gen-extra-chevron {
  transform: rotate(180deg);
  stroke: #e60023;
}

.gen-extra-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              opacity    0.22s ease,
              margin-top 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.gen-extra-body.open {
  max-height: 1200px;          /* достаточно для 3+ полей с длинным текстом */
  opacity: 1;
  margin-top: 14px;
}

.gen-extra-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gen-extra-field {
  display: flex;
  flex-direction: column;
  position: relative;  /* needed for .gen-extra-ok-btn absolute positioning */
}

/* ── OK button — appears bottom-right when field is focused ── */
.gen-extra-ok-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  height: 26px;
  padding: 0 10px;
  background: #e60023;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.gen-extra-field:focus-within .gen-extra-ok-btn {
  opacity: 1;
  pointer-events: auto;
}

.gen-extra-ok-btn:active {
  background: #c5001f;
}

.gen-extra-field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 6px;
  line-height: 1.35;
  padding-left: 2px;
}

.gen-extra-field-input {
  width: 100%;
  height: 44px;                /* collapsed = 1 line; expands on focus */
  padding: 11px 14px;
  border: 1.5px solid #e8e8e8;
  border-radius: 12px;
  background: #fafafa;
  font-size: 16px;             /* 16px+ prevents focus-zoom on iOS Safari */
  font-family: inherit;
  font-weight: 400;
  color: #111;
  line-height: 1.4;            /* 16px × 1.4 = 22.4px/line; 3 lines + padding = ~90px */
  box-sizing: border-box;
  outline: none;
  resize: none;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.18s ease, background 0.18s ease,
              height 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              padding-top 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.gen-extra-field-input::placeholder {
  color: #9ca3af;
}

.gen-extra-field-input:hover {
  border-color: #d4d4d4;
}

.gen-extra-field-input:focus {
  height: 90px;                /* 3 lines: 22.4 × 3 + 22px padding ≈ 90px */
  padding-top: 8px;            /* снижаем с 11→8px чтобы текст шёл с верхнего края */
  border-color: #e60023;
  background: #fff;
  /* overflow stays hidden — no scrollbar flash during height transition */
}

/* ─────────────────────────────────────────────
   Result mode — скрывает форму, оставляет только
   pending/result + боковую историю
   ───────────────────────────────────────────── */
.gen-wrap--result-mode .gen-upload-section,
.gen-wrap--result-mode .gen-chips-section,
.gen-wrap--result-mode .gen-extra-section,
.gen-wrap--result-mode .gen-price-section,
.gen-wrap--result-mode .gen-btn,
.gen-wrap--result-mode .gen-error {
  display: none !important;
}

.gen-wrap--result-mode .gen-body {
  padding-top: 16px;
}

/* ── Meta strip (date + params) — result mode, profile view ── */
.gen-result-meta {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 4px;
  font-size: 12px;
  color: #999;
  line-height: 1.4;
}

.gen-result-meta.has-data {
  display: flex;
}

.gen-result-meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.gen-result-meta-sep {
  opacity: 0.4;
}

.gen-result-meta-date,
.gen-result-meta-params,
.gen-result-meta-model {
  white-space: nowrap;
}

/* Source chip — tap to go back to the original pin */
.gen-source-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f2f2f2;
  border-radius: 12px;
  padding: 6px 12px 6px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.gen-source-chip:active {
  background: #e4e4e4;
}

.gen-source-chip__thumb {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: #ddd;
}

.gen-source-chip__label {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}

.gen-source-chip__arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #888;
}

/* ─────────────────────────────────────────────
   Similar pins section (С этим промтом обычно делают)
   ───────────────────────────────────────────── */

.gen-sim-section {
  margin-top: 8px;
  border-top: 1px solid #ebebeb;
  padding: 16px 0 32px;
}

.gen-sim-title {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  letter-spacing: 0.01em;
  margin: 0 0 12px 10px;
}

.gen-sim-masonry {
  display: flex;
  gap: 5px;
  padding: 0 5px;
}

.gen-sim-masonry .masonry-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gen-sim-skeleton {
  width: 100%;
  border-radius: 14px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: gen-sim-shimmer 1.4s infinite;
}

@keyframes gen-sim-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── "Повторить" strip on similar-pins masonry ── */
.gen-sim-masonry .pin {
  overflow: hidden;
}

.gen-sim-repeat-btn {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  min-height: 30px;
  margin: 0;
  padding: 4px 0;
  border: none;
  cursor: pointer;
  background: #E8272E;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.gen-sim-repeat-price {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.88;
}

.gen-sim-repeat-btn:active {
  background: #c41e24;
}

/* ── Repeat confirmation modal ──────────────────────────────────────── */
.gen-repeat-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 2200; backdrop-filter: blur(2px);
}
.gen-repeat-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  z-index: 2201; width: min(88vw, 340px);
  background: #1a1a1a; border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.gen-repeat-inner {
  padding: 20px 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.gen-repeat-title {
  font-size: 15px; font-weight: 700; color: #fff; text-align: center;
}
.gen-repeat-text {
  font-size: 13px; color: #aaa; text-align: center; margin: 0; line-height: 1.45;
}
.gen-repeat-cost {
  font-size: 14px; font-weight: 700; color: #fff; text-align: center; margin: 0;
}
.gen-repeat-thumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: 10px;
  display: none;
}
.gen-repeat-thumb.loaded { display: block; }
.gen-repeat-actions {
  width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 2px;
}
.gen-repeat-btn {
  width: 100%; padding: 12px 0; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.gen-repeat-btn:active { opacity: .75; }
.gen-repeat-btn--primary { background: #E8272E; color: #fff; }
.gen-repeat-btn--skip { background: #2e2e2e; color: #ccc; font-size: 12.5px; }
.gen-repeat-btn--outline { background: transparent; border: 1.5px solid #444; color: #ccc; }
.gen-repeat-btn--cancel { background: transparent; color: #666; font-weight: 400; }

/* ── History card badge (generation_mode) ────────────────────────────────── */
.gen-hist-badge {
  position: absolute; bottom: 3px; right: 3px;
  width: 16px; height: 16px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.gen-hist-badge--edit {
  background: rgba(94, 93, 246, 0.85);
}
.gen-hist-badge--edit svg {
  width: 9px; height: 9px; color: #fff;
}

/* ── Edit-result modal extras ─────────────────────────────────────────────── */
.gen-edit-modal { width: min(92vw, 380px); }
.gen-edit-inner { align-items: stretch; }
.gen-edit-modal--keyboard { overflow: hidden; }
.gen-edit-modal--keyboard .gen-edit-inner {
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.gen-edit-modal--keyboard .gen-edit-inner > * { flex-shrink: 0; }
.gen-edit-prompt-wrap { position: relative; width: 100%; }
.gen-edit-textarea {
  width: 100%; box-sizing: border-box;
  background: #252525; border: 1.5px solid #3a3a3a; border-radius: 12px;
  color: #f0f0f0; font-size: 13.5px; line-height: 1.5;
  padding: 10px 12px; resize: none; outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.gen-edit-textarea:focus { border-color: #666; }
.gen-edit-textarea::placeholder { color: #666; }
.gen-edit-counter {
  text-align: right; font-size: 11px; color: #666; margin-top: 4px;
}
.gen-edit-counter.warn { color: #c84; }
.gen-edit-counter.over { color: #e05; font-weight: 600; }
.gen-edit-error {
  font-size: 12px; color: #e05; margin-top: 4px;
}
.gen-edit-price-row {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 6px 2px 0;
}
.gen-edit-price-label { font-size: 13px; color: #aaa; }
.gen-edit-price-value { font-size: 14px; font-weight: 700; color: #fff; }

/* ── Video result: poster (blur → full poster → play button) ───────────── */
/* Video only loads when user taps play; before that we show a poster frame  */
.gen-vid-poster-wrap {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: #111;
  aspect-ratio: 9 / 16; /* default; overridden inline from resultW/H */
}
.gen-vid-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(18px);
  transform: scale(1.06); /* hide edge artifacts from blur */
  transition: opacity 0.3s ease;
}
.gen-vid-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.gen-vid-poster--loaded { opacity: 1; }
.gen-vid-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.gen-vid-spinner svg {
  animation: gen-pending-spin 0.85s linear infinite;
}
.gen-vid-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gen-vid-play-btn:active { opacity: 0.7; }
.gen-result--pending .gen-vid-poster-wrap { display: none !important; }
