:root {
  color-scheme: light;
  background: #102f4d;
  --scan-blue: #79e1f3;
  --scan-yellow: #ffd60a;
  --ink: #090909;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 100svh;
  background: #102f4d;
}

.experience {
  position: relative;
  isolation: isolate;
  width: min(100vw, 46.182266svh, 750px);
  aspect-ratio: 750 / 1624;
  flex: 0 0 auto;
  overflow: hidden;
}

.background-layer,
.elements-layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.background-layer { z-index: 0; }
.elements-layer { z-index: 2; }

.default-elements-layer,
.retry-elements-layer {
  transition: opacity .4s ease;
}

.retry-elements-layer {
  opacity: 0;
}

.experience.is-retry-visible .default-elements-layer { opacity: 0; }
.experience.is-retry-visible .retry-elements-layer { opacity: 1; }

.capture-frame,
.scan-overlay {
  position: absolute;
  top: 38.7%;
  left: 10.667%;
  width: 78.4%;
  height: 36.207%;
  overflow: hidden;
  border-radius: 6.3%;
}

.capture-frame {
  z-index: 1;
  background: rgba(255, 255, 255, .3);
}

#camera-view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b2637;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity .35s ease;
}

.capture-frame.is-camera-ready #camera-view { opacity: 1; }

.scan-overlay {
  z-index: 3;
  overflow: visible;
  pointer-events: none;
}

.scan-overlay::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: 2;
  border: 2px solid #fff;
  border-radius: calc(6.3% + 2px);
  box-shadow: none;
  transition: inset .22s ease, border-color .22s ease, border-width .22s ease, border-radius .22s ease, box-shadow .22s ease;
  pointer-events: none;
}

.scan-overlay.is-thinking::before {
  inset: clamp(-6px, -.8vw, -3px);
  border-width: clamp(3px, .8vw, 6px);
  border-color: var(--scan-yellow);
  border-radius: calc(6.3% + clamp(3px, .8vw, 6px));
  box-shadow:
    0 0 0 1px rgba(255, 214, 10, .18),
    0 0 24px rgba(255, 214, 10, .28);
}

.status {
  appearance: none;
  position: absolute;
  left: 8.3%;
  bottom: 5.35%;
  z-index: 2;
  width: 83.8%;
  height: 10.45%;
  min-width: 0;
  margin: 0;
  padding: 0 5%;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 clamp(11px, 2.75vw, 18px)/1.15 "PingFang SC", "Hiragino Sans GB", sans-serif;
  letter-spacing: .015em;
  text-align: center;
  opacity: 0;
  transition: opacity .2s ease, background-color .2s ease, color .2s ease, transform .2s ease;
  pointer-events: none;
}

.status.is-visible { opacity: 1; }

.status.thinking,
.status.success {
  background: var(--scan-yellow);
  color: #171100;
  box-shadow: 0 5px 18px rgba(93, 69, 0, .2);
}

.status-text {
  display: inline-block;
}

.status.thinking .status-text {
  animation: thinking-text 2s ease-in-out infinite;
}

.status.error {
  background: #fff;
  color: #8c2030;
}

.status.is-actionable {
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.status.is-actionable:active { transform: scale(.985); }

.status:focus-visible {
  outline: 3px solid var(--scan-yellow);
  outline-offset: 3px;
}

.retry-trigger {
  position: absolute;
  z-index: 4;
  left: 40%;
  top: 82%;
  width: 20%;
  height: 10%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.experience.is-retry-visible .retry-trigger {
  opacity: 1;
  pointer-events: auto;
}

.retry-trigger:focus-visible {
  outline: 2px solid var(--scan-yellow);
  outline-offset: 3px;
  border-radius: 12px;
}

@keyframes thinking-text {
  0%, 100% { opacity: .15; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
