/* ==========================================================================
   Virtual Fitting Studio — scoped under .vfs-*  (mobile-first)
   ========================================================================== */
.vfs-root {
  --vfs-bg: #0b0b0c;
  --vfs-bg-2: #141416;
  --vfs-line: rgba(255,255,255,.10);
  --vfs-text: #f3f1ec;
  --vfs-muted: rgba(243,241,236,.62);
  --vfs-champagne: #c8b28a;
  --vfs-ok: #c8b28a;
  --vfs-warn: #d9a46c;
  --vfs-err: #e07a6e;
  --vfs-ease: cubic-bezier(.2,.7,.2,1);
  --vfs-sans: "Helvetica Neue", Helvetica, "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --vfs-serif: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  position: fixed; inset: 0; z-index: 100;
  height: 100vh; height: 100dvh;
  background: var(--vfs-bg); color: var(--vfs-text);
  font-family: var(--vfs-sans); font-size: 14px; line-height: 1.4;
  display: flex; flex-direction: column;
  opacity: 0; transition: opacity .26s var(--vfs-ease);
  overflow: hidden; overscroll-behavior: contain; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.vfs-root.is-in { opacity: 1; }
html.vfs-open, html.vfs-open body { overflow: hidden; }
.vfs-root *, .vfs-root *::before, .vfs-root *::after { box-sizing: border-box; }
.vfs-root :where(button) { font: inherit; color: inherit; cursor: pointer; }
.vfs-root button:disabled { cursor: default; opacity: .45; }
.vfs-root :focus-visible { outline: 2px solid var(--vfs-champagne); outline-offset: 3px; }
.vfs-root [hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.vfs-header {
  position: absolute; z-index: 6; top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: calc(10px + var(--sat)) calc(10px + var(--sar)) 22px calc(16px + var(--sal));
  background: linear-gradient(180deg, rgba(0,0,0,.62), rgba(0,0,0,0));
  pointer-events: none;
}
.vfs-header > * { pointer-events: auto; }
.vfs-kicker { margin: 0; font-size: 10px; font-weight: 500; letter-spacing: .28em; text-transform: uppercase; color: var(--vfs-champagne); }
.vfs-product { margin: 3px 0 0; display: flex; gap: 10px; font-size: 13px; color: var(--vfs-text); min-width: 0; }
.vfs-product__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vfs-product__price { color: var(--vfs-muted); }
.vfs-status {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border: 1px solid var(--vfs-line); border-radius: 999px; background: rgba(12,12,13,.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--vfs-muted); white-space: nowrap;
}
.vfs-status__dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.5); }
.vfs-status[data-tone="ok"] { color: var(--vfs-text); }
.vfs-status[data-tone="ok"] .vfs-status__dot { background: var(--vfs-ok); box-shadow: 0 0 0 3px rgba(200,178,138,.18); }
.vfs-status[data-tone="warn"] .vfs-status__dot { background: var(--vfs-warn); }
.vfs-status[data-tone="err"] { color: #f2c9c3; }
.vfs-status[data-tone="err"] .vfs-status__dot { background: var(--vfs-err); }
.vfs-root[data-status="init-camera"] .vfs-status__dot,
.vfs-root[data-status="loading-model"] .vfs-status__dot,
.vfs-root[data-status="detecting"] .vfs-status__dot { animation: vfs-pulse 1.4s ease-in-out infinite; }
.vfs-icon {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--vfs-line); background: rgba(12,12,13,.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background .2s;
}
.vfs-icon:hover { background: rgba(40,40,42,.8); }
@media (max-width: 420px) { .vfs-status { padding: 0 10px; letter-spacing: .12em; } .vfs-product__price { display: none; } .vfs-kicker { letter-spacing: .16em; } }
.vfs-brand { min-width: 0; }
.vfs-header .vfs-kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- layout */
.vfs-main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vfs-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #050506; }
.vfs-video, .vfs-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.vfs-video { object-fit: cover; }
.vfs-root.is-mirrored .vfs-video { transform: scaleX(-1); }
.vfs-overlay { pointer-events: none; }

/* fitting frame — four quiet corners */
.vfs-frame { position: absolute; left: 14%; right: 14%; top: 16%; bottom: 30%; pointer-events: none; opacity: .55; transition: opacity .4s var(--vfs-ease); }
.vfs-frame i { position: absolute; width: 22px; height: 22px; border-color: rgba(255,255,255,.7); border-style: solid; border-width: 0; }
.vfs-frame i:nth-child(1) { left: 0; top: 0; border-left-width: 1px; border-top-width: 1px; }
.vfs-frame i:nth-child(2) { right: 0; top: 0; border-right-width: 1px; border-top-width: 1px; }
.vfs-frame i:nth-child(3) { left: 0; bottom: 0; border-left-width: 1px; border-bottom-width: 1px; }
.vfs-frame i:nth-child(4) { right: 0; bottom: 0; border-right-width: 1px; border-bottom-width: 1px; }
.vfs-root[data-status="tracked"] .vfs-frame { opacity: 0; }
.vfs-root[data-status="error"] .vfs-frame, .vfs-root[data-status="paused"] .vfs-frame { display: none; }

.vfs-guidance {
  position: absolute; left: 50%; top: calc(84px + var(--sat)); transform: translate(-50%, -6px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px;
  background: rgba(12,12,13,.62); border: 1px solid var(--vfs-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 13px; letter-spacing: .02em; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .35s var(--vfs-ease), transform .35s var(--vfs-ease);
}
.vfs-guidance[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
.vfs-guidance[data-tone="ok"] { color: var(--vfs-champagne); }
.vfs-notice {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 10px 14px; background: rgba(12,12,13,.78); border: 1px solid rgba(200,178,138,.35); color: var(--vfs-text);
  font-size: 12.5px; text-align: center;
}

.vfs-loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(11,11,12,.55), rgba(11,11,12,.92));
}
.vfs-loading__bar { width: 120px; height: 1px; background: rgba(255,255,255,.14); overflow: hidden; position: relative; }
.vfs-loading__bar span { position: absolute; inset: 0; width: 40%; background: var(--vfs-champagne); animation: vfs-bar 1.4s var(--vfs-ease) infinite; }
.vfs-loading__txt { margin: 0; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; }
.vfs-loading__sub { margin: 0; color: var(--vfs-muted); font-size: 12px; max-width: 32ch; }

.vfs-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100% - 32px));
  padding: 28px 24px; background: rgba(18,18,20,.94); border: 1px solid var(--vfs-line); text-align: center;
}
.vfs-card__kicker { margin: 0 0 10px; font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--vfs-champagne); }
.vfs-card__title { margin: 0 0 10px; font-family: var(--vfs-serif); font-weight: 400; font-size: 24px; }
.vfs-card__msg { margin: 0 0 22px; color: var(--vfs-muted); font-size: 14px; }
.vfs-card__actions { display: grid; gap: 10px; }
.vfs-error { max-height: calc(100% - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.28) transparent; }
.vfs-error::-webkit-scrollbar { width: 6px; }
.vfs-error::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); }
.vfs-error:has(.vfs-card__steps:not([hidden])) { width: min(460px, calc(100% - 24px)); padding: 22px 22px; }
.vfs-error:has(.vfs-card__steps:not([hidden])) .vfs-card__title { font-size: 21px; }
.vfs-error .vfs-card__msg { margin-bottom: 16px; }
.vfs-card__steps {
  margin: 0 0 16px; padding: 14px 16px 14px 34px; text-align: left; font-size: 13px; line-height: 1.5;
  color: var(--vfs-text, #f2f0ec); background: rgba(255,255,255,.04); border: 1px solid var(--vfs-line);
}
.vfs-card__steps li + li { margin-top: 6px; }
.vfs-card__steps li::marker { color: var(--vfs-champagne); }
.vfs-card__note { margin: 0 0 20px; font-size: 12px; line-height: 1.5; color: var(--vfs-champagne); }
.vfs-newtab { text-decoration: none; }
@media (max-width: 420px) { .vfs-card { padding: 22px 18px; } .vfs-card__title { font-size: 21px; } }

.vfs-switch { position: absolute; right: calc(12px + var(--sar)); bottom: 14px; z-index: 3; }
.vfs-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.vfs-flash.is-on { animation: vfs-flash .45s ease-out; }

/* ------------------------------------------------------------- buttons */
.vfs-btn {
  min-height: 48px; padding: 0 22px; border-radius: 0; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; white-space: nowrap;
  transition: background .2s var(--vfs-ease), color .2s var(--vfs-ease), border-color .2s var(--vfs-ease);
}
.vfs-btn--light { background: var(--vfs-text); color: #0b0b0c; }
.vfs-btn--light:hover { background: #fff; }
.vfs-btn--light.is-done { background: var(--vfs-champagne); color: #0b0b0c; }
.vfs-btn--ghost { background: transparent; border-color: rgba(255,255,255,.28); color: var(--vfs-text); }
.vfs-btn--ghost:hover { border-color: var(--vfs-text); }
.vfs-linkbtn { border: 0; background: none; padding: 8px 4px; font-size: 12px; letter-spacing: .08em; color: var(--vfs-text); text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------- panel
   Mobile: compact bottom sheet under the camera, thumb-reachable. */
.vfs-panel {
  position: relative; z-index: 5; flex: none;
  padding: 12px calc(14px + var(--sar)) calc(10px + var(--sab)) calc(14px + var(--sal));
  background: var(--vfs-bg); border-top: 1px solid var(--vfs-line);
  display: grid; gap: 10px;
}
.vfs-panel__info { display: none; }
.vfs-group { display: grid; gap: 8px; min-width: 0; }
.vfs-group.is-attn { animation: vfs-nudge .5s var(--vfs-ease); }
.vfs-label { margin: 0; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--vfs-muted); display: flex; gap: 10px; }
.vfs-label__val { color: var(--vfs-text); letter-spacing: .14em; }
.vfs-label__val.is-warn { color: var(--vfs-warn); }
.vfs-swatches, .vfs-sizes { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; margin: -4px -2px; }
.vfs-swatches::-webkit-scrollbar, .vfs-sizes::-webkit-scrollbar { display: none; }
.vfs-swatch { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid transparent; background: none; display: grid; place-items: center; position: relative; transition: border-color .25s var(--vfs-ease); }
.vfs-swatch__chip { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), inset 0 -6px 10px rgba(0,0,0,.18); transition: transform .25s var(--vfs-ease); }
.vfs-swatch[aria-checked="true"] { border-color: var(--vfs-champagne); }
.vfs-swatch[aria-checked="true"] .vfs-swatch__chip { transform: scale(.86); }
.vfs-swatch[data-noasset="true"]::after { content: ""; position: absolute; width: 30px; height: 1px; background: rgba(255,255,255,.75); transform: rotate(-45deg); }
.vfs-size { flex: none; min-width: 48px; height: 40px; padding: 0 12px; border: 1px solid rgba(255,255,255,.18); background: transparent; font-size: 12px; letter-spacing: .08em; transition: all .2s var(--vfs-ease); }
.vfs-size[aria-checked="true"] { background: var(--vfs-text); color: #0b0b0c; border-color: var(--vfs-text); }
.vfs-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-top: 2px; }
.vfs-switch-m { justify-self: start; }
.vfs-add { justify-self: end; padding: 0 16px; }
.vfs-shutter {
  grid-column: 2; width: 70px; height: 70px; border-radius: 50%; padding: 0; border: 2px solid rgba(255,255,255,.9);
  background: transparent; display: grid; place-items: center; transition: transform .15s var(--vfs-ease);
}
.vfs-shutter span { width: 54px; height: 54px; border-radius: 50%; background: var(--vfs-text); transition: transform .15s var(--vfs-ease), background .2s; }
.vfs-shutter:active span { transform: scale(.9); }
.vfs-shutter:hover span { background: #fff; }
.vfs-privacy { margin: 0; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--vfs-muted); font-size: 11px; text-align: center; }
.vfs-privacy svg { flex: none; opacity: .8; }
.vfs-added {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px;
  background: var(--vfs-bg-2); border: 1px solid rgba(200,178,138,.35); font-size: 12.5px;
}
/* the stage-level switch is desktop-only; mobile uses the one in the action row */
.vfs-switch { display: none; }

@media (max-width: 899px) {
  .vfs-switch-m:not([hidden]) { display: inline-grid; }
  /* error state: give the explanation the whole screen below the floating header */
  .vfs-root[data-status="error"] .vfs-panel { display: none; }
  .vfs-root .vfs-error.vfs-card {
    top: calc(62px + var(--sat)); bottom: calc(12px + var(--sab)); transform: translateX(-50%);
    height: fit-content; max-height: calc(100% - 74px - var(--sat) - var(--sab)); margin: auto 0;
    padding: 22px 20px; overflow-x: hidden;
  }
  .vfs-error .vfs-card__actions { position: sticky; bottom: -22px; margin: 0 -20px -22px; padding: 12px 20px 18px; background: linear-gradient(180deg, rgba(18,18,20,0), rgba(18,18,20,.97) 22%); }
  .vfs-panel { gap: 9px; }
  @media (max-height: 700px) { .vfs-privacy { display: none; } .vfs-shutter { width: 62px; height: 62px; } .vfs-shutter span { width: 48px; height: 48px; } }
}

/* ------------------------------------------------------- desktop layout */
@media (min-width: 900px) {
  .vfs-header { position: relative; background: var(--vfs-bg); border-bottom: 1px solid var(--vfs-line); padding: 14px 18px 14px 24px; }
  .vfs-main { flex-direction: row; }
  .vfs-stage { margin: 18px 0 18px 18px; border: 1px solid var(--vfs-line); }
  .vfs-guidance { top: 18px; }
  .vfs-switch:not([hidden]) { display: inline-grid; }
  .vfs-switch-m { display: none !important; }
  .vfs-panel { width: 380px; border-top: 0; padding: 28px 28px 24px; align-content: start; gap: 22px; overflow-y: auto; }
  .vfs-panel__info { display: block; padding-bottom: 18px; border-bottom: 1px solid var(--vfs-line); }
  .vfs-panel__cat { margin: 0 0 8px; font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--vfs-muted); }
  .vfs-panel__name { margin: 0 0 6px; font-family: var(--vfs-serif); font-weight: 400; font-size: 28px; line-height: 1.1; }
  .vfs-panel__price { margin: 0 0 14px; font-size: 15px; }
  .vfs-panel__tag { margin: 0; font-size: 10px; letter-spacing: .26em; text-transform: uppercase; color: var(--vfs-champagne); }
  .vfs-swatches, .vfs-sizes { flex-wrap: wrap; overflow: visible; }
  .vfs-actions { grid-template-columns: auto 1fr; gap: 16px; }
  .vfs-shutter { grid-column: 1; }
  .vfs-add { justify-self: stretch; }
  .vfs-privacy { justify-content: flex-start; text-align: left; }
}

/* --------------------------------------------------------------- review */
.vfs-review { position: absolute; inset: 0; z-index: 20; background: #080809; display: flex; flex-direction: column; animation: vfs-fade .3s var(--vfs-ease); }
.vfs-review__media { flex: 1; min-height: 0; display: grid; place-items: center; padding: calc(16px + var(--sat)) 16px 8px; }
.vfs-review__img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 30px 80px rgba(0,0,0,.6); border: 1px solid var(--vfs-line); }
.vfs-review__bar { padding: 12px calc(16px + var(--sar)) calc(14px + var(--sab)) calc(16px + var(--sal)); display: grid; gap: 12px; }
.vfs-review__meta { text-align: center; }
.vfs-review__name { margin: 4px 0 0; font-size: 14px; }
.vfs-review__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vfs-review__actions .vfs-add2 { grid-column: 1 / -1; order: -1; }
.vfs-review__actions .vfs-continue { grid-column: 1 / -1; }
.vfs-review__actions .vfs-btn { padding: 0 12px; }
@media (min-width: 900px) {
  .vfs-review { flex-direction: row; }
  .vfs-review__media { padding: 32px; }
  .vfs-review__bar { width: 380px; align-content: center; padding: 32px; border-left: 1px solid var(--vfs-line); }
  .vfs-review__meta { text-align: left; }
  .vfs-review__name { font-family: var(--vfs-serif); font-size: 24px; }
  .vfs-review__actions { grid-template-columns: 1fr; }
  .vfs-review__actions .vfs-add2 { order: 0; }
}

.vfs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes vfs-pulse { 50% { opacity: .3; } }
@keyframes vfs-bar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@keyframes vfs-flash { from { opacity: .8; } to { opacity: 0; } }
@keyframes vfs-fade { from { opacity: 0; } }
@keyframes vfs-nudge { 30% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  .vfs-root, .vfs-root * { animation: none !important; transition: none !important; }
}
