/* BrainCareClub Web MVP - minimal, responsive */
:root{
  --bg:#0b0f17;
  --card:#111827;
  --muted:#94a3b8;
  --text:#e5e7eb;
  --border:#243042;
  --primary:#22c55e;
  --danger:#ef4444;
  --warn:#f59e0b;
  --ok:#10b981;
  --shadow: 0 16px 40px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background: radial-gradient(1200px 800px at 20% 0%, #0b2740 0%, var(--bg) 60%);
  color:var(--text); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Apple SD Gothic Neo, "Noto Sans KR", sans-serif;
}
code{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;}
.hidden{display:none !important}
.app{min-height:100%}
.topbar{
  position:sticky; top:0; z-index:10;
  background: rgba(11,15,23,.75);
  backdrop-filter: blur(10px);
  border-bottom:1px solid rgba(36,48,66,.7);
}
.topbar{display:flex; align-items:center; justify-content:space-between; padding:14px 16px;}
.brand{display:flex; gap:12px; align-items:center;}
.logo{
  width:36px; height:36px; border-radius:12px;
  display:grid; place-items:center; font-weight:800;
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(59,130,246,.75));
}
.brandname{font-weight:800}
.branddesc{font-size:12px; color:var(--muted)}
.container{max-width:1000px; margin:0 auto; padding:18px 16px 52px;}
.stack{display:flex; flex-direction:column; gap:14px;}
.card{
  background: rgba(17,24,39,.78);
  border:1px solid rgba(36,48,66,.8);
  border-radius:18px;
  box-shadow: var(--shadow);
  padding:16px;
}
.h1{margin:0 0 10px; font-size:22px;}
.h2{margin:0 0 8px; font-size:18px;}
.h3{margin:0 0 8px; font-size:15px;}
.muted{color:var(--muted)}
.small{font-size:12px}
.row{flex-wrap:wrap; display:flex; gap:12px; align-items:center; justify-content:space-between;}
.row-gap{align-items:flex-start}
.row-end{justify-content:flex-end}
.pill{
  font-size:12px; padding:6px 10px; border:1px solid rgba(36,48,66,.9);
  border-radius:999px; color:var(--muted); white-space:nowrap;
}
.sop{margin:10px 0 0; padding-left:18px; color:var(--text)}
.sop li{margin:6px 0}
.cta{display:flex; flex-direction:column; gap:8px; margin-top:12px;}
.btn{
  border:1px solid rgba(36,48,66,.95);
  background: rgba(2,6,23,.35);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
}
.btn:hover{filter:brightness(1.08)}
.btn:active{transform: translateY(1px)}
.btn-lg{padding:12px 14px; font-size:15px}
.btn-primary{
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(16,185,129,.9));
  border-color: rgba(16,185,129,.85);
  color:#08130e;
  font-weight:800;
}
.btn-ghost{background:transparent}
.form{display:flex; flex-direction:column; gap:12px; margin-top:10px;}
.field{display:flex; flex-direction:column; gap:6px;}
input{
  background: rgba(2,6,23,.35); border:1px solid rgba(36,48,66,.95);
  color:var(--text); padding:11px 12px; border-radius:14px;
}
.grid3{
  display:grid; gap:12px; grid-template-columns: repeat(3, minmax(0,1fr));
}
.metric{
  border:1px solid rgba(36,48,66,.8);
  border-radius:16px; padding:12px;
  background: rgba(2,6,23,.25);
}
.metric .label{color:var(--muted); font-size:12px}
.metric .value{font-size:22px; font-weight:900; margin-top:4px}
.divider{height:1px; background: rgba(36,48,66,.75); margin:14px 0}
.chartWrap{flex:1; min-width:280px}
.tips{flex:1; min-width:280px}
.plan{margin:8px 0 0; padding-left:18px}
.plan li{margin:6px 0}
.history{display:flex; flex-direction:column; gap:10px; margin-top:10px}
.histItem{
  display:flex; justify-content:space-between; gap:10px;
  border:1px solid rgba(36,48,66,.7);
  border-radius:14px; padding:10px;
  background: rgba(2,6,23,.22);
}
.histLeft{display:flex; flex-direction:column; gap:4px}
.tagrow{display:flex; gap:6px; flex-wrap:wrap}
.tag{
  font-size:11px; padding:3px 8px; border-radius:999px;
  border:1px solid rgba(36,48,66,.85); color:var(--muted);
}
.tag.ok{border-color:rgba(16,185,129,.7); color:rgba(167,243,208,1)}
.tag.warn{border-color:rgba(245,158,11,.7); color:rgba(253,230,138,1)}
.tag.bad{border-color:rgba(239,68,68,.7); color:rgba(254,202,202,1)}
.footer{margin-top:16px; text-align:center}

