#web-creation{position:fixed;inset:0;z-index:30;background:#fff;color:#344156;font-family:system-ui,sans-serif}
#web-creation[hidden],#web-creation [hidden]{display:none!important}
#web-creation button{cursor:pointer}
#web-creation button:disabled{opacity:.4;cursor:default}
#web-creation :focus-visible{outline:2px solid #8997aa;outline-offset:3px}

/* The hosted camera has one capture action; review appears only after capture. */
#web-creation #web-camera-panel{position:fixed;inset:0;z-index:30;background:#fff;padding:max(12px,env(safe-area-inset-top)) 16px max(20px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px}
#web-creation .web-camera-header{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;gap:8px;min-height:52px}
#web-creation .web-camera-header button{display:grid;place-items:center;width:44px;height:44px;border:0;padding:10px;background:transparent;color:#27334c;border-radius:50%}
#web-creation .web-camera-header svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
#web-creation .web-camera-preview{display:grid;place-items:center;flex:1;min-height:0;width:100%;overflow:hidden}
#web-creation #web-camera-frame{position:relative;max-width:100%;max-height:100%}
#web-creation #web-camera-preview,#web-creation #web-camera-photo{display:block;width:100%;height:100%;object-fit:contain}
#web-creation #web-camera-preview{transform:scaleX(-1)}
#web-creation #web-camera-panel:not([data-frame-ready=true],[data-review=true],[data-shutter=true]) #web-camera-frame{opacity:0}
#web-creation #web-camera-preview[data-facing=environment]{transform:none}
#web-creation #web-camera-countdown{position:absolute;inset:0;display:grid;place-items:center;font:600 88px system-ui;color:#fff;text-shadow:0 2px 16px #27334c;pointer-events:none}
#web-creation .web-camera-actions{flex:none}
#web-creation .web-camera-controls{display:flex;justify-content:center;align-items:center;gap:28px;min-height:76px;flex:none;position:relative}
#web-creation .web-camera-controls button{font:500 16px system-ui;min-height:48px;padding:12px 22px;border:0;border-radius:28px;background:transparent;color:#27334c}
#web-creation #web-use-photo{background:#e8ebef}
#web-creation #web-cancel-timer,#web-creation #web-use-photo,#web-creation #web-retake-photo{display:none}
#web-creation #web-camera-panel[data-review=true] #web-switch-camera{display:none}
#web-creation #web-camera-panel[data-timer=true] #web-cancel-timer,#web-creation #web-camera-panel[data-review=true] #web-use-photo,#web-creation #web-camera-panel[data-review=true] #web-retake-photo{display:block}
#web-creation #web-camera-panel[data-shutter=true] #web-retake-photo{display:block}
#web-creation #web-camera-panel:is([data-review=true],[data-shutter=true]) #web-cancel-timer{display:none}
@media(max-height:440px){#web-creation #web-camera-panel{gap:4px;padding:4px 12px 8px}#web-creation .web-camera-header{min-height:44px}#web-creation .web-camera-controls{min-height:52px}}

/* Phones retain the native, uncropped frame with timer and photo review. */
#web-creation #web-camera-panel[data-camera-mobile=true]{background:#000;color:#fff;padding: max(8px,env(safe-area-inset-top)) 0 max(16px,env(safe-area-inset-bottom));gap:8px}
#web-creation #web-camera-panel[data-camera-mobile=true] .web-camera-header{padding:0 12px}
#web-creation #web-camera-panel[data-camera-mobile=true] .web-camera-header button,#web-creation #web-camera-panel[data-camera-mobile=true] .web-camera-controls button{color:#fff}
#web-creation #web-camera-panel[data-camera-mobile=true] #web-use-photo{background:#fff;color:#111}
#web-creation #web-camera-panel[data-camera-mobile=true][data-camera-ui=snap]{padding:0;display:grid;grid-template-rows:minmax(0,1fr)}
#web-creation #web-camera-panel[data-camera-mobile=true][data-camera-ui=snap] .web-camera-preview{grid-area:1/1;width:100%;height:100%}
#web-creation #web-camera-panel[data-camera-mobile=true][data-camera-ui=snap] .web-camera-header{position:absolute;top:0;left:0;right:0;z-index:3;padding-top:max(12px,env(safe-area-inset-top));background:linear-gradient(#0009,transparent);padding-bottom:24px}
#web-creation #web-camera-panel[data-camera-mobile=true][data-camera-ui=snap] .web-camera-actions{grid-area:1/1;align-self:end;z-index:2;padding:24px 12px max(24px,env(safe-area-inset-bottom));background:linear-gradient(transparent,#0009)}
#web-creation #web-camera-panel[data-camera-mobile=true][data-camera-ui=snap] .web-camera-header button{background:#0004}

#web-creation .web-shutter-flash{position:absolute;inset:0;background:#fff;opacity:0;pointer-events:none}
#web-creation [data-shutter=true] .web-shutter-flash{animation:web-shutter-flash 180ms ease-out both}
@keyframes web-shutter-flash{from{opacity:.78}to{opacity:0}}
#web-creation .web-photo-scan{display:none;position:absolute;left:0;right:0;top:14%;height:2px;box-shadow:0 0 18px 4px #dbefff98;background:#e4f5fff5;pointer-events:none}
#web-creation [data-photo-check=checking] .web-photo-scan{display:block;animation:web-photo-scan 2800ms ease-in-out both}
@keyframes web-photo-scan{from{top:14%;opacity:.75}to{top:87%;opacity:.9}}
#web-creation #web-photo-feedback{margin:0;min-height:2.6em;padding:0 12px;text-align:center;text-wrap:balance;font:400 15px/1.4 system-ui}
#web-creation #web-photo-feedback strong{display:block;font-weight:600}
#web-creation #web-photo-feedback span{display:block;font-size:14px}
#web-creation #web-camera-panel[data-photo-check] .web-camera-controls{min-height:60px;gap:17px}
@media(prefers-reduced-motion:reduce){
  #web-creation [data-shutter=true] .web-shutter-flash,#web-creation [data-photo-check=checking] .web-photo-scan{animation:none}
}

#web-creation #web-failure{position:fixed;inset:0;z-index:25;display:grid;place-items:center;overflow:auto;background:#fff;padding:32px 24px;text-align:center;color:#344156}
#web-creation #web-failure>div{width:100%;max-width:360px}
#web-failure-photo:not([hidden]){display:block;width:auto;height:auto;max-width:100%;max-height:35svh;margin:0 auto 20px;border-radius:16px;object-fit:contain}
#web-creation #web-failure h1{font:500 24px/1.3 system-ui;margin:0 0 16px}
#web-creation #web-failure p{font:400 16px/1.6 system-ui;margin:0 0 24px;overflow-wrap:anywhere}
#web-creation .web-failure-gallery{display:block;color:#596578;margin:20px auto 0;padding:12px;width:fit-content}

#web-creation #web-outfit-outline{position:absolute;inset:0;width:100%;height:100%;opacity:.68;pointer-events:none;filter:drop-shadow(0 1px 2px #0005)}
#web-creation #web-camera-panel[data-review=true] #web-outfit-outline{display:none}
#web-creation #web-camera-panel #web-timer-toggle{display:grid;place-items:center;min-width:140px;min-height:64px;padding:10px 20px;border:1px solid #e1e5eb;border-radius:22px;background:#f7f8fa;color:#344156;font:500 16px/1.3 system-ui;text-decoration:none;box-shadow:0 2px 8px #0000000a}
#web-creation #web-camera-panel:is([data-review=true],[data-timer=true]) #web-timer-toggle{display:none}
#web-creation #web-camera-panel[data-camera-mobile=true] #web-timer-toggle{background:#fffffff2;border-color:#ffffff80}
@media(max-height:440px){#web-creation #web-camera-panel #web-timer-toggle{min-height:48px;border-radius:16px;padding:7px 16px}}
#web-creation .web-recording-dot{display:none;position:absolute;top:14px;right:14px;z-index:2;width:9px;height:9px;border-radius:50%;background:#de4c4c;box-shadow:0 0 0 2px #0003}
#web-creation #web-camera-panel[data-recording=true] .web-recording-dot{display:block}

#web-creation #web-camera-frame:not([style]){width:100%;height:100%}
#web-creation #web-camera-preview,#web-creation #web-camera-photo{max-width:none;max-height:none}
#web-generation{position:fixed;inset:0;background:#fff}
#web-generation #creation{display:block;width:100%;height:100%;object-fit:contain}
#web-generation-status{position:absolute;bottom:max(6svh,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);max-width:calc(100% - 32px);width:max-content;margin:0;padding:12px 20px;border:1px solid #e8ebf0;border-radius:28px;background:#fffffff5;color:#344156;text-align:center;font:450 17px/1.4 system-ui;box-shadow:0 8px 28px #17243a20}
#web-generation-status:empty{display:none}
#web-creation .web-capture-back{position:absolute;top:max(12px,env(safe-area-inset-top));left:16px;display:grid;place-items:center;width:44px;height:44px;padding:10px;border:0;border-radius:50%;background:#fffffff0;color:#27334c}
.web-capture-back svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

#web-feature {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  border: 0;
  background: #fff;
  color: #222;
  overflow: auto;
}
#web-feature[open] { display: flex; flex-direction: column; }
.web-feature-content { width: min(100%, 424px); margin: auto; text-align: left; }
#web-feature-title {
  max-width: 20ch;
  margin: 0;
  font: 650 clamp(27px, 5vw, 34px)/1.1 system-ui;
  letter-spacing: -.035em;
  text-wrap: balance;
}
#web-feature-title:focus { outline: 0; }
#web-feature-intro { margin: 10px 0 0; color: #555; font: 400 15px/1.5 system-ui; text-wrap: pretty; }
.web-feature-preview {
  --media-height: clamp(132px, 24svh, 216px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: 4px;
  margin: 24px 0;
  padding: 16px;
  border: 1px solid #d5d5d5;
  border-radius: 18px;
  background: #f4f5f6;
}
#web-feature-playback {
  display: block;
  width: min(100%, calc(var(--media-height) * var(--camera-aspect, .5625)));
  aspect-ratio: var(--camera-aspect, .5625);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}
