:root {
  --bg: #000000;
  --bg-card: #141414;
  --bg-input: rgba(0, 0, 0, 0.42);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-hover: rgba(255, 255, 255, 0.32);
  --text: #ffffff;
  --text-2: #a3a3a3;
  --text-3: #6b6b6b;
  --radius: 18px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: #000000;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  padding: 40px 20px calc(32px + var(--safe-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 26px;
  animation: fade-in 0.28s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.brand .logo {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 22px;
  filter: drop-shadow(0 6px 28px rgba(255, 255, 255, 0.10));
}

.brand h1 {
  margin: 0;
  font-family: "Ma Shan Zheng", "STXingkai", "\u534e\u6587\u884c\u6977", "Xingkai SC", cursive;
  font-size: 34px;
  font-weight: 400;
  letter-spacing: 0;
  text-align: center;
  color: #ffffff;
  line-height: 1.2;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 24px 60px -28px rgba(0, 0, 0, 0.9);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 20px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  font-family: inherit;
  transition: color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 26px;
  height: 2px;
  border-radius: 1px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.option:not(:disabled):hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
}

.option:not(:disabled):active { transform: scale(0.99); }

.option .icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  color: var(--text-2);
}

.option .icon svg { width: 22px; height: 22px; }

.option .text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option .text strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.option .text small {
  font-size: 12px;
  color: var(--text-3);
}

.option .arrow {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 22px;
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
}

.option:not(:disabled):hover .arrow {
  color: #ffffff;
  transform: translateX(3px);
}

.option.disabled { opacity: 0.5; cursor: not-allowed; }

.option .badge {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-3);
  border: 1px solid rgba(255, 255, 255, 0.10);
  font-weight: 600;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade-in 0.22s ease;
}

.form .back {
  align-self: flex-start;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.form .back:hover { color: #ffffff; }

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form label > span {
  font-size: 12px;
  color: var(--text-3);
  padding-left: 2px;
  letter-spacing: 0.3px;
}

.form input {
  appearance: none;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form input::placeholder { color: var(--text-3); }

.form input:focus {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.form button.primary {
  appearance: none;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #0a0a0a;
  cursor: pointer;
  font-family: inherit;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9),
              0 10px 26px -14px rgba(255, 255, 255, 0.28);
  transition: filter 0.2s, transform 0.1s;
}

.form button.primary:hover { filter: brightness(0.94); }
.form button.primary:active { transform: scale(0.99); }
.form button.primary:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.msg {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.msg.error {
  background: rgba(255, 100, 100, 0.06);
  color: #ffb3b3;
  border: 1px solid rgba(255, 100, 100, 0.20);
}

.msg.success {
  background: rgba(100, 255, 140, 0.06);
  color: #b3ffcc;
  border: 1px solid rgba(100, 255, 140, 0.20);
}

.user-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #2a2a2a 0%, #101010 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.05);
}

.user-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-info strong {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info small {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.secondary {
  appearance: none;
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

button.secondary:hover {
  border-color: var(--border-hover);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: #0a0a0a;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.brand .subtitle {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 6px;
  text-indent: 6px;
  color: #5a5a5a;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  text-align: center;
}

.brand .title-img {
  display: block;
  width: 240px;
  height: auto;
  max-width: 76%;
  margin: 0 auto;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* ============ 收紧 brand 区块 ============ */
.brand {
  gap: 0;
}

.brand .logo {
  margin-bottom: 4px;
}

.brand .title-img {
  width: 200px;
  margin: 0 auto;
}

.brand .subtitle {
  margin: 6px 0 0 0;
  font-size: 10px;
  letter-spacing: 2px;
  text-indent: 2px;
}

/* ============ brand 微调 v2 ============ */
.brand .logo {
  margin-bottom: 8px;
}

.brand .title-img {
  width: 220px;
  margin: 0 auto;
}

.brand .subtitle {
  margin-top: 4px;
}

/* ============ 顶部安全距离 + 尺寸 v3 ============ */
#app {
  padding-top: calc(72px + env(safe-area-inset-top, 0px));
}

.brand .logo {
  width: 72px;
  height: 72px;
  margin-bottom: 6px;
}

.brand .title-img {
  width: 170px;
  margin: 0 auto;
}

.brand .subtitle {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-indent: 1.5px;
  margin-top: 3px;
}

/* ============ 尺寸 v4 ============ */
.brand .logo {
  margin-bottom: 18px;
}

.brand .title-img {
  width: 130px;
  margin: 0 auto;
}

/* ============ 修正 logo 比例 ============ */
.brand .logo {
  width: 76px;
  height: auto;
  aspect-ratio: auto;
  margin-bottom: 14px;
}

/* ============ 表单字段提示 ============ */
.field-hint {
  margin: -6px 0 0 2px;
  font-size: 11px;
  line-height: 1.5;
  color: #6b6b6b;
  letter-spacing: 0.2px;
}

.field-hint strong {
  color: #a3a3a3;
  font-weight: 600;
}

.field-hint-error {
  color: #f87171;
}

.field-hint-error[hidden] { display: none !important; }

.field-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: -6px 0 0 0;
  padding: 9px 11px;
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.20);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  color: #fbbf24;
  letter-spacing: 0.2px;
}

.field-warning svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  color: #fbbf24;
}

.field-warning strong {
  color: #fcd34d;
  font-weight: 700;
}

/* 输入框聚焦时 16px 防 iOS 自动缩放 */
.form input {
  font-size: 16px;
}

/* 邮箱提示里的强调色 */
.field-warning strong.emph {
  color: #fef08a;
  font-weight: 700;
}

.field-warning strong.emph-bad {
  color: #f87171;
  font-weight: 700;
}

/* ============ 彻底禁止 iOS 输入框自动缩放 ============ */
html {
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}

.form input,
.form textarea,
.form select {
  font-size: 16px !important;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* ============ 进入具体方式（账密登录/注册）时隐藏 brand ============ */
#auth-view.form-open .brand {
  display: none !important;
}

#auth-view.form-open {
  padding-top: 20px;
}

#auth-view.form-open .card {
  margin-top: 8px;
}


/* ============ 键盘适配 v2 · 恢复自然滚动 ============ */
html, body {
  height: auto !important;
  min-height: 100dvh;
  overflow: visible !important;
  overscroll-behavior-y: auto !important;
}

#app {
  height: auto !important;
  min-height: 100dvh;
  overflow: visible !important;
}

