:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --fill: rgba(0, 0, 0, 0.04);
  --track: #e5e5ea;
  --brand: #0071e3;
  --brand-press: #0077ed;
  --brand-soft: rgba(0, 113, 227, 0.12);
  --link: #0071e3;
  --danger: #ff3b30;
  --ok: #34c759;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --r: 18px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Helvetica Neue", Helvetica, "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #1c1c1e;
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.48);
    --line: rgba(255, 255, 255, 0.12);
    --fill: rgba(255, 255, 255, 0.06);
    --track: rgba(255, 255, 255, 0.14);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 100%/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

.shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 20px 40px;
}

.card {
  width: min(400px, 100%);
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}

/* —— 步骤条 —— */
.step-nav {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 28px 8px;
}

.step-track {
  position: absolute;
  top: 37px; /* 圆心对齐 step-num 中心 */
  left: 18%;
  right: 18%;
  height: 2px;
  background: var(--track);
  border-radius: 1px;
  overflow: hidden;
  pointer-events: none;
}

.step-track-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 1px;
  transition: width 420ms var(--spring);
}

.step-item {
  width: 33.33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--muted);
  background: var(--track);
  margin-bottom: 8px;
  transition:
    background 280ms var(--ease),
    color 280ms var(--ease),
    transform 220ms var(--spring),
    box-shadow 280ms var(--ease);
}

.step-text {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0;
  transition: color 280ms var(--ease), font-weight 280ms var(--ease);
}

.step-item.active .step-num {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 4px var(--brand-soft);
  transform: scale(1.04);
}

.step-item.active .step-text {
  color: var(--brand);
  font-weight: 600;
}

.step-item.done .step-num {
  background: var(--ok);
  color: #fff;
}

.step-item.done .step-text {
  color: var(--text);
}

/* —— 内容区 —— */
.panel {
  padding: 12px 24px 26px;
}

.panel h1 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.028em;
  font-weight: 650;
}

.hint {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0;
}

.lede {
  margin: -2px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0;
}
.field input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
  color: var(--text);
  background: var(--fill);
  outline: none;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.field input:focus {
  border-color: rgba(0, 113, 227, 0.55);
  background: rgba(0, 113, 227, 0.06);
}

.err {
  display: none;
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 10px;
}

.btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  color: #fff;
  background: var(--brand);
  transition: transform 100ms ease-out, background 120ms var(--ease), opacity 120ms;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); background: var(--brand-press); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.ghost {
  margin-top: 8px;
  background: transparent;
  color: var(--link);
  font-weight: 500;
}
.btn.ghost:active { background: var(--fill); }

.actions { margin-top: 4px; }

.view { display: none; }
.view.on {
  display: block;
  animation: rise 380ms var(--spring) both;
}

@media (prefers-reduced-motion: reduce) {
  .view.on { animation: fade 180ms ease both; }
  .step-num, .step-track-fill, .btn { transition: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qr-stage {
  margin: 4px auto 14px;
  width: 196px;
  height: 196px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.qr-stage img {
  width: 168px;
  height: 168px;
  opacity: 0;
  transition: opacity 280ms var(--ease);
}
.qr-stage img.show { opacity: 1; }

.meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 8px;
  letter-spacing: 0;
}
.meta strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.meta .dot { opacity: 0.5; }

.confirm {
  text-align: center;
  font-size: 13px;
  margin: 0 0 12px;
  min-height: 0;
}
.confirm a {
  color: var(--link);
  text-decoration: none;
}
.confirm:empty { display: none; }

.success {
  text-align: center;
  padding: 28px 0 8px;
}
.success h1 { margin-bottom: 8px; }
.success .lede { margin: 0 0 8px; }
.token-box {
  margin: 12px 0 0;
  padding: 12px 14px;
  text-align: left;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #1d1d1f;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease), transform 300ms var(--spring);
  max-width: min(86vw, 340px);
  text-align: center;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.err { background: rgba(255, 59, 48, 0.92); }
