/* ============================================================
   OTP 登录 · iOS 风格白色主题
   图标：Lucide（ISC），本地 icons/ 目录，通过 CSS mask 调用
   ============================================================ */

/* ---------- 设计变量 ---------- */
:root {
  --bg: #f5f5f7;             /* iOS 系统灰背景 */
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;
  --line: #e5e5ea;
  --fill: #f2f2f7;           /* iOS 填充灰 */
  --blue: #007aff;           /* iOS 系统蓝 */
  --blue-press: #0066d6;
  --blue-soft: rgba(0, 122, 255, .12);
  --green: #34c759;          /* iOS 系统绿 */
  --red: #ff3b30;            /* iOS 系统红 */
  --red-soft: rgba(255, 59, 48, .10);
  --disabled: #d1d1d6;
  --radius-card: 28px;
  --radius-control: 14px;
  --ease-ios: cubic-bezier(.32, .72, 0, 1);       /* iOS 标准缓动 */
  --ease-spring: cubic-bezier(.17, .9, .24, 1.18); /* 轻微回弹 */
  --shadow-card: 0 24px 60px -20px rgba(0, 0, 0, .14),
                 0 8px 24px -12px rgba(0, 0, 0, .08);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* 保证 HTML hidden 属性不被显式 display 覆盖 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #6dd5ed 0%, #2193b0 35%, #5e72e4 70%, #8e54e9 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }

/* ---------- 舞台 ---------- */
.stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  gap: 18px;
  align-content: center;
  justify-items: center;
}

.card {
  position: relative;
  width: 100%;
  max-width: 390px;
  min-width: 0; /* 防止并排视图把 grid/flex 容器撑宽 */
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  overflow: clip; /* clip 不构成滚动容器，避免并排视图被 scrollIntoView 带出偏移 */
  isolation: isolate;
}

/* ---------- 横向滑动轨道（iOS push 转场） ---------- */
.views {
  display: flex;
  width: 100%;
  transform: translateX(0);
  transition: transform .55s var(--ease-ios);
  will-change: transform;
}
.views.step-otp { transform: translateX(-100%); }

.view {
  flex: 0 0 100%;
  min-width: 100%;
  padding: 44px 30px 38px;
  display: flex;
  flex-direction: column;
}

.view-otp { padding-top: 18px; }

/* ---------- 标题排版 ---------- */
h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin-top: 22px;
}

.subtitle {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}
.subtitle b { color: var(--text); font-weight: 600; }

