/* ============================================================
   AI Fashion Hub — Main Styles
   ============================================================ */

/* --- CSS Variables (scoped to fashion hub) --- */
.fashion-hub {
  --fh-bg: #07060C;
  --fh-surface: rgba(255,255,255,0.03);
  --fh-surface-hover: rgba(255,255,255,0.06);
  --fh-surface-active: rgba(255,255,255,0.08);
  --fh-border: rgba(255,255,255,0.08);
  --fh-border-hover: rgba(255,255,255,0.18);
  --fh-border-active: rgba(255,0,140,0.4);
  --fh-text: #f0f0f8;
  --fh-text-muted: #b8b8cc;
  --fh-text-dim: #8e8ea2;
  --fh-pink: #ff008c;
  --fh-pink-glow: rgba(255,0,140,0.25);
  --fh-blue: #5dd5ff;
  --fh-green: #4ecb71;
  --fh-green-glow: rgba(78,203,113,0.25);
  --fh-gradient: linear-gradient(135deg, #ff62c5, #ff008c);
  --fh-radius: 16px;
  --fh-radius-sm: 10px;
  --fh-radius-xs: 6px;
  --fh-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --fh-transition: .25s cubic-bezier(.4,0,.2,1);

  font-family: var(--fh-font);
  color: var(--fh-text);
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Tab Navigation
   ============================================================ */
.fashion-nav {
  display: flex;
  gap: 6px;
  padding: 16px 24px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: wrap;
}
.fashion-nav::-webkit-scrollbar { display: none; }

.fashion-nav__tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--fh-transition);
  user-select: none;
}
.fashion-nav__tab:hover {
  background: var(--fh-surface-hover);
  border-color: var(--fh-border-hover);
  color: var(--fh-text);
}
.fashion-nav__tab--active {
  background: rgba(255,0,140,0.12);
  border-color: var(--fh-border-active);
  color: #fff;
  box-shadow: 0 0 20px var(--fh-pink-glow);
}
.fashion-nav__tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.fashion-nav__tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--fh-text-dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.fashion-nav__tab--active .fashion-nav__tab-badge {
  background: rgba(255,0,140,0.2);
  color: #ff62c5;
}

/* ============================================================
   Hub Body: History sidebar + Work Area wrapper
   ============================================================ */
.fashion-hub-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  min-height: 0;
  flex: 1;
}

/* ============================================================
   Generation History Panel (left sidebar)
   ============================================================ */
.fh-history {
  width: 200px;
  background: var(--fh-surface, rgba(255,255,255,0.03));
  border-right: 1px solid var(--fh-border, rgba(255,255,255,0.08));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease;
  margin-top: 20px;
  border-radius: 12px 0 0 0;
}
.fh-history--collapsed {
  width: 44px;
}
.fh-history--collapsed .fh-history__title,
.fh-history--collapsed .fh-history__list {
  display: none;
}
.fh-history--collapsed .fh-history__toggle svg {
  transform: rotate(180deg);
}
.fh-history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--fh-border, rgba(255,255,255,0.08));
}
.fh-history__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fh-text-dim, rgba(255,255,255,0.5));
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fh-history__toggle {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--fh-text-dim, rgba(255,255,255,0.5));
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.fh-history__toggle:hover {
  background: rgba(255,255,255,0.06);
  color: var(--fh-text, #fff);
}
.fh-history__toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.25s ease;
}

/* ── History list — scrollable grid of square thumbnails ── */
.fh-history__list {
  flex: 1 1 0;
  min-height: 0;        /* critical: allows flex child to shrink below content, enabling scroll */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: min-content;  /* prevent row compression */
  gap: 6px;
  align-content: start;
}
/* Custom thin scrollbar */
.fh-history__list::-webkit-scrollbar { width: 3px; }
.fh-history__list::-webkit-scrollbar-track { background: transparent; }
.fh-history__list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}
.fh-history__list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.22);
}
/* Firefox thin scrollbar */
.fh-history__list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

/* ── Empty state ── */
.fh-history__empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 8px;
  color: var(--fh-text-dim, rgba(255,255,255,0.35));
  text-align: center;
}
.fh-history__empty svg {
  width: 28px;
  height: 28px;
  opacity: 0.35;
}
.fh-history__empty span {
  font-size: 11px;
  line-height: 1.4;
}

/* ── History item — square thumbnail card ── */
.fh-history-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  background: var(--fh-surface, rgba(255,255,255,0.04));
  min-height: 0;
  flex-shrink: 0;
}
.fh-history-item:hover {
  border-color: var(--fh-accent, #ff008c);
  transform: scale(1.03);
}
.fh-history-item--active {
  border-color: var(--fh-accent, #ff008c);
  box-shadow: 0 0 12px rgba(255,0,140,0.25);
}

/* Square thumbnail container — padding-bottom hack for reliable 1:1 ratio in flex/grid */
.fh-history-item__thumb {
  position: relative;
  width: 100%;
  min-width: 0;
  padding-bottom: 100%; /* creates square via padding trick */
  height: 0;            /* required for padding-bottom trick */
  overflow: hidden;
  background: rgba(255,255,255,0.04);
}
.fh-history-item__thumb img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fh-history-item__placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9px;
  color: var(--fh-text-dim, rgba(255,255,255,0.35));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fh-history-item__badge-video {
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.fh-history-item__badge-count {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--fh-accent, #ff008c);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Shimmer placeholder */
.fh-history-item--shimmer {
  border: none;
  cursor: default;
}
.fh-history-item--shimmer .fh-history-item__thumb {
  background: linear-gradient(110deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: fh-shimmer-anim 1.5s infinite;
}

/* Status dot */
.fh-history-item__status {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.3);
}
.fh-history-item__status--done { background: #00d26a; }
.fh-history-item__status--pending { background: #ffa500; animation: fh-pulse 1.5s infinite; }
.fh-history-item__status--failed { background: #ff4444; }
@keyframes fh-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   History Preview (shown in work area on item click)
   ============================================================ */
.fh-history-preview {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 16px;
}
.fh-history-preview__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--fh-border, rgba(255,255,255,0.08));
}
.fh-history-preview__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--fh-text, #fff);
}
.fh-history-preview__time {
  font-size: 12px;
  color: var(--fh-text-dim, rgba(255,255,255,0.4));
}
.fh-history-preview__close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 8px;
  color: var(--fh-text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.fh-history-preview__close:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.fh-history-preview__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.fh-history-preview__media {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  object-fit: contain;
}
/* Before / After compare */
.fh-history-preview__compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 900px;
}
.fh-history-preview__side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.fh-history-preview__side img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.fh-history-preview__side-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fh-text-dim, rgba(255,255,255,0.5));
}
.fh-history-preview__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 8px;
}

/* Lookbook set grid in history preview */
.fh-history-preview__lb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  max-width: 900px;
  margin: 0 auto;
  align-content: center;
}
.fh-history-preview__lb-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fh-history-preview__lb-card:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.fh-history-preview__lb-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--fh-surface, #1a1a2e);
}

/* ============================================================
   Work Area (mode panel container)
   ============================================================ */
.fashion-work-area {
  padding: 20px 24px 32px;
  min-width: 0;
}

/* ============================================================
   Shimmer Loading
   ============================================================ */