.modal{
  position:fixed; inset:0; background: rgba(0,0,0,.55);
  display:flex; align-items:center; justify-content:center; padding:16px;
}
.modal-card{
  width:min(920px, 100%);
  height:min(92vh, 920px);
  background: rgba(17,24,39,.95);
  border:1px solid rgba(36,48,66,.95);
  border-radius:20px;
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; border-bottom:1px solid rgba(36,48,66,.75);
  flex:0 0 auto;
}
.modal-title{font-weight:900}
.step{padding:14px; overflow:auto; flex:1}
.progress{height:8px; background: rgba(2,6,23,.35); flex:0 0 auto}
.progress .bar{height:100%; background: linear-gradient(90deg, rgba(34,197,94,.9), rgba(59,130,246,.7))}
.quote{overflow-wrap:anywhere; word-break:keep-all; 
  padding:12px; border-radius:14px;
  border:1px dashed rgba(36,48,66,.95);
  background: rgba(2,6,23,.25);
  margin:10px 0;
}
.meter{
  flex:1; height:12px; border-radius:999px;
  background: rgba(2,6,23,.35);
  border:1px solid rgba(36,48,66,.85);
  overflow:hidden;
}
.meter-fill{
  height:100%; width:0%;
  background: linear-gradient(90deg, rgba(34,197,94,.9), rgba(245,158,11,.9), rgba(239,68,68,.9));
}
.hint{
  margin-top:8px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(36,48,66,.75);
  background: rgba(2,6,23,.22);
  color: var(--text);
}
.cameraWrap{
  position:relative; width:100%;
  border-radius:18px;
  border:1px solid rgba(36,48,66,.85);
  overflow:hidden;
  background:#000;
  aspect-ratio: 4/3;
  max-height: 62vh;
}
#video, #overlay{position:absolute; inset:0; width:100%; height:100%; object-fit:cover}
#overlay{pointer-events:none}
.badges{
  position:absolute; left:10px; bottom:10px;
  display:flex; gap:8px; flex-wrap:wrap;
}
.badge{
  font-size:12px; padding:6px 10px;
  border-radius:999px;
  background: rgba(0,0,0,.42);
  border:1px solid rgba(255,255,255,.18);
}
.countdown{
  position:absolute; inset:0; display:grid; place-items:center;
  font-size:64px; font-weight:900;
  background: rgba(0,0,0,.35);
}
.scan{
  margin-top:12px;
  height:140px;
  border-radius:18px;
  border:1px solid rgba(36,48,66,.85);
  background: rgba(2,6,23,.22);
  position:relative;
  overflow:hidden;
}
.scan-bar{
  position:absolute; left:-40%; top:0; bottom:0;
  width:40%;
  background: linear-gradient(90deg, transparent, rgba(34,197,94,.22), rgba(59,130,246,.18), transparent);
  animation: scan 1.2s linear infinite;
}
@keyframes scan{
  from { transform: translateX(0); }
  to { transform: translateX(400%); }
}
.note{
  margin-top:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(245,158,11,.35);
  background: rgba(245,158,11,.08);
  color: rgba(253,230,138,1);
  font-size:12px;
}
@media (max-width: 840px){
  .grid3{grid-template-columns: 1fr;}
  .row-gap{flex-direction:column; align-items:stretch}
  .chartWrap,.tips{min-width:unset}
  .cameraWrap{aspect-ratio: 1/1; max-height: 58vh;}
  .modal{padding:0}
  .modal-card{width:100%; height:100vh; border-radius:0;}
}


