:root {
  --bg: #13142b;
  --bg-elevated: #1c1d3a;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f4f3ff;
  --text-muted: #a8a5c4;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, 0.18);
  --accent-glow: rgba(139, 92, 246, 0.35);
  /* Photo-editor CTA accent (ui-ux-pro-max: violet chrome + cyan generate) */
  --cta: #22d3ee;
  --cta-strong: #06b6d4;
  --cta-text: #042f2e;
  --cta-glow: rgba(34, 211, 238, 0.42);
  --info: #22d3ee;
  --info-soft: rgba(34, 211, 238, 0.14);
  --info-border: rgba(34, 211, 238, 0.38);
  --danger: #f87171;
  --radius: 16px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  --page-max: 1280px;
  --coin-yellow: #facc15;
  --chrome-bg: rgba(19, 20, 43, 0.92);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(139, 92, 246, 0.22), transparent),
    var(--bg);
}

.photo-app.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.app-chrome-fixed {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 -1.5rem;
  padding: 0.85rem 1.5rem 0.65rem;
  background:
    linear-gradient(180deg, rgba(19, 20, 43, 0.98) 0%, var(--chrome-bg) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1 1 auto;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.coin-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.12);
  color: var(--coin-yellow);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
}

.ongoing-tasks-badge {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--bg-elevated, #232445);
  color: var(--text-muted, #9394b0);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0;
}

.ongoing-tasks-badge.is-active {
  border-color: var(--info-border, rgba(34, 211, 238, 0.38));
  background: var(--info-soft, rgba(34, 211, 238, 0.14));
  color: var(--info, #22d3ee);
}

.coin-chip-icon {
  flex-shrink: 0;
  color: var(--coin-yellow);
}

.coin-chip-value {
  font-variant-numeric: tabular-nums;
  color: var(--coin-yellow);
}

.coin-cost-num {
  color: var(--coin-yellow);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.account-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0.15rem 0.25rem;
  min-width: 2.75rem;
  max-width: 7.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}

.account-block--avatar-only {
  min-width: 0;
  max-width: none;
  padding: 0.2rem;
}

.account-block:hover,
.account-block:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.account-avatar--icon {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  overflow: hidden;
}

.account-avatar--icon svg {
  width: 20px;
  height: 20px;
}

.account-email {
  max-width: 100%;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-up-btn {
  white-space: nowrap;
}

.faceswap-generate-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-top: 0.75rem;
}

.faceswap-generate-btn,
.generate-btn {
  flex: 0 1 auto;
  min-width: 11rem;
  min-height: 2.85rem;
  padding-inline: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--cta-text);
  background: linear-gradient(180deg, #67e8f9 0%, var(--cta-strong) 100%);
  border-color: transparent;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 10px 28px var(--cta-glow);
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.faceswap-generate-btn:hover:not(:disabled),
.generate-btn:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 14px 34px var(--cta-glow);
}

.faceswap-generate-btn:focus-visible,
.generate-btn:focus-visible {
  outline: 3px solid var(--cta);
  outline-offset: 3px;
}

.faceswap-generate-btn:disabled,
.generate-btn:disabled {
  filter: grayscale(0.25);
  box-shadow: none;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .faceswap-generate-btn,
  .generate-btn {
    transition: none;
  }

  .faceswap-generate-btn:hover:not(:disabled),
  .generate-btn:hover:not(:disabled) {
    transform: none;
  }
}

.quality-radios {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.15rem;
  margin-left: auto;
}

.quality-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.quality-radio input[type="radio"] {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
}

.quality-radio:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.result-media-wrap {
  position: relative;
}

.result-save-chip {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 12, 16, 0.82);
  color: #fff;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.result-save-chip:hover {
  background: rgba(20, 20, 28, 0.92);
}

.result-save-chip svg {
  display: block;
  flex-shrink: 0;
}

.preview-wrap-light {
  background: rgba(255, 255, 255, 0.04);
}

.media-badge {
  position: absolute;
  left: 0.55rem;
  top: 0.55rem;
  z-index: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.faceswap-video-placeholder {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.back-portfolio {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.site-hero {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.site-hero--inline {
  gap: 0.75rem;
  margin-bottom: 0;
  min-width: 0;
}

.site-hero--settings {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.site-hero--settings:focus-visible {
  outline: 2px solid var(--info, #22d3ee);
  outline-offset: 3px;
  border-radius: 0.5rem;
}

.site-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  box-shadow: 0 12px 32px var(--accent-glow);
  flex-shrink: 0;
}

.site-hero--inline .site-hero-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  box-shadow: 0 8px 20px var(--accent-glow);
}

.site-hero h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
}

.site-hero--inline h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-hero-text {
  min-width: 0;
}

.site-hero-lead {
  margin: 0;
  color: var(--text-muted);
}

.site-hero--inline .site-hero-lead {
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22rem;
}

.app-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.slot-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.result-pane {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.workspace-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Card gap owns vertical rhythm — zero legacy top margins on direct children. */
.card.workspace-panel > .field,
.card.workspace-panel > .keep-face-model-row,
.card.workspace-panel > .background-row,
.card.workspace-panel > .style-hint,
.card.workspace-panel > .actions-bar,
.card.workspace-panel > .progress-block {
  margin-top: 0;
  margin-bottom: 0;
}

.card.workspace-panel > .background-row {
  margin: 0;
}

.controls-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.controls-footer .actions-bar,
.controls-footer .progress-block,
.style-card [data-style-footer] .actions-bar,
.style-card [data-style-footer] .progress-block {
  margin-top: 0;
}

.controls-footer .generate-btn,
.style-card [data-style-footer] .generate-btn {
  width: 100%;
  min-width: 0;
}

.style-card [data-style-footer] {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.workspace-col {
  min-width: 0;
}

.workspace + .compare-card,
.workspace + .actions-bar,
.workspace ~ .cost-note {
  margin-top: 1rem;
}

@media (min-width: 960px) {
  /* Match Edit empty-state height across tabs; give prompt + CTA room to breathe. */
  .workspace--split,
  .workspace--triple {
    --photo-workspace-min-h: 28rem;
    min-height: var(--photo-workspace-min-h);
    height: var(--photo-workspace-min-h);
    align-items: stretch;
  }

  .workspace--split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
  }

  .workspace--triple {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 1rem;
  }

  .workspace-col {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
  }

  .workspace-col > .card,
  .workspace-col > .compare-grid {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
  }

  .workspace-col--photo .compare-grid {
    grid-template-columns: 1fr;
  }

  .workspace-col--photo .pick-zone,
  .workspace-col--photo .preview-wrap {
    flex: 1 1 auto;
    min-height: 220px;
  }

  .workspace-col--photo .preview-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .workspace-col--photo .preview-wrap img {
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  .workspace-col--controls > .card,
  .workspace--triple > .card.workspace-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    /* Extra room under Generate — was flush against the card edge. */
    padding-bottom: 1.65rem;
  }

  .workspace--triple {
    padding-bottom: 0.35rem;
  }

  /* Prompt grows into leftover space; never paint over Generate. */
  .workspace-col--controls .field,
  .workspace--triple > .card.workspace-panel .field {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 0;
  }

  .workspace-col--controls .field textarea,
  .workspace--triple .field textarea {
    flex: 1 1 auto;
    min-height: 5rem;
    max-height: 100%;
    resize: none;
    overflow-y: auto;
  }

  .workspace-col--controls .controls-footer,
  .workspace--triple > .card.workspace-panel .controls-footer,
  .style-card [data-style-footer] {
    margin-top: auto;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    /* Opaque so progress never paints through category pills above. */
    background: var(--bg-elevated, #1a1228);
    padding-top: 0.15rem;
  }

  /* Chips scroll inside the body; categories stay above the Generate/progress footer. */
  .style-card [data-style-body] {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .style-card .style-chips {
    flex: 1 1 auto;
    min-height: 122px;
    overflow-x: auto;
    overflow-y: auto;
  }

  .style-card .style-categories {
    flex: 0 0 auto;
    margin-top: 0.55rem;
  }

  .style-card .sub-tabs,
  .style-card .accessory-subtabs {
    flex: 0 0 auto;
  }

  .workspace--triple > .card,
  .workspace--triple > .slot-pick-card {
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
  }

  .workspace--triple .slot-preview {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .workspace--triple .slot-pick-card .pick-zone-compact,
  .workspace--triple .slot-preview .preview-wrap {
    flex: 1 1 auto;
    min-height: 180px;
  }

  .workspace--triple .preview-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .workspace--triple .preview-wrap img,
  .workspace--triple .preview-wrap video {
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  /*
   * Combine / Clothes after result — still 3 columns:
   * stacked compact inputs | tall result (~2× one input) | config (unchanged).
   * Stay within the fixed workspace height so the page does not grow/scroll.
   */
  .workspace--triple.workspace--triple-result {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr) minmax(0, 1.1fr);
  }

  .workspace--triple-result > .slot-stack {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow: hidden;
  }

  .workspace--triple-result .slot-stack > .slot-pick-card {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    max-height: 50%;
    margin: 0;
    padding: 0.55rem 0.65rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .workspace--triple-result .slot-stack figcaption {
    flex: 0 0 auto;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
  }

  .workspace--triple-result .slot-stack .slot-preview {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
  }

  .workspace--triple-result .slot-stack .pick-zone-compact,
  .workspace--triple-result .slot-stack .preview-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
  }

  .workspace--triple-result .slot-stack .preview-wrap {
    display: block;
  }

  /* Force fit inside the compact box — do not let natural image height expand the card. */
  .workspace--triple-result .slot-stack .preview-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
  }

  .workspace--triple-result .slot-stack .slot-action-bar {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    z-index: 2;
  }

  .workspace--triple-result > .result-pane {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .workspace--triple-result .result-pane > .compare-card {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .workspace--triple-result .result-pane .result-media-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .workspace--triple-result .result-pane .preview-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .workspace--triple-result .result-pane .preview-wrap img {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  .workspace--triple-result .result-pane .actions-bar {
    margin-top: 0.35rem;
    flex: 0 0 auto;
  }

  .workspace--triple-result .result-pane .cost-note {
    margin: 0;
    flex: 0 0 auto;
  }

  /* Config column: same sizing as empty-state triple (do not shrink/grow). */
  .workspace--triple-result > .card.workspace-panel {
    height: 100%;
    min-height: 100%;
  }

  .style-card {
    margin-top: 0;
  }
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.pick-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(139, 92, 246, 0.45);
  border-radius: var(--radius);
  background: rgba(139, 92, 246, 0.06);
  cursor: pointer;
  text-align: center;
  padding: 1.5rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pick-zone:hover {
  border-color: rgba(139, 92, 246, 0.7);
  background: rgba(139, 92, 246, 0.1);
}

.pick-zone p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.pick-zone-compact {
  min-height: 140px;
  padding: 1rem;
}

.field-label {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.background-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.field-label-inline {
  margin: 0;
  flex: 0 0 auto;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-height: 40px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
}

.preview-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  display: flex;
  justify-content: center;
}

button.preview-wrap {
  width: 100%;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: zoom-in;
  appearance: none;
}

button.preview-wrap:disabled {
  cursor: default;
}

.preview-wrap-clickable:not(:disabled):hover {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preview-wrap img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
}

.preview-wrap video {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  background: #000;
}

.preview-wrap.is-generating img,
.preview-wrap.is-generating video { opacity: 0.45; }

.preview-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1rem;
}

.field label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.field textarea {
  width: 100%;
  min-height: 5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.keep-face-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* Edit / Style: keep-face is the first block — match left card top padding (no extra offset). */
.card > .keep-face-model-row:first-child {
  margin-top: 0;
}

.keep-face-model-row-end {
  justify-content: flex-end;
}

.keep-face-model-row .check-row-inline {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.model-select-inline {
  flex: 0 1 10.5rem;
  max-width: 42%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.65rem;
}

.model-picker-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.model-picker-row select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.75rem;
}

.model-picker-label {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.85;
}

.compare-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .compare-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Before / After drag slider (Edit + Style results) */
.ba-compare {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.ba-slider {
  position: relative;
  width: 100%;
  min-height: 220px;
  aspect-ratio: 3 / 4;
  max-height: min(70vh, 36rem);
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
  background: #0a0a12;
  --ba-pos: 50%;
  touch-action: none;
  user-select: none;
  cursor: ew-resize;
}

.ba-slider-layer {
  position: absolute;
  inset: 0;
}

.ba-slider-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.ba-slider-before {
  clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}

.ba-slider-scrub {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--ba-pos);
  width: 2px;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 2;
}

.ba-slider-knob {
  position: absolute;
  top: 50%;
  left: var(--ba-pos);
  z-index: 3;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  color: #111827;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  cursor: ew-resize;
  touch-action: none;
}

.ba-slider-knob:focus-visible {
  outline: 3px solid var(--cta);
  outline-offset: 3px;
}

.ba-slider-arrows {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.ba-badge {
  position: absolute;
  z-index: 2;
  top: 0.65rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(10, 10, 18, 0.55);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.ba-badge-before {
  left: 0.65rem;
}

.ba-badge-after {
  right: 0.65rem;
}

.ba-compare-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ba-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (min-width: 960px) {
  .workspace-col--photo .ba-compare {
    flex: 1 1 auto;
    min-height: 100%;
    height: 100%;
  }

  .workspace-col--photo .ba-slider {
    flex: 1 1 auto;
    aspect-ratio: auto;
    height: 100%;
    max-height: none;
    min-height: 220px;
  }
}

.compare-card figcaption {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.slot-pick-card {
  position: relative;
}

.slot-preview {
  display: block;
  cursor: pointer;
}

.slot-camera-btn,
.slot-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: rgba(19, 20, 43, 0.82);
  color: var(--text);
  cursor: pointer;
}

.slot-action-btn svg,
.slot-camera-btn svg {
  width: 1.75rem;
  height: 1.75rem;
}

.slot-action-bar {
  position: absolute;
  top: 2.35rem;
  right: 0.75rem;
  z-index: 2;
  display: flex;
  gap: 0.45rem;
}

.preview-wrap .slot-action-bar {
  top: 0.65rem;
  right: 0.65rem;
}

.slot-camera-btn:hover,
.slot-action-btn:hover {
  color: var(--accent, #8b5cf6);
}

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

.progress-block {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 0 0 auto;
}

.progress-background {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem 0.6rem 0.85rem;
  background: var(--info-soft);
  border-top: 1px solid var(--info-border);
  border-bottom: 1px solid var(--info-border);
  border-left: 3px solid var(--info);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

.progress-background .btn-danger {
  border-color: var(--info-border);
  color: var(--info);
  background: transparent;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  transition: width 0.25s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn, .icon-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.btn {
  padding: 0.55rem 0.9rem;
  font-weight: 600;
}

.btn-primary {
  background: linear-gradient(180deg, #a78bfa 0%, #7c3aed 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px var(--accent-glow);
  transition: filter 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:focus-visible {
  outline: 3px solid #c4b5fd;
  outline-offset: 3px;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

/* Swap / Photo Generate — cyan CTA accent */
.btn-primary.faceswap-generate-btn,
.btn-primary.generate-btn {
  color: var(--cta-text);
  background: linear-gradient(180deg, #67e8f9 0%, var(--cta-strong) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 10px 28px var(--cta-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.actions-bar {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.error-banner {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  margin-top: 0.75rem;
}

.cost-note {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hidden-input {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #111827;
  border: 1px solid var(--border);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  z-index: 40;
}

.site-footer {
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.site-footer a {
  color: inherit;
}

.photo-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: none;
}

.photo-tab {
  flex: 1 1 0;
  min-width: 0;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 44px;
  padding: 0 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-tab.is-on {
  background: var(--accent-soft);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--text);
}

.style-card {
  margin-top: 0;
}

.style-hint {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.style-hint.is-single-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 0.75rem;
  padding: 0;
  min-height: 2.125rem;
  height: 2.125rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  box-sizing: border-box;
}

/* Same box as .sub-tabs — Accessory must not add extra padding (that caused a top-offset flicker). */
.sub-tabs-scroll {
  flex-wrap: nowrap;
}

.sub-tab {
  font: inherit;
  background: none;
  border: none;
  padding: 0.35rem 0;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

.sub-tab.is-on {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.style-chips {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0 0 0.65rem;
  min-height: 122px;
  /* Reserve chip row so tab switches do not jump the category pills / Generate. */
  height: 122px;
  box-sizing: content-box;
}

.style-chips-loading {
  position: sticky;
  left: 0;
  z-index: 2;
  flex: 0 0 auto;
  align-self: center;
  margin-right: 0.25rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(11, 11, 24, 0.82);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.style-chip {
  flex: 0 0 76px;
  width: 76px;
  height: 122px;
  min-height: 122px;
  max-height: 122px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.style-chip.is-on {
  border-color: #c4b5fd;
  box-shadow: inset 0 0 0 1px #c4b5fd;
}

.style-chip-art {
  position: relative;
  flex: 0 0 96px;
  width: 100%;
  height: 96px;
  min-height: 96px;
  max-height: 96px;
  overflow: hidden;
  border-radius: 11px 11px 0 0;
  background: #0b0b18;
}

.style-chip-art.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  background-size: 200% 100%;
  animation: style-chip-shimmer 1.1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .style-chip-art.is-loading::after {
    animation: none;
  }
}

@keyframes style-chip-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.style-chip-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.style-chip-check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.1rem;
  background: rgba(124, 58, 237, 0.45);
}

.style-chip-label {
  flex: 0 0 26px;
  margin: 0;
  padding: 0.25rem 0;
  height: 26px;
  width: 100%;
  font-size: 11px;
  line-height: 18px;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  display: block;
}

.style-chip-label-text {
  display: inline-block;
  padding: 0 4px;
  white-space: nowrap;
  vertical-align: middle;
}

.style-chip-label.is-marquee {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 16px;
  width: max-content;
  animation: style-chip-marquee var(--marquee-duration, 8s) linear infinite;
}

.style-chip-label.is-marquee .style-chip-label-text {
  flex: 0 0 auto;
  padding: 0;
}

@keyframes style-chip-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--marquee-distance, 50%))); }
}

@media (prefers-reduced-motion: reduce) {
  .style-chip-label.is-marquee {
    animation: none;
    width: 100%;
    justify-content: center;
  }
}

.style-categories {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.55rem;
}

.style-pills {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}

.style-pill {
  flex: 0 0 auto;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.45rem 0.75rem;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
}

.style-pill.is-on {
  background: var(--accent-soft);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--text);
}

.apply-fab {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
  cursor: pointer;
}

.apply-fab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .site-hero--inline .site-hero-lead {
    display: none;
  }

  .top-bar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .top-bar-actions {
    margin-left: auto;
  }

  .account-email {
    max-width: 4.5rem;
  }
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.62);
}

.confirm-panel {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}

.confirm-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.confirm-panel p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.result-preview-fs {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  flex-direction: column;
}

.result-preview-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  z-index: 2;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(28, 29, 58, 0.85);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.result-preview-close:hover {
  background: rgba(40, 42, 80, 0.95);
}

.result-preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: zoom-in;
  padding: 3.5rem 1rem 4.5rem;
  box-sizing: border-box;
}

.result-preview-stage.is-zoomed {
  cursor: zoom-out;
}

.result-preview-stage.is-dragging {
  cursor: grabbing !important;
}

.result-preview-stage img {
  display: block;
  /* Fit the full photo inside the stage — no crop / default zoom. */
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  transform-origin: center center;
  transition: transform 0.12s ease-out;
  pointer-events: none;
}

.result-preview-stage.is-dragging img {
  transition: none;
}

.result-preview-stage.is-video {
  cursor: default;
  touch-action: auto;
}

.result-preview-stage video {
  display: block;
  max-width: min(96vw, 1100px);
  max-height: min(78vh, 900px);
  width: auto;
  height: auto;
  background: #000;
}

.result-preview-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(0.85rem, env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.result-preview-footer .btn {
  pointer-events: auto;
}

.compare-card .btn,
.compare-card .file-btn {
  margin-top: 0.65rem;
}

/* Settings popup (Workout-style) */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.8);
}

.settings-sheet {
  width: 100%;
  max-width: 28rem;
  max-height: min(90vh, 40rem);
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.35rem;
  box-shadow: var(--shadow);
}

.app-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 60px;
  margin-bottom: 0.35rem;
}

.app-popup-title {
  margin: 0;
  flex: 1;
  font-size: 1.0625rem;
  line-height: 1.375rem;
  font-weight: 600;
  color: var(--text-muted);
}

.app-popup-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.app-popup-close:hover {
  background: rgba(255, 255, 255, 0.06);
}

.settings-signed-as,
.card-muted {
  margin: 0.35rem 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
}

.ongoing-tasks-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}

.ongoing-tasks-sheet {
  width: min(560px, 100%);
  margin: 0 auto;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  padding: 1rem 1.1rem 1.25rem;
  box-sizing: border-box;
}

.ongoing-tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ongoing-tasks-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.ongoing-tasks-summary {
  margin: 0.35rem 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.ongoing-tasks-empty {
  margin: 2rem 0;
  text-align: center;
  color: var(--text-muted);
}

.ongoing-tasks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ongoing-task-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.65rem;
  align-items: start;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
}

.ongoing-task-main {
  grid-column: 1 / -1;
}

.ongoing-task-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.ongoing-task-sub {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.ongoing-task-progress {
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ongoing-task-progress .progress-track {
  flex: 1;
  margin: 0;
}

.ongoing-task-phase {
  justify-self: start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  background: rgba(34, 211, 238, 0.16);
  color: var(--info);
}

.ongoing-task-phase.is-queued {
  background: rgba(147, 148, 176, 0.18);
  color: var(--text-muted);
}

.ongoing-task-row > .btn {
  justify-self: end;
}