.fh-shimmer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}
.fh-shimmer__box {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background: linear-gradient(110deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: fh-shimmer-anim 1.5s infinite;
}
@keyframes fh-shimmer-anim {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.fh-photo-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.fh-photo-loader__shimmer {
  width: 120px;
  height: 160px;
  border-radius: 12px;
}
.fh-photo-loader__text {
  margin-top: 12px;
  color: var(--fh-text-dim);
  font-size: 13px;
}

/* ============================================================
   Common: Two-Column Layout (preview + sidebar)
   ============================================================ */
.fh-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

/* Left: Preview Area — compact when empty, grows when photo loaded */
.fh-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* When photo loaded, allow up to full available height; when empty, content is small */
  max-height: calc(100vh / var(--zoom, 1) - 380px);
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.fh-preview__zone {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  border-radius: var(--fh-radius);
  border: 2px dashed var(--fh-border);
  background: var(--fh-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: border-color var(--fh-transition);
}
.fh-preview__zone--dragover {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.06);
}
.fh-preview__zone img,
.fh-preview__zone video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--fh-radius-sm);
  display: block;
  margin: auto;
}
/* Ensure uploaded photo fills height when flex container has space */
#fh-photo-preview {
  max-width: 100%;
  max-height: 100%;
  height: 100% !important;
  width: auto !important;
  object-fit: contain;
}
/* BA container inside preview zone */
.fh-preview__zone #fh-result-preview {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Drop zone placeholder */
.fh-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
  color: var(--fh-text-dim);
  cursor: pointer;
}
.fh-dropzone svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}
.fh-dropzone__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fh-text-muted);
}
.fh-dropzone__hint {
  font-size: 12px;
  color: var(--fh-text-dim);
}

/* Thumbnail strip */
.fh-thumbstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  flex-shrink: 0;
}
.fh-thumbstrip::-webkit-scrollbar { display: none; }
.fh-thumbstrip__item {
  width: 56px;
  height: 56px;
  border-radius: var(--fh-radius-xs);
  border: 2px solid var(--fh-border);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--fh-transition);
}
.fh-thumbstrip__item--active {
  border-color: var(--fh-pink);
}
.fh-thumbstrip__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fh-thumbstrip__add {
  width: 56px;
  height: 56px;
  border-radius: var(--fh-radius-xs);
  border: 2px dashed var(--fh-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--fh-text-dim);
  transition: all var(--fh-transition);
}
.fh-thumbstrip__add:hover {
  border-color: var(--fh-border-hover);
  color: var(--fh-text);
}

/* Right: Sidebar */
.fh-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  /* Same cap as preview: fit within viewport minus chrome elements */
  max-height: calc(100vh / var(--zoom, 1) - 380px);
  min-height: 0;
  position: sticky;
  top: 100px;
  padding-right: 4px;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ============================================================
   Gender Toggle
   ============================================================ */
.fh-gender-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--fh-surface);
  border: 1px solid var(--fh-border);
}
.fh-gender-toggle__btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--fh-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fh-transition);
}
.fh-gender-toggle__btn--active {
  background: rgba(255,0,140,0.15);
  color: #fff;
}
.fh-gender-toggle__btn:hover:not(.fh-gender-toggle__btn--active) {
  background: var(--fh-surface-hover);
}

/* ============================================================
   Sidebar Section (Accordion)
   ============================================================ */
.fh-section {
  position: relative;
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius-sm);
  background: var(--fh-surface);
  overflow: hidden;
  flex-shrink: 0;
}
.fh-section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--fh-transition);
}
.fh-section__header:hover {
  background: var(--fh-surface-hover);
}
.fh-section__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--fh-pink);
}
.fh-section__title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--fh-text);
}
.fh-section__badge {
  font-size: 10px;
  color: var(--fh-text-dim);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 999px;
}
.fh-section__chevron {
  width: 16px;
  height: 16px;
  color: var(--fh-text-dim);
  transition: transform var(--fh-transition);
}
.fh-section--open .fh-section__chevron {
  transform: rotate(180deg);
}
.fh-section__body {
  display: none;
  padding: 0 14px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.fh-section--open .fh-section__body {
  display: block;
}
/* Last section in sidebar stretches to fill remaining space */
.fh-section--grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.fh-section--grow .fh-section__body {
  flex: 1;
  max-height: none;
  display: flex;
  flex-direction: column;
}
.fh-section--grow .fh-textarea {
  flex: 1;
  min-height: 80px;
}

/* ============================================================
   Preset Grid
   ============================================================ */
.fh-preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fh-preset-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--fh-radius-xs);
  border: 2px solid var(--fh-border);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--fh-transition);
  background: var(--fh-surface);
}
.fh-preset-card:hover {
  border-color: var(--fh-border-hover);
  transform: translateY(-2px);
}
.fh-preset-card--selected {
  border-color: var(--fh-green);
  box-shadow: 0 0 16px var(--fh-green-glow);
}
.fh-preset-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.fh-preset-card__check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--fh-green);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}
.fh-preset-card--selected .fh-preset-card__check {
  display: flex;
}
.fh-preset-card__label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  z-index: 1;
}

/* Garment card action buttons (replace / remove) */
.fh-garment-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .2s;
}

.fh-preset-card:hover .fh-garment-actions {
  opacity: 1;
}
.fh-garment-action {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.fh-garment-action:hover {
  background: rgba(255,0,140,0.8);
}

/* Upload card (first cell) */
.fh-preset-card--upload {
  border-style: dashed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--fh-text-dim);
  font-size: 11px;
}
.fh-preset-card--upload svg {
  width: 24px;
  height: 24px;
}
.fh-preset-card--upload:hover {
  border-color: var(--fh-pink);
  color: var(--fh-text);
  background: rgba(255,0,140,0.06);
}

/* ── Video outfit grid: taller cards, full image visible ──── */
#fh-video-outfit-grid {
  max-height: calc(100vh / var(--zoom, 1) - 260px);
  overflow-y: auto;
}
#fh-video-outfit-grid .fh-preset-card {
  aspect-ratio: 3 / 5;
}
#fh-video-outfit-grid .fh-preset-card img {
  object-fit: contain;
  background: var(--fh-surface);
}

/* ── Photo outfit section: scroll when templates loaded ───── */
.fh-section[data-section="outfit"] {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.fh-section[data-section="outfit"].fh-section--open .fh-section__body {
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.fh-section[data-section="outfit"] .fh-section__body::-webkit-scrollbar { width: 4px; }
.fh-section[data-section="outfit"] .fh-section__body::-webkit-scrollbar-track { background: transparent; }
.fh-section[data-section="outfit"] .fh-section__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
#fh-outfit-grid .fh-preset-card[data-outfit-template] img {
  object-fit: cover;
}
/* Outfit template card: position relative for apply button overlay */
#fh-outfit-grid .fh-preset-card[data-outfit-template] {
  position: relative;
}
.fh-preset-card__apply {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 0, 140, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s, background 0.18s;
  padding: 0;
  z-index: 2;
}
.fh-preset-card__apply svg {
  width: 16px;
  height: 16px;
}
.fh-preset-card[data-outfit-template]:hover .fh-preset-card__apply,
.fh-preset-card[data-outfit-template]:focus-within .fh-preset-card__apply {
  opacity: 1;
}
.fh-preset-card__apply:hover {
  background: rgba(255, 0, 140, 1);
}
.fh-preset-card--selected .fh-preset-card__apply {
  opacity: 1;
  background: #ff008c;
}

