.vto-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.vto-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 3-panel layout: [recommendations | workspace | preview]
   Left column fills the remaining space; the right side (workspace + preview)
   has a fixed footprint so the result image isn't surrounded by whitespace
   and the catalog gets the leftover room to show more products. */
.vto-modal {
  background: #ffffff;
  width: 96vw;
  max-width: 1300px;
  height: 90vh;
  max-height: 720px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 2px solid #000000;
  transform: translateY(20px);
  transition: transform 0.2s ease;
  position: relative; /* anchor for .vto-toast */
}

.vto-overlay.active .vto-modal {
  transform: translateY(0);
}

/* ── Header ── */
.vto-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid #000000;
  background: #000000;
}

.vto-header h2 {
  font-size: 11px;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.vto-close {
  width: 26px;
  height: 26px;
  border: 1px solid #ffffff;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.vto-close:hover {
  background: #ffffff;
  color: #000000;
}

/* ── Left Panel: Recommendations ── */
.vto-left {
  border-right: 2px solid #000000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
}

.vto-section-label {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #111111;
  padding: 14px 14px 4px;
  margin: 0;
}

/* Product search — wireframe style: soft rounded input with subtle border. */
.vto-search-wrap {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.vto-search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  background: #ffffff;
  color: #111111;
  font: inherit;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.vto-search::placeholder {
  color: #9ca3af;
}

.vto-search:focus {
  border-color: #111111;
}

/* Category filter chips — rounded pills, white-on-black when active. */
.vto-tabs {
  display: flex;
  gap: 8px;
  padding: 4px 12px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.vto-tabs::-webkit-scrollbar { display: none; }

.vto-tab {
  height: 32px;
  padding: 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 0;
  background: #ffffff;
  color: #374151;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.vto-tab:hover {
  border-color: #111111;
  color: #111111;
}

.vto-tab.active {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

.vto-tab .count {
  opacity: 0.7;
  font-weight: 500;
  margin-left: 2px;
}

/* Product grid container */
.vto-products {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px;
}

.vto-products-grid {
  display: grid;
  /* Auto-fit: 2-col on a phone (~360px wide panel), 3-col when desktop hands
     us the wider left panel (~580px+). Min 150px per card keeps cards readable. */
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: max-content;
  gap: 12px;
  align-content: start;
}

.vto-no-products {
  padding: 24px 12px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
}

/* Product card — soft 12px corners, hairline border, image up top with badges. */
.vto-product-card {
  border: 1px solid #e5e7eb;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  background: #ffffff;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vto-product-card:hover {
  border-color: #111111;
}

.vto-product-card.selected {
  border: 1.5px solid #111111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06);
}

.vto-product-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.vto-product-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background:
    repeating-linear-gradient(45deg,
      #f3f4f6 0px, #f3f4f6 8px,
      #fafafb 8px, #fafafb 16px);
  border-bottom: 1px solid #f0f1f3;
}

.vto-product-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s;
}

.vto-product-card:hover img {
  transform: scale(1.03);
}

/* Category badge: floats top-left over the product image. */
.vto-product-cat-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #e5e7eb;
  border-radius: 0;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #374151;
  pointer-events: none;
}

/* +/✓ toggle — circle, top-right of image. */
.vto-product-add {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 0;
  background: #ffffff;
  color: #111111;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.vto-product-add:hover {
  transform: scale(1.06);
}

.vto-product-add.selected {
  background: #111111;
  color: #ffffff;
}

.vto-product-info {
  padding: 10px 12px 12px;
  background: #ffffff;
}

.vto-product-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: #111111;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
}

.vto-product-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
}

.vto-product-price {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111111;
  margin: 0;
}

.vto-product-added {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  background: #111111;
  padding: 2px 6px;
  border-radius: 0;
}

/* ── Right Panel: Workspace + Preview ── */
.vto-right {
  display: grid;
  /* Workspace 280 (wider — holds the photo PLUS a vertical recents column
     next to it on desktop). Preview 400 (tighter — image fills the box,
     no horizontal whitespace, buttons sit at the image's width). */
  grid-template-columns: 280px 400px;
  overflow: hidden;
  min-height: 0;
}

.vto-workspace {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-right: 2px solid #000000;
  overflow: hidden;
}

.vto-photo-section {
  padding: 14px;
  border-bottom: 1px solid #ccc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
}

