:root {
  --asm-blue: #0074C1;
  --asm-blue-dk: #005A96;
  --asm-green: #57B947;
  --ink: #07111f;
  --line: rgba(255, 255, 255, .12);
  --txt: #eaf2fb;
  --txt-dim: #9db0c7;
  --radius: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  margin: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background:
    radial-gradient(120% 80% at 15% -10%, rgba(0, 116, 193, .30), transparent 60%),
    radial-gradient(110% 70% at 95% 8%, rgba(87, 185, 71, .22), transparent 62%),
    var(--ink);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 16px);
}

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
  animation: fade .3s ease both
}

.screen.on {
  display: flex
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

/* ---------- header ---------- */
.brandbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 4px 0;
  flex: 0 0 auto;
}

.brandbar img {
  height: 52px;
  width: auto;
  background: #fff;
  border-radius: 11px;
  padding: 5px 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

.brandbar .bt {
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--txt-dim);
  line-height: 1.4;
}

.brandbar .bt b {
  display: block;
  color: #fff;
  letter-spacing: .04em;
  font-size: 17px;
  font-weight: 800;
}

/* ---------- welcome ---------- */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 6px;
  min-height: 0
}

.frame {
  position: relative;
  width: min(56vw, 196px);
  aspect-ratio: 3/4;
  margin: 0 auto 4px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(160deg, #1d3350, #12203a);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 22px 40px rgba(0, 0, 0, .5)
}

.frame .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: .5
}

.frame .ph svg {
  width: 48%;
  stroke: #8fb4dc;
  fill: none;
  stroke-width: 1.5
}

.frame .fl {
  position: absolute;
  top: 7%;
  right: 7%;
  width: 30%;
  background: #fff;
  border-radius: 5px;
  padding: 3px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4)
}

.frame .fl img {
  width: 100%;
  display: block
}

.frame .fc {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22% 8% 7%;
  background: linear-gradient(to top, rgba(4, 10, 20, .88), transparent);
  text-align: left
}

.frame .fc b {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #fff
}

.frame .fc i {
  display: block;
  width: 52%;
  height: 2px;
  background: var(--asm-green);
  margin-top: 3px
}

h1 {
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.1;
  margin: 8px 0 0;
  font-weight: 800;
  letter-spacing: -.02em
}

h1 .g {
  background: linear-gradient(92deg, var(--asm-green), #8fd97f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent
}

.sub {
  color: var(--txt-dim);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 10px auto 0;
  max-width: 22em
}

.warn {
  background: rgba(224, 130, 18, .14);
  border: 1px solid rgba(224, 130, 18, .45);
  color: #f5c66a;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 14px;
  margin: 0 auto 12px;
  max-width: 22em;
  text-align: left;
}

.warn b {
  color: #ffe082;
}

.steps {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap
}

.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  color: #cfe0f2
}

.chip i {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--asm-blue);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center
}

/* ---------- mode switch ---------- */
.seg {
  display: flex;
  gap: 4px;
  margin: 20px auto 0;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  width: max-content;
  max-width: 100%
}

.seg button {
  background: transparent;
  color: var(--txt-dim);
  font-size: 13.5px;
  font-weight: 650;
  padding: 9px 18px;
  border-radius: 999px;
  transition: background .16s ease, color .16s ease
}

.seg button.on {
  background: linear-gradient(180deg, var(--asm-blue), var(--asm-blue-dk));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 116, 193, .4)
}

.segnote {
  text-align: center;
  font-size: 12px;
  color: #7d8ea3;
  margin: 9px 0 0
}

/* ---------- buttons ---------- */
.actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px
}

.row {
  display: flex;
  gap: 10px
}

.row>* {
  flex: 1
}

button {
  font: inherit;
  border: 0;
  cursor: pointer
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(180deg, var(--asm-blue), var(--asm-blue-dk));
  color: #fff;
  box-shadow: 0 10px 24px rgba(0, 116, 193, .36);
  transition: transform .12s ease;
}

.btn:active {
  transform: scale(.975)
}

.btn.green {
  background: linear-gradient(180deg, var(--asm-green), #3f9b32);
  box-shadow: 0 10px 24px rgba(87, 185, 71, .34)
}

.btn.ghost {
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--txt);
  font-weight: 600
}