/* ── Outfit Lightbox (inline) ─────────────────────────────── */
.fh-outfit-lb {
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.fh-outfit-lb--open { opacity: 1; }
.fh-outfit-lb__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 9, 0.92);
}
.fh-outfit-lb__wrap {
  position: relative;
  max-width: 85vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}
.fh-outfit-lb__img {
  max-width: 85vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 12px;
  transition: filter 0.3s;
  filter: blur(6px);
  user-select: none;
}
.fh-outfit-lb__img--loaded {
  filter: none;
}
.fh-outfit-lb__label {
  margin-top: 10px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  text-align: center;
}
.fh-outfit-lb__counter {
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  margin-top: 4px;
}
.fh-outfit-lb__close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.fh-outfit-lb__close:hover { background: rgba(255,255,255,0.18); }
.fh-outfit-lb__prev,
.fh-outfit-lb__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.fh-outfit-lb__prev { left: 16px; }
.fh-outfit-lb__next { right: 16px; }
.fh-outfit-lb__prev:hover,
.fh-outfit-lb__next:hover { background: rgba(255,255,255,0.18); }
.fh-outfit-lb__apply {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  border: none;
  border-radius: 10px;
  background: #ff008c;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.fh-outfit-lb__apply svg { width: 18px; height: 18px; }
.fh-outfit-lb__apply:hover {
  background: #e0007b;
  transform: translateX(-50%) scale(1.04);
}

/* Outfit lightbox — mobile */
@media (max-width: 768px) {
  .fh-outfit-lb__wrap { max-width: 96vw; max-height: 80vh; }
  .fh-outfit-lb__img { max-width: 96vw; max-height: 68vh; border-radius: 8px; }
  .fh-outfit-lb__close {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: rgba(0,0,0,0.55);
  }
  .fh-outfit-lb__prev,
  .fh-outfit-lb__next {
    width: 36px;
    height: 36px;
    font-size: 22px;
    background: rgba(0,0,0,0.45);
  }
  .fh-outfit-lb__prev { left: 6px; }
  .fh-outfit-lb__next { right: 6px; }
  .fh-outfit-lb__apply {
    bottom: 16px;
    padding: 10px 24px;
    font-size: 14px;
  }
}

/* ── Pose preset grid (taller cards) ──────────────────────── */
/* Pose section: show at least 2 rows of pose cards when open, scroll the rest */
.fh-section[data-section="pose"] {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.fh-section[data-section="pose"].fh-section--open .fh-section__body {
  display: flex;
  flex-direction: column;
  /* 2 rows of 3:4 cards ≈ 310px + pose ref preview ~120px + padding */
  min-height: 280px;
  max-height: 460px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.fh-section[data-section="pose"] .fh-section__body::-webkit-scrollbar { width: 4px; }
.fh-section[data-section="pose"] .fh-section__body::-webkit-scrollbar-track { background: transparent; }
.fh-section[data-section="pose"] .fh-section__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.fh-preset-grid--poses .fh-preset-card {
  min-height: 100px;
  position: relative;
}
.fh-preset-grid--poses .fh-preset-card--selected {
  scroll-margin-top: 8px;
}
.fh-preset-grid--poses .fh-preset-card[data-pose] {
  cursor: pointer;
}

/* ── Pose reference preview ───────────────────────────────── */
.fh-pose-ref-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  background: var(--fh-surface);
  border: 1px solid var(--fh-border);
  position: relative;
}
.fh-pose-ref-preview img {
  width: 60px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
}
.fh-pose-ref-preview__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.fh-pose-ref-preview__remove:hover {
  background: rgba(255,0,0,0.7);
}

/* ============================================================
   Aspect Ratio Selector
   ============================================================ */
.fh-aspect-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.fh-aspect-row__label {
  font-size: 12px;
  color: var(--fh-text-dim);
  margin-right: 4px;
  white-space: nowrap;
}
.fh-aspect-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--fh-border);
  border-radius: 999px;
  background: transparent;
  color: var(--fh-text-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.fh-aspect-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.fh-aspect-pill:hover {
  border-color: var(--fh-border-hover);
  color: var(--fh-text);
}
.fh-aspect-pill--active {
  border-color: var(--fh-pink);
  background: rgba(255, 0, 140, 0.1);
  color: #fff;
}

/* ============================================================
   Generate Button
   ============================================================ */
.fh-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 999px;
  background: var(--fh-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--fh-transition);
  box-shadow: 0 4px 24px var(--fh-pink-glow);
  flex-shrink: 0;
}
.fh-generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 40px var(--fh-pink-glow);
}
.fh-generate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Generate button loading spinner */
.fh-generate-btn--loading {
  position: relative;
  pointer-events: none;
}
.fh-generate-btn--loading svg:first-child {
  animation: fh-spin 1s linear infinite;
}
.fh-generate-btn--loading .fh-generate-btn__cost {
  display: none;
}
@keyframes fh-spin {
  to { transform: rotate(360deg); }
}
.fh-generate-btn__cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  font-size: 12px;
  font-weight: 700;
}

/* ============================================================
   Wizard (Video Try-On steps)
   ============================================================ */
.fh-wizard {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: calc(100vh / var(--zoom, 1) - 260px);
  min-height: 0;
}
.fh-wizard__steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  flex-shrink: 0;
}
.fh-wizard__step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fh-text-dim);
  font-weight: 500;
  white-space: nowrap;
}
.fh-wizard__step--active {
  color: var(--fh-pink);
}
.fh-wizard__step--done {
  color: var(--fh-green);
}
.fh-wizard__step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--fh-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: all var(--fh-transition);
}
.fh-wizard__step--active .fh-wizard__step-num {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.15);
  color: #fff;
}
.fh-wizard__step--done .fh-wizard__step-num {
  border-color: var(--fh-green);
  background: rgba(78,203,113,0.15);
  color: var(--fh-green);
}
.fh-wizard__line {
  flex: 1;
  height: 2px;
  background: var(--fh-border);
  margin: 0 8px;
}
.fh-wizard__line--done {
  background: var(--fh-green);
}
.fh-wizard__content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.fh-wizard__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  flex-shrink: 0;
}

/* Layout inside wizard adapts to available space */
.fh-wizard__content .fh-layout {
  height: 100%;
}
.fh-wizard__content .fh-preview {
  max-height: 100%;
}

/* Wizard nav buttons */
.fh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fh-transition);
}
.fh-btn:hover {
  background: var(--fh-surface-hover);
  border-color: var(--fh-border-hover);
}
.fh-btn--primary {
  background: var(--fh-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px var(--fh-pink-glow);
}
.fh-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--fh-pink-glow);
}
.fh-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.fh-btn--sm {
  padding: 6px 14px;
  font-size: 12px;
  gap: 5px;
  border-radius: 8px;
}

/* ============================================================
   Music Preset Grid (Video)
   ============================================================ */
