* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
}

button,
label {
  font: inherit;
}

.camera-app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

#camera {
  display: none;
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
  background: #050505;
}

#imageLoader {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 72px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.28)),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.025) 0,
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px,
      transparent 9px
    );
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.scan-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: -18%;
  height: 18%;
  background:
    linear-gradient(
      180deg,
      transparent 0,
      rgba(255, 255, 255, 0.02) 32%,
      rgba(255, 255, 255, 0.38) 72%,
      rgba(255, 255, 255, 0.86) 76%,
      rgba(255, 255, 255, 0.18) 80%,
      transparent 100%
    );
  filter: blur(0.4px);
  animation: scanMove 2.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
}

.progress-pill {
  position: relative;
  z-index: 1;
  min-width: 82px;
  padding: 11px 16px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.96);
  background: rgba(0, 0, 0, 0.52);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  backdrop-filter: blur(22px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.cancel-button {
  position: relative;
  z-index: 2;
  margin-top: 0;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(22, 22, 22, 0.7);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  backdrop-filter: blur(20px);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cancel-button[hidden] {
  display: none;
}

@keyframes scanMove {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(660%);
  }
}

.controls {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: max(28px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 96px 1fr;
  align-items: center;
  padding: 0 28px;
  pointer-events: none;
}

.upload-button,
.shutter,
.filter-button,
.mode-option,
.download-button {
  pointer-events: auto;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.upload-button,
.filter-button {
  justify-self: start;
  min-width: 64px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(22, 22, 22, 0.62);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  backdrop-filter: blur(18px);
}

.filter-button {
  justify-self: end;
}

.download-button {
  position: absolute;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  min-width: 64px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(22, 22, 22, 0.62);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  backdrop-filter: blur(18px);
}

.download-button[hidden] {
  display: none;
}

.result-strip {
  position: absolute;
  z-index: 25;
  left: 50%;
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 106px);
  display: flex;
  max-width: min(92vw, 430px);
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 8px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.54);
  backdrop-filter: blur(20px);
  pointer-events: auto;
  scroll-snap-type: x proximity;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.result-strip::-webkit-scrollbar {
  display: none;
}

.result-strip[hidden] {
  display: none;
}

.result-thumb {
  position: relative;
  width: 54px;
  height: 54px;
  overflow: hidden;
  flex: 0 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  scroll-snap-align: center;
}

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

.result-thumb.active {
  border-color: #fff;
}

.result-thumb span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.62);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.shutter {
  justify-self: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 56%, transparent 57%),
    radial-gradient(circle, transparent 0 64%, #fff 65% 100%);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.shutter:active {
  transform: scale(0.94);
}

.shutter:disabled,
.upload-button.disabled,
.filter-button.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.status {
  position: absolute;
  left: 50%;
  bottom: calc(max(28px, env(safe-area-inset-bottom)) + 176px);
  max-width: min(78vw, 420px);
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.48);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.status.visible {
  opacity: 1;
}

.mode-sheet {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 0 18px calc(max(28px, env(safe-area-inset-bottom)) + 112px);
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    background 180ms ease;
}

.mode-sheet.open {
  background: rgba(0, 0, 0, 0.18);
  opacity: 1;
  pointer-events: auto;
}

.mode-panel {
  display: grid;
  gap: 8px;
  width: min(420px, 100%);
  justify-self: center;
  padding: 10px;
  border-radius: 24px;
  background: rgba(24, 24, 24, 0.68);
  backdrop-filter: blur(24px);
}

.mode-option {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 13px 15px;
  border-radius: 17px;
  color: #fff;
  background: transparent;
  text-align: left;
}

.mode-option span {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.mode-option small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.35;
}

.mode-option.active {
  background: rgba(255, 255, 255, 0.16);
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr 86px 1fr;
    padding: 0 20px;
  }

  .shutter {
    width: 72px;
    height: 72px;
  }
}
