/* 登录页。颜色、字号、时长只出现在下面的 token；组件规则引用变量。 */

:root {
  color-scheme: light dark;
  --vc-canvas: #f5f5f7;
  --vc-group: #ffffff;
  --vc-fill: #ededf0;
  --vc-fill-2: #e3e3e8;
  --vc-ink: #1d1d1f;
  --vc-ink-2: #6e6e73;
  --vc-ink-3: #aeaeb2;
  --vc-separator: rgba(60, 60, 67, .16);
  --vc-accent: #0071e3;
  --vc-accent-text: #0066cc;
  --vc-on-accent: #ffffff;
  --vc-danger: #d70015;
  --vc-qr-paper: #ffffff;
  --vc-switch-knob: #ffffff;
  --vc-glass-shadow: rgba(0, 0, 0, .10);
  --vc-shadow: 0 8px 28px var(--vc-glass-shadow);
  --vc-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --vc-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --vc-fs-large: 34px;
  --vc-fs-body: 17px;
  --vc-fs-subhead: 15px;
  --vc-fs-footnote: 13px;
  --vc-fs-otp: 28px;
  --vc-title-tracking: -0.01em;
  --vc-radius-sm: 12px;
  --vc-radius-md: 16px;
  --vc-radius-lg: 20px;
  --vc-radius-otp: 10px;
  --vc-radius-pill: 9999px;
  --vc-space-xxs: 4px;
  --vc-space-xs: 8px;
  --vc-space-sm: 12px;
  --vc-space-md: 16px;
  --vc-space-lg: 20px;
  --vc-space-xl: 24px;
  --vc-space-xxl: 32px;
  --vc-touch: 44px;
  --vc-btn: 50px;
  --vc-switch-w: 51px;
  --vc-switch-h: 31px;
  --vc-knob: 27px;
  --vc-knob-inset: 2px;
  --vc-knob-shift: 20px;
  --vc-qr-size: 200px;
  --vc-card: 400px;
  --vc-mark: 56px;
  --vc-otp-w: 48px;
  --vc-otp-h: 56px;
  --vc-step: 200ms;
  --vc-step-shift: 8px;
  --vc-shake: 200ms;
  --vc-press: 160ms;
  --vc-spin: 800ms;
  --vc-focus: 2px;
  --vc-disabled: 0.35;
  --vc-spring: cubic-bezier(.32, .72, 0, 1);
  --vc-ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --vc-canvas: #000000;
    --vc-group: #1c1c1e;
    --vc-fill: #2c2c2e;
    --vc-fill-2: #3a3a3c;
    --vc-ink: #f5f5f7;
    --vc-ink-2: #98989d;
    --vc-ink-3: #636366;
    --vc-separator: rgba(84, 84, 88, .55);
    --vc-accent: #0071e3;
    --vc-accent-text: #2997ff;
    --vc-on-accent: #ffffff;
    --vc-danger: #ff6961;
    --vc-qr-paper: #ffffff;
    --vc-switch-knob: #ffffff;
    --vc-glass-shadow: rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--vc-canvas);
  color: var(--vc-ink);
  font-family: var(--vc-font);
  font-size: var(--vc-fs-body);
  font-weight: 400;
  line-height: 1.47;
}

.auth-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: calc(10vh + env(safe-area-inset-top, 0px)) var(--vc-space-lg) calc(var(--vc-btn) + (2 * var(--vc-space-sm)) + var(--vc-space-xs) + env(safe-area-inset-bottom, 0px));
}

.auth-mark {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--vc-mark);
  height: var(--vc-mark);
  margin: 0 0 var(--vc-space-md);
  border-radius: var(--vc-radius-md);
  background: var(--vc-fill);
  color: var(--vc-accent);
}

.auth-panel:has(#login-form:not([hidden])) .auth-mark {
  display: flex;
}

h1 {
  margin: 0 0 var(--vc-space-xl);
  font-size: var(--vc-fs-large);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: var(--vc-title-tracking);
}

.step,
#password-form,
#verify-form {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.step { flex: 1; }

.step-body {
  min-width: 0;
  animation: auth-enter var(--vc-step) var(--vc-ease) both;
}

.field { margin-bottom: var(--vc-space-md); }

.group-card .field { margin: 0; }

.group-card {
  background: var(--vc-group);
  border-radius: var(--vc-radius-sm);
  overflow: hidden;
}

.group-card .field + .field {
  border-top: 0.5px solid var(--vc-separator);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  height: var(--vc-btn);
  margin: 0;
  padding: 0 var(--vc-space-md);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--vc-ink);
  font: inherit;
  font-size: var(--vc-fs-body);
  font-variant-numeric: tabular-nums;
}

input::placeholder { color: var(--vc-ink-3); opacity: 1; }

input[aria-invalid="true"]:not(.otp-input) {
  outline: var(--vc-focus) solid var(--vc-danger);
  outline-offset: var(--vc-focus);
}