/* ---------- 顶部图标徽章 ---------- */
.badge {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: var(--blue-soft);
  display: grid;
  place-items: center;
  animation: badge-in .6s var(--ease-spring) both;
}
@keyframes badge-in {
  from { opacity: 0; transform: scale(.5); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- 图标：本地 Lucide SVG 文件，<img> 直接调用 ---------- */
.ic {
  display: block;
  flex: none;
  -webkit-user-drag: none;
  user-select: none;
}
.ic-lg { width: 30px; height: 30px; }

/* ---------- 输入框（iOS 分组填充样式） ---------- */
.field {
  margin-top: 30px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--fill);
  border-radius: var(--radius-control);
  border: 1.5px solid transparent;
  transition: border-color .25s var(--ease-ios), box-shadow .25s var(--ease-ios),
             background .25s var(--ease-ios);
}
.field:focus-within {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
/* 发送成功：输入框边缘变绿 */
.field.is-success {
  background: #fff;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 199, 89, .12);
}
/* 发送失败：输入框边缘变红并抖动（提高优先级，盖过入场动画） */
.view .field.is-error {
  background: #fff;
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
  animation: shake .5s var(--ease-ios);
}
.field-prefix {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .3px;
}
.field-divider { width: 1px; height: 22px; background: var(--line); }
.field-input {
  flex: 1;
  min-width: 0;
  border: 0; outline: 0; background: none;
  font-size: 17px;
  letter-spacing: .5px;
  color: var(--text);
}
.field-input::placeholder { color: var(--text-3); }

.field-clear {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  color: var(--text-3);
  border-radius: 50%;
  transition: color .2s, transform .2s var(--ease-spring);
}
.field-clear:active { transform: scale(.82); }
.field-clear:hover { color: var(--text-2); }

/* ---------- 主按钮 ---------- */
.btn-primary {
  position: relative;
  margin-top: 20px;
  height: 52px;
  border-radius: var(--radius-control);
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  transition: transform .18s var(--ease-ios), background .25s, opacity .25s, box-shadow .25s;
  box-shadow: 0 10px 22px -10px rgba(0, 122, 255, .65);
}
.btn-primary:hover:not(:disabled):not(.is-loading) { background: var(--blue-press); }
.btn-primary:active:not(:disabled):not(.is-loading) { transform: scale(.97); }
.btn-primary:disabled {
  background: var(--disabled);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-label { position: relative; z-index: 1; }

/* 获取中：iOS 风白色加载圈，仅加载阶段显示 */
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: btn-spin .7s linear infinite;
}
.btn-primary.is-loading:not(.is-result) .btn-spinner { display: block; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* 加载/结果阶段：灰底 */
.btn-primary.is-loading {
  background: #c7c7cc;
  box-shadow: none;
  cursor: default;
}

/* 文字按钮 */
.btn-link {
  margin-top: 16px;
  align-self: center;
  font-size: 14px;
  color: var(--blue);
  padding: 8px 10px;
  border-radius: 8px;
  transition: opacity .2s, transform .2s var(--ease-ios);
}
.btn-link:active { transform: scale(.95); opacity: .7; }

/* ---------- OTP 视图顶部导航 ---------- */
.nav { display: flex; align-items: center; height: 32px; }
.nav-back {
  margin-left: -8px;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--blue);
  display: grid; place-items: center;
  transition: background .2s, transform .2s var(--ease-ios);
}
.nav-back:hover { background: var(--fill); }
.nav-back:active { transform: scale(.88); }

/* ---------- OTP 验证码区 ---------- */
.otp {
  position: relative;
  margin-top: 30px;
}

.otp-cells {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1.18;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  transition: background-color .26s var(--ease-ios),
              border-color .26s var(--ease-ios),
              box-shadow .26s var(--ease-ios),
              transform .3s var(--ease-spring);
}
.cell-digit {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
/* 已填充 */
.cell.is-filled {
  border-color: #c7dfff;
  background: #f7faff;
}
/* 当前待输入格 */
.cell.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
/* iOS 式闪烁光标 */
.cell.is-active::after {
  content: "";
  position: absolute;
  width: 2px; height: 22px;
  border-radius: 2px;
  background: var(--blue);
  animation: cursor-blink 1.05s steps(1) infinite;
}
.cell.is-active .cell-digit:empty + * { display: none; }
@keyframes cursor-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* 数字填入的回弹动画 */
.cell.is-filled .cell-digit { animation: digit-pop .3s var(--ease-spring); }
@keyframes digit-pop {
  0%   { transform: scale(.4); opacity: .2; }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); opacity: 1; }
}

/* ========== 校验阶段：仅边框依次变色波浪（底色/数字色不变） ========== */
/* 校验中 · 边框变蓝（唯一放大的阶段，变蓝瞬间轻微弹放） */
.cell.is-blue {
  border-color: var(--blue);
  transform: scale(1.1);
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, .14);
}

/* 校验失败 · 边框由蓝依次变红：保持尺寸、不再放大，快速过渡 */
.cell.is-red {
  border-color: var(--red);
  transform: scale(1.1);
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(255, 59, 48, .12);
  transition-duration: .14s;
}

/* 校验成功 · 边框由蓝依次变绿：保持尺寸、不再放大，快速过渡 */
.cell.is-green {
  border-color: var(--green);
  transform: scale(1.1);
  z-index: 1;
  box-shadow: 0 0 0 4px rgba(52, 199, 89, .14);
  transition-duration: .14s;
}

/* 失败后整行抖动 */
.otp-cells.is-shaking { animation: shake .5s var(--ease-ios); }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* 透明真实输入框：覆盖整个验证码区接收键盘 */
.otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  font-size: 16px; /* ≥16px 防止 iOS Safari 聚焦自动缩放 */
  opacity: 0;
  border: 0; outline: 0;
  background: none;
  caret-color: transparent;
  cursor: text;
  -webkit-tap-highlight-color: transparent;
}
.otp-input:disabled { cursor: default; }