.fh-music-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.fh-music-card {
  position: relative;
  border-radius: var(--fh-radius-sm);
  border: 2px solid var(--fh-border);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--fh-text);
  transition: all var(--fh-transition);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-height: 96px;
}
.fh-music-card__desc {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
  line-height: 1.3;
}
.fh-music-card:hover {
  border-color: var(--fh-border-hover);
  transform: translateY(-2px);
}
.fh-music-card--selected {
  border-color: var(--fh-green);
  box-shadow: 0 0 16px var(--fh-green-glow);
}
/* Gradient backgrounds for music cards */
.fh-music-card--gradient-1 { background: linear-gradient(135deg, #3a1c71, #d76d77); }
.fh-music-card--gradient-2 { background: linear-gradient(135deg, #0f2027, #2c5364); }
.fh-music-card--gradient-3 { background: linear-gradient(135deg, #1a002e, #ff008c); }
.fh-music-card--gradient-4 { background: linear-gradient(135deg, #141e30, #243b55); }
.fh-music-card--gradient-5 { background: linear-gradient(135deg, #2d1b69, #ee1d52); }
.fh-music-card--gradient-6 { background: linear-gradient(135deg, #0d0d0d, #434343); }
.fh-music-card--upload {
  border-style: dashed;
  background: var(--fh-surface);
  color: var(--fh-text-dim);
  align-items: center;
  text-align: center;
}
.fh-music-card--upload:hover {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.06);
}
.fh-music-card--prompt {
  border-style: dashed;
  background: var(--fh-surface);
  color: var(--fh-text-dim);
  align-items: center;
  text-align: center;
}
.fh-music-card--prompt:hover {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.06);
}
.fh-music-card--prompt.fh-music-card--selected {
  border-color: var(--fh-green);
  border-style: solid;
  box-shadow: 0 0 16px var(--fh-green-glow);
}
.fh-music-card--random {
  background: linear-gradient(135deg, #1a0033, #3d0066, #ff008c);
  align-items: center;
  text-align: center;
}
.fh-music-card svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Review Card (Video step 4)
   ============================================================ */
.fh-review {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.fh-review__card {
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius-sm);
  background: var(--fh-surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fh-review__card--full {
  grid-column: 1 / -1;
}
.fh-review__card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--fh-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fh-review__card-title svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.fh-review__card img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--fh-radius-xs);
}
.fh-review__settings {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ── Video Review 3-col layout (Step 4) ───────────────────── */
.fh-video-review {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
  height: 100%;
  min-height: 0;
}
.fh-video-review__col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.fh-video-review__col--settings {
  background: var(--fh-surface);
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius-sm);
  padding: 16px;
}
.fh-video-review__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fh-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fh-video-review__label svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.fh-video-review__img {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius-sm);
  background: var(--fh-surface);
  overflow: hidden;
}
.fh-video-review__img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.fh-video-review__empty {
  color: var(--fh-text-dim);
  font-size: 24px;
}
.fh-video-review__setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--fh-border);
}
.fh-video-review__setting:last-of-type {
  border-bottom: none;
}
.fh-video-review__setting-label {
  font-size: 11px;
  color: var(--fh-text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
.fh-video-review__setting-label svg {
  width: 14px;
  height: 14px;
}
.fh-video-review__setting-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--fh-text);
}

/* Aspect ratio / Quality pill */
.fh-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fh-transition);
}
.fh-pill:hover {
  border-color: var(--fh-border-hover);
}
.fh-pill--active {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.1);
}
.fh-pill svg {
  width: 14px;
  height: 14px;
}

/* Quality dropdown */
.fh-quality-dropdown {
  position: relative;
}
.fh-quality-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #12101a;
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius-sm);
  padding: 6px;
  z-index: 100;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.fh-quality-dropdown--open .fh-quality-dropdown__menu {
  display: block;
}
.fh-quality-dropdown__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--fh-radius-xs);
  cursor: pointer;
  font-size: 13px;
  color: var(--fh-text);
  transition: background var(--fh-transition);
}
.fh-quality-dropdown__item:hover {
  background: var(--fh-surface-hover);
}
.fh-quality-dropdown__item--active {
  color: var(--fh-pink);
}

/* ============================================================
   Placeholder panels (Phase 2/3 modes)
   ============================================================ */
.fh-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 400px;
  text-align: center;
  padding: 40px;
}
.fh-placeholder svg {
  width: 64px;
  height: 64px;
  color: var(--fh-text-dim);
  opacity: 0.4;
}
.fh-placeholder__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--fh-text);
}
.fh-placeholder__desc {
  font-size: 14px;
  color: var(--fh-text-dim);
  max-width: 400px;
  line-height: 1.5;
}
.fh-placeholder__badge {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255,0,140,0.1);
  color: var(--fh-pink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ============================================================
   Strength Slider (Restyle)
   ============================================================ */
.fh-slider {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fh-slider input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--fh-border);
  border-radius: 2px;
  outline: none;
}
.fh-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--fh-pink);
  cursor: pointer;
  box-shadow: 0 0 8px var(--fh-pink-glow);
}
.fh-slider__value {
  font-size: 13px;
  font-weight: 600;
  color: var(--fh-text);
  min-width: 36px;
  text-align: right;
}

/* ============================================================
   Result actions
   ============================================================ */
.fh-result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.fh-result-actions .fh-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   AI Consultant Chat
   ============================================================ */
.fhc-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh / var(--zoom, 1) - 180px);
  min-height: 480px;
  margin: 0 auto;
  border: 1px solid var(--fh-border);
  border-radius: var(--fh-radius);
  background: var(--fh-surface);
  overflow: hidden;
}

/* Header */
.fhc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--fh-border);
  background: rgba(255,255,255,0.02);
}
.fhc-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,0,140,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fh-pink);
}
.fhc-header__avatar svg { width: 20px; height: 20px; }
.fhc-header__info { flex: 1; }
.fhc-header__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fh-text);
}
.fhc-header__status {
  font-size: 11px;
  color: var(--fh-green);
}
.fhc-header__action {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fh-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--fh-transition);
  flex-shrink: 0;
}
.fhc-header__action:hover {
  background: var(--fh-surface-hover);
  color: var(--fh-text);
}
.fhc-header__action svg { width: 18px; height: 18px; }

/* Body wrapper — holds history + main chat side by side */
.fhc-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.fhc-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* History panel (sidebar) */
.fhc-history {
  display: none;
  flex-direction: column;
  width: 0;
  min-width: 0;
  border-right: 1px solid var(--fh-border);
  background: rgba(255,255,255,0.02);
  overflow: hidden;
  transition: width 0.22s ease, min-width 0.22s ease;
}
.fhc-history--open {
  width: 280px;
  min-width: 280px;
}
.fhc-history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--fh-border);
  flex-shrink: 0;
}
.fhc-history__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fh-text);
}
.fhc-history__close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fh-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--fh-transition);
}
.fhc-history__close:hover { background: var(--fh-surface-hover); color: var(--fh-text); }
.fhc-history__close svg { width: 16px; height: 16px; }
.fhc-history__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.fhc-history__empty {
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--fh-text-dim);
}
.fhc-history__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.fhc-history__item:hover {
  background: rgba(255,255,255,0.06);
}
.fhc-history__item-body {
  flex: 1;
  min-width: 0;
}
.fhc-history__item-preview {
  font-size: 13px;
  color: var(--fh-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.fhc-history__item-meta {
  font-size: 11px;
  color: var(--fh-text-dim);
  margin-top: 2px;
  display: flex;
  gap: 4px;
}
.fhc-history__item-delete {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fh-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.fhc-history__item:hover .fhc-history__item-delete { opacity: 1; }
.fhc-history__item-delete:hover {
  background: rgba(255,60,60,0.15);
  color: #ff6b6b;
}
.fhc-history__item-delete svg { width: 14px; height: 14px; }

/* Messages area */
.fhc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* Single message */
.fhc-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: fhc-fade-in .3s ease;
}
@keyframes fhc-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fhc-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.fhc-msg--assistant {
  align-self: flex-start;
}

/* Avatar */
.fhc-msg__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fhc-msg__avatar svg { width: 16px; height: 16px; }
.fhc-msg__avatar--bot {
  background: rgba(255,0,140,0.12);
  color: var(--fh-pink);
}
.fhc-msg__avatar--user {
  background: rgba(93,213,255,0.12);
  color: var(--fh-blue);
}

/* Message body */
.fhc-msg__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fhc-msg--assistant .fhc-msg__body {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--fh-border);
  border-radius: 2px 14px 14px 14px;
  padding: 12px 16px;
}
.fhc-msg--user .fhc-msg__body {
  background: rgba(255,0,140,0.10);
  border: 1px solid rgba(255,0,140,0.2);
  border-radius: 14px 2px 14px 14px;
  padding: 12px 16px;
}

.fhc-msg__text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--fh-text);
}
.fhc-msg__text strong {
  color: #fff;
  font-weight: 600;
}