/* Garment section is now just a container for the self-padded outfit sheet
   plus the (mobile-hidden) Add-to-cart button. No internal padding here —
   the sheet header manages its own 16px insets. */
.vto-garment-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

/* Shared style for every section heading inside the modal — "YOUR PHOTO",
   "YOUR OUTFIT · N / 3", and the "RECENT" label all read identically. */
.section-title,
.vto-outfit-sheet-count,
.vto-photo-recents-label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #111111;
  margin: 0;
}
.section-title           { margin: 0 0 8px; }
.vto-photo-recents-label { margin: 16px 0 8px; }

/* User photo upload area (single photo, top half of workspace).
   Black 1px border to match the action buttons / close icon. */
.vto-photo-upload-area {
  flex: 1;
  border: 1px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
  min-height: 60px;
  background: #f5f5f5;
}

.vto-photo-upload-area:hover {
  background: #e8e8e8;
}

.vto-photo-upload-area.has-photo {
  background: #ffffff;
  cursor: default;
  /* Photo is in — hand the border off to the img so it traces the photo
     exactly (no whitespace around it inside a bigger bordered box). */
  border-color: transparent;
}

.vto-photo-upload-area img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border: 1px solid #000000;
}

/* ── Outfit sheet: collapsible tray ───────────────────────────────────────
   Wraps the header bar + body. Lives inside #vto-outfit-list which is
   inside .vto-garment-section. The .vto-sheet-open class on the section
   drives the body open/close. */
.vto-outfit-list {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  flex-shrink: 0;
  transition: box-shadow 0.22s ease;
}

.vto-garment-section.vto-sheet-open .vto-outfit-list {
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.05);
}

/* Header bar — full-width button, click to expand/collapse. */
.vto-outfit-sheet-header {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: inherit;
  text-align: left;
}

.vto-outfit-sheet-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.vto-outfit-sheet-header-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

/* Typography is set via the shared .section-title group above. */

/* "Clear" pill button — same dark-circle family as the × remove on
   mini-cards, but text-shaped because the word matters. */