/* 验证码提示信息 */
.otp-msg {
  margin-top: 14px;
  min-height: 20px;
  font-size: 14px;
  color: var(--red);
  transition: color .2s;
}
.otp-msg.is-info { color: var(--text-2); }

/* OTP 底部操作行 */
.otp-foot {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.btn-link-inline {
  margin-top: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 14px;
}
.btn-link-inline:disabled { opacity: .35; pointer-events: none; }

.resend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-size: 14px;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: 10px;
  transition: color .2s, transform .2s var(--ease-ios);
}
.resend:not(:disabled) { color: var(--blue); }
.resend:not(:disabled):active { transform: scale(.94); }
.resend:disabled { cursor: default; }
.resend-ic { animation: none; }
.resend:not(:disabled) .resend-ic { animation: spin-once .6s var(--ease-ios); }
@keyframes spin-once { from { transform: rotate(-180deg); } to { transform: rotate(0); } }

/* ---------- 成功视图 ---------- */
.view-success {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--card);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  opacity: 0;
  transform: scale(.94);
  pointer-events: none;
  transition: opacity .45s var(--ease-ios), transform .45s var(--ease-spring);
}
.view-success.is-show {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.view-success h1 { margin-top: 26px; }
.view-success .btn-link { margin-top: 26px; }

.success-mark { width: 92px; height: 92px; }
.success-circle {
  stroke: var(--green);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 132;
  stroke-dashoffset: 132;
}
.success-check {
  stroke: var(--green);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}
.view-success.is-show .success-circle { animation: draw .55s var(--ease-ios) forwards; }
.view-success.is-show .success-check  { animation: draw .35s var(--ease-ios) .42s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- 入场交错动画（进入 OTP 视图时） ---------- */
.view [data-stagger] {
  animation: rise-in .55s var(--ease-ios) both;
}
.view [data-stagger]:nth-child(1) { animation-delay: .05s; }
.view [data-stagger]:nth-child(2) { animation-delay: .10s; }
.view [data-stagger]:nth-child(3) { animation-delay: .15s; }
.view [data-stagger]:nth-child(4) { animation-delay: .20s; }
.view [data-stagger]:nth-child(5) { animation-delay: .25s; }
.view [data-stagger]:nth-child(6) { animation-delay: .30s; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* 首屏手机视图：徽章自带弹入，其余直接 rise */
.views:not(.step-otp) .view-otp [data-stagger] { animation: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -16px);
  background: rgba(29, 29, 31, .88);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease-ios), transform .3s var(--ease-spring);
  z-index: 50;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .35);
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 页脚说明 ---------- */
.page-foot {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  max-width: 390px;
  line-height: 1.5;
}

/* ---------- 响应式：手机全屏 ---------- */
@media (max-width: 440px) {
  .stage { padding: 0; gap: 0; align-content: stretch; }
  .card {
    max-width: none;
    min-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }
  .views { flex: 1; min-width: 0; max-width: 100%; }
  .view { padding: 56px 24px 32px; justify-content: flex-start; }
  .view-success { border-radius: 0; }
  .page-foot { display: none; }
}

/* ---------- 减弱动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   液态玻璃 + 昼夜模式
   ============================================================ */

/* 背景渐变光斑 */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 320px; height: 320px;
  background: var(--blue);
  top: -60px; left: -40px;
}
body::after {
  width: 280px; height: 280px;
  background: var(--green);
  bottom: -80px; right: -50px;
}
@keyframes blobFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.15); }
}
.stage { position: relative; z-index: 1; }

/* 液态玻璃卡片 */
.card {
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .6);
}

/* 输入框玻璃态 */
.field { background: rgba(118, 118, 128, .12); }
.field:focus-within { background: rgba(255, 255, 255, .85); }

