html, body.scan-body { height: 100%; }
body.scan-body {
  background: #04070a; color: #fff; overflow: hidden; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.boot.dark { background: #04070a; }
.boot.dark .spinner { border-color: rgba(255,255,255,.12); border-top-color: var(--lime); }

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --glass: rgba(6,10,14,.62);
  --glass-line: rgba(255, 255, 255, .13);
  --ease: cubic-bezier(.22, .8, .24, 1);
}

/* ---------- gate (no link) ---------- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 28px 24px;
  background:
    radial-gradient(700px 420px at 0% 0%, rgba(62,240,176,.5), transparent 60%),
    radial-gradient(500px 400px at 100% 100%, rgba(62,240,176,.12), transparent 60%),
    var(--night);
}
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-logo { display: inline-block; font-size: 26px; margin-bottom: 28px; color: #fff; }
.gate .kicker { color: var(--lime); }
.gate h1 { font: 700 30px/1.1 var(--display); margin: 0 0 10px; letter-spacing: -.02em; }
.gate p { color: #b3c0cb; margin: 0 0 24px; }
.gate .input { height: 54px; font-size: 16px; text-align: center; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; user-select: text; -webkit-user-select: text; }
.gate .input::placeholder { color: #7c8a97; }
.gate .input:focus { border-color: var(--lime); box-shadow: 0 0 0 4px rgba(62,240,176,.15); }
.gate .form-error { color: #ff9aa8; }

/* ---------- stage ---------- */
.scanner { position: fixed; inset: 0; display: flex; flex-direction: column; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(14,7,36,.78), rgba(14,7,36,0) 24%),
    linear-gradient(0deg, rgba(14,7,36,.9), rgba(14,7,36,0) 34%);
}
.scanner.idle .shade { background: rgba(14,7,36,.86); }

/* ---------- top: event + progress ---------- */
.s-top { position: relative; z-index: 5; padding: calc(var(--safe-t) + 12px) 14px 0; }
.s-event {
  width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px 10px 10px; border-radius: 18px; text-align: left; color: #fff;
  background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.s-event img { width: 34px; height: 34px; border-radius: 10px; }
.s-event-text { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.s-event-name { font-weight: 700; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-event-bar { height: 4px; border-radius: 999px; background: rgba(255,255,255,.16); overflow: hidden; }
.s-event-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--lime); transition: width .5s var(--ease); }
.s-event-count { font: 700 17px/1 var(--display); white-space: nowrap; }
.s-event-count small { font: 500 11.5px var(--sans); color: #b3c0cb; margin-left: 2px; }

/* ---------- center: frame ---------- */
.s-center { position: relative; z-index: 2; flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; pointer-events: none; }
.frame { --s: min(68vw, 40vh, 300px); position: relative; width: var(--s); height: var(--s); flex: none; border-radius: 30px; box-shadow: 0 0 0 100vmax rgba(14,7,36,.5); overflow: hidden; }
.frame .c { position: absolute; width: 46px; height: 46px; border: 4px solid var(--lime); }
.frame .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 30px; }
.frame .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 30px; }
.frame .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 30px; }
.frame .br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 30px; }
.laser {
  position: absolute; left: 8%; right: 8%; top: 0; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--lime) 30%, var(--lime) 70%, transparent);
  box-shadow: 0 0 18px 3px rgba(62,240,176,.5);
  will-change: transform; animation: laser 2.4s ease-in-out infinite alternate;
}
@keyframes laser { from { transform: translateY(22px); } to { transform: translateY(calc(var(--s) - 25px)); } }
.s-hint {
  position: relative; z-index: 1; margin: 0; padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--glass-line);
}
.scanner.idle .s-center, .scanner.paused .laser { visibility: hidden; }

