:root {
  --orange: #ff8c00;
  --blue: #4a90d9;
  --teal: #00bcd4;
  --green: #27ae60;
  --red: #e74c3c;
  --purple: #9b59b6;
  --text: #333;
  --bg: #f4f6f8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px 6px;
  flex-shrink: 0;
}
.header .title { font-size: 20px; font-weight: 600; color: var(--orange); }
.header .datetime { text-align: right; color: var(--red); font-size: 15px; line-height: 1.4; }
.bizid-row { padding: 0 18px 10px; color: var(--orange); font-size: 14px; flex-shrink: 0; word-break: break-all; }

.main { flex: 1; display: flex; gap: 14px; padding: 0 18px 14px; min-height: 0; }
.left-col { width: 34%; max-width: 340px; min-width: 190px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.box { border-radius: 10px; color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; padding: 10px; font-size: 14px; position: relative; overflow: hidden; }
.box img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.box-chip { background: var(--orange); flex: 1; min-height: 120px; }
.box-live { background: var(--blue); flex: 1; min-height: 120px; }
.box-tip { background: var(--green); flex: 1; min-height: 90px; font-size: 15px; line-height: 1.8; text-align: left; align-items: flex-start; }
.box-tip b { display:block; margin-bottom:8px; font-size:17px; }

.right-stage { flex: 1; background: var(--teal); border-radius: 10px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.right-stage .placeholder-text { color: #fff; font-size: 15px; }

#video, #captureCanvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像显示，符合"照镜子"的直觉体验 */
}
#overlayCanvas { position: absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; }
.action-banner { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.55); color: #fff; padding: 10px 20px; border-radius: 24px; font-size: 16px; z-index: 5; min-width: 60%; text-align: center; }
.action-dots { display:flex; gap:8px; justify-content:center; margin-top:6px; }
.action-dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.4); }
.action-dots span.done { background: #4CAF50; }
.action-dots span.active { background: #ffeb3b; }

.warn-banner { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: #ff3b30; font-weight: 700; font-size: 18px; z-index: 6; text-shadow: 0 1px 3px rgba(0,0,0,0.4); text-align: center; }

/* 调试面板：仅用于联调/测试阶段查看实时 EAR/MAR 数值，生产环境可在 config.json 里关闭 (liveness.debugOverlay: false) */
.debug-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.6);
  color: #0f0;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 10px;
  border-radius: 6px;
  z-index: 8;
  white-space: pre;
}

#pdfScroll { position: absolute; inset: 0; overflow-y: auto; background: #e6f9fa; padding: 10px; }
#pdfScroll canvas { display: block; margin: 0 auto 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); background:#fff; }

.sign-modal { position: absolute; inset: 0; background: var(--blue); display: none; flex-direction: column; z-index: 20; }
.sign-modal.open { display: flex; }
.sign-modal .sign-header { display:flex; justify-content: space-between; align-items:center; padding: 10px 14px; color:#fff; font-size:14px; }
.sign-modal .close-x { cursor:pointer; font-size:20px; line-height:1; padding:4px 10px; }
#signCanvas { flex:1; background:#fff; touch-action:none; margin: 0 12px 12px; border-radius: 8px; }
.sign-actions { display:flex; justify-content:flex-end; gap:10px; padding: 0 14px 14px; }

.footer {
  display: flex;
  align-items: center;
  justify-content: center; /* 主操作按钮（开始认证/签字确认/确认提交）在这一行水平居中 */
  position: relative;
  padding: 10px 18px 18px;
  flex-shrink: 0;
  min-height: 56px;
}
/* "返回"按钮固定在同一行的最左侧，不参与居中计算，不管它多宽都不会影响主按钮的居中位置 */
.footer #btnBack {
  position: absolute;
  left: 18px;
}
.btn { border: none; border-radius: 6px; padding: 13px 26px; font-size: 15px; color: #fff; cursor: pointer; font-weight: 600; min-width: 100px; transition: opacity .15s; }
.btn:active { opacity: 0.8; }
.btn:disabled { background: #b9bec4 !important; cursor: not-allowed; }
.btn-orange { background: var(--orange); }
.btn-blue { background: var(--blue); }
.btn-purple { background: var(--purple); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #ccc; }

.footer-hint { align-self: center; font-size: 12px; color: #999; }

.result-wrap { max-width: 480px; margin: 15vh auto 0; padding: 0 24px; }
.result-wrap h2 { color: var(--orange); font-size: 22px; }
.result-wrap.fail h2 { color: var(--red); }
.result-wrap p { color: var(--orange); font-size: 15px; }
.result-wrap.fail p { color: var(--red); }
.result-wrap .btn { margin-top: 20px; width: 100%; }

.loading-mask { position: fixed; inset: 0; background: rgba(255,255,255,0.85); display: none; align-items: center; justify-content: center; z-index: 999; flex-direction: column; gap: 12px; font-size: 15px; color: #555; }
.loading-mask.show { display: flex; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #ddd; border-top-color: var(--orange); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 14px; z-index: 1000; display:none; }

/* 闪光反射活体校验：短暂全屏点亮，用于观察人脸区域的亮度反射变化 */
#flashOverlay {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 150ms ease-out;
}

.img-viewer { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 998; }
.img-viewer.open { display: flex; }
.img-viewer img { max-width: 92%; max-height: 92%; border-radius: 6px; }

@media (max-width: 640px) {
  .main { flex-direction: column; }
  .left-col { width: 100%; max-width: none; flex-direction: row; }
  .box-tip { display: none; }
  .right-stage { min-height: 280px; }
  .header .title { font-size: 17px; }
}