/* 右上角昼夜切换按钮 */
.theme-toggle {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  z-index: 10;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .5);
  display: grid; place-items: center;
  color: var(--text);
  transition: transform .2s var(--ease-ios), background .25s;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .12);
}
.theme-toggle:active { transform: scale(.9); }
.theme-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 深色模式 ---------- */
[data-theme="dark"] {
  --bg: #1c1c1e;
  --card: rgba(28, 28, 30, .72);
  --text: #f5f5f7;
  --text-2: #aeaeb2;
  --text-3: #6e6e73;
  --line: #38383a;
  --fill: rgba(118, 118, 128, .24);
  --blue: #0a84ff;
  --blue-press: #409cff;
  --blue-soft: rgba(10, 132, 255, .22);
  --disabled: #3a3a3c;
  --shadow-card: 0 24px 60px -20px rgba(0, 0, 0, .6), 0 8px 24px -12px rgba(0, 0, 0, .4);
}
[data-theme="dark"] body { background: linear-gradient(135deg, #0f2027 0%, #203a43 35%, #2c5364 70%, #1a1a2e 100%); background-attachment: fixed; }
[data-theme="dark"] .card {
  background: rgba(28, 28, 30, .72);
  border-color: rgba(255, 255, 255, .1);
}
[data-theme="dark"] .field { background: rgba(118, 118, 128, .24); }
[data-theme="dark"] .field:focus-within { background: rgba(44, 44, 46, .9); }
[data-theme="dark"] .cell { background: rgba(44, 44, 46, .9); border-color: var(--line); }
[data-theme="dark"] .cell.is-filled { background: rgba(10, 132, 255, .12); border-color: rgba(10, 132, 255, .35); }
[data-theme="dark"] .view-success { background: rgba(28, 28, 30, .92); }
[data-theme="dark"] .theme-toggle {
  background: rgba(44, 44, 46, .6);
  border-color: rgba(255, 255, 255, .1);
  color: #f5f5f7;
}
[data-theme="dark"] body::before { opacity: .25; }
[data-theme="dark"] body::after { opacity: .2; }

/* 密码输入框样式（替代 OTP 格子） */
.pwd-field { margin-top: 30px; }
.pwd-hint { margin-top: 10px; font-size: 13px; color: var(--text-2); }

/* ---------- 右上角工具栏 ---------- */
.top-tools {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* QQ 头像 */
.qq-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .5);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .3s var(--ease-ios), box-shadow .3s;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .12);
  overflow: hidden;
}
.qq-avatar:hover { transform: scale(1.1) rotate(-6deg); box-shadow: 0 8px 24px -6px rgba(18, 183, 245, .4); }
.qq-avatar:active { transform: scale(.92); }
.qq-avatar svg { width: 34px; height: 34px; animation: qq-bob 3s ease-in-out infinite; }
@keyframes qq-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
[data-theme="dark"] .qq-avatar {
  background: rgba(44, 44, 46, .6);
  border-color: rgba(255, 255, 255, .1);
}


/* ============================================================
   静态液态玻璃升级 · Static Liquid Glass (v4)
   登录页全部玻璃面：分层渐变 + 内凹高光 + 边缘流光（静态，不持续重绘）
   ============================================================ */
@keyframes lgEdgePulse {
  0%, 100% { opacity: .5; }
  50% { opacity: .95; }
}

/* 主卡片：分层静态玻璃 + 内凹高光 */
.card {
  background-image: none;
  animation: none;
  box-shadow:
    0 28px 64px -20px rgba(0, 0, 0, .38),
    0 1px 0 0 rgba(255, 255, 255, .5) inset,
    0 0 0 1px rgba(255, 255, 255, .2) inset;
}
[data-theme="dark"] .card {
  background-image: none;
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.5) 0%, rgba(255,255,255,0) 40%, rgba(255,255,255,.2) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  padding: 1px;
  animation: lgEdgePulse 6s ease-in-out infinite;
}

/* 输入框：静态玻璃（聚焦时变亮） */
.field {
  background-image: none;
  animation: none;
}
.field:focus-within {
  background-image: none;
}
[data-theme="dark"] .field, [data-theme="dark"] .field:focus-within {
  background-image: none;
}

/* OTP 格子：静态玻璃 */
.cell {
  background-image: none;
  animation: none;
}
[data-theme="dark"] .cell {
  background-image: none;
}
.cell.is-filled {
  background-image: none;
}

/* 右上角按钮：静态玻璃 */
.theme-toggle, .qq-avatar {
  background-image: none;
  animation: none;
}
[data-theme="dark"] .theme-toggle, [data-theme="dark"] .qq-avatar {
  background-image: none;
}