.vto-outfit-sheet-clear {
  border: none;
  border-radius: 0;
  background: rgba(17, 17, 17, 0.85);
  color: #ffffff;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.vto-outfit-sheet-clear:hover { background: #111111; }

/* Chevron button — same black-circle treatment as the × remove. */
.vto-outfit-sheet-chevron-btn {
  width: 26px;
  height: 26px;
  border-radius: 0;
  background: rgba(17, 17, 17, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.vto-outfit-sheet-header:hover .vto-outfit-sheet-chevron-btn {
  background: #111111;
}

.vto-outfit-sheet-chevron-icon {
  width: 14px;
  height: 14px;
  stroke: #ffffff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* Closed by default → show ^ (tap to expand). Open → V (tap to collapse). */
  transform: rotate(180deg);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.vto-garment-section.vto-sheet-open .vto-outfit-sheet-chevron-icon {
  transform: rotate(0deg);
}

/* Mini stack preview — shows up to 3 thumbs when sheet is collapsed. */
.vto-outfit-mini-stack {
  display: flex;
  align-items: center;
}
.vto-outfit-mini-stack-thumb {
  width: 24px;
  height: 24px;
  border-radius: 0;
  background:
    repeating-linear-gradient(45deg,
      #f3f4f6 0px, #f3f4f6 8px,
      #fafafb 8px, #fafafb 16px);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid #000000;
  flex-shrink: 0;
}
.vto-outfit-mini-stack-thumb + .vto-outfit-mini-stack-thumb {
  margin-left: -8px;
}

/* Collapsible body — animates max-height between 0 and a sensible cap. */
.vto-outfit-sheet-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.vto-garment-section.vto-sheet-open .vto-outfit-sheet-body {
  max-height: 320px;
}

.vto-outfit-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 16px 12px;
}

/* Mini cards inside the tray. */
.vto-outfit-mini {
  border: 1px solid #e5e7eb;
  border-radius: 0;
  background: #ffffff;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  animation: vto-pop-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Items sharing a body region with another picked item — yellow outline
   so the conflict is visible at the card level (the banner below explains
   what the AI may struggle with). */
.vto-outfit-mini--dup {
  border: 2px solid #f5b800;
  box-shadow: 0 0 0 1px #f5b800 inset;
}

@keyframes vto-pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.vto-outfit-mini-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    repeating-linear-gradient(45deg,
      #f3f4f6 0px, #f3f4f6 8px,
      #fafafb 8px, #fafafb 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.vto-outfit-mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vto-outfit-mini-thumb .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: #111111;
  border-radius: 50%;
  animation: vto-spin 0.6s linear infinite;
}

.vto-outfit-mini-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 0;
  background: rgba(17, 17, 17, 0.85);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s;
}
.vto-outfit-mini-remove:hover { background: #111111; }

.vto-outfit-mini-info {
  padding: 6px 8px 8px;
  min-width: 0;
}

.vto-outfit-mini-category {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
  margin: 0 0 2px;
  line-height: 1.2;
}

.vto-outfit-mini-name {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  color: #111111;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vto-outfit-mini-price {
  font-size: 11px;
  font-weight: 700;
  color: #111111;
  margin: 0;
}

/* Empty slot — dashed placeholder. */
.vto-outfit-empty-slot {
  border: 1.5px dashed #d1d5db;
  border-radius: 0;
  background: rgba(243, 244, 246, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  min-height: 96px;
}

.vto-outfit-empty-slot-icon {
  width: 28px;
  height: 28px;
  border-radius: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.vto-outfit-empty-slot-label {
  font-size: 10px;
  font-weight: 500;
  color: #9ca3af;
  letter-spacing: 0.02em;
  margin: 0;
}

/* "Pick up to 3 — or upload your own." shown when outfit is fully empty. */
.vto-outfit-empty-state {
  margin: 4px 16px 12px;
  padding: 14px;
  border: 1.5px dashed #d1d5db;
  border-radius: 0;
  background:
    repeating-linear-gradient(45deg,
      #f3f4f6 0px, #f3f4f6 8px,
      #fafafb 8px, #fafafb 16px);
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  line-height: 1.5;
}

/* ── Desktop overrides for the outfit sheet ────────────────────────────────
   On the wide layout the sheet sits inside a narrow 240px column and there's
   no reason to collapse it. The 3-up mini-card grid also doesn't read well in
   that width — switch to a vertical list (thumb + info side-by-side). */
@media (min-width: 901px) {
  /* Sheet stays open; the chevron disappears and the header isn't a toggle. */
  .vto-outfit-sheet-chevron-btn { display: none; }
  .vto-outfit-sheet-header { cursor: default; }
  .vto-outfit-sheet-body {
    max-height: none !important;
  }
  /* The collapsed-state mini-stack is irrelevant when the sheet is always open. */
  .vto-outfit-mini-stack { display: none; }

  /* Items as a vertical list. */
  .vto-outfit-mini-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 14px 12px;
  }

  /* Each item: 48-wide thumb left, info right, × at the row's top-right. */
  .vto-outfit-mini {
    flex-direction: row;
    align-items: stretch;
    min-height: 64px;
  }
  .vto-outfit-mini-thumb {
    position: static;        /* so .vto-outfit-mini-remove anchors to the row */
    width: 48px;
    height: auto;
    aspect-ratio: 3 / 4;
    flex-shrink: 0;
  }
  .vto-outfit-mini-remove {
    top: 4px;
    right: 4px;
    z-index: 2;
  }
  .vto-outfit-mini-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    padding-right: 28px;     /* room for the × */
  }
  .vto-outfit-mini-name {
    margin: 0;
  }

  /* "Slot N" placeholders only make sense in the 3-up mobile grid. */
  .vto-outfit-empty-slot { display: none; }

  /* Workspace split — FIXED outfit height that fits exactly 3 list-view
     items + header + add-to-cart with no overflow. Photo section takes
     all remaining height. Heights do not change as outfit items are
     added or removed.

     Outfit height math (desktop list view):
       border-top                              1
       sheet header (padding 12+12 + content)  52
       body padding-top                        4
       3 mini cards × 64px + 2 × 6px gap       204
       body padding-bottom                     12
       add-to-cart (padding 12+12 + font + 2px border)  50
       ──                                      323
     So 325px gives a 2px buffer.

     If a warning banner appears (duplicate-region picks), the body's
     overflow-y:auto handles the extra rows by scrolling INSIDE the
     fixed outfit section — the section itself doesn't grow. */
  .vto-workspace {
    grid-template-rows: 1fr 325px;
  }

  .vto-outfit-sheet-body {
    overflow-y: auto;
  }

  /* ── Desktop photo layout: photo + recents side-by-side ─────────────────
     Photo takes the full available height in its natural aspect; the
     RECENT thumbs live in a narrow vertical column to its right. When
     there are no recents yet, the column collapses (single-col grid). */
  .vto-photo-section {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    column-gap: 8px;
    row-gap: 8px;
    align-items: stretch;
  }
  .vto-photo-section:has(.vto-photo-recents.has-recents) {
    grid-template-columns: 1fr 44px;
  }
  .vto-photo-section > .section-title {
    grid-column: 1 / -1;
    margin: 0;
  }
  .vto-photo-section > #vto-photo-upload-area {
    grid-column: 1;
    grid-row: 2;
    flex: none;
    margin: 0;
    /* Photo box centers the image within whatever the row gives us. */
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .vto-photo-section > #vto-photo-recents {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    align-self: stretch;
  }
  /* Vertical thumbs — full column width, 3:4 each, capped per thumb so
     even 5 recents fit without scrolling on a tall workspace. */
  .vto-photo-section > #vto-photo-recents .vto-photo-recent-thumb {
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 60px;
  }
  /* The "RECENT" label gets injected as a sibling BEFORE the strip — but
     that doesn't fit naturally inside our grid layout. Hide it on desktop;
     the column of thumbs reads as self-evident. */
  .vto-photo-section > .vto-photo-recents-label {
    display: none;
  }
  .vto-photo-section > #vto-photo-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 0;
  }
}

/* Add-to-cart button — sticks to the bottom of .vto-garment-section. */
.vto-add-cart {
  margin-top: auto; /* push to bottom of flex column */
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #000000;
  background: #000000;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.vto-add-cart:hover:not(:disabled) {
  background: #d62121;
  border-color: #d62121;
}

.vto-add-cart:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Soft warning when outfit has duplicate body regions (two tops, etc.). */
.vto-outfit-warning {
  padding: 8px 10px;
  background: #fff8d4;
  border-left: 3px solid #d62121;
  color: #000000;
  font-size: 10px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

/* Floating toast for cap warnings, failed fetches, etc. */
.vto-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 16px;
  background: #d62121;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
  animation: vto-toast-in 0.15s ease-out;
}

@keyframes vto-toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.vto-upload-prompt {
  text-align: center;
  color: #888888;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px;
}

.vto-upload-prompt svg {
  width: 20px;
  height: 20px;
  margin-bottom: 4px;
  opacity: 0.4;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.vto-upload-prompt p { margin: 0; line-height: 1.4; }

.vto-photo-change {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px;
  border: none;
  border-top: 1px solid #000000;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: center;
}

/* Action row under the user photo upload area (only visible when no photo). */
.vto-photo-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-shrink: 0;
}
.vto-photo-actions:empty { display: none; }

/* "RECENT" section label above the strip — injected by renderRecentPhotosStrip
   when there's at least one photo. Matches .section-title styling so both
   labels in the same column read as siblings. */
/* Typography is set via the shared .section-title group above. */

/* Recent photos strip (localStorage-backed). Hidden until there's at least one. */
.vto-photo-recents {
  display: none;
  gap: 6px;
  flex-shrink: 0;
}
.vto-photo-recents.has-recents { display: flex; }

.vto-photo-recent-thumb {
  /* Fixed 64px basis so a single recent thumb doesn't blow up to full
     container width on mobile. Shrinks if 5 thumbs + gaps overflow the
     row. Desktop overrides this with width:100% in the @media block. */
  flex: 0 1 64px;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 1px solid #000000;
  background: #f5f5f5;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

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

.vto-photo-recent-thumb.active {
  border: 2px solid #000000;
  box-shadow: 0 0 0 1px #ffffff inset;
}
.vto-photo-recent-thumb.active::after {
  /* Centered black checkmark overlay (matches the wireframe). */
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
  border: 1px solid #000000;
}
.vto-photo-recent-thumb.active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 11px;
  border-right: 2px solid #000000;
  border-bottom: 2px solid #000000;
  /* Move ::before above ::after by giving it higher z-index implicit ordering. */
  transform: translate(-50%, -60%) rotate(45deg);
  z-index: 1;
}

.vto-take-photo-btn,
.vto-upload-new-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid #000000;
  background: #ffffff;
  color: #000000;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}

.vto-take-photo-btn:hover,
.vto-upload-new-btn:hover {
  background: #000000;
  color: #ffffff;
}

/* In-modal crop overlay — appears after upload/capture so the user can
   re-frame to 3:4 before the photo is set as state.userPhoto. */
.vto-crop-overlay {
  position: absolute;
  inset: 0;
  z-index: 55;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.vto-crop-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.vto-crop-stage:active { cursor: grabbing; }

.vto-crop-image {
  position: absolute;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  max-width: none;
  max-height: none;
}

.vto-crop-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  aspect-ratio: 3 / 4;
  height: min(85%, 600px);
  width: auto;
  max-width: 88%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.vto-crop-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  width: 100%;
}

.vto-crop-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.vto-crop-zoom-label {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 420px;
}

.vto-crop-zoom-minus,
.vto-crop-zoom-plus {
  color: rgba(255, 255, 255, 0.85);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  width: 18px;
  text-align: center;
}

.vto-crop-zoom { flex: 1; cursor: pointer; }

.vto-crop-actions {
  display: flex;
  gap: 10px;
}

.vto-crop-cancel,
.vto-crop-confirm {
  padding: 10px 22px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.15s, opacity 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vto-crop-cancel {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}
.vto-crop-cancel:hover { background: rgba(255, 255, 255, 0.08); }

.vto-crop-confirm {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}
.vto-crop-confirm:hover { background: #e0e0e0; }
.vto-crop-confirm:disabled { opacity: 0.6; cursor: wait; }

/* In-modal live camera (selfie) overlay — anchored to .vto-modal. */
.vto-camera-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.vto-camera-video {
  width: 100%;
  max-height: calc(100% - 110px);
  object-fit: contain;
  background: #000;
}

.vto-camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
  width: 100%;
}

.vto-camera-capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #ffffff;
  background: #ffffff;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}
.vto-camera-capture-btn:hover  { transform: scale(1.05); }
.vto-camera-capture-btn:active { transform: scale(0.94); }

.vto-camera-capture-inner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #000000;
  display: block;
}

.vto-camera-secondary-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vto-camera-secondary-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.vto-camera-secondary-btn svg {
  width: 20px;
  height: 20px;
  stroke: #ffffff;
}

.vto-camera-cancel {
  background: rgba(214, 33, 33, 0.2);
  border-color: rgba(214, 33, 33, 0.5);
}
.vto-camera-cancel:hover {
  background: rgba(214, 33, 33, 0.35);
}

@media (max-width: 768px) {
  .vto-take-photo-btn,
  .vto-upload-new-btn { font-size: 11px; padding: 10px 8px; min-height: 44px; }
  .vto-camera-overlay { padding: 12px; }
  .vto-camera-capture-btn { width: 64px; height: 64px; }
  .vto-camera-capture-inner { width: 48px; height: 48px; }
}

/* ── Preview ── */
.vto-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f8f8;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.vto-preview-placeholder {
  text-align: center;
  color: #666666;
  padding: 32px;
}

.vto-preview-placeholder svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
  stroke: #666666;
}

.vto-preview-placeholder p {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vto-preview-placeholder .hint {
  font-size: 11px;
  color: #999999;
  text-transform: none;
  letter-spacing: 0;
}

.vto-result-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;   /* leftover space distributes evenly above/below */
  padding: 16px;
  gap: 14px;
  box-sizing: border-box;
  min-height: 0;
}

/* Image takes its natural aspect — no flex-grow + no object-fit means the
   element's box matches the rendered image exactly, so the border traces
   the photo with no surrounding whitespace inside the bordered area. */
.vto-result-img {
  flex: 0 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border: 1px solid #000000;
}

.vto-result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
}

.vto-result-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: 1px solid #000000;
  background: #ffffff;
  color: #000000;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  min-height: 38px;
  white-space: nowrap;
  min-width: 0;
}