.fhc-msg__image {
  max-width: 200px;
  border-radius: var(--fh-radius-sm);
  overflow: hidden;
}
.fhc-msg__image img {
  width: 100%;
  display: block;
  border-radius: var(--fh-radius-sm);
}

/* Suggestions */
.fhc-msg__suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.fhc-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--fh-radius-xs);
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--fh-transition);
}
.fhc-suggestion:hover {
  background: var(--fh-surface-hover);
  border-color: var(--fh-border-hover);
}
.fhc-suggestion svg { width: 16px; height: 16px; flex-shrink: 0; }
.fhc-suggestion--generate svg { color: var(--fh-pink); }
.fhc-suggestion--navigate svg { color: var(--fh-blue); }
.fhc-suggestion__cost {
  margin-left: auto;
  font-size: 11px;
  color: var(--fh-text-dim);
}

/* Typing indicator */
.fhc-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.fhc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fh-text-dim);
  animation: fhc-dot-pulse 1.4s infinite ease-in-out;
}
.fhc-typing span:nth-child(2) { animation-delay: .2s; }
.fhc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes fhc-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Quick prompts */
.fhc-quick-prompts {
  text-align: center;
  padding: 24px 0;
}
.fhc-quick-prompts__hint {
  font-size: 13px;
  color: var(--fh-text-dim);
  margin-bottom: 14px;
}
.fhc-quick-prompts__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.fhc-quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--fh-transition);
}
.fhc-quick-btn:hover {
  background: rgba(255,0,140,0.08);
  border-color: rgba(255,0,140,0.3);
  color: #fff;
}
.fhc-quick-btn__icon { font-size: 16px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fhc-quick-btn__icon svg { width: 18px; height: 18px; }

/* Input bar */
.fhc-input-bar {
  border-top: 1px solid var(--fh-border);
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
}
.fhc-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fhc-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--fh-border);
  background: var(--fh-surface);
  color: var(--fh-text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--fh-transition);
}
.fhc-input::placeholder { color: var(--fh-text-dim); }
.fhc-input:focus { border-color: var(--fh-pink); }

.fhc-input-btn,
.fhc-send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--fh-transition);
  flex-shrink: 0;
}
.fhc-input-btn {
  background: transparent;
  color: var(--fh-text-dim);
}
.fhc-input-btn:hover { color: var(--fh-text); background: var(--fh-surface-hover); }
.fhc-input-btn svg { width: 20px; height: 20px; }

.fhc-send-btn {
  background: var(--fh-gradient);
  color: #fff;
}
.fhc-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.fhc-send-btn svg { width: 18px; height: 18px; }

/* Attach preview */
.fhc-attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: var(--fh-radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--fh-border);
}
.fhc-attach-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--fh-radius-xs);
}
.fhc-attach-remove {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: var(--fh-text-dim);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fhc-attach-remove:hover { background: rgba(255,0,0,0.2); color: #f44; }

/* ============================================================
   Lookbook — Grid & Cards
   ============================================================ */
.fh-lb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
}
.fh-lb-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--fh-text-dim);
  text-align: center;
}
.fh-lb-empty svg { width: 48px; height: 48px; opacity: 0.3; }
.fh-lb-empty p { font-size: 14px; max-width: 260px; }

.fh-lb-result-card {
  position: relative;
  border-radius: var(--fh-radius);
  overflow: hidden;
  background: var(--fh-surface);
  border: 1px solid var(--fh-border);
  /* aspect-ratio задаётся через inline style из JS (_format) */
}
.fh-lb-result-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.fh-lb-result-card__actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--fh-transition);
}
.fh-lb-result-card:hover .fh-lb-result-card__actions { opacity: 1; }

.fh-lb-shimmer {
  /* aspect-ratio задаётся через inline style из JS (_format) */
  border-radius: var(--fh-radius);
  background: linear-gradient(110deg, var(--fh-surface) 30%, rgba(255,0,140,0.06) 50%, var(--fh-surface) 70%);
  background-size: 200% 100%;
  animation: fh-shimmer 1.5s ease-in-out infinite;
}

.fh-lb-photo-preview,
.fh-lb-outfit-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fh-lb-photo-preview img,
.fh-lb-outfit-preview img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--fh-border);
}

/* ============================================================
   Restyle — Before/After Slider
   ============================================================ */
.fh-rs-single {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.fh-rs-single img {
  max-width: 100%;
  max-height: 480px;
  border-radius: var(--fh-radius);
  object-fit: contain;
}

.fh-rs-dropzone-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 320px;
  border: 2px dashed var(--fh-border);
  border-radius: var(--fh-radius);
  cursor: pointer;
  color: var(--fh-text-dim);
  transition: all var(--fh-transition);
}
.fh-rs-dropzone-full:hover,
.fh-rs-dropzone-full.fh-dropzone--hover {
  border-color: var(--fh-pink);
  background: rgba(255,0,140,0.04);
}
.fh-rs-dropzone-full svg { width: 40px; height: 40px; opacity: 0.4; }
.fh-rs-dropzone-full p { font-size: 14px; }

.fh-rs-ba {
  position: relative;
  width: 100%;
  min-height: 320px;
  overflow: hidden;
  border-radius: var(--fh-radius);
  user-select: none;
}
.fh-rs-ba__before,
.fh-rs-ba__after {
  position: absolute;
  inset: 0;
}
.fh-rs-ba__before { z-index: 2; clip-path: inset(0 50% 0 0); }
.fh-rs-ba__after { z-index: 1; }
.fh-rs-ba__before img,
.fh-rs-ba__after img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fh-rs-ba__label {
  position: absolute;
  top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}
.fh-rs-ba__before .fh-rs-ba__label {
  left: 12px;
  background: rgba(0,0,0,0.6);
  color: #fff;
}
.fh-rs-ba__after .fh-rs-ba__label {
  right: 12px;
  background: rgba(255,0,140,0.7);
  color: #fff;
}
.fh-rs-ba__slider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--fh-pink);
  z-index: 5;
  cursor: ew-resize;
  transform: translateX(-50%);
}
.fh-rs-ba__handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fh-pink);
  border: 3px solid #fff;
  box-shadow: 0 0 12px rgba(255,0,140,0.4);
}
.fh-rs-ba__actions {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 6;
  display: flex;
  gap: 6px;
}

.fh-rs-thumb {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fh-rs-thumb img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--fh-border);
}