/* ---------- start ---------- */
.s-start {
  position: absolute; z-index: 4; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  padding: 0 28px; text-align: center; max-width: 400px; margin: 0 auto;
}
.s-start-ico { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 24px; display: grid; place-items: center; background: var(--grad); color: var(--on-brand); box-shadow: 0 18px 40px -12px rgba(62,240,176,.6); }
.s-start-ico .ico { width: 34px; height: 34px; }
.s-start h2 { font: 700 26px/1.12 var(--display); margin: 0 0 10px; letter-spacing: -.01em; }
.s-start p { color: #b3c0cb; margin: 0 0 24px; font-size: 14.5px; }

/* ---------- bottom bar ---------- */
.s-bar {
  position: relative; z-index: 5; margin: 0 14px calc(var(--safe-b) + 14px);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 6px;
  border-radius: 24px; background: var(--glass); border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.s-bar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 64px;
  border: 0; border-radius: 18px; background: transparent; color: #b3c0cb; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
}
.s-bar button:active { transform: scale(.96); background: rgba(255,255,255,.08); }
.s-bar-ico { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; transition: background .2s, color .2s, box-shadow .2s; }
.s-bar-ico .ico { width: 23px; height: 23px; }
.s-bar button[aria-pressed="true"] { color: var(--lime); }
.s-bar button[aria-pressed="true"] .s-bar-ico { background: var(--lime); color: var(--night); box-shadow: 0 0 22px rgba(62,240,176,.55); }

/* ---------- result ---------- */
.result {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; cursor: pointer; text-align: center;
  padding: calc(var(--safe-t) + 24px) 26px calc(var(--safe-b) + 26px);
  --a: #1c9a60; --b: #0d5a36;
  background: radial-gradient(120% 80% at 50% 38%, var(--a), var(--b));
  animation: res-in .18s ease both;
}
.result.already { --a: #e59a12; --b: #8d5600; }
.result.invalid { --a: #d2243a; --b: #6a0a1c; }
.result.error { --a: #4a5866; --b: #141c25; }
@keyframes res-in { from { opacity: 0; } to { opacity: 1; } }
.result-in { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.result-ico {
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 26px;
  background: rgba(255,255,255,.2); box-shadow: 0 0 0 14px rgba(255,255,255,.09);
  animation: pop-in .36s var(--ease) both;
}
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.result-ico svg { width: 58px; height: 58px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.result-ico .draw { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .36s .16s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.result-title, .result-name, .result-co, .result-meta { animation: rise-in .34s var(--ease) both; }
.result-title { animation-delay: .06s; font-size: 12.5px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.88); }
.result-name { animation-delay: .1s; font: 700 clamp(30px, 9vw, 44px)/1.06 var(--display); margin: 12px 0 8px; letter-spacing: -.02em; overflow-wrap: anywhere; max-width: 100%; }
.result-co { animation-delay: .14s; font-size: 17px; font-weight: 600; color: rgba(255,255,255,.9); }
.result-meta { animation-delay: .18s; margin-top: 22px; padding: 9px 16px; border-radius: 999px; background: rgba(0,0,0,.2); font-size: 14px; font-weight: 600; }
.result-meta:empty, .result-co:empty { display: none; }
.result-table { animation: rise-in .34s var(--ease) .16s both; margin-top: 20px; display: flex; flex-direction: column; align-items: center;
  min-width: 132px; padding: 10px 26px 12px; border-radius: 22px; background: #fff; color: #15121f; box-shadow: 0 14px 40px -12px rgba(0,0,0,.45); }
.result-table[hidden] { display: none; }
.result-table span { font-size: 12px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; color: #85858f; }
.result-table b { font: 800 clamp(44px, 15vw, 64px)/1 var(--display); letter-spacing: -.02em; }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-foot { font-size: 13px; color: rgba(255,255,255,.75); }
.result-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255,255,255,.6); transform-origin: left; }
.result-timer.run { animation: timer var(--dur, 3s) linear forwards; }
@keyframes timer { to { transform: scaleX(0); } }

/* ---------- sheets ---------- */
.sheet-scrim { position: absolute; inset: 0; z-index: 30; background: rgba(2,4,6,.65); animation: res-in .18s ease both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 88%; display: flex; flex-direction: column;
  padding: 10px 18px calc(var(--safe-b) + 18px); border-radius: 28px 28px 0 0;
  background: var(--card); color: var(--ink); box-shadow: 0 -18px 50px rgba(0,0,0,.4);
  animation: sheet-in .28s var(--ease) both; user-select: text; -webkit-user-select: text;
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 0 auto 14px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font: 700 22px/1.1 var(--display); }
.sheet-x { width: 38px; height: 38px; border: 0; border-radius: 12px; background: var(--raise); color: var(--ink-2); font-size: 22px; line-height: 1; cursor: pointer; }
.sheet .search { display: block; position: relative; margin-bottom: 8px; }
.sheet .search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.sheet .search .input { padding-left: 42px; height: 50px; font-size: 16px; }
.sheet-list { overflow-y: auto; margin: 0 -18px; padding: 0 18px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left;
  padding: 16px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-decoration: none; color: var(--ink); font-size: 15px; font-weight: 600;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item.static { cursor: default; }
.sheet-item b { color: var(--ink-3); font-weight: 600; font-size: 14px; white-space: nowrap; }
.sheet-item.on { color: var(--brand); }
.sheet-item .sub { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); margin-top: 3px; line-height: 1.4; }
.person { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .avatar { width: 42px; height: 42px; border-radius: 14px; }
.person.in .avatar { background: var(--ok-bg); color: var(--ok); }
.person .pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .pco { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .btn { height: 40px; }
.person .done { font-size: 12.5px; font-weight: 700; color: var(--ok); white-space: nowrap; }
.sheet-empty { padding: 30px 0; text-align: center; color: var(--ink-3); }

@media (min-width: 700px) {
  .s-top, .s-bar { width: 100%; max-width: 460px; margin-left: auto; margin-right: auto; }
  .sheet { max-width: 520px; margin: 0 auto; }
}
.gate-login { display: block; margin-top: 18px; text-align: center; font-size: 13.5px; font-weight: 600; color: var(--lime); text-decoration: none; }
