:root{
  --bg:#0b0f14;
  --panel:rgba(255,255,255,.06);
  --panel2:rgba(255,255,255,.09);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.65);
  --line:rgba(255,255,255,.12);
  --accent:#6ee7ff;
  --ok:#4ade80;
  --err:#ff6b6b;
  --radius:16px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(110,231,255,.08), transparent 60%),
              radial-gradient(900px 600px at 80% 30%, rgba(74,222,128,.06), transparent 55%),
              var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

.hidden{display:none !important;}

.app{height:100%; display:flex; flex-direction:column;}
.topbar{
  height:64px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 18px;
  border-bottom:1px solid var(--line);
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(12px);
}
.brandTitle{font-weight:700; letter-spacing:.2px;}
.brandSub{font-size:12px; color:var(--muted); margin-top:2px;}
.statusDot{
  width:12px;height:12px;border-radius:999px;
  background:var(--accent);
  box-shadow:0 0 0 3px rgba(110,231,255,.12);
}

.screens{flex:1; position:relative; overflow:hidden;}
.screen{
  position:absolute; inset:0;
  display:none;
  padding:18px;
}
.screen.active{display:block;}

.center{
  height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:14px;
  text-align:center;
}
.center.wide{justify-content:flex-start; padding-top:22px;}

.h1{font-size:42px; margin:0;}
.h2{font-size:26px; margin:0;}
.p{margin:0; color:var(--muted);}
.p.subtle{font-size:13px; color:rgba(255,255,255,.55);}

.grid2{
  width:min(520px, 100%);
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-top:10px;
}
.cardBtn{
  border:1px solid var(--line);
  border-radius:20px;
  background:var(--panel);
  padding:16px 10px;
  color:var(--text);
}
.cardBtn:active{transform:scale(.99)}
.cardEmoji{font-size:34px;}
.cardTitle{margin-top:8px; font-weight:700;}

.btnPrimary,.btnGhost{
  border-radius:16px;
  padding:14px 16px;
  font-weight:700;
  border:1px solid var(--line);
  width:min(420px, 100%);
  cursor:pointer;
}
.btnPrimary{
  background: linear-gradient(135deg, rgba(110,231,255,.24), rgba(255,255,255,.06));
  color:var(--text);
}
.btnGhost{
  background:transparent;
  color:rgba(255,255,255,.82);
}
.btnPrimary:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.row{
  width:min(520px, 100%);
  display:flex;
  gap:12px;
  justify-content:center;
  margin-top:14px;
}
.row .btnPrimary,.row .btnGhost{width:auto; min-width:160px;}

.form{
  width:min(520px, 100%);
  margin-top:12px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:20px;
  background:var(--panel);
  text-align:left;
}
.label{display:block; margin:12px 0 8px; font-weight:700; font-size:13px; color:rgba(255,255,255,.85);}

.seg{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.segBtn{
  border:1px solid var(--line);
  background:rgba(0,0,0,.18);
  color:rgba(255,255,255,.85);
  padding:10px 12px;
  border-radius:999px;
  font-weight:700;
}
.segBtn.active{
  border-color: rgba(110,231,255,.55);
  box-shadow: 0 0 0 3px rgba(110,231,255,.10);
  background: rgba(110,231,255,.12);
}
.select{
  width:100%;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(0,0,0,.18);
  color:rgba(255,255,255,.9);
  padding:12px 12px;
  font-weight:700;
}

.cameraWrap{
  height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:14px;
  padding-top:12px;
}
.cameraHeader{
  width:min(720px, 100%);
  text-align:center;
}
.cameraFrame{
  width:min(720px, 100%);
  aspect-ratio: 3 / 4;
  border-radius:24px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.25);
  overflow:hidden;
  position:relative;
}
.cameraFrame video{
  width:100%;
  height:100%;
  object-fit:cover;
  /* mirror preview for user */
  transform: scaleX(-1);
  display:block;
}

/* Soft face guide (helps framing) */
.faceGuide{
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(circle at 50% 38%, rgba(110,231,255,.18) 0 38%, transparent 41%),
    radial-gradient(circle at 50% 38%, transparent 0 39%, rgba(0,0,0,.22) 41% 100%);
  mix-blend-mode: screen;
  opacity:.28;
}

/* Countdown (CRISP) */
.countdown{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:96px;
  font-weight:900;
  letter-spacing:2px;
  color:rgba(255,255,255,.92);
  text-shadow: 0 12px 34px rgba(0,0,0,.55);
  opacity:0;
  transform: translateZ(0);
  pointer-events:none;
}
.countdown.show{
  opacity:1;
  animation: pop .70s ease both;
}
@keyframes pop{
  0%{transform:scale(.92); opacity:.0}
  40%{transform:scale(1.05); opacity:1}
  100%{transform:scale(1.0); opacity:1}
}

/* Flash */
.flash{
  position:absolute; inset:0;
  background:white;
  opacity:0;
  pointer-events:none;
}
.flash.on{
  animation: flash .25s ease both;
}
@keyframes flash{
  0%{opacity:0}
  30%{opacity:.95}
  100%{opacity:0}
}

.cameraControls{
  width:min(720px, 100%);
  display:flex;
  gap:12px;
  justify-content:center;
}

.previewBox{
  width:min(520px, 100%);
  border-radius:22px;
  border:1px solid var(--line);
  background:rgba(0,0,0,.20);
  overflow:hidden;
  margin-top:10px;
}
.previewBox img{
  width:100%;
  display:block;
}

.stylesHeader{
  width:min(820px, 100%);
  margin:0 auto;
  text-align:center;
}
.stylesGrid{
  width:min(820px, 100%);
  margin:14px auto 0;
  height: calc(100% - 170px);
  overflow-y:auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:12px;
}
@media (min-width: 900px){
  .stylesGrid{grid-template-columns: repeat(3, minmax(0, 1fr));}
}
.styleCard{
  border:1px solid var(--line);
  border-radius:20px;
  overflow:hidden;
  background:var(--panel);
  padding:0;
  color:var(--text);
}
.styleCard:active{transform:scale(.99)}
.styleThumb{
  height:140px;
  background: rgba(0,0,0,.18);
  display:flex;
  align-items:center;
  justify-content:center;
}
.styleThumb img{width:100%;height:100%;object-fit:cover;display:block}
.styleLabel{
  padding:12px 12px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  font-weight:800;
}
.badge{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: rgba(255,255,255,.75);
}

.stylesFooter{
  width:min(820px, 100%);
  margin:12px auto 0;
  display:flex;
  justify-content:center;
}

.spinner{
  width:46px;height:46px;border-radius:50%;
  border:4px solid rgba(255,255,255,.15);
  border-top-color: rgba(110,231,255,.85);
  animation: spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.progressWrap{width:min(420px, 100%); margin-top:12px;}
.progressBar{
  height:12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.14);
  overflow:hidden;
  background: rgba(0,0,0,.18);
}
.progressFill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, rgba(110,231,255,.55), rgba(74,222,128,.45));
}
.progressText{margin-top:8px; color:rgba(255,255,255,.7); font-weight:800;}

.qrBox{
  width:260px; height:260px;
  border-radius:22px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}
.qrBox img{width:92%; height:92%; object-fit:contain; display:block;}

.toast{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:18px;
  padding:10px 14px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.9);
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
}
.toast.show{opacity:1;}