#web-feature-clip { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
#web-feature-clip::-webkit-media-controls { display: none !important; }
#web-feature-clip::-webkit-media-controls-start-playback-button { display: none !important; }
#web-feature-character { display: block; width: 100%; height: var(--media-height); object-fit: contain; mix-blend-mode: multiply; }
.web-feature-preview > span { color: #777; font: 400 20px/1 system-ui; }
.web-feature-actions { display: grid; justify-items: center; gap: 2px; }
#web-feature-yes { width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: #222; color: #fff; font: 600 15px system-ui; box-shadow: none; }
#web-feature-no { min-height: 44px; padding: 8px 16px; border: 0; background: none; color: #555; font: 500 14px system-ui; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#web-feature-privacy { display: flex; align-items: flex-start; gap: 8px; margin: 16px 0 0; padding-top: 16px; border-top: 1px solid #d5d5d5; color: #555; font: 400 13px/1.45 system-ui; }
#web-feature-privacy svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
@media (max-height: 600px) {
  #web-feature { padding-block: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-bottom)); }
  .web-feature-preview { margin-block: 16px; padding: 10px; }
  #web-feature-privacy { margin-top: 8px; padding-top: 10px; }
}
@media (min-width: 560px) and (max-height: 480px) {
  .web-feature-content {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
    grid-template-areas: "title preview" "intro preview" "privacy actions";
    column-gap: clamp(20px, 4vw, 40px);
    width: min(100%, 720px);
  }
  #web-feature-title { grid-area: title; align-self: end; font-size: 26px; }
  #web-feature-intro { grid-area: intro; }
  .web-feature-preview { grid-area: preview; margin: 0; }
  .web-feature-actions { grid-area: actions; margin-top: 14px; }
  #web-feature-privacy { grid-area: privacy; align-self: start; margin-top: 18px; }
}

#web-reveal {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  align-content: safe center;
  justify-items: center;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
  background: #fff;
}

