/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 确保 hidden 属性始终生效（避免被下方 display:flex 等规则覆盖） */
[hidden] { display: none !important; }

:root {
  --primary: #2f6bff;
  --primary-dark: #1f56d6;
  --danger: #e5484d;
  --text: #1f2329;
  --text-sub: #8a9099;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e6e8eb;
  --radius: 14px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 头部 ===== */
.app-header {
  padding: 22px 20px 18px;
  background: linear-gradient(135deg, #2f6bff 0%, #5b8cff 100%);
  color: #fff;
}
.app-header h1 { font-size: 22px; font-weight: 600; }
.app-sub { margin-top: 4px; font-size: 13px; opacity: 0.85; }

/* ===== 主体 ===== */
.app-main { padding: 16px; max-width: 560px; margin: 0 auto; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 12px rgba(31, 35, 41, 0.06);
}

.step-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.step-title h2 { font-size: 18px; font-weight: 600; }

.btn-icon {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--text-sub);
  cursor: pointer;
}

/* ===== 表单 ===== */
.field-label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 15px; }

.search-row { display: flex; gap: 10px; }
.text-input {
  flex: 1;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  background: #fafbfc;
}
.text-input:focus { border-color: var(--primary); background: #fff; }

.hint { margin-top: 8px; font-size: 12px; color: var(--text-sub); }
.hint.center { text-align: center; }

/* ===== 按钮 ===== */
.btn {
  height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):active { background: var(--primary-dark); }

.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }

.btn-block { width: 100%; margin-top: 14px; }
.btn-group { display: flex; gap: 10px; margin-top: 16px; }
.btn-group .btn { flex: 1; }

/* ===== 账户列表 ===== */
.result-list { list-style: none; margin-top: 10px; }

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.result-item.selected { border-color: var(--primary); background: #f0f5ff; }

.result-avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dbe6ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
}
.result-info { flex: 1; min-width: 0; }
.result-name { font-size: 16px; font-weight: 600; }
.result-meta { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.result-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
}
.result-item.selected .result-radio { border-color: var(--primary); }
.result-item.selected .result-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary);
}

.empty { text-align: center; color: var(--text-sub); padding: 30px 0; font-size: 14px; }

/* ===== 摄像头 ===== */
.camera-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.camera-video { width: 100%; height: 100%; object-fit: cover; }

.face-frame { position: absolute; inset: 12%; pointer-events: none; }
.face-frame .corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.9);
}
.corner.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 8px; }
.corner.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 8px; }
.corner.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 8px; }
.corner.br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 8px; }

.btn-flip {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.btn-flip:active { background: rgba(0, 0, 0, 0.65); }

.camera-error {
  position: absolute;
  inset: 0;
  background: #111;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
}
.camera-error .err-detail { font-size: 12px; color: #aaa; word-break: break-all; }

/* ===== 预览 ===== */
.preview-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-img { width: 100%; height: 100%; object-fit: cover; }

/* ===== 加载遮罩 ===== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  color: #fff;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 轻提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  max-width: 80%;
  text-align: center;
}
