:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7f9;
  --card: #fff;
  --brand: #0f766e;
  --brand-ink: #ecfdf5;
  --ok: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; padding: 24px 16px 40px; }
a { color: var(--brand); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.narrow { max-width: 520px; margin: 0 auto; }
h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 8px; }
.muted { color: var(--muted); line-height: 1.5; }
.fine { color: var(--muted); font-size: 12px; margin-top: 18px; }
.step-kicker { color: var(--brand); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.prose p { line-height: 1.6; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 12px 18px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn.link { background: none; color: var(--muted); padding: 12px 8px; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.file { position: relative; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
form.inline { display: inline; }

.checklist { padding: 0; list-style: none; margin: 18px 0; }
.checklist li { padding: 8px 0 8px 30px; position: relative; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 9px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-ink); border: 2px solid var(--brand); }

.handoff { display: flex; gap: 20px; align-items: center; border: 1px dashed var(--line); border-radius: 12px; padding: 16px; margin-top: 8px; }
.qr { border-radius: 8px; flex-shrink: 0; }
.waiting { display: flex; align-items: center; gap: 8px; color: var(--brand); font-weight: 600; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.or { text-align: center; position: relative; margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.or::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.or span { background: #fff; padding: 0 10px; position: relative; }
@media (max-width: 560px) { .handoff { flex-direction: column; text-align: center; } .waiting { justify-content: center; } }

.progress { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 20px; counter-reset: s; }
.progress li { flex: 1; font-size: 12px; color: var(--muted); border-top: 3px solid var(--line); padding-top: 6px; }
.progress li.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }

.cam { position: relative; background: #0b1220; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; margin-top: 12px; }
.cam video, .cam img.shot { width: 100%; height: 100%; object-fit: cover; }
.face-frame { aspect-ratio: 3 / 4; max-width: 320px; margin-left: auto; margin-right: auto; }
.face-frame video { transform: scaleX(-1); }
.frame-guide { position: absolute; inset: 14% 8%; border: 2px solid rgba(255, 255, 255, .8); border-radius: 12px; pointer-events: none; }
.oval-guide { position: absolute; inset: 12% 16% 18%; border: 2px solid rgba(255, 255, 255, .8); border-radius: 50%; pointer-events: none; }
.cam .nocam { color: #94a3b8; font-size: 14px; padding: 20px; text-align: center; }

.idcard { display: flex; gap: 16px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: linear-gradient(135deg, #f0fdfa, #fff); margin-top: 12px; }
.idcard-photo { width: 84px; height: 108px; border-radius: 8px; background: #cbd5e1 center/cover; flex-shrink: 0; }
.idcard-body { flex: 1; display: grid; gap: 10px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select { font: inherit; color: var(--ink); padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 10px 0; }
.check.small { font-size: 12px; margin: 0; }

.center { text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 1s linear infinite; margin: 10px auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.checks { list-style: none; padding: 0; text-align: left; max-width: 320px; margin: 16px auto 0; }
.checks li { padding: 6px 0 6px 28px; position: relative; color: var(--muted); }
.checks li::before { content: "○"; position: absolute; left: 4px; }
.checks li.done { color: var(--ink); }
.checks li.done::before { content: "✓"; color: var(--ok); font-weight: 700; }
.icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 14px; font-size: 28px; font-weight: 700; }
.icon.ok { background: #dcfce7; color: var(--ok); }
.icon.bad { background: #fee2e2; color: var(--bad); }

/* presenter console */
body.wide main { max-width: 1280px; margin: 0 auto; width: 100%; }
.admin { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.admin .trace-card { grid-column: 1 / -1; }
@media (max-width: 900px) { .admin { grid-template-columns: 1fr; } }
.kv { border-collapse: collapse; width: 100%; font-size: 13px; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 10px 6px 0; white-space: nowrap; vertical-align: top; }
.kv td { padding: 6px 0; word-break: break-all; }
.kv code.copy { cursor: pointer; background: #f1f5f9; padding: 2px 6px; border-radius: 6px; }
.warn { color: var(--warn); background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.saved { min-height: 1.2em; font-size: 12px; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details .field { margin-top: 10px; }
.trace-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trace-head > div { display: flex; gap: 12px; align-items: center; }
.trace { grid-template-columns: minmax(0, 1fr); max-height: 70vh; overflow: auto; margin-top: 10px; display: grid; gap: 8px; }
.evt { min-width: 0; border: 1px solid var(--line); border-left: 4px solid #94a3b8; border-radius: 8px; padding: 8px 12px; background: #fff; }
.evt.ok { border-left-color: var(--ok); }
.evt.warn { border-left-color: var(--warn); }
.evt.error { border-left-color: var(--bad); background: #fff7f7; }
.evt-head { display: flex; gap: 10px; align-items: baseline; font-size: 13px; cursor: pointer; }
.evt-step { font-family: ui-monospace, monospace; color: var(--muted); font-size: 12px; }
.evt-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.evt pre { margin: 8px 0 0; background: #0b1220; color: #e2e8f0; padding: 10px 12px; border-radius: 6px; overflow: auto; font-size: 12px; line-height: 1.45; max-height: 420px; }
.evt pre .k { color: #7dd3fc; } .evt pre .s { color: #bbf7d0; } .evt pre .hl { background: #134e4a; border-radius: 3px; }
.flowsep { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 8px; }