.field-error {
  margin: var(--vc-space-xs) 0 0;
  color: var(--vc-danger);
  font-size: var(--vc-fs-footnote);
  line-height: 1.4;
}

.otp { position: relative; }

.otp-cells {
  display: flex;
  justify-content: space-between;
  gap: var(--vc-space-xs);
}

.otp-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--vc-otp-w);
  max-width: var(--vc-otp-w);
  height: var(--vc-otp-h);
  flex: 1 1 auto;
  border-radius: var(--vc-radius-otp);
  background: var(--vc-group);
  color: var(--vc-ink);
  font-family: var(--vc-mono);
  font-size: var(--vc-fs-otp);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.otp-cell.is-current {
  box-shadow: inset 0 0 0 var(--vc-focus) var(--vc-accent);
}

.otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: var(--vc-fs-body);
  outline: none;
}

.otp-input::placeholder { color: transparent; }

.otp.is-invalid .otp-cells {
  animation: auth-shake var(--vc-shake) linear;
}

#verify-step.is-recovery .otp-cells { display: none; }

#verify-step.is-recovery .otp {
  background: var(--vc-group);
  border-radius: var(--vc-radius-sm);
  overflow: hidden;
}

#verify-step.is-recovery .otp-input {
  position: static;
  height: var(--vc-btn);
  padding: 0 var(--vc-space-md);
  color: var(--vc-ink);
  caret-color: auto;
  -webkit-text-fill-color: currentColor;
  font-family: var(--vc-mono);
  font-size: var(--vc-fs-body);
}

#verify-step.is-recovery .otp-input::placeholder { color: var(--vc-ink-3); }

.switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--vc-space-sm);
  min-height: var(--vc-btn);
  margin: 0;
  padding: 0 var(--vc-space-md);
  font-size: var(--vc-fs-body);
  font-weight: 400;
}

.switch input {
  position: absolute;
  z-index: 1;
  top: 50%;
  right: var(--vc-space-md);
  width: var(--vc-switch-w);
  height: var(--vc-switch-h);
  margin: 0;
  opacity: 0;
  cursor: pointer;
  transform: translateY(-50%);
}

.track {
  flex: none;
  width: var(--vc-switch-w);
  height: var(--vc-switch-h);
  margin-left: auto;
  border-radius: var(--vc-radius-pill);
  background: var(--vc-fill-2);
  position: relative;
}

.track::after {
  content: "";
  position: absolute;
  top: var(--vc-knob-inset);
  left: var(--vc-knob-inset);
  width: var(--vc-knob);
  height: var(--vc-knob);
  border-radius: var(--vc-radius-pill);
  background: var(--vc-switch-knob);
  transition: transform var(--vc-press) var(--vc-spring);
}

.switch input:checked + .track { background: var(--vc-accent); }

.switch input:checked + .track::after { transform: translateX(var(--vc-knob-shift)); }

.switch input:focus-visible + .track {
  outline: var(--vc-focus) solid var(--vc-accent);
  outline-offset: var(--vc-focus);
}

#setup-block { margin-bottom: var(--vc-space-xl); }

.qr-frame,
#show-qr,
#add-authenticator { display: none; }

#verify-step.is-setup #show-qr,
#verify-step.is-setup #add-authenticator { display: flex; }

.qr-frame.is-open { display: flex; }

.qr-frame {
  align-self: center;
  width: fit-content;
  margin: var(--vc-space-md) auto;
  padding: var(--vc-space-sm);
  border-radius: var(--vc-radius-md);
  background: var(--vc-qr-paper);
}

.qr-frame img {
  display: block;
  width: var(--vc-qr-size);
  height: var(--vc-qr-size);
}

#add-authenticator {
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--vc-btn);
  margin-bottom: var(--vc-space-sm);
  border-radius: var(--vc-radius-pill);
  background: var(--vc-fill-2);
  color: var(--vc-accent-text);
  font-size: var(--vc-fs-body);
  font-weight: 600;
  text-decoration: none;
}

#show-qr {
  justify-content: flex-start;
  width: 100%;
}

.secret-line {
  display: flex;
  align-items: center;
  height: var(--vc-btn);
  min-width: 0;
  margin-top: var(--vc-space-md);
  padding-left: var(--vc-space-md);
  border-radius: var(--vc-radius-pill);
  background: var(--vc-fill-2);
}

#setup-secret {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  font-family: var(--vc-mono);
  font-size: var(--vc-fs-subhead);
  font-variant-numeric: tabular-nums;
  line-height: var(--vc-btn);
}

#setup-secret::-webkit-scrollbar { display: none; }

/* 过长时右缘淡出，提示可横向滚动 */
#setup-secret {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--vc-space-lg)), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - var(--vc-space-lg)), transparent);
}

