/*
 * Sizes come from the 1090px-wide wireframes. --u is 1% of the column width, so
 * 10.9 wireframe pixels are 1u on every phone. Text and touch targets have a
 * pixel floor, because the wireframe's smallest sizes are too small to tap.
 */

:root {
  color-scheme: light;

  --ink: #49378f;
  --purple: #7058bf;
  --violet: #8969d6;
  --tint: #eee8fc;
  --line: #8c71cb;
  --white: #fff;
  --pink: #ec6cab; /* Result poster headlines */

  --u: 1cqw;
  --touch: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: #d9d8fb;
  color: var(--ink);
  font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p { margin: 0; }
img { display: block; }
button, input { font: inherit; color: inherit; }
button { border: 0; padding: 0; background: none; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}
h2:focus { outline: none; }

/* The gradient stays put while long pages scroll over it. */
.backdrop {
  position: fixed;
  inset: -8%;
  z-index: -1;
  background: url("assets/background.jpg") center / 100% 100% no-repeat;
  animation: drift 24s ease-in-out infinite alternate;
}

/* With WebGL, js/background.js bends the same image in a canvas instead. */
.backdrop canvas { display: block; width: 100%; height: 100%; }
.backdrop.is-moving { inset: 0; background: none; animation: none; }

@keyframes drift {
  from { transform: translate(-2.5%, -1.5%) scale(1.03); }
  to { transform: translate(2.5%, 2%) scale(1.1); }
}

main {
  width: min(100%, 430px);
  margin: 0 auto;
  container-type: inline-size;
}

.screen { animation: enter 260ms cubic-bezier(0.2, 0.7, 0.3, 1); }

@keyframes enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Shared pieces ---------- */

.wordmark { width: calc(35.2 * var(--u)); height: auto; margin: 0 auto; }

.brand { text-align: center; }
.brand .wordmark { width: calc(27.5 * var(--u)); }
.brand p { margin-top: calc(0.8 * var(--u)); font-size: calc(4.7 * var(--u)); font-weight: 500; }

.button {
  display: inline-block;
  min-width: calc(28.4 * var(--u));
  min-height: max(var(--touch), calc(7.7 * var(--u)));
  padding: 0 calc(6 * var(--u));
  border-radius: 99px;
  background: var(--purple);
  color: var(--white);
  font-size: max(15px, calc(3.6 * var(--u)));
  font-weight: 500;
  transition: scale 140ms ease-out;
}

.button-wide { width: 100%; }

.button-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 0 calc(4.4 * var(--u));
  border: 1.6px solid var(--purple);
  border-radius: 99px;
  background: rgb(255 255 255 / 0.55);
  color: var(--purple);
  font-size: max(14px, calc(3 * var(--u)));
  font-weight: 500;
}

.button-outline svg { width: 20px; height: 20px; }

.link {
  min-height: var(--touch);
  color: var(--purple);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.back {
  display: grid;
  place-items: center;
  width: max(var(--touch), calc(8 * var(--u)));
  aspect-ratio: 1;
  border: 1.6px solid var(--purple);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.6);
  color: var(--purple);
}

.back svg { width: 55%; margin-right: 6%; }

.panel {
  border-radius: calc(2.8 * var(--u));
  background: var(--white);
}

@media (prefers-reduced-motion: no-preference) {
  .button:enabled:active, .card:active, .shutter:enabled:active { scale: 0.97; }
}

/* ---------- Page 1: start ---------- */

.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(8 * var(--u)) 0;
  text-align: center;
}

.intro .wordmark { width: calc(28.4 * var(--u)); }
.intro h1 img { width: calc(79.5 * var(--u)); height: auto; margin: calc(5.6 * var(--u)) auto calc(2.2 * var(--u)); }