.fh-rs-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fh-rs-slider {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--fh-border);
  border-radius: 2px;
  outline: none;
}
.fh-rs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fh-pink);
  cursor: pointer;
  box-shadow: 0 0 8px var(--fh-pink-glow);
}
.fh-rs-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--fh-text-dim);
}
.fh-rs-slider-labels span:nth-child(2) {
  font-weight: 600;
  color: var(--fh-pink);
}

.fh-rs-shimmer {
  opacity: 0.5;
  animation: fh-shimmer 1.5s ease-in-out infinite;
}

/* ============================================================
   Collage / Moodboard Screen
   ============================================================ */
.fh-collage-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px 20px;
  min-height: 480px;
  text-align: center;
}
.fh-collage-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.fh-collage-icon {
  width: 64px;
  height: 64px;
  color: var(--fh-pink);
  opacity: 0.6;
}
.fh-collage-icon svg { width: 100%; height: 100%; }
.fh-collage-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fh-text);
}
.fh-collage-desc {
  font-size: 14px;
  color: var(--fh-text-dim);
  max-width: 480px;
  line-height: 1.5;
}

.fh-collage-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.fh-collage-preset {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--fh-surface);
  border: 1px solid var(--fh-border);
  font-size: 13px;
  color: var(--fh-text-dim);
}
.fh-collage-preset__icon {
  width: 20px;
  height: 20px;
  color: var(--fh-pink);
}
.fh-collage-preset__icon svg { width: 100%; height: 100%; }

.fh-collage-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.fh-generate-btn--wide {
  min-width: 260px;
}
.fh-collage-hint {
  font-size: 12px;
  color: var(--fh-text-dim);
  opacity: 0.6;
}

/* ============================================================
   Custom Scrollbar (all panels) — thin & dark, site-wide match
   ============================================================ */
.fashion-hub,
.fashion-hub-body,
.fh-sidebar,
.fhc-messages,
.fhc-history__list,
.fashion-work-area,
.fh-section__body,
.fh-history__list,
.fh-wizard__content,
#fh-video-outfit-grid {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.10) transparent;
}
.fashion-hub::-webkit-scrollbar,
.fashion-hub-body::-webkit-scrollbar,
.fh-sidebar::-webkit-scrollbar,
.fhc-messages::-webkit-scrollbar,
.fhc-history__list::-webkit-scrollbar,
.fashion-work-area::-webkit-scrollbar,
.fh-section__body::-webkit-scrollbar,
.fh-history__list::-webkit-scrollbar,
.fh-wizard__content::-webkit-scrollbar,
#fh-video-outfit-grid::-webkit-scrollbar {
  width: 5px;
}
.fashion-hub::-webkit-scrollbar-track,
.fashion-hub-body::-webkit-scrollbar-track,
.fh-sidebar::-webkit-scrollbar-track,
.fhc-messages::-webkit-scrollbar-track,
.fhc-history__list::-webkit-scrollbar-track,
.fashion-work-area::-webkit-scrollbar-track,
.fh-section__body::-webkit-scrollbar-track,
.fh-history__list::-webkit-scrollbar-track,
.fh-wizard__content::-webkit-scrollbar-track,
#fh-video-outfit-grid::-webkit-scrollbar-track {
  background: transparent;
}
.fashion-hub::-webkit-scrollbar-thumb,
.fashion-hub-body::-webkit-scrollbar-thumb,
.fh-sidebar::-webkit-scrollbar-thumb,
.fhc-messages::-webkit-scrollbar-thumb,
.fhc-history__list::-webkit-scrollbar-thumb,
.fashion-work-area::-webkit-scrollbar-thumb,
.fh-section__body::-webkit-scrollbar-thumb,
.fh-history__list::-webkit-scrollbar-thumb,
.fh-wizard__content::-webkit-scrollbar-thumb,
#fh-video-outfit-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 4px;
}
.fashion-hub::-webkit-scrollbar-thumb:hover,
.fashion-hub-body::-webkit-scrollbar-thumb:hover,
.fh-sidebar::-webkit-scrollbar-thumb:hover,
.fhc-messages::-webkit-scrollbar-thumb:hover,
.fhc-history__list::-webkit-scrollbar-thumb:hover,
.fashion-work-area::-webkit-scrollbar-thumb:hover,
.fh-section__body::-webkit-scrollbar-thumb:hover,
.fh-history__list::-webkit-scrollbar-thumb:hover,
.fh-wizard__content::-webkit-scrollbar-thumb:hover,
#fh-video-outfit-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.20);
}

/* ============================================================
   "From Resources" button in dropzone
   ============================================================ */
.fh-btn--resources {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fh-text);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.fh-btn--resources:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--fh-green);
}
.fh-btn--resources svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================================
   Remove-BG tool button
   ============================================================ */
.fh-btn--tool {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fh-text);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, opacity 0.18s;
}
.fh-btn--tool:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--fh-green);
}
.fh-btn--tool:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.fh-btn--tool svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================================
   Before / After Slider Overlay
   ============================================================ */
.fh-ba-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.75);
  opacity: 0;
  transition: opacity 0.25s;
}
.fh-ba-overlay--visible {
  opacity: 1;
}
.fh-ba-modal {
  position: relative;
  width: 90%;
  max-width: 800px;
  background: var(--fh-card, #1a1a2e);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.fh-ba-modal__close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--fh-text);
  font-size: 28px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  z-index: 1;
}
.fh-ba-modal__close:hover {
  opacity: 1;
}
.fh-ba-container {
  position: relative;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  border-radius: 12px;
  user-select: none;
  -webkit-user-select: none;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fh-ba-img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.fh-ba-img--after {
  display: block;
}
.fh-ba-clip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;
}
.fh-ba-clip .fh-ba-img--before {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  max-width: none;
}
.fh-ba-handle {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: #fff;
  transform: translateX(-50%);
  z-index: 2;
}
.fh-ba-handle__line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: #fff;
  transform: translateX(-50%);
}
.fh-ba-handle__grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: col-resize;
}
.fh-ba-handle__grip svg {
  color: #fff;
}
.fh-ba-label {
  position: absolute;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
}
.fh-ba-label--before {
  left: 12px;
}
.fh-ba-label--after {
  right: 12px;
}

/* ============================================================
   Before/After Inline Comparison (tryon-photo generation)
   ============================================================ */
#fh-result-preview {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fh-ba {
  --ba-split: 50%;
  position: relative;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: var(--fh-radius-sm);
  user-select: none;
  -webkit-user-select: none;
  cursor: col-resize;
}
/* Before image is in-flow to set the natural size */
.fh-ba__before {
  position: relative;
  height: 100%;
  max-height: 100%;
  clip-path: inset(0 calc(100% - var(--ba-split)) 0 0);
}
.fh-ba__after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(0 0 0 var(--ba-split));
}
.fh-ba__before img,
.fh-ba__after img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.fh-ba__label {
  position: absolute;
  bottom: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
  z-index: 4;
}
.fh-ba__label--before { left: 12px; }
.fh-ba__label--after { right: 12px; }

.fh-ba__slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--ba-split);
  transform: translateX(-50%);
  width: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  cursor: col-resize;
}
.fh-ba__line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--fh-pink, #ff2ea6);
  pointer-events: none;
}
.fh-ba__handle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,46,166,0.85);
  border: 2px solid #fff;
  box-shadow: 0 0 12px rgba(255,0,140,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
}
.fh-ba__handle svg {
  width: 16px;
  height: 16px;
}

