.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(4px);
}

.auth-modal.show {
  display: flex;
}

.auth-modal .auth-card {
  display: block;
  gap: 0;
  width: min(420px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 55px rgba(15, 23, 42, .28);
}

.auth-header {
  position: relative;
  overflow: hidden;
  min-height: 154px;
  display: grid;
  align-content: center;
  margin: 0;
  padding: 20px 54px 26px;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(135deg, #f45702 0%, #ff8a00 100%);
  text-align: center;
  color: #fff;
}

.auth-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)" opacity="0.1"/%3E%3C/svg%3E');
  opacity: .3;
}

.close-modal {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: block;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  font-family: Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: opacity .2s;
}

.close-modal:hover {
  background: transparent;
  color: #fff;
  opacity: .78;
}

.close-modal span {
  display: block;
}

.auth-header h2 {
  position: relative;
  z-index: 10;
  margin: 0 0 5px;
  color: #fff;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.25;
}

.auth-header p {
  position: relative;
  z-index: 10;
  margin: 0;
  color: #fff;
  font-size: 13px;
  opacity: .8;
}

.auth-body {
  padding: 28px 10px 26px;
}

.modal-auth-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 16px;
  padding: 0;
  border-bottom: 1px solid #e5eaf2;
  border-radius: 0;
  background: transparent;
}

.modal-auth-tab {
  flex: 1;
  position: relative;
  min-height: 39px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  font-weight: 800;
  cursor: pointer;
}

.modal-auth-tab.active {
  background: transparent;
  color: #f05a16;
  box-shadow: none;
}

.modal-auth-tab.active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: #f05a16;
}

.register-method-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -2px 0 16px;
  padding: 4px;
  border: 1px solid #e5eaf2;
  border-radius: 10px;
  background: #f8fafc;
}

.register-method-tab {
  flex: 1;
  position: relative;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.register-method-tab.active {
  background: #fff7ed;
  color: #f05a16;
  box-shadow: inset 0 0 0 1px #fed7aa;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-label {
  color: #51627a;
  font-size: 13px;
  font-weight: 800;
}

.form-input {
  width: 100%;
  min-height: 43px;
  padding: 8px 16px;
  border: 1px solid #d7e0eb;
  border-radius: 10px;
  outline: none;
  background: #f8fafc;
  color: #1e293b;
  font-size: 14px;
}

.form-input::placeholder {
  color: #c3ceda;
}

.form-input:focus {
  border-color: #f05a16;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(240, 90, 22, .12);
}

.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.auth-btn,
.btn-wechat,
.btn-alipay,
.auth-code-btn {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

.auth-btn {
  color: #fff;
  background: #1f2a3d;
  box-shadow: 0 8px 15px rgba(15, 23, 42, .22);
  font-size: 15px;
  margin-top: 1px;
}

.auth-btn:disabled,
.auth-code-btn:disabled {
  background: #cbd5e1;
  box-shadow: none;
}

.auth-code-btn {
  color: #fff;
  background: #f59e0b;
  font-size: 12px;
}

.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 8px;
}

.auth-separator-line {
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.auth-separator-text {
  color: #c2ccd8;
  font-size: 12px;
  font-weight: 800;
}

.btn-wechat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid #dce4ee;
  color: #334155;
  background: #fff;
}

.btn-alipay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  border: 1px solid #bfdbfe;
  color: #1677ff;
  background: #f8fbff;
}

.btn-alipay:hover {
  border-color: #60a5fa;
  background: #eff6ff;
}

.auth-footer {
  color: #7f8fa3;
  font-size: 12px;
  text-align: center;
}

.link-text {
  color: #1f2a3d;
  cursor: pointer;
  font-weight: 800;
}

[data-auth-forgot-link] {
  margin: 8px 0 0;
  text-align: right;
}

[data-auth-forgot-link] .link-text {
  color: #3d4a60;
  font-size: 12px;
  font-weight: 800;
}

.wechat-mini-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #10c66f;
}

.wechat-mini-icon::before,
.wechat-mini-icon::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: #fff;
}

.alipay-mini-icon,
.alipay-auth-icon {
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: #1677ff;
  font-family: Arial, sans-serif;
  font-weight: 900;
}