/* 键盘弹出时给底部留空间 */
body.keyboard-open {
  padding-bottom: calc(var(--kb, 200px) + 40px);
}

/* 移除 backdrop-filter 提升滚动/点击性能 */
.card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: #141414 !important;
}

/* 减少移动端点击延迟 */
.tab,
.option,
.form .back,
.form button.primary,
button.secondary,
.form input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 输入框聚焦时给滚动留余量 */
.form input {
  scroll-margin-top: 120px;
  scroll-margin-bottom: 240px;
}

/* ============ 密码规则列表 ============ */
.pwd-rules {
  list-style: none;
  padding: 0;
  margin: -4px 0 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.pwd-rule {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: #6b6b6b;
  transition: color 0.2s ease;
  user-select: none;
}

.pwd-rule svg {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  fill: none;
  stroke: #3a3a3a;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}

.pwd-rule.ok {
  color: #86efac;
}

.pwd-rule.ok svg {
  stroke: #22c55e;
}

/* ============ 密码强度条 ============ */
.pwd-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: -4px;
}

.pwd-strength-bars {
  flex: 1 1 auto;
  display: flex;
  gap: 4px;
}

.pwd-strength-bars span {
  flex: 1 1 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  transition: background 0.25s ease;
}

.pwd-strength[data-level="1"] .pwd-strength-bars span:nth-child(-n+1) {
  background: #ef4444;
}
.pwd-strength[data-level="2"] .pwd-strength-bars span:nth-child(-n+2) {
  background: #f59e0b;
}
.pwd-strength[data-level="3"] .pwd-strength-bars span:nth-child(-n+3) {
  background: #eab308;
}
.pwd-strength[data-level="4"] .pwd-strength-bars span:nth-child(-n+4) {
  background: #22c55e;
}

.pwd-strength-label {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: #6b6b6b;
  transition: color 0.2s ease;
  min-width: 44px;
  text-align: right;
}

.pwd-strength[data-level="1"] .pwd-strength-label { color: #f87171; }
.pwd-strength[data-level="2"] .pwd-strength-label { color: #fbbf24; }
.pwd-strength[data-level="3"] .pwd-strength-label { color: #facc15; }
.pwd-strength[data-level="4"] .pwd-strength-label { color: #4ade80; }

/* 让表单字段纵向间距更均匀 */
.form label {
  margin-top: 4px;
}
.form .pwd-rules,
.form .pwd-strength {
  margin-bottom: 6px;
}


/* ============ 人机验证组件 ============ */
.captcha-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  margin-top: 4px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, background 0.2s;
}

.captcha-box[data-state="passed"] {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.05);
}

.captcha-box[data-state="failed"] {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.05);
}

.captcha-btn {
  appearance: none;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  touch-action: manipulation;
}

.captcha-box[data-state="working"] .captcha-btn,
.captcha-box[data-state="passed"] .captcha-btn {
  cursor: default;
}

.captcha-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid #6b6b6b;
  border-radius: 5px;
  display: grid;
  place-items: center;
  position: relative;
  transition: border-color 0.2s, background 0.2s;
}

.captcha-box[data-state="idle"] .captcha-icon {
  border-color: #6b6b6b;
}

.captcha-box[data-state="working"] .captcha-icon {
  border-color: #fbbf24;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.captcha-box[data-state="passed"] .captcha-icon {
  background: #22c55e;
  border-color: #22c55e;
}

.captcha-box[data-state="passed"] .captcha-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.captcha-box[data-state="failed"] .captcha-icon {
  background: #ef4444;
  border-color: #ef4444;
}

.captcha-box[data-state="failed"] .captcha-icon::after {
  content: "!";
  position: absolute;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.captcha-text {
  flex: 1 1 auto;
  font-size: 14px;
  color: #ffffff;
  line-height: 1.4;
}

.captcha-box[data-state="passed"] .captcha-text {
  color: #86efac;
}

.captcha-box[data-state="failed"] .captcha-text {
  color: #fca5a5;
}

.captcha-brand {
  flex: 0 0 auto;
  font-size: 10px;
  color: #4a4a4a;
  letter-spacing: 0.6px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ============ 人机验证 · 紧凑布局 v2 ============ */
.captcha-btn {
  gap: 10px !important;
}

.captcha-text {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.captcha-percent {
  flex: 0 0 auto;
  min-width: 40px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #6b6b6b;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.4px;
  transition: color 0.2s ease;
}

.captcha-box[data-state="working"] .captcha-percent {
  color: #fbbf24;
}

.captcha-box[data-state="passed"] .captcha-percent {
  color: #22c55e;
}

.captcha-box[data-state="failed"] .captcha-percent {
  color: #ef4444;
}

/* 品牌挪到右下角更小更淡 */
.captcha-brand {
  font-size: 9px !important;
  letter-spacing: 0.5px !important;
}


/* ============ Passkey 按钮不可用状态 ============ */
.option[data-pk-state="checking"],
.option[data-pk-state="unavailable"] {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

.option[data-pk-state="unavailable"] .icon {
  color: #4a4a4a !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}

.option[data-pk-state="unavailable"] .text strong {
  color: #6b6b6b !important;
}

.option[data-pk-state="unavailable"] .text small {
  color: #4a4a4a !important;
}

.option[data-pk-state="unavailable"]::after {
  content: "";
  display: inline-block;
  width: 0;
}


/* ============ Passkey 不支持提示（按钮下方红字）============ */
.pk-unsupported-msg {
  display: none;
  margin: 4px 2px 0;
  padding: 7px 11px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #fca5a5;
  letter-spacing: 0.2px;
  border-radius: 7px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
}

.pk-unsupported-msg.show {
  display: block;
}

/* 不可用按钮：统一灰化 + 不响应点击 */
.option[data-pk-state="checking"],
.option[data-pk-state="unavailable"] {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* 选项列表里的红字（按钮下方的 pk-unsupported-msg） */
.options .pk-unsupported-msg {
  margin: -4px 0 4px 0;
  padding: 8px 12px;
  font-size: 11.5px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.20);
  border-radius: 8px;
}

.options .pk-unsupported-msg.show {
  display: block;
}
