* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #000; color: #fff;
  max-width: 480px; margin: 0 auto; height: 100vh; overflow: hidden;
  font-size: 20px; /* 适老化：基准字号 20px */
}
#app { position: relative; height: 100%; display: flex; flex-direction: column; }

/* ---------- 相机取景 ---------- */
.stage {
  position: relative; flex: 1; overflow: hidden; background: #111;
}
#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- 顶部状态条（两行固定布局） ---------- */
.top-bar {
  position: absolute; top: 12px; left: 14px; right: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.tb-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.tb-row > * { pointer-events: auto; }
.step-pill {
  background: rgba(10,12,16,.92); /* SaaS 深色胶囊 + 细描边 */
  border: 1px solid rgba(255,255,255,.14);
  padding: 10px 20px; border-radius: 999px; font-size: 22px; font-weight: 800;
  color: #fff; white-space: nowrap;
}
.step-pill span:first-child { color: #4ade80; }
.step-pill span:last-child { color: #fff; }
.status-pill {
  margin-left: auto; background: rgba(10,12,16,.92);
  border: 1px solid rgba(255,255,255,.14);
  padding: 10px 20px; border-radius: 999px; font-size: 20px; font-weight: 700;
  color: #fff; transition: background .3s, border-color .3s; white-space: nowrap;
}
.status-pill.aligned { background: #16a34a; border-color: #4ade80; color: #fff; }
.status-pill.review { background: #2563eb; border-color: #7db4ff; color: #fff; }
.status-pill.reject { background: #dc2626; border-color: #f87171; color: #fff; }

/* ---------- 录制指示器（随流布局，在第二行右侧） ---------- */
.rec-indicator {
  display: flex; align-items: center; gap: 8px;
  background: #dc2626;
  padding: 8px 18px; border-radius: 999px; font-size: 20px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- 任务标题（锚定在对焦框上方，永不与框体重叠） ---------- */
.task-title {
  position: absolute; left: 0; right: 0; z-index: 5;
  top: auto; bottom: calc(40% + 21vmin + 18px); /* 对齐 drawCenteredFrame：框顶 = 60%高 - 21vmin */
  text-align: center; pointer-events: none; padding: 0 20px;
}
.task-area {
  font-size: 24px; letter-spacing: 3px; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,1), 0 0 4px rgba(0,0,0,.8); font-weight: 600;
}
.task-name {
  margin-top: 8px; font-size: 38px; font-weight: 800; letter-spacing: 1px;
  text-shadow: 0 2px 16px rgba(0,0,0,1), 0 0 6px rgba(0,0,0,.8);
}

/* ---------- 进度点 ---------- */
.progress-dots {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 12px;
}
.progress-dots .pd { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.35); transition: all .3s; }
.progress-dots .pd.done { background: #4ade80; }
.progress-dots .pd.current { background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.25); width: 36px; border-radius: 8px; }

/* ---------- 底部操作区 ---------- */
.bottom-sheet {
  position: relative; z-index: 10; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #171b25, #0f1117); /* SaaS 深色底 */
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 14px;
}
.guidance {
  display: flex; align-items: center; gap: 14px;
  background: #1a1d26; border: 1px solid #2c3140; border-radius: 16px;
  padding: 16px; font-size: 20px; color: #fff; min-height: 64px; line-height: 1.5;
}
.guide-dot { flex: none; width: 16px; height: 16px; border-radius: 50%; background: #22c55e; animation: breathe-dot 1.6s ease-in-out infinite; }
.guidance.reject .guide-dot { background: #f87171; animation: breathe-dot-red 1.6s ease-in-out infinite; }
.guidance.reject { border-color: rgba(248,113,113,.5); }
@keyframes breathe-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
@keyframes breathe-dot-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(248,113,113,0); }
}

/* ---------- 拍摄控制行 ---------- */
.capture-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px;
}

/* 暂停按钮 */
.ctrl-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: none; background: transparent; cursor: pointer;
  color: #fff; transition: transform .15s ease;
  min-width: 72px; padding: 8px;
}
.ctrl-btn:active { transform: scale(.88); }
.pause-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(255,255,255,.2); border: 3px solid rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.pause-icon::before, .pause-icon::after {
  content: ''; position: absolute; width: 6px; height: 24px;
  background: #fff; border-radius: 3px;
}
.pause-icon::before { left: 19px; }
.pause-icon::after { right: 19px; }
.pause-icon.resumed::before, .pause-icon.resumed::after { display: none; }
.pause-icon.resumed {
  background: #16a34a; border-color: #22c55e;
}
.pause-icon.resumed::before {
  content: ''; position: absolute; width: 0; height: 0;
  border-left: 18px solid #fff; border-top: 12px solid transparent; border-bottom: 12px solid transparent;
  left: 23px; display: block;
}
.pause-icon.resumed::after { display: none; }
.ctrl-label { font-size: 18px; font-weight: 700; }

/* 拍照按钮（底部居中大圆） */
.capture-btn {
  width: 88px; height: 88px; border-radius: 50%; border: 5px solid #fff;
  background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease; position: relative;
}
.capture-btn:active { transform: scale(.88); }
.capture-btn:not(:disabled):active .capture-ring { width: 56px; height: 56px; }
.capture-btn:disabled { opacity: .3; border-color: rgba(255,255,255,.4); }
.capture-ring { width: 68px; height: 68px; border-radius: 50%; background: #fff; transition: all .15s; }

.ctrl-placeholder { min-width: 72px; }

/* ---------- 居中大圆开始按钮 ---------- */
.start-overlay {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
}
.start-circle-btn {
  position: relative; width: 160px; height: 160px; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease;
}
.start-circle-btn:active { transform: scale(.9); }

.start-ring-outer {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid rgba(22,163,74,.6);
  animation: pulse-ring 2s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(.75); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.start-ring-mid {
  position: absolute; inset: 14px; border-radius: 50%;
  border: 3px solid rgba(74,222,128,.5);
  animation: breathe 1.5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: .5; }
  50%      { transform: scale(1.05); opacity: 1; }
}

.start-core {
  position: relative; width: 120px; height: 120px; border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 8px 30px rgba(22,163,74,.5);
}
.start-text { font-size: 34px; font-weight: 800; color: #fff; letter-spacing: 4px; }
.start-sub { font-size: 20px; color: #fff; margin-top: 2px; }

/* ---------- 通用按钮 ---------- */
.action-btn {
  flex: 1; border: none; border-radius: 16px; padding: 22px 0;
  background: #3a3a3a; color: #fff; font-size: 22px; font-weight: 700; letter-spacing: 2px;
  cursor: pointer; transition: transform .15s ease; min-height: 64px;
  position: relative; overflow: hidden;
}
.action-btn:active { transform: scale(.92); }
.action-btn::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle at center, rgba(255,255,255,.35) 0%, transparent 60%);
  opacity: 0; transform: scale(0); pointer-events: none;
}
.action-btn.tapped::after { animation: ripple .5s ease-out; }
.action-btn.tapped { animation: tap-bounce .35s ease-out; }
@keyframes ripple { 0% { opacity: 1; transform: scale(0); } 100% { opacity: 0; transform: scale(2.2); } }
@keyframes tap-bounce { 0% { transform: scale(.92); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
.action-btn.primary { background: #16a34a; color: #fff; }
.action-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- 拍摄闪光提示 ---------- */
.auto-capture-flash {
  position: absolute; inset: 0; z-index: 15;
  background: #fff; opacity: 0; pointer-events: none;
}
.auto-capture-flash.flash { animation: capture-flash .4s ease-out; }
@keyframes capture-flash {
  0%   { opacity: 0; }
  15%  { opacity: .8; }
  100% { opacity: 0; }
}

/* ---------- 上传 toast ---------- */
.upload-toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: rgba(0,0,0,.9); backdrop-filter: blur(8px);
  padding: 32px 44px; border-radius: 20px; text-align: center;
}
.upload-toast.success { background: #16a34a; }
.upload-toast.error { background: #dc2626; }
.toast-spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2); border-top-color: #4ade80;
  animation: spin .8s linear infinite;
}
.upload-toast.success .toast-spinner { display: none; }
.upload-toast.error .toast-spinner { display: none; }
.toast-text { font-size: 20px; font-weight: 700; color: #fff; }

/* ---------- 完成页面 + 上传动画 ---------- */
.completion {
  position: absolute; inset: 0; z-index: 25;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 16px; background: #0f1117;
  text-align: center; padding: 40px 20px 20px; overflow-y: auto;
}

.upload-spinner {
  position: relative; width: 100px; height: 100px; flex: none; margin-top: 20px;
}
.upload-spinner .spinner-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 4px solid transparent;
}
.upload-spinner .spinner-ring:nth-child(1) {
  border-top-color: #22c55e; border-bottom-color: #22c55e;
  animation: spin 1s linear infinite;
}
.upload-spinner .spinner-ring:nth-child(2) {
  inset: 12px; border-left-color: #4ade80; border-right-color: #4ade80;
  animation: spin 1.5s linear infinite reverse;
}
.upload-spinner .spinner-ring:nth-child(3) {
  inset: 24px; border-top-color: #86efac; border-bottom-color: #86efac;
  animation: spin 2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.check-icon {
  width: 100px; height: 100px; border-radius: 50%;
  background: #16a34a; color: #fff; font-size: 56px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  animation: pop .45s cubic-bezier(.2,1.4,.4,1); flex: none; margin-top: 20px;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.completion .c-title { font-size: 30px; font-weight: 800; color: #fff; }
.completion .c-sub { font-size: 20px; color: #fff; }

/* ---------- 照片展示区 ---------- */
.photo-gallery {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 12px; margin-top: 8px;
}
.gallery-title {
  font-size: 22px; font-weight: 700; color: #fff;
  text-align: left; margin-bottom: 4px;
}
.photo-card {
  display: flex; gap: 14px; align-items: center;
  background: #1a1d26; border-radius: 14px; overflow: hidden;
  border: 1px solid #2c3140;
}
.photo-card img {
  flex: none; width: 100px; height: 75px; object-fit: cover; border-radius: 8px;
}
.photo-meta {
  flex: 1; display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 8px 8px 8px 0;
}
.photo-meta-area { font-size: 20px; font-weight: 700; color: #fff; }
.photo-meta-name { font-size: 18px; color: rgba(255,255,255,.8); }
.photo-meta-time { font-size: 16px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; }
.photo-meta-status { font-size: 18px; font-weight: 700; }

/* ---------- 姓名标识 ---------- */
.name-chip {
  flex: none; background: rgba(10,12,16,.92); color: #fff;
  border: 1px solid rgba(255,255,255,.14);
  padding: 10px 16px; border-radius: 999px; font-size: 18px; font-weight: 700;
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}

/* ---------- 姓名登记弹窗 ---------- */
.name-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.85);
}
.name-card {
  width: 86%; max-width: 360px; background: #1a1d26;
  border: 1px solid #2c3140; border-radius: 20px; padding: 28px 24px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.name-title { font-size: 28px; font-weight: 800; color: #fff; }
.name-sub { font-size: 18px; color: #9aa2b2; }
.name-input {
  padding: 16px; border-radius: 12px; border: 1px solid #2c3140;
  background: #0f1117; color: #fff; font-size: 22px; text-align: center;
}
.name-input:focus { border-color: #22c55e; outline: none; }
.name-save { flex: none; }

/* ---------- 完成按钮 ---------- */
.done-btn {
  width: 100%; max-width: 420px; margin-top: 12px; padding: 24px 0;
  font-size: 26px; font-weight: 800; letter-spacing: 4px;
  border-radius: 18px; min-height: 68px;
}