.vto-result-btn:hover {
  background: #000000;
  color: #ffffff;
}

.vto-result-btn.primary {
  background: #000000;
  color: #ffffff;
}

.vto-result-btn.primary:hover {
  background: #333333;
}

.vto-result-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Generate button ── */
.vto-generate-btn {
  padding: 13px 28px;
  border: none;
  background: #000000;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.vto-generate-btn:hover:not(:disabled) {
  background: #d62121;
}

.vto-generate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Loading ── */
.vto-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #666666;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px;
}

.vto-generate-btn .spinner,
.vto-loading .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: vto-spin 0.6s linear infinite;
}

.vto-loading .spinner {
  border-color: #e0e0e0;
  border-top-color: #000000;
}

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

/* ── Trigger button ── */
.vto-trigger-btn {
  font: inherit;
  font-weight: 900;
  width: 100%;
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid #000000;
  background: #ffffff;
  color: #000000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
}

.vto-trigger-btn:hover {
  background: #000000;
  color: #ffffff;
}

/* ── Responsive ── */
/* ── Mobile-only stepper + primary action bar (hidden on desktop) ─────────── */
/* Both elements live in the DOM at all widths but are display:none on
   desktop. data-mobile-tab on .vto-modal drives which panel is visible at
   the mobile breakpoint. Desktop ignores all of this. */
