/* RAGper — styles */
:root {
  --paper: #F1F4F8; --surface: #FFFFFF; --ink: #172033; --ink2: #4A5568; --muted: #7B8597; --line: #DCE2EA;
  --brand: #1E3EBB; --brand-ink: #0E2272; --brand-soft: #E7ECFB;
  --ok: #128A4B; --ok-soft: #E3F5EA; --bad: #D2334A; --bad-soft: #FCE8EB;
  --c0: #2659E6; --c1: #DB8100; --c2: #7840E0; --c3: #CF3670;
  --r: 10px; --r-s: 6px;
  --font: 'Readex Pro', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-tap-highlight-color: transparent; }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* brand mark: a miniature answer card */
.mark { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.18em; margin-inline-end: .4em; border-radius: 2px;
  background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 6'%3E%3Cpath fill='%23fff' d='M1 1h1v1H1zM3 1h2v1H3zM2 2h1v2H2zM4 3h1v1H4zM1 4h1v1H1zM3 4h1v1H3z'/%3E%3C/svg%3E") center/100% no-repeat; }

/* ---------- shell ---------- */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
#nav { background: var(--brand-ink); color: #DCE3FF; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.brand { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: .3px; padding: 0 8px; }
.brand .mark, .sc-logo .mark { filter: invert(1); }
#navlist { display: flex; flex-direction: column; gap: 2px; }
#navlist a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-s); color: inherit; text-decoration: none; font-weight: 500; }
#navlist a:hover { background: rgba(255,255,255,.07); }
#navlist a.on { background: #fff; color: var(--brand-ink); }
.nav-foot { margin-top: auto; font-size: 12px; opacity: .6; padding: 0 8px; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#page { padding: 34px clamp(18px, 4vw, 48px) 60px; max-width: 1180px; width: 100%; }

/* ---------- headings & blocks ---------- */
.ph { margin-bottom: 26px; }
.ph h1 { font-size: 28px; line-height: 1.25; margin: 0 0 4px; font-weight: 700; letter-spacing: -.2px; }
.sub { color: var(--ink2); margin: 0; max-width: 68ch; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-size: 14px; }
.back::before { content: '› '; }
.block { margin-top: 34px; }
.block-h { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 14px; padding-bottom: 6px; }
.block-h h2 { font-size: 18px; margin: 0; font-weight: 600; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; } .row.center { justify-content: center; } .row.wrap { flex-wrap: wrap; }
.end-items { align-items: flex-end; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.empty, .emptybox p { color: var(--ink2); }
.emptybox { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 28px; background: var(--surface); }
.emptybox p { margin: 0; max-width: 62ch; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r-s); padding: 9px 16px; font-weight: 500; cursor: pointer; background: var(--surface); text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.primary:disabled { background: #9AA6C9; cursor: not-allowed; }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 5px 11px; font-size: 13.5px; }
.btn.big { padding: 13px 22px; font-size: 17px; }
.btn .ico { width: 18px; height: 18px; }
.danger-t { color: var(--bad) !important; }
.ibtn { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-s); cursor: pointer; font-size: 12px; }
.ibtn:disabled { opacity: .35; cursor: default; }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 200px; }
.fld > span, .fld-l { font-size: 13px; color: var(--ink2); font-weight: 500; margin: 0; }
.fld.sm { min-width: 0; } .fld.sm input { width: 84px; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { border: 1px solid var(--line); border-radius: var(--r-s); padding: 9px 11px; background: var(--surface); width: 100%; }
textarea { resize: vertical; line-height: 1.7; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-s); padding: 3px; background: var(--surface); margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 6px 16px; border-radius: 4px; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- home ---------- */
.launch { display: grid; grid-template-columns: 1.15fr 1fr; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.launch-form { padding: 26px 28px; }
.launch-form .btn { margin-top: 6px; }
.pair { display: flex; gap: 22px; align-items: center; padding: 24px 26px; background: var(--brand-soft); }
.pair.flat { background: none; padding: 0; }
.pair-qr svg { display: block; border-radius: 6px; border: 6px solid #fff; }
.pair-txt h3 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; font-size: 17px; }
.pair-txt p { margin: 0 0 6px; color: var(--ink2); font-size: 14px; }
.room { font-size: 30px; font-weight: 700; letter-spacing: 5px; color: var(--brand-ink); margin: 2px 0 8px; font-variant-numeric: tabular-nums; text-align: start; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13.5px !important; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #B5BDCB; display: inline-block; flex: none; }
.ok > .dot, .status.ok .dot { background: #1DB45E; box-shadow: 0 0 0 4px rgba(29,180,94,.18); }
.status.ok { color: var(--ok) !important; }

/* ---------- tables & lists ---------- */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tbl-wrap .tbl { border: 0; }
.tbl th { text-align: start; font-weight: 500; color: var(--ink2); font-size: 13px; background: #F7F9FB; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid #EDF0F4; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.dense td, .tbl.dense th { padding: 7px 10px; }
.tbl .cell { text-align: center; font-weight: 600; min-width: 38px; }
.tbl .qh { text-align: center; }
.cell.ok { color: var(--ok); background: var(--ok-soft); } .cell.no { color: var(--bad); background: var(--bad-soft); } .cell.na { color: #C0C6D0; }
.clk { cursor: pointer; } tr.clk:hover td { background: #F8FAFE; }
.mbar { display: inline-block; width: 90px; height: 7px; background: #E8ECF2; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.mbar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.clist { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.crow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid #EDF0F4; }
.crow:last-child { border-bottom: 0; }
.crow h3 { margin: 0; font-size: 16px; font-weight: 600; } .crow p { margin: 0; color: var(--muted); font-size: 13.5px; }
.crow.clk:hover { background: #F8FAFE; }

/* ---------- question editor ---------- */
.title-in { font-size: 24px; font-weight: 700; border: 0 !important; border-bottom: 2px dashed var(--line) !important; border-radius: 0 !important; background: none !important; padding: 2px 0 !important; max-width: 560px; }
.title-in:focus { border-bottom-color: var(--brand) !important; outline: 0; }
.sm-in { width: 190px !important; }
.qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.qitem { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.qnum { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.qtext { font-size: 16px; font-weight: 500; }
.qthumb { max-height: 120px; max-width: 260px; border-radius: 6px; border: 1px solid var(--line); margin-top: 8px; display: block; }
.qchoices { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; color: var(--ink2); }
.qchoices li.ok { color: var(--ok); font-weight: 600; }
.qchoices li b { display: inline-block; width: 1.6em; }
.qact { display: flex; gap: 6px; align-items: flex-start; }
.chrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-s); border: 1px solid transparent; margin-bottom: 6px; cursor: pointer; }
.chrow.on { border-color: var(--ok); background: var(--ok-soft); }
.chrow input[type=radio] { accent-color: var(--ok); width: 18px; height: 18px; flex: none; }
.chl { width: 30px; height: 30px; flex: none; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 700; }
.chl.c0, .lv-opt.c0 { background: var(--c0); } .chl.c1, .lv-opt.c1 { background: var(--c1); } .chl.c2, .lv-opt.c2 { background: var(--c2); } .chl.c3, .lv-opt.c3 { background: var(--c3); }
.tf { font-weight: 600; }
.preview { background: #F7F9FB; border-radius: var(--r-s); padding: 0 10px; margin: -6px 0 12px; }
.preview:not(:empty) { padding: 10px; }
.math .katex { font-size: 1.08em; }

/* ---------- cards page ---------- */
.cards-hero { display: grid; grid-template-columns: auto 1fr; gap: 34px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 26px 30px; }
.demo-card svg { width: 220px; height: 220px; display: block; transform: rotate(-4deg); box-shadow: 0 10px 30px -12px rgba(23,32,51,.35); border-radius: 8px; }
.cards-hero h2 { margin: 0 0 8px; font-size: 18px; }
.steps { margin: 0; padding-inline-start: 20px; color: var(--ink2); } .steps li { margin-bottom: 6px; }
.card-svg .cl { font: 600 5.2px var(--font); fill: #3B4456; }
.card-svg .cn { font: 700 4.2px var(--font); fill: #8A93A3; }
.card-svg .nm { font: 500 3.4px var(--font); fill: #5A6375; }
.card-svg .brand { font: 600 2.8px var(--font); fill: #B4BBC7; }

/* ---------- stats & reports ---------- */
.stats { display: flex; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 22px; }
.stats > div { flex: 1; padding: 16px 22px; border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; }
.stats > div:first-child { border-inline-start: 0; }
.stats b { font-size: 28px; font-weight: 700; color: var(--brand-ink); line-height: 1.2; }
.stats span { color: var(--ink2); font-size: 13.5px; }
.tabs { margin-bottom: 16px; }
.qres { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.qres > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.qres-h { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: start; margin-bottom: 12px; }
.big-pct { font-size: 22px; color: var(--ink2); } .big-pct.good { color: var(--ok); } .big-pct.bad { color: var(--bad); }
.dist { display: flex; flex-direction: column; gap: 6px; }
.drow { display: grid; grid-template-columns: 30px minmax(120px, 1.3fr) 2fr 36px; gap: 12px; align-items: center; }
.drow .chl { width: 26px; height: 26px; font-size: 13px; }
.drow.ok .dtxt { font-weight: 600; color: var(--ok); }
.dbar { height: 10px; background: #EDF0F4; border-radius: 5px; overflow: hidden; } .dbar i { display: block; height: 100%; background: #9AA8C7; }
.drow.ok .dbar i { background: var(--ok); }

/* ---------- modal & toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(14,22,40,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; padding: 24px 26px; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 30px 60px -20px rgba(10,20,50,.4); }
.modal.wide { width: min(680px, 100%); }
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.confirm-msg { font-size: 16px; margin: 0 0 18px; }
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 90; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14.5px; transition: opacity .4s, transform .4s; box-shadow: 0 10px 24px -10px rgba(0,0,0,.5); }
.toast.ok { background: var(--ok); } .toast.err { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* =================== LIVE PRESENTATION =================== */
#live { position: fixed; inset: 0; z-index: 40; background: #F6F8FB; overflow: auto; }
body.live-on { overflow: hidden; }
.lv { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; padding: 0 clamp(16px, 2.6vw, 44px); }
.lv-top { display: flex; align-items: center; gap: 22px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.lv-brand { font-weight: 700; font-size: 20px; color: var(--brand-ink); }
.lv-meta { display: flex; flex-direction: column; line-height: 1.3; } .lv-meta span { color: var(--muted); font-size: 14px; }
.lv-prog { margin-inline-start: auto; font-size: 17px; color: var(--ink2); }
.lv-phone { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.lv-phone.ok { color: var(--ok); }
.lv-count { display: flex; align-items: baseline; gap: 6px; background: var(--brand-ink); color: #fff; padding: 4px 16px; border-radius: 30px; }
.lv-count b { font-size: 30px; line-height: 1.25; } .lv-count span { opacity: .75; font-size: 18px; }
.lv-main { padding: clamp(18px, 3vh, 40px) 0; display: grid; grid-template-columns: 1fr; gap: clamp(16px, 2.6vh, 30px); align-content: center; }
.lv-main.has-img { grid-template-columns: 1.1fr .9fr; grid-template-areas: "q img" "ch img"; }
.lv-main.has-img .lv-q { grid-area: q; } .lv-main.has-img .lv-ch { grid-area: ch; }
.lv-img { grid-area: img; max-width: 100%; max-height: 52vh; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); align-self: center; justify-self: center; }
.lv-q { font-weight: 600; line-height: 1.45; color: var(--ink); }
.lv-q.tl { font-size: clamp(30px, 3.6vw, 64px); } .lv-q.tm { font-size: clamp(24px, 2.7vw, 46px); } .lv-q.ts { font-size: clamp(20px, 2vw, 34px); }
.lv-ch { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 1.4vw, 20px); }
.lv-opt { border-radius: 14px; color: #fff; padding: clamp(12px, 1.6vh, 22px) clamp(14px, 1.4vw, 24px); display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 18px; min-height: clamp(70px, 11vh, 130px); transition: opacity .35s, filter .35s; position: relative; }
.lv-l { font-size: clamp(30px, 3vw, 54px); width: 1.4em; height: 1.4em; display: grid; place-items: center; background: rgba(255,255,255,.2); border-radius: 10px; line-height: 1; }
.lv-t { font-size: clamp(20px, 2.1vw, 38px); font-weight: 500; line-height: 1.35; }
.lv-t .katex { color: #fff; }
.lv-ch.rev .lv-opt.wrong { filter: saturate(.25); opacity: .55; }
.lv-ch.rev .lv-opt.right { box-shadow: 0 0 0 5px #fff, 0 0 0 10px var(--ok); }
.lv-ch.rev .lv-opt.right::after { content: '✓'; position: absolute; top: -16px; inset-inline-end: -10px; width: 40px; height: 40px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 24px; display: grid; place-items: center; font-weight: 700; }
.lv-res { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; margin-top: 10px; }
.lv-bar { height: 12px; background: rgba(255,255,255,.28); border-radius: 6px; overflow: hidden; } .lv-bar i { display: block; height: 100%; background: #fff; border-radius: 6px; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.lv-res b { font-size: clamp(20px, 1.8vw, 30px); } .lv-n { opacity: .8; font-size: 16px; }
.lv-who { grid-column: 1 / -1; font-size: 15px; margin-top: 6px; opacity: .95; }
.lv-roster { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 6px; border-radius: 8px; border: 1.5px dashed #C3CAD6; color: #8D96A6; font-size: 15px; background: #fff; transition: background .25s, color .25s, transform .25s, border-color .25s; }
.chip b { min-width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; background: #EEF1F5; font-size: 13px; color: #8D96A6; }
.chip.in { background: var(--brand-ink); border: 1.5px solid var(--brand-ink); color: #fff; transform: translateY(-2px); }
.chip.in b { background: #fff; color: var(--brand-ink); }
.chip.in.ok { background: var(--ok); border-color: var(--ok); } .chip.in.ok b { color: var(--ok); }
.chip.in.no { background: var(--bad); border-color: var(--bad); } .chip.in.no b { color: var(--bad); }
@media (prefers-reduced-motion: no-preference) { .chip.pop { animation: pop .45s ease; } }
@keyframes pop { 0% { transform: rotate(-90deg) scale(.7); } 70% { transform: rotate(6deg) scale(1.06); } 100% { transform: translateY(-2px); } }
.lv-bar-ctl { display: flex; gap: 10px; align-items: center; padding: 12px 0 18px; }
.lv-bar-ctl .sp { flex: 1; }
.lbtn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px 26px; font-size: 17px; font-weight: 500; cursor: pointer; }
.lbtn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.lbtn:disabled { opacity: .4; cursor: default; }
.lbtn.main { background: var(--brand); color: #fff; border-color: var(--brand); }
.lbtn.main:hover { background: var(--brand-ink); color: #fff; }
.lbtn.ghost { background: none; color: var(--muted); }
.lv-end { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.lv-end h1 { font-size: 46px; margin: 0; }
.stats.big { min-width: min(760px, 100%); } .stats.big b { font-size: 46px; }

/* =================== PHONE SCANNER =================== */
#scan { position: fixed; inset: 0; z-index: 45; background: #0D1730; color: #E9EEFF; overflow: auto; }
body.scan-on #app { display: none; }
.sbtn { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.08); color: #fff; border-radius: 12px; padding: 13px 16px; font-size: 16px; font-weight: 500; cursor: pointer; }
.sbtn:disabled { opacity: .35; }
.sbtn.main { background: #3D66FF; border-color: #3D66FF; }
.sbtn.huge { width: 100%; padding: 22px; font-size: 22px; font-weight: 700; border-radius: 16px; }
.sc-logo { font-size: 21px; font-weight: 700; color: #fff; }

.sc-pair { min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 28px 24px; max-width: 460px; margin: 0 auto; }
.sc-pair h1 { font-size: 26px; margin: 18px 0 0; line-height: 1.35; }
.sc-pair p { color: #AEB9DA; margin: 0 0 10px; }
.sc-or { text-align: center; color: #8592BA; font-size: 14px; margin-top: 6px; }
.sc-code { display: flex; gap: 8px; }
.sc-code input { flex: 1; background: rgba(255,255,255,.06) !important; border: 1px solid rgba(255,255,255,.2) !important; color: #fff; font-size: 22px; letter-spacing: 6px; text-align: center; text-transform: uppercase; border-radius: 12px !important; }
.sc-link { color: #9FB2FF; background: none; border: 0; font-size: 14px; text-align: center; margin-top: 12px; cursor: pointer; }
.sc-home { min-height: 100%; display: flex; flex-direction: column; gap: 18px; padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }
.sc-h { display: flex; justify-content: space-between; align-items: center; }
.sc-conn { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #AEB9DA; }
.sc-conn.ok { color: #6EE3A0; }
.sc-now { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 18px; }
.sc-cls { color: #AEB9DA; margin: 0; font-size: 14px; }
.sc-now h2 { margin: 6px 0; font-size: 26px; }
.sc-qt { margin: 0 0 10px; color: #D5DCF5; }
.sc-cnt { margin: 0; color: #AEB9DA; } .sc-cnt b { color: #fff; font-size: 22px; }
.sc-ctl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sc-wait { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.sc-wait p { color: #AEB9DA; max-width: 30ch; margin: 0; }
.pulse { width: 64px; height: 64px; border-radius: 10px; background: #fff; margin-bottom: 12px; position: relative; }
.pulse::after { content: ''; position: absolute; inset: 14px; background: #0D1730; }
@media (prefers-reduced-motion: no-preference) { .pulse { animation: tilt 2.4s ease-in-out infinite; } }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(90deg); } 50% { transform: rotate(180deg); } 75% { transform: rotate(270deg); } }
.sc-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; color: #8592BA; font-size: 14px; }
.sc-foot b { color: #fff; letter-spacing: 2px; }
.sc-cam { position: fixed; inset: 0; background: #000; }
.sc-cam video, #scO { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sc-cam-top { position: absolute; top: 0; inset-inline: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 26px; background: linear-gradient(rgba(0,0,0,.65), transparent); font-size: 15px; }
.sc-cam-top b { font-size: 22px; }
.sc-state { background: #1DB45E; color: #fff; padding: 2px 10px; border-radius: 20px; font-size: 13px; } .sc-state.rev { background: #DB8100; }
.sc-cam-bot { position: absolute; bottom: 0; inset-inline: 0; display: grid; grid-template-columns: 1fr 1fr 1fr 1.3fr; gap: 8px; padding: 30px 12px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.sc-cam-bot .sbtn { padding: 13px 6px; background: rgba(20,28,50,.6); backdrop-filter: blur(6px); }
.sc-cam-bot .sbtn.main { background: #3D66FF; }
.sc-tools { position: absolute; inset-inline-end: 12px; top: 72px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tbtn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(20,28,50,.6); color: #fff; font-size: 20px; }
.tbtn.on { background: #FFD24A; color: #000; }
.sc-miss { position: absolute; bottom: 92px; inset-inline: 12px; max-height: 34vh; overflow: auto; background: rgba(13,23,48,.9); border-radius: 12px; padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.sc-miss span { background: rgba(255,255,255,.1); border-radius: 6px; padding: 3px 9px; font-size: 14px; }
.qr-frame { position: absolute; top: 50%; left: 50%; width: 64vmin; height: 64vmin; transform: translate(-50%, -50%); border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }

/* =================== PRINT =================== */
#printArea { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; }
  body.printing { background: #fff; }
  .sheet { width: 210mm; height: 297mm; display: flex; flex-wrap: wrap; align-content: space-evenly; justify-content: space-evenly; page-break-after: always; break-after: page; overflow: hidden; }
  .sheet.per1 .cardcell, .sheet.per2 .cardcell { width: 100%; display: flex; justify-content: center; }
  .sheet.per4 .cardcell { width: 50%; display: flex; justify-content: center; }
  .card-svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =================== RESPONSIVE =================== */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #nav { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; gap: 10px; }
  #navlist { flex-direction: row; } #navlist a span { white-space: nowrap; }
  .nav-foot { display: none; }
  .launch { grid-template-columns: 1fr; }
  .cards-hero { grid-template-columns: 1fr; justify-items: center; }
  .lv-main.has-img { grid-template-columns: 1fr; grid-template-areas: "q" "img" "ch"; }
  .ph.row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .ph .row.gap { flex-wrap: wrap; }
  .qitem { grid-template-columns: 34px 1fr; } .qact { grid-column: 1 / -1; justify-content: flex-end; }
  .stats { flex-direction: column; } .stats > div { border-inline-start: 0; border-top: 1px solid var(--line); } .stats > div:first-child { border-top: 0; }
}

/* =================== v2: accounts, feedback, zoom =================== */
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--brand); cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.col { display: flex; flex-direction: column; } .col.gap { gap: 10px; }
.nav-user { display: flex; flex-direction: column; line-height: 1.35; margin-bottom: 6px; }
.nav-user b { color: #fff; font-size: 14px; font-weight: 600; opacity: 1; }
.nav-user span { font-size: 11.5px; word-break: break-all; }
#nav .linkbtn { color: #B9C6FF; font-size: 13px; }
.nav-foot { opacity: .85; }

/* sign-in */
#auth { position: fixed; inset: 0; z-index: 30; overflow: auto; background: var(--brand-ink); }
.au { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 16px; gap: 18px; }
.au-card { width: min(420px, 100%); background: var(--surface); border-radius: 14px; padding: 28px 28px 24px; box-shadow: 0 30px 70px -30px rgba(0,0,0,.6); }
.au-brand { font-size: 24px; font-weight: 700; color: var(--brand-ink); margin-bottom: 18px; }
.au-card h2 { font-size: 20px; margin: 0 0 8px; }
.au-card p { color: var(--ink2); margin: 0 0 16px; }
.au-tabs { width: 100%; margin-bottom: 18px; } .au-tabs button { flex: 1; }
.au-go { width: 100%; justify-content: center; margin-top: 4px; }
#auForm .linkbtn { display: block; margin: 12px auto 0; }
.au-foot { color: #AEB9DA; font-size: 14px; margin: 0; } .au-foot a { color: #fff; }

/* supervisor */
.tgrid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; }
.panel h2 { font-size: 17px; margin: 0 0 12px; }
.panel p { color: var(--ink2); margin: 0 0 10px; }
.tc-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: end; }
.tc-form .fld { min-width: 0; } .tc-form .btn { justify-self: start; margin-bottom: 14px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.no { background: var(--bad-soft); color: var(--bad); }
.tbl tr.off td { color: var(--muted); }
.tbl td.acts { white-space: nowrap; } .tbl td.acts .btn { margin-inline-end: 4px; }
.cred { background: #F3F6FB; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font: inherit; white-space: pre-wrap; margin: 0 0 16px; }
#viewBanner { position: fixed; top: 0; inset-inline-start: 232px; inset-inline-end: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #FFF4DB; border-bottom: 1px solid #F0D58C; color: #6B4A00; padding: 10px clamp(18px, 4vw, 48px); }
body.viewing #page { padding-top: 84px; }
body.live-on #viewBanner, body.scan-on #viewBanner { display: none; }

/* question editor: explanation */
.fb-edit { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 14px; }
.qexp-tag { margin: 6px 0 0; font-size: 12.5px; color: var(--ok); font-weight: 500; }
.qres-exp { margin-top: 12px; background: #F4F8F5; border-inline-start: 3px solid var(--ok); border-radius: 6px; padding: 10px 12px; color: var(--ink2); }

/* live: feedback after reveal */
.lv-main.with-fb { align-content: start; padding-top: clamp(12px, 2vh, 24px); gap: clamp(10px, 1.6vh, 18px); }
.lv-main.with-fb .lv-opt { min-height: clamp(56px, 8vh, 96px); padding-block: clamp(8px, 1.1vh, 14px); }
.lv-main.with-fb.has-img { grid-template-areas: "q img" "ch img" "fb fb"; }
.lv-main.with-fb.has-img .lv-fb { grid-area: fb; }
.lv-fb { display: flex; flex-direction: column; gap: 12px; }
@media (prefers-reduced-motion: no-preference) { .lv-fb { animation: fbIn .5s cubic-bezier(.2,.8,.2,1); } }
@keyframes fbIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.lv-cheer { display: flex; align-items: center; gap: 18px; border-radius: 12px; padding: 12px 22px; font-size: clamp(19px, 1.7vw, 30px); font-weight: 600; }
.lv-cheer b { font-size: 1.5em; line-height: 1; }
.lv-cheer.top { background: #DFF5E8; color: #0C6B39; }
.lv-cheer.good { background: #E4EEFF; color: #1C3FA8; }
.lv-cheer.mid { background: #FFF1D6; color: #8A5300; }
.lv-cheer.low { background: #FDE6EA; color: #A4223A; }
.lv-exp { background: #fff; border: 1px solid var(--line); border-inline-start: 6px solid var(--ok); border-radius: 12px; padding: 14px 22px; }
.lv-exp h3 { margin: 0 0 6px; font-size: clamp(16px, 1.2vw, 20px); color: var(--ok); }
.lv-exp-b { display: flex; gap: 20px; align-items: flex-start; }
.lv-exp-t { flex: 1; font-size: clamp(19px, 1.7vw, 32px); line-height: 1.6; }
.lv-exp-b img { max-height: 26vh; max-width: 40%; border-radius: 8px; border: 1px solid var(--line); }

/* scanner: zoom */
.sc-cam { overflow: hidden; touch-action: none; }
.sc-cam video { transform-origin: 50% 50%; transition: transform .15s ease-out; }
.sc-zoom { position: absolute; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: rgba(13,23,48,.6); backdrop-filter: blur(6px); padding: 5px; border-radius: 30px; }
.sc-zoom button { min-width: 46px; height: 38px; border-radius: 20px; border: 0; background: transparent; color: #fff; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sc-zoom button.on { background: #FFD24A; color: #111; }
.sc-zoom span:empty { display: none; } .sc-zoom span { color: #FFD24A; padding: 0 8px; font-size: 14px; }
.sc-miss { bottom: calc(140px + env(safe-area-inset-bottom)); }

@media (max-width: 900px) {
  .tgrid, .tc-form { grid-template-columns: 1fr; }
  #viewBanner { flex-wrap: wrap; inset-inline-start: 0; top: auto; bottom: 0; border-top: 1px solid #F0D58C; }
  body.viewing #page { padding-top: 34px; padding-bottom: 110px; }
  .lv-exp-b { flex-direction: column; } .lv-exp-b img { max-width: 100%; }
}
/* supervisor read-only view: hide editing controls */
body.viewing [data-del], body.viewing [data-edit], body.viewing [data-dup], body.viewing [data-e], body.viewing [data-up], body.viewing [data-dn], body.viewing [data-x],
body.viewing #cNew, body.viewing #cImp, body.viewing #sNew, body.viewing #sImp, body.viewing #seAdd, body.viewing #stImp, body.viewing #stRoom { display: none !important; }
body.viewing .title-in, body.viewing #seSubj { pointer-events: none; }