.aiPanel{
  margin-top:12px;
  border-radius:18px;
  border:1px solid rgba(36,48,66,.85);
  background: rgba(2,6,23,.22);
  padding:14px;
  display:flex;
  gap:14px;
  align-items:center;
}
.aiOrb{
  width:86px; height:86px; border-radius:999px;
  background: radial-gradient(circle at 30% 30%, rgba(34,197,94,.45), rgba(59,130,246,.25), rgba(2,6,23,.1));
  border:1px solid rgba(255,255,255,.12);
  position:relative;
  overflow:hidden;
}
.aiOrb::before{
  content:"";
  position:absolute; inset:-30%;
  background: conic-gradient(from 0deg, rgba(34,197,94,.0), rgba(34,197,94,.5), rgba(59,130,246,.35), rgba(34,197,94,.0));
  animation: spin 1.4s linear infinite;
}
.aiOrb::after{
  content:"";
  position:absolute; inset:12px;
  border-radius:999px;
  background: rgba(2,6,23,.55);
  border:1px solid rgba(255,255,255,.08);
}
@keyframes spin{
  from{ transform: rotate(0deg); }
  to{ transform: rotate(360deg); }
}
.aiSteps{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.aiStep{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid rgba(36,48,66,.7);
  background: rgba(2,6,23,.18);
  font-size:13px;
}
.aiStep .dot{
  width:10px; height:10px; border-radius:999px;
  background: rgba(255,255,255,.25);
  border:1px solid rgba(255,255,255,.12);
}
.aiStep.done .dot{ background: rgba(16,185,129,.9); border-color: rgba(16,185,129,.8); }
.aiStep.active .dot{ background: rgba(245,158,11,.9); border-color: rgba(245,158,11,.8); }
.aiStep .status{ color: var(--muted); font-size:12px; white-space:nowrap; }



html, body{ overflow-x:hidden; }
*{ box-sizing:border-box; }

.modal-card{ padding-bottom: env(safe-area-inset-bottom); }
.modal-head{ padding-top: calc(12px + env(safe-area-inset-top)); }

.script{overflow-wrap:anywhere; word-break:keep-all;}


.lightStage{
  position:relative;
  border-radius:18px;
  border:1px solid rgba(36,48,66,.85);
  overflow:hidden;
  min-height: 360px;
}
.lightBg{
  position:absolute; inset:0;
  background: #fff;
  opacity: 1;
}
.lightHud{
  position:absolute;
  top:12px; left:12px;
  display:flex; gap:8px;
  z-index:3;
}
.lightPreview{
  position:relative;
  z-index:2;
  width:min(420px, 84vw);
  margin: 70px auto 18px auto;
  border-radius:18px;
  border:1px solid rgba(0,0,0,.25);
  overflow:hidden;
  background:#000;
  aspect-ratio: 1/1;
}
.lightPreview video{
  width:100%; height:100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.lightCountdown{
  position:absolute;
  inset:auto 0 22px 0;
  margin:auto;
  width:64px; height:64px;
  border-radius:999px;
  display:grid; place-items:center;
  font-weight:800;
  font-size:22px;
  color:#fff;
  background: rgba(2,6,23,.55);
  border:1px solid rgba(255,255,255,.2);
  z-index:4;
  left:0; right:0;
}
/* .faceRing.big deprecated */
/* .faceRing.big{
  width: 78%;
  height: 78%;
  left: 11%;
  top: 11%;
  border-width: 4px;
}



/* Cyber upgrade for AI analyzing */
#stepAnalyzing{
  position:relative;
}
#stepAnalyzing::before{
  content:"";
  position:absolute; inset:-40px;
  background:
    linear-gradient(rgba(34,197,94,.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.10) 1px, transparent 1px);
  background-size: 32px 32px;
  filter: blur(.0px);
  opacity:.55;
  transform: translateZ(0);
  animation: gridMove 3.4s linear infinite;
  pointer-events:none;
}
@keyframes gridMove{
  from{ background-position: 0 0, 0 0; }
  to{ background-position: 0 32px, 32px 0; }
}
.aiPanel{ position:relative; overflow:hidden; }
.aiPanel::after{
  content:"";
  position:absolute; inset:-60%;
  background: radial-gradient(circle at 50% 50%, rgba(59,130,246,.18), rgba(34,197,94,.08), rgba(2,6,23,0));
  animation: pulse 2.2s ease-in-out infinite;
  pointer-events:none;
}
@keyframes pulse{
  0%,100%{ transform: scale(1); opacity:.7; }
  50%{ transform: scale(1.06); opacity:1; }
}


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

.modal-card{ max-width:100vw; width:100%; }

.lightRing{
  position:absolute;
  inset: 11% 11%;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,.75);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.10) inset;
  pointer-events:none;
}