.vto-stepper,
.vto-primary-action { display: none; }

@media (max-width: 900px) {
  /* Mobile layout: flex column instead of the desktop grid. Header + tabs
     pinned at top, the active panel fills the rest. */
  .vto-modal {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: none;
    grid-template-columns: none;
    grid-template-rows: none;
  }

  .vto-header { flex-shrink: 0; }

  /* ── Primary action bar (sits above stepper, mobile-only) ─────────────── */
  .vto-primary-action {
    display: flex;
    gap: 8px;
    padding: 10px 14px 12px;
    background: #ffffff;
    flex-shrink: 0;
  }
  .vto-primary-action:empty { display: none; }

  .vto-pa-btn {
    height: 50px;
    padding: 0 18px;
    border: 1px solid #000000;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
  }
  .vto-pa-btn.is-full { flex: 1 1 auto; min-width: 0; width: 100%; }
  .vto-pa-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  .vto-pa-btn-primary {
    background: #000000;
    color: #ffffff;
  }
  .vto-pa-btn-primary:hover:not(:disabled) {
    background: #d62121;
    border-color: #d62121;
  }

  .vto-pa-btn-ghost {
    background: #ffffff;
    color: #000000;
  }
  .vto-pa-btn-ghost:hover:not(:disabled) {
    background: #000000;
    color: #ffffff;
  }

  .vto-pa-btn-icon {
    width: 50px;
    padding: 0;
    background: #ffffff;
    color: #000000;
    flex-shrink: 0;
  }
  .vto-pa-btn-icon svg { width: 18px; height: 18px; stroke-width: 1.6; }
  .vto-pa-btn-icon:hover:not(:disabled) {
    background: #000000;
    color: #ffffff;
  }

  .vto-pa-btn-content {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .vto-pa-btn-content > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Constrain in-button icons. Without explicit dims an inline SVG can
     balloon to fill the flex line and erase the label entirely. */
  .vto-pa-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    flex-shrink: 0;
  }

  /* ── Bottom stepper (replaces old top tab bar) ────────────────────────── */
  .vto-stepper {
    display: flex;
    flex-shrink: 0;
    background: #ffffff;
    border-top: 2px solid #000000;
    /* Reserve room for iOS home indicator if present */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .vto-stepper-step {
    flex: 1;
    padding: 10px 6px 12px;
    border: none;
    border-right: 1px solid #e5e5e5;
    background: #ffffff;
    color: #999999;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    transition: color 0.12s, opacity 0.12s;
    min-height: 56px;
  }
  .vto-stepper-step:last-child { border-right: none; }

  /* Top-edge active indicator bar */
  .vto-stepper-step::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.12s;
  }
  .vto-stepper-step.active { color: #000000; }
  .vto-stepper-step.active::before { background: #000000; }
  .vto-stepper-step.done { color: #000000; }
  .vto-stepper-step:disabled { cursor: not-allowed; opacity: 0.55; }

  .vto-stepper-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid currentColor;
    background: #ffffff;
    font-size: 10px;
    font-weight: 900;
    color: currentColor;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
  }
  .vto-stepper-step.active .vto-stepper-num {
    background: #d62121;
    border-color: #d62121;
    color: #ffffff;
  }
  .vto-stepper-step.done .vto-stepper-num {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
    /* Drop the number on completed (non-active) steps in favour of a tick */
    font-size: 0;
    position: relative;
  }
  .vto-stepper-step.done .vto-stepper-num::after {
    content: "";
    position: absolute;
    left: 6px; top: 4px;
    width: 6px; height: 10px;
    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: rotate(45deg);
  }

  .vto-stepper-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* Very narrow screens: drop the label, keep just the numbered circle */
  @media (max-width: 360px) {
    .vto-stepper-label { display: none; }
  }

  /* Panel containers stack as flex column. .vto-left and .vto-right share
     the remaining vertical space, hidden/shown via tab visibility rules
     further down. */
  .vto-left,
  .vto-right {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: none;
    overflow: hidden;
  }
  .vto-right {
    grid-template-columns: 1fr;
  }
  .vto-workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-right: none;
    border-bottom: none;
    grid-template-rows: none;
  }
  .vto-photo-section,
  .vto-garment-section {
    flex: 1;
    min-height: 0;
    border-bottom: none;
  }

  /* Aspect-ratio fixes — without these, the photo upload area collapses
     vertically and the result image gets letterboxed weirdly. Width-bound
     so the box fills the section width; aspect-ratio computes the height;
     max-height caps it on tall viewports. */
  .vto-photo-upload-area {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 60vh;
    flex: 0 0 auto;
    margin: 0;
  }
  /* Result on mobile — let the image take its own aspect ratio (no
     object-fit letterbox inside the bordered box). The image scales
     to fit the available area, capped at 100% width and height; any
     leftover space spreads evenly above and below the image + actions
     stack so the layout still reads as uniformly spaced. */
  .vto-result-img {
    flex: 0 1 auto;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }
  .vto-result-wrap {
    height: 100%;
    min-height: 0;
    padding: 16px;
    gap: 16px;
    justify-content: center;
  }
  .vto-preview {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* Tab visibility ── default: hide every panel; per-tab rules show what
     this step needs. .vto-modal[data-mobile-tab] selector wins over the
     panel's own display rules. */
  .vto-modal[data-mobile-tab] .vto-left,
  .vto-modal[data-mobile-tab] .vto-right,
  .vto-modal[data-mobile-tab] .vto-photo-section,
  .vto-modal[data-mobile-tab] .vto-garment-section,
  .vto-modal[data-mobile-tab] .vto-preview {
    display: none;
  }

  /* PHOTO tab on mobile — show photo-section only. The Take Photo / Upload
     Photo buttons now live in the primary action bar (above the stepper),
     so the in-section action row is hidden here to avoid duplication. */
  .vto-modal[data-mobile-tab="photo"] .vto-right { display: flex; }
  .vto-modal[data-mobile-tab="photo"] .vto-photo-section {
    display: flex;
    padding: 14px;
  }
  /* Recents on mobile photo tab: spread to fill width.
     The "RECENT" label (.vto-photo-recents-label) provides the gap above
     via its own margin — no padding-top needed on the strip itself. */
  .vto-modal[data-mobile-tab="photo"] .vto-photo-recents.has-recents {
    gap: 8px;
    padding: 0;
    flex-shrink: 0;
  }
  /* The .vto-photo-recent-thumb base rule already uses flex:1 + aspect-ratio,
     so each thumb fills equal width — no per-tab overrides needed. */
  /* In-section actions hidden — moved to .vto-primary-action above stepper */
  .vto-modal .vto-photo-actions { display: none; }
  /* The old in-preview Generate button — replaced by primary action bar */
  .vto-modal #vto-generate-btn { display: none; }
  /* The old in-section Add-to-cart button — replaced by primary action bar */
  .vto-modal #vto-add-cart { display: none; }

  /* OUTFIT: catalog fills the top; outfit sheet glued to the bottom and
     sizes itself based on whether it's expanded (sheetOpen) or collapsed. */
  .vto-modal[data-mobile-tab="outfit"] .vto-left {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
  }
  .vto-modal[data-mobile-tab="outfit"] .vto-right {
    display: flex;
    flex: 0 0 auto;
    border-top: none;
  }
  .vto-modal[data-mobile-tab="outfit"] .vto-workspace { display: flex; }
  .vto-modal[data-mobile-tab="outfit"] .vto-photo-section { display: none; }
  .vto-modal[data-mobile-tab="outfit"] .vto-garment-section {
    display: flex;
    flex: 0 0 auto;
    border-top: 1px solid #e5e7eb;
  }

  /* RESULT: show .vto-right's preview only */
  .vto-modal[data-mobile-tab="result"] .vto-right { display: flex; }
  .vto-modal[data-mobile-tab="result"] .vto-preview { display: flex; }
  .vto-modal[data-mobile-tab="result"] .vto-workspace { display: none; }
}