.intro-band {
  width: calc(77 * var(--u));
  padding: calc(1.7 * var(--u)) 0;
  background: linear-gradient(90deg, transparent, #fff 20% 80%, transparent);
  color: var(--purple);
  font-size: calc(3.5 * var(--u));
  font-weight: 500;
}

.intro-band + p { margin: calc(2.4 * var(--u)) 0 calc(9.4 * var(--u)); font-size: calc(3.6 * var(--u)); }

/* ---------- Page 2: contact form ---------- */

.lead { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.hero { width: 100%; height: auto; }

.sheet {
  flex: 1;
  margin-top: calc(-6.9 * var(--u));
  padding: calc(8.2 * var(--u)) calc(7.4 * var(--u)) calc(10 * var(--u));
  border-radius: calc(7.4 * var(--u)) calc(7.4 * var(--u)) 0 0;
  background: var(--white);
}

.sheet .brand { margin-bottom: calc(6.4 * var(--u)); }

.field {
  display: block;
  margin-bottom: calc(3 * var(--u));
  text-indent: calc(4.4 * var(--u));
  font-size: max(15px, calc(3.6 * var(--u)));
}

.field input {
  display: block;
  width: 100%;
  min-height: max(var(--touch), calc(7.8 * var(--u)));
  margin-top: calc(1.2 * var(--u));
  padding: 0 calc(4.4 * var(--u));
  border: 1.6px solid transparent;
  border-radius: 99px;
  background: #ebe5fe;
  font-size: max(16px, calc(3.6 * var(--u))); /* Below 16px iOS zooms into the field. */
}

.field input:focus { outline: none; border-color: var(--purple); }
.field input:user-invalid { border-color: #c2416b; }

.check {
  display: flex;
  gap: 10px;
  margin: calc(1 * var(--u)) calc(4.4 * var(--u)) calc(3.6 * var(--u));
  font-size: max(13px, calc(3.1 * var(--u)));
  line-height: 1.25;
}

.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--purple); }

.lead-notice { margin: 0 calc(4.4 * var(--u)) calc(3.6 * var(--u)); color: var(--purple); font-size: 12px; line-height: 1.35; }

/* ---------- Pages 3-6: quiz ---------- */

.quiz { padding: calc(11 * var(--u)) calc(4.2 * var(--u)) calc(8 * var(--u)); }

.step { margin-top: calc(5 * var(--u)); color: var(--violet); font-size: max(13px, calc(3.2 * var(--u))); }

.quiz progress {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: calc(1.2 * var(--u));
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: rgb(255 255 255 / 0.8);
  -webkit-appearance: none;
  appearance: none;
}

.quiz progress::-webkit-progress-bar { background: rgb(255 255 255 / 0.8); }
.quiz progress::-webkit-progress-value { border-radius: 99px; background: var(--violet); }
.quiz progress::-moz-progress-bar { border-radius: 99px; background: var(--violet); }

.quiz h2 {
  min-height: 2.5em;
  margin: calc(4.4 * var(--u)) 0 calc(3.4 * var(--u));
  font-size: calc(4.5 * var(--u));
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: calc(2.6 * var(--u)); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: calc(1.2 * var(--u));
  border: calc(0.45 * var(--u)) solid transparent;
  border-radius: calc(3.2 * var(--u));
  background: var(--white);
  background-clip: border-box;
}

.card img { width: 100%; height: auto; aspect-ratio: 457 / 360; border-radius: calc(1.8 * var(--u)); object-fit: cover; }

.card-label {
  display: grid;
  flex: 1;
  align-content: center;
  justify-items: center;
  min-height: calc(8.6 * var(--u));
  padding: calc(1.2 * var(--u)) 0;
  font-size: max(13px, calc(3.2 * var(--u)));
  line-height: 1.2;
}

.card-label small { max-width: calc(38 * var(--u)); margin-top: 2px; font-size: max(11px, calc(2.35 * var(--u))); text-wrap: balance; }

.card[aria-pressed="true"] { border-color: var(--violet); background: var(--tint); }

.card[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: calc(0.4 * var(--u));
  right: calc(0.4 * var(--u));
  width: calc(6.6 * var(--u));
  aspect-ratio: 1;
  border: calc(0.4 * var(--u)) solid var(--white);
  border-radius: 50%;
  background: var(--violet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6.5 12.5 4 4 7.5-8.5' fill='none' stroke='%23fff' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 88% no-repeat;
}

.quiz-nav { display: flex; align-items: center; justify-content: space-between; margin-top: calc(4.6 * var(--u)); }

/* ---------- Page 7: scan ---------- */

.scan { padding: calc(7 * var(--u)) calc(7.3 * var(--u)) calc(5 * var(--u)); text-align: center; }
.scan .brand { margin-bottom: calc(3 * var(--u)); }

.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 930 / 1210;
  border: calc(0.5 * var(--u)) solid var(--white);
  border-radius: calc(4.4 * var(--u));
  overflow: hidden;
  background: #cfc6d6;
}

.viewfinder video,
.viewfinder canvas,
.guide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.viewfinder video,
.viewfinder canvas { transform: scaleX(-1); }

.guide path { fill: none; stroke: #fff; stroke-width: 6; transition: stroke 200ms; }
.viewfinder[data-ready="true"] .guide path { stroke: #7be0b0; }

.scan-pill {
  position: absolute;
  top: 3.2%;
  left: 50%;
  translate: -50% 0;
  padding: calc(0.8 * var(--u)) calc(3.6 * var(--u));
  border: 1.6px solid var(--purple);
  border-radius: 99px;
  background: rgb(255 255 255 / 0.72);
  color: var(--purple);
  font-size: max(13px, calc(2.8 * var(--u)));
  font-weight: 500;
  white-space: nowrap;
}

.viewfinder[data-view="problem"] .scan-pill { display: none; }

.scan-line { display: none; }

.viewfinder[data-view="analyzing"] .guide { opacity: 0; }
.viewfinder[data-view="analyzing"] .scan-line {
  display: block;
  position: absolute;
  inset: 0 0 auto;
  height: 22%;
  background: linear-gradient(to bottom, transparent, rgb(166 140 240 / 0.6));
  border-bottom: 2px solid #fff;
  animation: sweep 1.9s ease-in-out infinite alternate;
}

@keyframes sweep {
  from { transform: translateY(-100%); }
  to { transform: translateY(450%); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: calc(7 * var(--u));
  overflow-y: auto;
  background: rgb(250 248 255 / 0.96);
  text-align: left;
  font-size: 15px;
}

.overlay h2 { font-size: 22px; font-weight: 600; }
.overlay .button { margin-top: 6px; }
.overlay .link { align-self: center; }

.scan-controls { position: relative; display: flex; justify-content: center; align-items: center; margin: calc(4.4 * var(--u)) 0 calc(3 * var(--u)); }
.scan-controls .button-outline { position: absolute; left: 0; }

.shutter {
  display: grid;
  place-items: center;
  width: calc(14.3 * var(--u));
  aspect-ratio: 1;
  padding: calc(0.5 * var(--u));
  border: calc(0.45 * var(--u)) solid var(--white);
  border-radius: 50%;
  background: var(--white) content-box;
  color: var(--purple);
}

.shutter svg { width: calc(5.9 * var(--u)); }
.scan-hint { color: var(--purple); font-size: max(13px, calc(2.8 * var(--u))); }

/* ---------- Page 8: results ---------- */

.results { padding: calc(9 * var(--u)) calc(5 * var(--u)) calc(14 * var(--u)); }

.results h1 { margin-top: calc(8 * var(--u)); font-size: calc(5.6 * var(--u)); font-weight: 600; line-height: 1.16; }
.results h1 small { display: block; font-size: calc(4.8 * var(--u)); font-weight: 600; }
.tagline { margin-top: calc(1 * var(--u)); font-size: max(14px, calc(3.4 * var(--u))); }

.result-note { margin-top: calc(3 * var(--u)); padding: 10px 14px; border-radius: 12px; background: rgb(255 255 255 / 0.6); font-size: 13px; }
.result-note .link { min-height: 0; font-size: 13px; }

.palette { margin: calc(5 * var(--u)) 0 calc(7 * var(--u)); padding: calc(5.4 * var(--u)) calc(3.2 * var(--u)) calc(3.2 * var(--u)); font-size: max(14px, calc(3.4 * var(--u))); }
.palette-grid { display: grid; grid-template-columns: repeat(8, 1fr); margin-bottom: calc(2 * var(--u)); border: 1px solid #ddd; }
.palette-grid i { aspect-ratio: 1; }

.results h2 { margin: calc(6 * var(--u)) 0 calc(2.2 * var(--u)); font-size: calc(4.8 * var(--u)); font-weight: 600; }

.product,
.try-product {
  display: grid;
  grid-template-columns: 26% minmax(0, 1fr);
  column-gap: calc(1.6 * var(--u));
  align-items: center;
}

/* Same layout as the try-on panel: pack on the left, name and shade balls on the right. */
.product { align-items: start; padding: calc(4.2 * var(--u)) calc(3 * var(--u)) calc(4 * var(--u)) calc(2 * var(--u)); }
.product + .product { margin-top: calc(2.6 * var(--u)); }
.product .pack { align-self: center; }
.product .ball-grid { height: auto; overflow: visible; margin-bottom: 0; }
.pack { grid-row: 1 / span 2; justify-self: center; max-width: 92%; max-height: calc(39 * var(--u)); object-fit: contain; }
.product-info h3 { font-size: max(12px, calc(2.9 * var(--u))); font-weight: 600; line-height: 1.2; }
.product-info p { margin-top: calc(1 * var(--u)); color: var(--purple); font-size: max(11px, calc(2.45 * var(--u))); }

.best {
  position: absolute;
  top: calc(1.6 * var(--u));
  left: calc(1.6 * var(--u));
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--purple);
  color: var(--white);
  font-size: 10px;
  font-weight: 600;
}

.try-button { grid-column: 1 / -1; justify-self: center; width: calc(38 * var(--u)); margin-top: calc(4 * var(--u)); padding: 0; }

/* Voucher: a ticket with a tear-off stub, above the store logos. */
.voucher {
  --stub: 29%;
  --notch: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--stub);
  margin-top: calc(13 * var(--u));
  border-radius: calc(2.8 * var(--u));
  background: var(--white);
  -webkit-mask:
    radial-gradient(circle at calc(100% - var(--stub)) 0, #0000 var(--notch), #000 calc(var(--notch) + 0.5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at calc(100% - var(--stub)) 100%, #0000 var(--notch), #000 calc(var(--notch) + 0.5px)) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle at calc(100% - var(--stub)) 0, #0000 var(--notch), #000 calc(var(--notch) + 0.5px)) top / 100% 51% no-repeat,
    radial-gradient(circle at calc(100% - var(--stub)) 100%, #0000 var(--notch), #000 calc(var(--notch) + 0.5px)) bottom / 100% 51% no-repeat;
}

.voucher-main { min-width: 0; padding: calc(4.6 * var(--u)) calc(3.6 * var(--u)) calc(4.4 * var(--u)) calc(5 * var(--u)); }
.voucher-kicker { color: var(--pink); font-size: max(11px, calc(2.4 * var(--u))); font-weight: 700; letter-spacing: 0.14em; }
.voucher-title { margin-top: calc(0.8 * var(--u)); font-size: max(14px, calc(3.4 * var(--u))); font-weight: 600; }

.voucher-code {
  display: inline-block;
  max-width: 100%;
  margin-top: calc(2.6 * var(--u));
  padding: calc(1.2 * var(--u)) calc(2.4 * var(--u));
  overflow-wrap: anywhere; /* Only for codes longer than about 12 characters. */
  border: 1.6px dashed var(--pink);
  border-radius: calc(1.6 * var(--u));
  background: #fff4f9;
  color: var(--pink);
  font-family: Unbounded, "Hanken Grotesk", sans-serif;
  font-size: max(15px, calc(3.8 * var(--u)));
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.voucher-note { margin-top: calc(2.2 * var(--u)); color: var(--purple); font-size: max(11px, calc(2.45 * var(--u))); line-height: 1.35; }

.voucher-copy {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: calc(1.6 * var(--u));
  border-left: 2px dashed rgb(112 88 191 / 0.35);
  background: linear-gradient(160deg, var(--tint), #fde6f1);
  color: var(--purple);
  font-size: max(12px, calc(2.6 * var(--u)));
  font-weight: 600;
}

.voucher-copy .icon { display: grid; place-items: center; width: max(40px, calc(9 * var(--u))); aspect-ratio: 1; border-radius: 50%; background: var(--purple); color: var(--white); }
.voucher-copy svg { width: 48%; }

.results .shops-title { margin-top: calc(13 * var(--u)); text-align: center; }
.voucher + .shops-title { margin-top: calc(9 * var(--u)); }
.shops { display: flex; justify-content: space-evenly; }
.shops img { width: calc(15.6 * var(--u)); height: auto; }
.shops a { border-radius: 22%; }
.reseller { display: block; width: max-content; margin: calc(4 * var(--u)) auto 0; padding: 10px 4px; color: var(--purple); font-size: max(14px, calc(3.4 * var(--u))); font-weight: 600; text-underline-offset: 3px; }

/* The page ends on Results, the main action, so it stands out. */
.results-cta { display: grid; justify-items: center; gap: calc(4 * var(--u)); margin-top: calc(16 * var(--u)); text-align: center; font-size: max(15px, calc(3.6 * var(--u))); font-weight: 600; }

.results-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: calc(52 * var(--u));
  min-height: max(52px, calc(10.5 * var(--u)));
  font-size: max(17px, calc(4.2 * var(--u)));
  font-weight: 600;
  box-shadow: 0 8px 22px rgb(112 88 191 / 0.35);
}

.results-button svg { width: 22px; height: 22px; }

@media (prefers-reduced-motion: no-preference) {
  .results-button { animation: results-pulse 2.4s ease-out infinite; }
}

/* A soft ring that grows and fades, drawing the eye to the button. */
@keyframes results-pulse {
  0% { box-shadow: 0 8px 22px rgb(112 88 191 / 0.35), 0 0 0 0 rgb(137 105 214 / 0.5); }
  70%, 100% { box-shadow: 0 8px 22px rgb(112 88 191 / 0.35), 0 0 0 14px rgb(137 105 214 / 0); }
}


/* Poster: a full-screen story preview, opened by Results or Share. */
.poster-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #1a1433;
  color: var(--white);
  text-align: center;
}

.poster-dialog[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.poster-dialog::backdrop { background: #1a1433; }
body:has(.poster-dialog[open]) { overflow: hidden; }

/* The poster, blurred and dimmed, fills the space around it, as Instagram does. */
.poster-backdrop {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  object-fit: cover;
  filter: blur(28px) brightness(0.5) saturate(1.2);
}

/* As large as the screen allows, the whole poster always in view. */
.poster-stage { position: relative; display: grid; place-items: center; min-height: 0; padding-top: env(safe-area-inset-top); }
.poster-image {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  width: 100%;
  height: calc(100% - env(safe-area-inset-top));
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgb(0 0 0 / 0.35));
}
.poster-status { padding: 16px; font-size: 14px; }

.poster-bar {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}

.poster-actions { display: flex; gap: 10px; }
.poster-actions .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.poster-actions .button svg { width: 20px; height: 20px; }
.poster-actions .button-outline { background: rgb(255 255 255 / 0.92); }

.poster-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  display: grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  border-radius: 50%;
  background: rgb(26 20 51 / 0.55);
  color: var(--white);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.poster-close svg { width: 22px; }
.debug-result { overflow-x: auto; margin-top: 24px; padding: 12px; border-radius: 12px; background: var(--white); font-size: 11px; }

/* ---------- Virtual try on ---------- */

.tryon { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100vh; height: 100svh; }

.mirror { position: relative; overflow: hidden; background: #241d33; }

/* Video and canvas share one box and one fit mode. The canvas holds the full
   frame at native size, so the makeup cannot drift from the picture. */
.mirror video,
.mirror canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mirror video { transform: scaleX(-1); } /* Kept in the page so iOS keeps decoding frames. */

.mirror .back { position: absolute; top: calc(4.2 * var(--u) + env(safe-area-inset-top)); left: calc(4.2 * var(--u)); background: rgb(255 255 255 / 0.85); }


.chip {
  min-height: var(--touch);
  padding: 0 14px;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.85);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  /* Holding Compare must not scroll, select text or open a long-press menu. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.chip[aria-pressed="true"] { background: var(--purple); color: var(--white); }

.notice {
  position: absolute;
  top: 42%;
  left: 8%;
  right: 8%;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.94);
  font-size: 14px;
  text-align: center;
}

.notice .button { margin-top: 10px; }

.debug { position: absolute; top: 80px; left: 12px; margin: 0; padding: 6px 8px; border-radius: 6px; background: rgb(0 0 0 / 0.6); color: #fff; font: 12px/1.4 ui-monospace, Menlo, monospace; }

/* Compare, then the intensity slider, just above the product tabs. */
.mirror-controls {
  position: absolute;
  left: calc(4.2 * var(--u));
  right: calc(4.2 * var(--u));
  bottom: calc(max(40px, 7 * var(--u)) + 3.5 * var(--u)); /* Clears the tabs below. */
  display: grid;
  justify-items: start;
  gap: 4px;
}

.intensity {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgb(0 0 0 / 0.55);
}

.intensity input {
  --fill: 75%;
  flex: 1;
  height: var(--touch);
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.intensity input::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, #fff var(--fill), rgb(255 255 255 / 0.4) var(--fill)); }
.intensity input::-moz-range-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, #fff var(--fill), rgb(255 255 255 / 0.4) var(--fill)); }
.intensity input::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9.5px; border: 2px solid var(--purple); border-radius: 50%; background: #fff; -webkit-appearance: none; appearance: none; }
.intensity input::-moz-range-thumb { width: 22px; height: 22px; border: 2px solid var(--purple); border-radius: 50%; background: #fff; }

.try-panel { position: relative; background: var(--white); padding-bottom: env(safe-area-inset-bottom); }

.tabs { position: absolute; bottom: 100%; left: calc(8.4 * var(--u)); display: flex; gap: calc(1.4 * var(--u)); }

.tabs button {
  min-height: max(40px, calc(7 * var(--u)));
  padding: 0 calc(3.6 * var(--u));
  border-radius: calc(2 * var(--u)) calc(2 * var(--u)) 0 0;
  background: var(--purple);
  color: var(--white);
  font-size: max(14px, calc(3.1 * var(--u)));
  font-weight: 500;
}

.tabs button[aria-selected="true"] { background: var(--white); color: var(--purple); }

/* Sizes from the try-on mockup (VIRTUAL TRY ON/MOCKUP.png). */
.try-product {
  grid-template-columns: 28% minmax(0, 1fr);
  align-items: start;
  padding: calc(4.2 * var(--u)) calc(3 * var(--u)) calc(6 * var(--u)) calc(2 * var(--u));
}

.try-product .pack { align-self: center; max-height: calc(37 * var(--u)); }

.ball-grid {
  --ball: calc(15.3 * var(--u));
  --row-gap: calc(1.7 * var(--u));
  display: grid;
  grid-template-columns: repeat(3, var(--ball));
  column-gap: calc(2.8 * var(--u));
  row-gap: var(--row-gap);
  /* Two rows, and a glimpse of a third when there is one (the 10 lip shades).
     The same height on every tab, so the controls above don't jump. */
  height: calc(2.45 * var(--ball) + 2 * var(--row-gap) + 8px);
  align-content: start;
  margin: calc(4.2 * var(--u) - 4px) -4px -4px;
  padding: 4px; /* Room for the selection ring. */
  overflow-y: auto;
  scroll-snap-type: y proximity;
  scrollbar-width: none;
}

.ball-grid::-webkit-scrollbar { display: none; }

.ball { position: relative; border-radius: 50%; scroll-snap-align: start; }
.ball img { display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 50%; }
.ball[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--purple); }

.ball .best {
  top: auto;
  bottom: -3px;
  left: 50%;
  translate: -50% 0;
  white-space: nowrap;
  font-size: 9px;
  box-shadow: 0 0 0 1.5px var(--white);
}

/* ---------- Page furniture ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 5;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.demo-flag { position: fixed; top: 0; left: 50%; z-index: 6; translate: -50% 0; padding: 3px 12px; border-radius: 0 0 8px 8px; background: #b3261e; color: #fff; font-size: 11px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .backdrop, .screen { animation: none; }
  .viewfinder[data-view="analyzing"] .scan-line { animation-duration: 6s; }
}