.alipay-mini-icon {
  width: 16px;
  height: 16px;
  font-size: 12px;
}

.wechat-mini-icon::before {
  width: 3px;
  height: 3px;
  top: 4px;
  left: 4px;
}

.wechat-mini-icon::after {
  width: 3px;
  height: 3px;
  top: 4px;
  right: 4px;
}

.auth-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.auth-message.error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.auth-message.success {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.wechat-qr-view {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 8px 0 0;
  text-align: center;
}

.alipay-auth-view {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 0 8px;
  text-align: center;
  color: #1e293b;
  font-weight: 800;
}

.alipay-auth-view p {
  margin: 0;
}

.alipay-auth-view .alipay-auth-hint {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
}

.alipay-auth-message {
  width: min(100%, 280px);
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.alipay-auth-message.error {
  padding: 8px 10px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
}

.alipay-auth-view .auth-btn {
  width: min(100%, 280px);
  background: #1677ff;
  box-shadow: 0 8px 15px rgba(22, 119, 255, .2);
}

.alipay-auth-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 34px;
}

.wechat-qr-box {
  display: grid;
  width: 300px;
  height: 400px;
  place-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: #64748b;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .06);
  overflow: hidden;
}

.wechat-qr-box iframe {
  width: 300px;
  height: 400px;
  border: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 520px) {
  .auth-modal {
    align-items: center;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .auth-modal .auth-card {
    width: min(100%, 380px);
    max-height: calc(100vh - 20px);
    border-radius: 18px;
  }

  .auth-header {
    min-height: 98px;
    padding: 13px 44px 15px;
    border-radius: 18px 18px 0 0;
  }

  .close-modal {
    top: 16px;
    right: 18px;
    font-size: 28px;
  }

  .auth-header h2 {
    margin-bottom: 3px;
    font-size: 23px;
  }

  .auth-header p {
    font-size: 12px;
  }

  .auth-body {
    padding: 12px 18px 16px;
  }

  .modal-auth-tabs {
    margin-bottom: 10px;
  }

  .modal-auth-tab {
    min-height: 32px;
    font-size: 14px;
  }

  .register-method-tabs {
    margin-bottom: 10px;
    padding: 3px;
  }

  .register-method-tab {
    min-height: 28px;
    padding: 0 8px;
  }

  .auth-form {
    gap: 7px;
  }

  .form-group {
    gap: 4px;
  }

  .form-label {
    font-size: 12px;
  }

  .form-input {
    min-height: 40px;
    padding: 7px 12px;
    border-radius: 9px;
    font-size: 13px;
  }

  .auth-code-row {
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 8px;
  }

  .auth-code-btn {
    min-height: 40px;
    border-radius: 9px;
    font-size: 11px;
  }

  .auth-btn,
  .btn-wechat {
    min-height: 40px;
    border-radius: 9px;
    font-size: 14px;
  }

  [data-auth-forgot-link] {
    margin-top: 4px;
  }

  .auth-separator {
    gap: 10px;
    margin: 5px 0;
  }

  .auth-footer {
    font-size: 11px;
    line-height: 1.45;
  }

  .auth-message {
    padding: 8px 10px;
    font-size: 12px;
  }

  .wechat-qr-view {
    gap: 8px;
    padding-top: 0;
  }

  .wechat-qr-box,
  .wechat-qr-box iframe {
    width: min(100%, 300px);
    height: min(58vh, 360px);
  }
}

@media (max-width: 380px) {
  .auth-modal {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .auth-modal .auth-card {
    max-height: calc(100dvh - 16px);
    border-radius: 16px;
  }

  .auth-header {
    min-height: 88px;
    padding: 10px 40px 12px;
    border-radius: 16px 16px 0 0;
  }

  .auth-header h2 {
    font-size: 21px;
  }

  .auth-body {
    padding: 10px 14px 14px;
  }

  .auth-form {
    gap: 6px;
  }

  .form-input,
  .auth-code-btn,
  .auth-btn,
  .btn-wechat {
    min-height: 38px;
  }

  .wechat-qr-box,
  .wechat-qr-box iframe {
    height: min(54dvh, 330px);
  }
}