.btn[disabled] {
  opacity: .55;
  pointer-events: none
}

.note {
  text-align: center;
  font-size: 11.5px;
  color: #7d8ea3;
  line-height: 1.5;
  margin-top: 4px
}

/* ---------- camera ---------- */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block
}

.stage video.mirror {
  transform: scaleX(-1)
}

.guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center
}

.guide svg {
  width: 64%;
  max-width: 250px;
  opacity: .32
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  text-align: center;
  font-size: 12.5px;
  color: #dbe7f5;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .9);
  padding: 0 20px
}

.topbtn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .18);
  display: grid;
  place-items: center
}

.topbtn svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round
}

.count {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, .42);
  font-size: clamp(80px, 26vw, 150px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 8px 40px rgba(0, 0, 0, .7)
}

.count.on {
  display: grid;
  animation: pop .9s ease
}

@keyframes pop {
  0% {
    transform: scale(.55);
    opacity: 0
  }

  30% {
    transform: scale(1);
    opacity: 1
  }

  100% {
    transform: scale(1.25);
    opacity: 0
  }
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none
}

.flash.go {
  animation: fl .45s ease
}

@keyframes fl {
  0% {
    opacity: .95
  }

  100% {
    opacity: 0
  }
}

/* ---------- result ---------- */
.resultwrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0
}

.resultwrap img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .6);
  border: 1px solid var(--line);
  animation: rise .4s cubic-bezier(.2, .9, .3, 1) both
}

@keyframes rise {
  from {
    opacity: 0;
    transform: scale(.96)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  background: rgba(87, 185, 71, .16);
  border: 1px solid rgba(87, 185, 71, .45);
  color: #a8e79a;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 10px
}

.saved {
  text-align: center;
  font-size: 12px;
  color: var(--asm-green);
  height: 1.2em;
  margin-top: 2px;
  opacity: 0;
  transition: opacity .2s
}

.saved.on {
  opacity: 1
}

/* ---------- processing loader ---------- */
.procbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
  padding: 20px 10px;
}

.proc-visual {
  position: relative;
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.proc-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(0, 116, 193, .2);
  border-top-color: var(--asm-green);
  border-right-color: var(--asm-blue);
  animation: spin 1.1s linear infinite;
  box-shadow: 0 0 25px rgba(0, 116, 193, .35);
}

.proc-ring-outer {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px dashed rgba(87, 185, 71, .35);
  animation: spin-reverse 3.5s linear infinite;
}

.proc-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(87, 185, 71, .4), rgba(0, 116, 193, .3));
  border: 1px solid rgba(255, 255, 255, .25);
  display: grid;
  place-items: center;
  font-size: 32px;
  animation: pulse 1.4s ease-in-out infinite alternate;
  box-shadow: 0 0 30px rgba(87, 185, 71, .3);
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

@keyframes spin-reverse {
  to {
    transform: rotate(-360deg)
  }
}

@keyframes pulse {
  from {
    transform: scale(0.93);
    opacity: .85
  }

  to {
    transform: scale(1.07);
    opacity: 1
  }
}

.proc-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.proc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 116, 193, .16);
  border: 1px solid rgba(0, 116, 193, .45);
  color: #7ac4f5;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
}

.proc-msg {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: fadeMsg .35s ease both;
  line-height: 1.4;
  padding: 0 8px;
}

@keyframes fadeMsg {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

.proc-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, .1);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  position: relative;
}

.proc-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--asm-blue), var(--asm-green));
  border-radius: 999px;
  transition: width .08s linear;
  box-shadow: 0 0 12px rgba(87, 185, 71, .6);
}

/* ---------- error ---------- */
.errbox {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px
}

.errbox .ic {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(255, 90, 90, .14);
  border: 1px solid rgba(255, 90, 90, .4);
  display: grid;
  place-items: center;
  font-size: 28px
}

.errbox p {
  color: var(--txt-dim);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 23em;
  margin: 0
}

details.diag {
  margin-top: 2px;
  font-size: 11px;
  color: #63748a;
  max-width: 100%
}

details.diag pre {
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
  background: rgba(255, 255, 255, .05);
  padding: 9px;
  border-radius: 9px;
  max-height: 110px;
  overflow: auto;
  margin: 6px 0 0
}
