:root {
  color-scheme: light dark;
}
@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  margin: 0;

  min-height: 100vh;
  display: flex;
  align-items: center;
  /* vertical center */
  justify-content: center;
  /* horizontal center */
  /* background-color: rgb(255, 255, 255); */
}

/* Back to gallery link/button */
.back-btn {
  font-size: 12px;
  position: fixed;
  top: 100px;
  left: 16px;
  padding-left: 26px; /* space for arrow */
  font-weight: 400;
  color: #ffffff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  z-index: 10;
}

.back-btn::after {
  content: "";
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to bottom,
    #000000 0%,
    rgba(0, 0, 0, 0.8) 50%,
    transparent 100%
  );
  z-index: -1;
  pointer-events: none;
}

.back-btn::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M12 6 L8 10 L12 14' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
}

.wrap {
  display: grid;
  gap: 1rem;
  max-width: 900px;
  width: 100%;
  padding: 2rem;
  margin-top: 60px;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0;
  color: #ffffff;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 0;
  color: #ffffff;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

button,
select {
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid #8884;
  cursor: pointer;
}

label {
  font-size: 0.9rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

#openBtn,
#stopBtn,
#snapBtn {
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid #8884;
  cursor: pointer;
}

video,
canvas,
img {
  width: 100%;
  max-width: 640px;

  border-radius: 0.8rem;
  /* border: 1px solid #8884; */
  background: #000;
}

video {
  min-height: 280px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

#downloadLink {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  font-size: 0.8rem;
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.8rem;
  background: #272727;
  color: #fff;
  text-decoration: none;
  border-radius: 0.5rem;
}

.selfie_directions {
  font-size: 0.85rem;
  line-height: 1.5rem;
  color: #ffffff;
}

.selfie_directions span {
  font-size: 0.85rem;
  line-height: 1.5rem;
  color: #a6a6a6;
}
.preview-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  /* aspect-ratio: 4 / 3; */
  min-height: 280px;
  background: rgba(0, 0, 0, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-container::before {
  content: "Your silhouette will appear here";
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  text-align: center;
  position: absolute;
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

#preview[src]:not([src=""]) ~ .preview-container::before,
.preview-container:has(#preview[src]:not([src=""])) ::before {
  display: none;
}

/* Hide placeholder when image is loaded */
.preview-container:has(img[src]:not([src=""])) {
  background: transparent;
  border: none;
}

.preview-container:has(img[src]:not([src=""])) ::before {
  display: none;
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  display: none;
  z-index: 200;

  .loader {
    width: 48px;
    height: 48px;
    border: 5px solid #fff;
    border-bottom-color: #ff3d00;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
  }
}

@media (max-width: 900px) {
  .row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  #back-gallery {
    left: 72px;
    font-size: 0.85rem;
    padding: 5px 8px;
  }
}

.note {
  font-size: 0.95rem;
  opacity: 0.8;
}

.error {
  color: #b00020;
  font-weight: 600;
}