/* Shimmer for "after" while generating */
.fh-ba__shimmer {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    110deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,0,140,0.12) 37%,
    rgba(93,213,255,0.10) 50%,
    rgba(255,0,140,0.12) 63%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 300% 100%;
  animation: fh-ba-shimmer 2s ease-in-out infinite;
}
@keyframes fh-ba-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Section locked (mutual Outfit ↔ Garments exclusion) */
.fh-section--locked {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.4);
  transition: opacity 0.3s, filter 0.3s;
}
.fh-section--locked::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Replace-photo popup */
.fh-replace-popup-wrap {
  position: relative;
  display: inline-block;
}
.fh-replace-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fh-surface, #1e1e2e);
  border: 1px solid var(--fh-border, #333);
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 20;
  animation: fh-popup-in 0.15s ease-out;
}
.fh-replace-popup__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--fh-text, #e4e4e4);
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.fh-replace-popup__item:hover {
  background: rgba(255,255,255,0.07);
}
.fh-replace-popup__item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
@keyframes fh-popup-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Photo action buttons — absolute overlay inside preview zone (bottom-center) */
.fh-photo-actions {
  display: flex;
  flex-direction: row;
  gap: 6px;
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 5;
  background: transparent;
  padding: 0;
}
.fh-photo-actions .fh-btn--tool {
  background: rgba(26,26,46,0.80);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  padding: 6px 14px;
  margin-top: 0;
}
.fh-btn--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   Responsive — Tablet (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
  .fh-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .fh-preview {
    max-height: none;
  }
  .fh-sidebar {
    max-height: none;
    position: static;
    height: auto;
  }
  .fh-music-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .fh-review {
    grid-template-columns: 1fr;
  }
  .fh-video-review {
    grid-template-columns: 1fr 1fr;
  }
  .fh-video-review__col--settings {
    grid-column: 1 / -1;
  }
  .fashion-nav {
    padding: 12px 16px 0;
  }
  .fashion-work-area {
    padding: 16px 16px 24px;
  }
  .fh-lb-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* History panel — collapse on tablet */
  .fh-history { width: 44px; }
  .fh-history .fh-history__title,
  .fh-history .fh-history__list { display: none; }
  .fh-history .fh-history__toggle svg { transform: rotate(180deg); }
  /* History preview — stack compare vertically */
  .fh-history-preview__compare {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
}

/* ============================================================
   Responsive — Mobile / Telegram WebApp (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* ── Root fashion hub ── */
  .fashion-hub {
    --fh-mobile: 1;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  /* ── Tab Navigation — horizontal scroll, no wrap, no overlap ── */
  .fashion-nav {
    position: relative;
    padding: 8px 12px 6px;
    flex-wrap: nowrap;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    /* Thin visible scrollbar as visual scroll indicator */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
    z-index: auto;
    padding-bottom: 10px; /* room for scrollbar */
  }
  .fashion-nav::-webkit-scrollbar {
    display: block;
    height: 4px;
  }
  .fashion-nav::-webkit-scrollbar-track {
    background: transparent;
  }
  .fashion-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: 4px;
  }
  .fashion-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
  }

  /* Scroll fade-hint — gradient on the right edge */
  .fashion-nav::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    flex-shrink: 0;
    width: 32px;
    height: 100%;
    background: linear-gradient(to right, transparent, var(--fh-bg, #07060C) 80%);
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s;
  }
  /* Hide fade when scrolled to the end */
  .fashion-nav.fashion-nav--scrolled-end::after {
    opacity: 0;
  }

  .fashion-nav__tab {
    padding: 7px 12px;
    font-size: 11px;
    gap: 5px;
    flex-shrink: 0;
  }
  .fashion-nav__tab svg {
    width: 14px;
    height: 14px;
  }
  .fashion-nav__tab-badge {
    font-size: 9px;
    padding: 1px 5px;
  }

  /* ── Hub Body — single column, no history sidebar, scrollable ── */
  .fashion-hub-body {
    grid-template-columns: 1fr;
    overflow: visible;
    height: auto;
  }

  /* ── Work Area — scrollable, not trapped ── */
  .fashion-work-area {
    padding: 8px 12px 24px;
    overflow: visible;
    height: auto;
  }

  /* ── History panel — hidden by default, fullscreen overlay when open ── */
  .fh-history {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100% !important;
    background: var(--fh-bg, #07060C);
    border-right: none;
    border-radius: 0;
    margin-top: 0;
  }
  .fh-history.fh-history--mobile-open {
    display: flex;
  }
  .fh-history--collapsed {
    width: 100% !important;
  }
  .fh-history.fh-history--mobile-open .fh-history__title,
  .fh-history.fh-history--mobile-open .fh-history__list {
    display: grid;
  }
  .fh-history.fh-history--mobile-open .fh-history__list {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
  }
  .fh-history.fh-history--mobile-open .fh-history__header {
    padding: 16px;
    border-bottom: 1px solid var(--fh-border);
  }
  .fh-history.fh-history--mobile-open .fh-history__title {
    font-size: 14px;
    display: block;
  }

  /* ── Work Area ── */
  .fashion-work-area {
    padding: 12px 12px 24px;
  }

  /* ── Two-column layout → single column ── */
  .fh-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    height: auto;
  }

  /* ── Preview area — full width, bounded height ── */
  .fh-preview {
    max-height: 50vh;
    max-height: 50dvh;
    min-height: 200px;
  }
  /* Dropzone inside preview — ensure decent height */
  .fh-preview__zone {
    min-height: 280px;
  }

  /* ── Sidebar → vertical scroll section ── */
  .fh-sidebar {
    position: static;
    height: auto;
    max-height: none;
    overflow-y: visible;
    overflow-x: hidden;
    padding-right: 0;
    padding-bottom: 0;
  }

  /* ── Sidebar accordion sections — touch-friendly ── */
  .fh-section__header {
    padding: 14px 16px;
    min-height: 48px;
  }
  .fh-section__title {
    font-size: 14px;
  }

  /* ── Preset grids → 3 columns on mobile ── */
  .fh-preset-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .fh-preset-grid--poses {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  /* ── Generate button — compact, sticky bottom ── */
  .fh-generate-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    border-radius: 12px;
    position: sticky;
    bottom: 8px;
    z-index: 50;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.3), 0 2px 16px var(--fh-pink-glow);
  }
  .fh-generate-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  /* ── Result actions — wrap ── */
  .fh-result-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .fh-result-actions .fh-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    font-size: 12px;
    padding: 10px 8px;
  }

  /* ── Photo actions — absolute overlay inside zone on mobile too ── */
  .fh-photo-actions {
    position: absolute !important;
    left: 50% !important;
    bottom: 8px !important;
    right: auto !important;
    top: auto !important;
    transform: translateX(-50%) !important;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 0;
    margin: 0;
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
  }
  .fh-photo-actions .fh-btn--tool {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    margin-top: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Thumbnail strip — touch scroll ── */
  .fh-thumbstrip {
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 8px;
  }
  .fh-thumbstrip__item {
    width: 48px;
    height: 48px;
  }
  .fh-thumbstrip__add {
    width: 48px;
    height: 48px;
  }

  /* ── Gender toggle — full width ── */
  .fh-gender-toggle {
    width: 100%;
  }
  .fh-gender-toggle__btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* ── Dropzone — smaller padding ── */
  .fh-dropzone {
    padding: 24px 16px;
    gap: 8px;
  }
  .fh-dropzone svg {
    width: 36px;
    height: 36px;
  }
  .fh-dropzone__title {
    font-size: 14px;
  }
  .fh-dropzone__hint {
    font-size: 11px;
  }

  /* ── Music grid ── */
  .fh-music-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ── Wizard steps — icons only ── */
  .fh-wizard__step span {
    display: none;
  }
  .fh-collage-presets {
    flex-direction: column;
  }

  /* ── Lookbook grid ── */
  .fh-lb-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* ── History preview — single column compare ── */
  .fh-history-preview__compare {
    grid-template-columns: 1fr;
    max-width: 100%;
    gap: 12px;
  }
  .fh-history-preview__side img {
    max-height: 40vh;
    max-height: 40dvh;
  }
  .fh-history-preview__lb-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  /* History preview — scrollable body, actions not overlapping */
  .fh-history-preview {
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 24px;
  }
  .fh-history-preview__body {
    flex: none;
    min-height: auto;
  }
  .fh-history-preview__actions {
    position: static;
    padding: 12px 0 8px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .fh-history-preview__actions .fh-btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    padding: 10px 12px;
  }
  .fh-history-preview__media {
    max-height: 50vh;
    max-height: 50dvh;
  }

  /* ── Prompt textarea ── */
  .fh-textarea {
    min-height: 60px;
    font-size: 14px;
  }

  /* ── Video review ── */
  .fh-video-review {
    grid-template-columns: 1fr;
  }
  .fh-video-review__col--settings {
    grid-column: 1;
  }

  /* ── Aspect ratio pills ── */
  .fh-aspect-pills {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* ── Pose section — no flex-grow on mobile (sidebar is auto-height) ── */
  .fh-section[data-section="pose"] {
    flex: none;
    overflow: visible;
  }
  .fh-section[data-section="pose"].fh-section--open .fh-section__body {
    overflow-y: visible;
    max-height: none;
  }
  /* ── Pose grid — visible, scrollable ── */
  .fh-preset-grid--poses {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Sidebar — all sections accessible ── */
  .fh-sidebar {
    overflow: visible;
    max-height: none;
    height: auto;
  }
}

/* ============================================================
   Telegram WebApp — extra safe-area and compact mode
   ============================================================ */

/*
  html.tg-webapp is set by an early inline script in index.html
  BEFORE stylesheets are parsed — so header/footer are hidden from
  first paint, no flash, no layout shift.
*/

/* 1. Immediately hide site chrome when running in TG WebApp or mobile */
html.tg-webapp .site-header,
html.tg-webapp [data-include*="header"],
html.tg-webapp footer,
html.tg-webapp [data-include*="footer"],
html.tg-webapp .header,
html.aidc-mobile-header .site-header,
html.aidc-mobile-header [data-include*="header"],
html.aidc-mobile-header .top-bar,
html.aidc-mobile-header .nav-bar,
html.aidc-mobile-header footer,
html.aidc-mobile-header [data-include*="footer"] {
  display: none !important;
}

/* 2. Full-screen layout — ONLY on narrow screens (mobile TG or phone browsers).
      On desktop TG WebApp just hide chrome, keep normal document flow. */
@media (max-width: 768px) {
  html.tg-webapp,
  html.tg-webapp body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    background: #07060C;
  }

  html.tg-webapp #app {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100dvh;
    min-height: 100vh; /* fallback */
  }

  html.tg-webapp .shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 !important;
  }

  /* 3. fashion-hub — fill remaining height (mobile TG) */
  html.tg-webapp .fashion-hub {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* 4. fashion-hub-body fills available height below nav (mobile TG) */
  html.tg-webapp .fashion-hub-body {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* 5. fashion-work-area scrolls inside (mobile TG) */
  html.tg-webapp .fashion-work-area {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 6. Tab nav safe area */
  html.tg-webapp .fashion-nav {
    padding-top: 6px;
  }

  /* 7. Generate button safe area */
  html.tg-webapp .fh-generate-btn {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
}

/* 8. Mobile header — tg-topbar styles already in tg.css, add spacing */
#tg-header-root:empty { display: none; }
#tg-header-root { flex-shrink: 0; }

/* tg-topbar inherits sticky from tg.css — same behaviour as other TG pages */

/* Desktop TG WebApp — just remove extra padding, keep normal flow */
html.tg-webapp .shell {
  padding: 0 !important;
}

/* Mobile shell — remove extra padding */
html.aidc-mobile-header .shell {
  padding: 0 !important;
}
html.aidc-mobile-header #app {
  padding: 0 !important;
}

/* 9. Keep old class-based selectors as fallback for non-?tg=1 TG sessions */
.fashion-hub--tg ~ footer,
body:has(.fashion-hub--tg) .site-header,
body:has(.fashion-hub--tg) footer,
body:has(.fashion-hub--tg) .header,
body:has(.fashion-hub--tg) [data-include*="header"],
body:has(.fashion-hub--tg) [data-include*="footer"] {
  display: none !important;
}

/* ── Mobile History FAB (floating action button to open history) ── */
.fh-history-fab {
  display: none;
}
@media (max-width: 768px) {
  .fh-history-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 140px;
    right: 16px;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--fh-surface);
    border: 1px solid var(--fh-border);
    color: var(--fh-text-muted);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: all var(--fh-transition);
  }
  .fh-history-fab:hover,
  .fh-history-fab:active {
    background: var(--fh-surface-hover);
    border-color: var(--fh-border-hover);
    color: var(--fh-text);
    transform: scale(1.05);
  }
  .fh-history-fab svg {
    width: 22px;
    height: 22px;
  }
  .fh-history-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--fh-pink);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  /* Telegram — adjust FAB position for safe area */
  .fashion-hub--tg .fh-history-fab {
    bottom: calc(140px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Mobile history close button ── */
.fh-history__close-mobile {
  display: none;
}
@media (max-width: 768px) {
  .fh-history__close-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--fh-surface-hover);
    color: var(--fh-text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
  }
}

/* ── Custom textarea (prompt) ────────────────────────────── */
.fh-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 10px 12px;
  background: var(--fh-bg-card, #1e1e2e);
  color: var(--fh-text, #e4e4e4);
  border: 1px solid var(--fh-border, #333);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
  box-sizing: border-box;
}
.fh-textarea:focus {
  border-color: var(--fh-accent, #8b5cf6);
}
.fh-textarea::placeholder {
  color: var(--fh-text-dim, #888);
  opacity: 1;
}

/* ============================================================
   Lightbox compatibility — suppress competing stacking contexts
   When the lightbox is open, body.aidc-overlay-lock is set by
   overlays.js. Reset z-index and isolation on Fashion Hub
   elements that use backdrop-filter or position:sticky so they
   cannot visually bleed over the lightbox overlay.
   ============================================================ */
body.aidc-overlay-lock .fashion-hub,
body.aidc-overlay-lock .fashion-hub .fh-history,
body.aidc-overlay-lock .fashion-hub .fashion-nav,
body.aidc-overlay-lock .fashion-hub .fh-sidebar,
body.aidc-overlay-lock .fashion-hub .fashion-hub-body,
body.aidc-overlay-lock .fashion-hub .fh-photo-actions {
  z-index: auto !important;
  isolation: auto !important;
  position: static !important;
}
/* Also neutralize backdrop-filter which creates stacking contexts */
body.aidc-overlay-lock .fh-photo-actions {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
body.aidc-overlay-lock .fh-history-item__badge-video {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