.secret-copy {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--vc-touch);
  height: var(--vc-touch);
  margin-right: var(--vc-space-xxs);
  padding: 0;
  border: 0;
  border-radius: var(--vc-radius-pill);
  background: transparent;
  color: var(--vc-accent-text);
  cursor: pointer;
}

.icon { display: block; }

.icon-check { display: none; }

.is-copied .icon-copy { display: none; }

.is-copied .icon-check { display: block; }

.recovery-grid {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  margin: 0;
  padding: 0;
}

.recovery-grid li {
  margin: 0;
  padding: var(--vc-space-sm) var(--vc-space-xs);
  color: var(--vc-ink);
  font-family: var(--vc-mono);
  font-size: var(--vc-fs-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 0;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.recovery-grid li + li {
  border-top: 0.5px solid var(--vc-separator);
}

.secondary-row {
  display: flex;
  gap: var(--vc-space-xs);
  margin-top: var(--vc-space-md);
}

.secondary {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: var(--vc-space-xs);
  min-width: 0;
  height: var(--vc-btn);
  padding: 0 var(--vc-space-sm);
  border: 0;
  border-radius: var(--vc-radius-pill);
  background: var(--vc-fill-2);
  color: var(--vc-ink);
  font: inherit;
  font-size: var(--vc-fs-body);
  font-weight: 600;
  cursor: pointer;
}

.text-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--vc-space-xs);
  margin-top: var(--vc-space-sm);
}

#back-login { margin-left: auto; }

.thumb {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: var(--vc-space-sm) var(--vc-space-lg) calc(var(--vc-space-sm) + env(safe-area-inset-bottom, 0px));
  background: var(--vc-canvas);
}

.primary,
.text,
.secondary,
.secret-copy {
  font-family: inherit;
}

.primary,
.text {
  cursor: pointer;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--vc-btn);
  border: 0;
  border-radius: var(--vc-radius-pill);
  background: var(--vc-accent);
  color: var(--vc-on-accent);
  font-size: var(--vc-fs-body);
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--vc-press) var(--vc-spring);
}

.primary:active { transform: scale(0.96); }

.text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--vc-touch);
  padding: 0 var(--vc-space-xs);
  border: 0;
  background: transparent;
  color: var(--vc-accent-text);
  font-size: var(--vc-fs-subhead);
}

button:focus-visible,
#add-authenticator:focus-visible,
input:not([type="checkbox"]):not(.otp-input):focus-visible {
  outline: var(--vc-focus) solid var(--vc-accent);
  outline-offset: var(--vc-focus);
}

.group-card input:not([type="checkbox"]):focus-visible,
#verify-step.is-recovery .otp-input:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 var(--vc-focus) var(--vc-accent);
}

button:disabled,
.primary[aria-disabled="true"] {
  opacity: var(--vc-disabled);
  cursor: default;
}

/* 主按钮禁用用灰色填充，深色下不会变成看不清的暗蓝 */
.primary:disabled,
.primary[aria-disabled="true"] {
  opacity: 1;
  background: var(--vc-fill-2);
  color: var(--vc-ink-3);
}

.primary[aria-busy="true"] { opacity: 1; }

.auth-panel.is-busy .primary,
.auth-panel.is-busy #add-authenticator,
.auth-panel.is-busy .secondary,
.auth-panel.is-busy .text,
.auth-panel.is-busy .secret-copy { pointer-events: none; }

.primary[aria-busy="true"]::before {
  content: "";
  width: 1em;
  height: 1em;
  margin-right: var(--vc-space-xs);
  border: var(--vc-focus) solid currentColor;
  border-right-color: transparent;
  border-radius: var(--vc-radius-pill);
  animation: auth-spin var(--vc-spin) linear infinite;
}

@keyframes auth-enter {
  from { opacity: 0; transform: translateY(var(--vc-step-shift)); }
  to { opacity: 1; transform: none; }
}

@keyframes auth-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 744px) and (hover: hover) and (pointer: fine) {
  #verify-step.is-setup .qr-frame { display: flex; }
  #verify-step.is-setup #show-qr,
  #verify-step.is-setup #add-authenticator { display: none !important; }
}

@media (min-width: 744px) {
  body {
    align-items: center;
    padding: var(--vc-space-xxl);
  }

  .auth-panel {
    flex: none;
    width: min(var(--vc-card), 100%);
    margin: auto;
    padding: var(--vc-space-xxl);
    background: var(--vc-group);
    border-radius: var(--vc-radius-lg);
  }

  .group-card,
  #verify-step.is-recovery .otp,
  .otp-cell { background: var(--vc-fill); }

  .step { flex: none; }

  .thumb {
    position: static;
    margin-top: var(--vc-space-xl);
    padding: 0;
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step:not([hidden]) .step-body { animation-name: auth-fade; }
  .primary,
  .track::after { transition: none; }
  .primary:active { transform: none; }
  .primary[aria-busy="true"]::before { animation: none; }
  .otp.is-invalid .otp-cells { animation: none; }
}