#web-reveal:focus {
  outline: none;
}

.web-reveal-stage {
  position: relative;
  width: min(100vw, 1280px, calc((100svh - 100px) * 4 / 3));
  aspect-ratio: 4 / 3;
}

#web-reveal-character {
  position: absolute;
  top: 7.2222%;
  left: calc(50% - var(--web-figure-offset, 0%));
  width: 56.25%;
  height: auto;
  aspect-ratio: 1;
  transform: translateX(-50%);
  pointer-events: none;
}

#web-profile-host {
  position: absolute;
  top: 46%;
  right: 8.8542%;
  width: 29.6875%;
  transform: translateY(-50%);
}

/* The figure moves independently of the form, which fades at its final position. */
#web-reveal[data-phone="true"] {
  top: var(--reveal-viewport-top, 0px);
  bottom: auto;
  height: var(--reveal-viewport-height, 100dvh);
  display: block;
  padding: 0;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scroll-padding-block: 12px;
  --viewport-height: var(--reveal-viewport-height, 100dvh);
  --figure-progress: 0;
  --hero-size: min(calc(88vw / var(--ink-width, 1)), calc(var(--viewport-height) * .68 / var(--ink-height, 1)));
  --form-top: max(16px, env(safe-area-inset-top), var(--viewport-height) * .035);
  --form-bottom: max(12px, env(safe-area-inset-bottom));
  --form-gap: 16px;
  /* Leave room for the closed form. Expanded details and very short screens can scroll. */
  --form-size: min(calc((var(--hero-size) + min(56.25vw, 31svh)) / 2),
    max(64px, calc(var(--viewport-height) - var(--form-top) - var(--form-bottom) - var(--form-gap) - var(--profile-height, 0px))));
  --hero-top: calc(var(--viewport-height) / 2 - var(--hero-size) * var(--ink-centre-y, .5));
  --figure-top: calc(var(--hero-top) * (1 - var(--figure-progress)) + var(--form-top) * var(--figure-progress));
  --figure-size: calc(var(--hero-size) * (1 - var(--figure-progress)) + var(--form-size) * var(--figure-progress));
}

#web-reveal[data-phone="true"] .web-reveal-stage {
  width: 100%;
  min-height: 100%;
  aspect-ratio: auto;
  box-sizing: border-box;
  padding: calc(var(--form-top) + var(--form-size) + var(--form-gap)) 0 var(--form-bottom);
  overflow: clip;
}

#web-reveal[data-phone="true"] #web-reveal-character {
  left: 50%;
  top: var(--figure-top);
  width: var(--figure-size);
  max-width: none;
}

#web-reveal[data-phone="true"] #web-profile-host {
  position: static;
  width: min(calc(100% - 40px), 340px);
  margin: 0 auto;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  #web-reveal[data-phone="true"],
  #web-reveal[data-phone="true"] .web-reveal-stage,
  #web-reveal[data-phone="true"] #web-reveal-character {
    transition-property: none;
  }
}
